public void TestMake()
        {
            NetEntity enitiy = new NetEntity();

            enitiy.ConnectionID = 123456789;

            PlayerData data = new PlayerData();

            data.Name       = "Player yall";
            data.PrefabName = "Player";

            MakeEntity.AddComponent(enitiy, data);

            GameObject obj = new GameObject();

            obj.transform.position = new Vector3(Random.RandomRange(1, 25), Random.RandomRange(1, 25), Random.RandomRange(1, 25));

            obj.name = "a name yall";
            NetTransform trans = new NetTransform();

            trans.position.x = obj.transform.position.x;
            trans.position.y = obj.transform.position.y;
            trans.position.z = obj.transform.position.z;

            MakeEntity.AddComponent(enitiy, trans);



            NetTransform trans2 = MakeEntity.GetComponent <NetTransform>(enitiy);

            PlayerData playerData = MakeEntity.GetComponent <PlayerData>(enitiy);


            Debug.Log("Did it work?");
        }
示例#2
0
    public override void HandleSnapshot(Package pkg)
    {
        Debug.Log("处理快照");
        var          trans   = pkg.GetValue <Transform3DData>();
        NetTransform netTran = cube.GetComponent <NetTransform>();

        netTran.SetData(trans);
    }
示例#3
0
    public override void HandleSnapshot(Package pkg)
    {
        Debug.Log("处理快照");
        var          trans   = pkg.GetValue <Transform3DData>();
        NetTransform netTran = cube.GetComponent <NetTransform>();

        netTran.SetData(trans);
        cube.transform.localPosition = new Vector3(trans.LocalPosition.X, trans.LocalPosition.Y, trans.LocalPosition.Z);
    }
示例#4
0
    public override void OnAfterConnect(bool result)
    {
        base.OnAfterConnect(result);
        Object obj = Resources.Load("Cube");

        cube = GameObject.Instantiate(obj) as GameObject;
        cube.ResetTransform();
        NetTransform netTran = cube.GetComponent <NetTransform>();

        netTran.instanceId = 100;
    }
示例#5
0
 public override void OnStart()
 {
     InitData(new List <(System.Func <object, Packet>, System.Action <Packet>)>()
     {
         (SendInput, HandleInput),
         (SendRot, HandleRot),
     });
     DontDestroyOnLoad(gameObject);
     netTransform = GetComponent <NetTransform>();
     cam          = GetComponentInChildren <Camera>();
     rBody        = GetComponent <Rigidbody2D>();
     if (!hasAuthority)
     {
         cam.gameObject.SetActive(false);
     }
 }
示例#6
0
 void Awake()
 {
     tran = GetComponent <NetTransform>();
 }