少年修仙传客户端代码仓库
client_Hale
2019-03-04 03a7dc0924450a37c9c1972edbdbd0154945836c
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
39
40
41
42
43
44
45
46
47
48
49
using UnityEngine;
using System.IO;
 
namespace H2Engine
{
    public class Bhv_MonsterData : MonoBehaviour
    {
        [HideInInspector]
        public int npcID;
        [HideInInspector]
        public string resName;
        [HideInInspector]
        public byte ai;
 
#if UNITY_EDITOR
 
        public void Save(BinaryWriter bw)
        {
            bw.Write(resName);
            bw.Write(npcID);
            bw.Write(ai);
            bw.Write((float)System.Math.Round(transform.position.x, 2));
            bw.Write((float)System.Math.Round(transform.position.y, 2));
            bw.Write((float)System.Math.Round(transform.position.z, 2));
        }
 
        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 = "RefreshMonster_" + npcID;
        }
 
        public void Export(BinaryWriter bw)
        {
            bw.Write(npcID);
            bw.Write(ai);
            bw.Write((float)System.Math.Round(transform.position.x, 2));
            bw.Write((float)System.Math.Round(transform.position.y, 2));
            bw.Write((float)System.Math.Round(transform.position.z, 2));
        }
 
#endif
    }
}