少年修仙传客户端代码仓库
client_linchunjie
2019-01-18 fc8c78e4a2bcbef5327d1859cd3b7f84dbd651ff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using UnityEngine;
using System.IO;
 
namespace H2Engine
{
    public class Bhv_MonsterData : MonoBehaviour
    {
        [HideInInspector]
        public int npcID;
        [HideInInspector]
        public byte ai;
 
        public void Save(BinaryWriter bw)
        {
            bw.Write(npcID);
            bw.Write(ai);
            bw.Write((float)System.Math.Round(transform.position.x));
            bw.Write((float)System.Math.Round(transform.position.y));
            bw.Write((float)System.Math.Round(transform.position.z));
        }
 
        public void Load(BinaryReader br)
        {
            npcID = br.ReadInt32();
            ai = br.ReadByte();
            float _x = br.ReadSingle();
            float _y = br.ReadSingle();
            float _z = br.ReadSingle();
            transform.position = new Vector3(_x, _y, _z);
            name = npcID + "_RefreshMonster";
        }
 
        public void Export(BinaryWriter bw)
        {
            Save(bw);
        }
    }
}