public ChickenData(
                GameObjectId id,
                Point3D position,
                double beakAngle,
                ModelVisual3D visual,
                MatrixTransform3D transform,
                BillboardTextVisual3D billboardVisual)
                : base(id, position, transform)
            {
                #region Argument Check

                if (visual == null)
                {
                    throw new ArgumentNullException("visual");
                }

                if (billboardVisual == null)
                {
                    throw new ArgumentNullException("billboardVisual");
                }

                #endregion

                this.BeakAngle       = beakAngle;
                this.Visual          = visual;
                this.BillboardVisual = billboardVisual;
            }
    public static GameObject[] FindMultiGameObject(byte[] data)
    {
        MemoryStream stream = new MemoryStream(data);

        GameObjectId[] ids = (GameObjectId[])formatter.Deserialize(stream);
        if (null == ids)
        {
            return(null);
        }

        List <GameObject> goList = new List <GameObject>();

        for (int i = 0; i < ids.Length; ++i)
        {
            GameObjectId id = ids[i];
            GameObject   go = FindGameObject(id.path, id.hash);
            if (null == go)
            {
                Logger.LogError("can not find game object {0}", id.path);
            }
            else
            {
                //Debug.Log("GameObject: "+go, go);
                goList.Add(go);
            }
        }

        return(goList.ToArray());
    }
Esempio n. 3
0
    public override object Read(ES2Reader reader)
    {
        GameObjectId data = new GameObjectId();

        Read(reader, data);
        return(data);
    }
    static public byte[] BuildGameObjectId(GameObject go, string compStr = "", List <string> compTypeList = null)
    {
        StringBuilder sb = new StringBuilder();

        BuildGameObjectPath(sb, go.transform);
        string path = sb.ToString();

        GameObjectId id = new GameObjectId();

        id.path = path;
        if (!string.IsNullOrEmpty(compStr))
        {
            id.compStr = compStr;
        }
        if (null != compTypeList)
        {
            id.compTypeArr = compTypeList.ToArray();
        }

        if (go.GetComponent <GameObjectActiver>() != null)
        {
            id.hash = go.GetComponent <GameObjectActiver>().Code;
        }
        else
        {
            Logger.LogError("BuildGameObjectId can not find component {0}", path);
        }

        Logger.LogError(string.Format("[Build] {0}:{1}", id.path, id.hash));
        MemoryStream stream = new MemoryStream();

        formatter.Serialize(stream, id);
        byte[] bytes = stream.ToArray();
        return(bytes);
    }
    public static byte[] GetComponent(byte[] bytes)
    {
        MemoryStream stream = new MemoryStream(bytes);
        GameObjectId goi    = (GameObjectId)formatter.Deserialize(stream);

        if (null == goi)
        {
            Logger.LogError("can not convert to GameObjectId");
            return(null);
        }

        GameObject go = HierarchySerializer.FindGameObject(goi.path, goi.hash);

        if (null == go)
        {
            Debug.LogError(string.Format("can not find gameobject: {0}:{1}", goi.hash, goi.compStr));
            return(null);
        }

        string compStr = "";

        ComponentSimulator.encode(out compStr, go, goi.compTypeArr);

        MemoryStream outstream = new MemoryStream();
        GameObjectId outGoi    = new GameObjectId();

        outGoi.hash    = go.GetHashCode();
        outGoi.compStr = compStr;
        formatter.Serialize(outstream, outGoi);
        byte[] outBytes = outstream.ToArray();

        return(outBytes);
    }
Esempio n. 6
0
 public void SetGameState <T>(GameObjectId id, string key, T value)
 {
     if (GameClientObject != null)
     {
         DeObfuscator.SetStateMethod.MakeGenericMethod(typeof(T)).Invoke(GameClientObject, new object[] { id, key, value, false });
     }
 }
Esempio n. 7
0
 public GameObject(GameObjectId id, string name, string description, string article)
 {
     Id          = id;
     Article     = article;
     Name        = name;
     Description = description;
 }
Esempio n. 8
0
        public static Vector3 screenPosition(this GameObjectId self, float time = 0f)
        {
            var position = self.position(time);
            var adjusted = refs.camera.WorldToScreenPoint(new Vector3(position.X, 0, position.Y));

            adjusted.y = Screen.height - adjusted.y;
            return(adjusted);
        }
Esempio n. 9
0
    public override void Read(ES2Reader reader, object c)
    {
        GameObjectId data = (GameObjectId)c;

        // Add your reader.Read calls here to read the data into the object.
        data.name      = reader.Read <System.String>();
        data.sceneName = reader.Read <System.String>();
    }
Esempio n. 10
0
    public override void Write(object obj, ES2Writer writer)
    {
        GameObjectId data = (GameObjectId)obj;

        // Add your writer.Write calls here.
        writer.Write(data.name);
        writer.Write(data.sceneName);
    }
Esempio n. 11
0
 public Character(GameObjectId id, string name, string description, string article, int strength,
                  int dexterity, int constitution, int wisdom, int charisma) :
     base(id, name, description, article)
 {
     Strength     = strength;
     Dexterity    = dexterity;
     Constitution = constitution;
     Wisdom       = wisdom;
     Charisma     = charisma;
 }
Esempio n. 12
0
 public GameValue GetGameState(GameObjectId id, string key)
 {
     if (GameClientObject != null)
     {
         GameValue gameValue = default(GameValue);
         object[]  array     = new object[] { id, key, gameValue };
         object    success   = DeObfuscator.GetStateMethod.Invoke(GameClientObject, array);
         return((GameValue)array[2]);
     }
     return(default(GameValue));
 }
Esempio n. 13
0
 public static Vector3 Position(this GameObjectId gameObjectId)
 {
     foreach (ModelState current in API.Instance.ViewState.Models.Values)
     {
         if (current.Id == gameObjectId)
         {
             return(current.Position.ToUnityVector3(current.Height));
         }
     }
     return(Vector3.zero);// Loader.Controller.UnityMain.GetModelPosition(playerInfo.ID.ToGame());
 }
    public static GameObject FindGameObject(byte[] data)
    {
        MemoryStream stream = new MemoryStream(data);
        GameObjectId id     = (GameObjectId)formatter.Deserialize(stream);

        GameObject go = FindGameObject(id.path, id.hash);

        if (go == null)
        {
            Logger.LogError("can not find game object {0}", id.path);
        }
        return(go);
    }
Esempio n. 15
0
        public static Vector2 position(this GameObjectId self, float time = 0f)
        {
            //real-time
            Vector2 pos = refs?.client?.GetState(self, "Position", false) ?? default;

            if (time <= 0)
            {
                return(pos);
            }

            //prediction
            Vector2 velocity = refs?.client?.GetState(self, "Velocity", false) ?? default;

            return(pos + velocity.Normalized * time);
        }
            public ShotData(
                GameObjectId id,
                Point3D position,
                GeometryModel3D model,
                MatrixTransform3D transform)
                : base(id, position, transform)
            {
                #region Argument Check

                if (model == null)
                {
                    throw new ArgumentNullException("model");
                }

                #endregion

                this.Model = model;
            }
            protected GameObjectData(
                GameObjectId id,
                Point3D position,
                MatrixTransform3D transform)
            {
                #region Argument Check

                if (transform == null)
                {
                    throw new ArgumentNullException("transform");
                }

                #endregion

                this.Id        = id;
                this.Position  = position;
                this.Transform = transform;
            }
Esempio n. 18
0
        public static List <GameValue> GetStateList(this GameObjectId obj, string name)
        {
            var stateList = DeObfuscator.GetStateListMethod.Invoke(API.Instance.GameClientObject, new object[] { obj, name });

            if (GetStateListValueMethod == null)
            {
                var structMethods = stateList.GetType().GetMethods(Reflection.flags);
                GetStateListValueMethod   = structMethods.First(m => m.Name == "get_Item");
                GetStateListCountProperty = stateList.GetType().GetProperty("Count");
            }
            var count = (int)GetStateListCountProperty.GetValue(stateList, new object[0]);
            List <GameValue> elements = new List <GameValue>();

            for (int i = 0; i < count; i++)
            {
                elements.Add((GameValue)GetStateListValueMethod.Invoke(stateList, new object[] { i }));
            }
            return(elements);
        }
    static public byte[] BuildMultiGameObjectId(GameObject[] gos, bool bActive)
    {
        if (null == gos)
        {
            return(null);
        }

        List <GameObjectId> idList = new List <GameObjectId>();

        for (int i = 0; i < gos.Length; ++i)
        {
            GameObject    go = gos[i];
            StringBuilder sb = new StringBuilder();
            BuildGameObjectPath(sb, go.transform);
            string path = sb.ToString();

            GameObjectId id = new GameObjectId();
            id.path = path;
            if (go.GetComponent <GameObjectActiver>() != null)
            {
                go.GetComponent <GameObjectActiver>().setActive(bActive);
                id.hash = go.GetComponent <GameObjectActiver>().Code;
                idList.Add(id);
            }
            else
            {
                Logger.LogError("BuildGameObjectId can not find component {0}", path);
            }
        }
        Logger.Log("[BuildMultiGameObjectId] num of GameObject: {0}", idList.Count);
        if (0 == idList.Count)
        {
            return(null);
        }

        MemoryStream stream = new MemoryStream();

        formatter.Serialize(stream, idList.ToArray());
        byte[] bytes = stream.ToArray();
        return(bytes);
    }
    public static void ShowComponent(byte[] bytes)
    {
        MemoryStream stream = new MemoryStream(bytes);
        GameObjectId go     = (GameObjectId)formatter.Deserialize(stream);

        if (null == go)
        {
            Logger.LogError("can not convert to GameObjectId");
            return;
        }

        //Debug.Log(string.Format("{0}:{1}", go.hash, go.compStr));
        GameObjectActiver[] goas = GameObject.FindObjectsOfType <GameObjectActiver>();
        for (int i = 0; i < goas.Length; ++i)
        {
            if (go.hash == goas[i].Code)
            {
                ComponentSimulator cs = goas[i].GetComponent <ComponentSimulator>();
                cs.compStr = go.compStr;
                break;
            }
        }
    }
Esempio n. 21
0
 public void GetAbilities()
 {
     AbilityStateSystem              = (GameObjectId)API.Instance.LocalPlayer.ID.ToGame().Get("AbilityStateSystem");
     AbilityStateSystemAbilities     = AbilityStateSystem.GetStateList("Abilities");
     AbilityStateSystemAbilityGroups = AbilityStateSystem.GetStateList("AbilityGroups");
     foreach (var abilityStateTable in AbilityStateSystemAbilities)
     {
         var name    = ((StateTableId)abilityStateTable).GetField <GameObjectTypeId>("#a").ToString(API.GameData).Replace("Ability", "");
         var ability = new Ability {
             Name = name, SingleAbilityTable = abilityStateTable
         };
         var group = 5;// ((StateTableId)abilityStateTable).Get("AbilityGroupIndex");
         if (group > -1)
         {
             ability.GroupAbilityTable = AbilityStateSystemAbilityGroups[group];
         }
         ability.Data = AbilityData.ChampionAbilityData[GetType().Name].FirstOrDefault(a => a.Name == ability.Name);
         if (ability.Data != null)
         {
             Abilities.Add(name, ability);
         }
     }
 }
        private void StartFollowingChicken(GameObjectId chickenId)
        {
            _followedChickenId = chickenId;

            var data = _chickenDatas.GetValueOrDefault(_followedChickenId.Value);

            if (data == null)
            {
                RestoreCameraDefaults();
                return;
            }

            this.Camera.Position = new Point3D(
                GameConstants.ChickenUnit.BodyCircleRadius / _nominalSizeCoefficient,
                0d,
                0d);
            this.Camera.LookDirection = new Vector3D(1d, 0d, 0d);
            this.Camera.UpDirection   = new Vector3D(0d, 0d, 1d);
            this.Camera.FieldOfView   = GameConstants.ChickenUnit.ViewAngle * 2d;
            this.Camera.Transform     = null;

            FollowChicken();
        }
    public static void SetComponent(byte[] bytes)
    {
        MemoryStream stream = new MemoryStream(bytes);
        GameObjectId goi    = (GameObjectId)formatter.Deserialize(stream);

        if (null == goi)
        {
            Logger.LogError("can not convert to GameObjectId");
            return;
        }

        GameObject go = HierarchySerializer.FindGameObject(goi.path, goi.hash);

        if (null == go)
        {
            Debug.LogError(string.Format("can not find gameobject: {0}:{1}", goi.hash, goi.compStr));
            return;
        }
        ComponentSimulator.setComp(go, goi.compStr);

        //将修改后的值返回给服务端
        List <string> compTypeList = ComponentSimulator.getCompTypeList(goi.compStr);

        if (null != compTypeList)
        {
            string compStr = "";
            ComponentSimulator.encode(out compStr, go, compTypeList.ToArray());

            MemoryStream outstream = new MemoryStream();
            GameObjectId outGoi    = new GameObjectId();
            outGoi.hash    = go.GetHashCode();
            outGoi.compStr = compStr;
            formatter.Serialize(outstream, outGoi);
            byte[] outBytes = outstream.ToArray();
            RemoteGameObjectControl.RemoteSendComponent(outBytes);
        }
    }
Esempio n. 24
0
 public GameValue GetGameState(GameObjectId id, String key)
 {
     return((GameValue)GetState.Invoke(game, new object[] { id, key, false }));
 }
Esempio n. 25
0
 public Enemy(GameObjectId id, string name, string description, string article, int strength,
              int dexterity, int constitution, int wisdom, int charisma)
     : base(id, name, description, article, strength, dexterity, constitution, wisdom, charisma)
 {
 }
Esempio n. 26
0
 public bool equals(GameObjectId goId)
 {
     return(this.name == goId.name && this.sceneName == goId.sceneName);
 }
Esempio n. 27
0
 public Item(GameObjectId id, string name, string description, string article) :
     base(id, name, description, article)
 {
 }
Esempio n. 28
0
 public void SetGameState <T>(GameObjectId id, String key, T value)
 {
     SetState.MakeGenericMethod(typeof(T)).Invoke(Loader.Controller.game, new object[] { id, key, value });
 }
 public GameObject GetObject(GameObjectId id) =>
 AllObjects.FirstOrDefault(i => i.Id == id);
Esempio n. 30
0
 public EquipableItem(GameObjectId id, string name, string description, string article, List <BodyPart> equipableOn)
     : base(id, name, description, article)
 {
     EquipableOn = equipableOn;
 }