Ejemplo n.º 1
0
        void SendKeyFrame(int idx)
        {
            PtKeyFrameCollection collection = KeyFrameSender.GetFrameCommand();

            if (collection.KeyFrames.Count > 0)
            {
                Service.Get <LoginService>().RequestSyncClientKeyframes(idx, collection);
                KeyFrameSender.ClearFrameCommand();
            }
        }
Ejemplo n.º 2
0
        public void Update()
        {
            LogicFrameBehaviour logic = Sim.GetBehaviour <LogicFrameBehaviour>();

            Entitas.Entity entity = Sim.GetEntityWorld().GetEntity(GameClientData.SelfControlEntityId);
            if (entity != null)
            {
                MoveComponent comp = entity.GetComponent <MoveComponent>();
                if (comp != null)
                {
                    Vector2 dir = comp.GetDirVector2();
                    if (InputManager.Instance.IsKeyCodeActive(KeyCode.A))
                    {
                        dir.x = -1;
                    }
                    if (InputManager.Instance.IsKeyCodeActive(KeyCode.S))
                    {
                        dir.y = -1;
                    }
                    if (InputManager.Instance.IsKeyCodeActive(KeyCode.W))
                    {
                        dir.y = 1;
                    }
                    if (InputManager.Instance.IsKeyCodeActive(KeyCode.D))
                    {
                        dir.x = 1;
                    }
                    if (!InputManager.Instance.IsAnyKeyCodeActive())
                    {
                        dir.x = 0;
                        dir.y = 0;
                    }
                    if (dir != comp.GetDirVector2())
                    {
                        Debug.Log(string.Format("keyframeIdx:{0} roleid:{1}", logic.CurrentFrameIdx, comp.EntityId));

                        //KeyFrameSender.AddFrameCommand(new FrameIdxInfo(logic.CurrentFrameIdx,FrameCommand.SYNC_MOVE,comp.EntityId,new string[] { dir.x + "", dir.y + "", "0" }));

                        KeyFrameSender.AddCurrentFrameCommand(FrameCommand.SYNC_MOVE, comp.EntityId, new string[] { dir.x + "", dir.y + "", "0" });
                    }

                    //bullet
                    if (InputManager.Instance.IsKeyCodeActive(KeyCode.Space))
                    {
                        KeyFrameSender.AddCurrentFrameCommand(FrameCommand.SYNC_CREATE_ENTITY, Common.Utils.GuidToString(), new string[] { ((int)EntityWorld.EntityOperationEvent.CreateBullet) + "", comp.EntityId });
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void Update()
        {
            LogicFrameBehaviour logic = Sim.GetBehaviour <LogicFrameBehaviour>();

            if (logic.CurrentFrameIdx % randomStepFrame == 0)
            {
                //randomStepFrame = new System.Random().Next(10, 30);
                Entitas.Entity entity = Sim.GetEntityWorld().GetEntity(GameClientData.SelfControlEntityId);
                if (entity != null)
                {
                    MoveComponent comp = entity.GetComponent <MoveComponent>();
                    if (comp != null)
                    {
                        Vector2 dir   = comp.GetDirVector2();
                        int     value = new System.Random().Next(0, 5);
                        if (value == 0)
                        {
                            dir.x = -1;
                        }
                        else if (value == 1)
                        {
                            dir.y = -1;
                        }
                        else if (value == 2)
                        {
                            dir.y = 1;
                        }
                        else if (value == 3)
                        {
                            dir.x = 1;
                        }
                        else if (value == 4)
                        {
                            dir.x = 0;
                            dir.y = 0;
                        }
                        if (dir != comp.GetDirVector2())
                        {
                            //Debug.Log(string.Format("keyframeIdx:{0} roleid:{1}", logic.CurrentFrameIdx, comp.EntityId));

                            KeyFrameSender.AddFrameCommand(new FrameIdxInfo(logic.CurrentFrameIdx, FrameCommand.SYNC_MOVE, comp.EntityId.ToString(), new string[] { dir.x + "", dir.y + "", "0" }));
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
 void OnClickAddEntity()
 {
     GameClientData.SelfControlEntityId = Guid.NewGuid();
     KeyFrameSender.AddCurrentFrameCommand(FrameCommand.SYNC_CREATE_ENTITY, GameClientData.SelfControlEntityId.ToString(), new string[] { ((int)EntityWorld.EntityOperationEvent.CreatePlayer) + "" });
 }
Ejemplo n.º 5
0
 void OnClickBoxEntity()
 {
     System.GC.Collect();
     KeyFrameSender.AddCurrentFrameCommand(FrameCommand.SYNC_CREATE_ENTITY, Common.Utils.GuidToString(), new string[] { (int)EntityWorld.EntityOperationEvent.CreateBox + "", new System.Random().Next(3, 15).ToString(), new System.Random().Next(-1, 2).ToString(), new System.Random().Next(-1, 2).ToString() });
 }