コード例 #1
0
        public void Update()
        {
            ReplayLogicFrameBehaviour replayLogic = Sim.GetBehaviour <ReplayLogicFrameBehaviour>();
            List <FrameIdxInfo>       list        = replayLogic.GetFrameIdxInfoAtCurrentFrame();

            if (list != null)
            {
                foreach (FrameIdxInfo info in list)
                {
                    switch (info.Cmd)
                    {
                    case FrameCommand.SYNC_MOVE:
                        Entitas.Entity ent = Sim.GetEntityWorld().GetEntity(info.EntityId);
                        if (ent != null)
                        {
                            ent.GetComponent <MoveComponent>().UpdateParams(info.Params);
                            //Debug.Log(string.Format("EntityId: {0} Dir:{1} {2} ", info.EntityId, float.Parse(info.Params[0]), float.Parse(info.Params[1])));
                        }
                        break;

                    case FrameCommand.SYNC_CREATE_ENTITY:
                        Sim.GetEntityWorld().NotifyCreateEntity(info);
                        break;
                    }
                }
            }
        }
コード例 #2
0
        protected override void OnRender(Entitas.Entity entity)
        {
            base.OnRender(entity);
            FrameClockComponent com = entity.GetComponent <FrameClockComponent>();

            if (com != null)
            {
                m_Rate = com.GetRate();
            }
        }
コード例 #3
0
        protected override void OnRender(Entitas.Entity entity)
        {
            base.OnRender(entity);

            PlayerInfoComponent com = entity.GetComponent <PlayerInfoComponent>();

            if (com != null)
            {
                m_Txt.text = com.Value.ToString();
            }
        }
コード例 #4
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" }));
                        }
                    }
                }
            }
        }