示例#1
0
    public override void FixedUpdate(int deltaTime)
    {
        List <EntityBase> list = GetEntityList();

        for (int i = 0; i < list.Count; i++)
        {
            CommandComponent com  = list[i].GetComp <CommandComponent>();
            MoveComponent    move = list[i].GetComp <MoveComponent>();

            if (com.isForward)
            {
                move.m_velocity = 5;
            }

            if (com.isBack)
            {
                move.m_velocity = 0;
            }

            if (com.isLeft)
            {
                move.m_dirx = -5;
            }

            if (com.isRight)
            {
                move.m_dirx = 5;
            }
        }
    }
    public override void FixedUpdate(int deltaTime)
    {
        List <EntityBase> list = GetEntityList();

        for (int i = 0; i < list.Count; i++)
        {
            CommandComponent     cc  = list[i].GetComp <CommandComponent>();
            CDComponent          cdc = list[i].GetComp <CDComponent>();
            SkillStatusComponent ssc = list[i].GetComp <SkillStatusComponent>();

            cdc.CD -= deltaTime;

            if (cc.skillDir.ToVector() != Vector3.zero &&
                cc.isFire &&
                cdc.CD <= 0)
            {
                cdc.CD = 2 * 1000;

                Debug.Log("FIRE!!!");

                //FIRE!!!
                string skillID = "2000";

                ssc.m_skillTime        = 0;
                ssc.m_isTriggerSkill   = false;
                ssc.m_skillStstus      = SkillStatusEnum.Before;
                ssc.m_currentSkillData = ssc.GetSkillData(skillID);
                ssc.m_currentSkillData.UpdateInfo();
            }
        }
    }
    static void SendCommandComponent(SyncSession session, CommandComponent msg)
    {
        Dictionary <string, object> data = new Dictionary <string, object>();

        {
            Dictionary <string, object> data2 = new Dictionary <string, object>();
            data2.Add("x", msg.moveDir.x);
            data2.Add("y", msg.moveDir.y);
            data2.Add("z", msg.moveDir.z);
            data.Add("movedir", data2);
        }
        {
            Dictionary <string, object> data2 = new Dictionary <string, object>();
            data2.Add("x", msg.skillDir.x);
            data2.Add("y", msg.skillDir.y);
            data2.Add("z", msg.skillDir.z);
            data.Add("skilldir", data2);
        }
        data.Add("element1", msg.element1);
        data.Add("element2", msg.element2);
        data.Add("isfire", msg.isFire);
        data.Add("id", msg.id);
        data.Add("frame", msg.frame);
        data.Add("time", msg.time);
        session.SendMsg("commandcomponent", data);
    }
示例#4
0
    public override void BeforeFixedUpdate(int deltaTime)
    {
        List <EntityBase> list = GetEntityList();

        for (int i = 0; i < list.Count; i++)
        {
            CommandComponent com  = list[i].GetComp <CommandComponent>();
            MoveComponent    move = list[i].GetComp <MoveComponent>();
            PlayerComponent  pc   = list[i].GetComp <PlayerComponent>();
            LifeComponent    lc   = list[i].GetComp <LifeComponent>();
            BlowFlyComponent blc  = list[i].GetComp <BlowFlyComponent>();

            if (lc.Life > 0 &&
                !blc.isBlow &&
                !pc.GetIsDizziness())
            {
                pc.faceDir = com.skillDir.DeepCopy();
                move.dir   = com.moveDir.DeepCopy();

                move.m_velocity = pc.GetSpeed();
            }
            else
            {
                move.dir.FromVector(Vector3.zero);
            }
        }
    }
    static void ReceviceCommandComponent(SyncSession session, ProtocolRequestBase e)
    {
        CommandComponent msg = new CommandComponent();

        {
            Dictionary <string, object> data2 = (Dictionary <string, object>)e.m_data["movedir"];
            SyncVector3 tmp2 = new SyncVector3();
            tmp2.x      = (int)data2["x"];
            tmp2.y      = (int)data2["y"];
            tmp2.z      = (int)data2["z"];
            msg.moveDir = tmp2;
        }
        {
            Dictionary <string, object> data2 = (Dictionary <string, object>)e.m_data["skilldir"];
            SyncVector3 tmp2 = new SyncVector3();
            tmp2.x       = (int)data2["x"];
            tmp2.y       = (int)data2["y"];
            tmp2.z       = (int)data2["z"];
            msg.skillDir = tmp2;
        }
        msg.isFire = (bool)e.m_data["isfire"];
        msg.id     = (int)e.m_data["id"];
        msg.frame  = (int)e.m_data["frame"];

        EventService.DispatchTypeEvent(session, msg);
    }
    public override bool EqualsCmd(PlayerCommandBase cmd)
    {
        if (!(cmd is CommandComponent))
        {
            return(false);
        }

        CommandComponent cc = cmd as CommandComponent;

        if (id != cc.id)
        {
            return(false);
        }

        if (frame != cc.frame)
        {
            return(false);
        }

        if (isFire != cc.isFire)
        {
            return(false);
        }

        if (!moveDir.Equals(cc.moveDir))
        {
            return(false);
        }

        if (!skillDir.Equals(cc.skillDir))
        {
            return(false);
        }
        return(true);
    }
示例#7
0
    public override void FixedUpdate(int deltaTime)
    {
        List <EntityBase> list = GetEntityList();

        for (int i = 0; i < list.Count; i++)
        {
            CommandComponent     cc  = (CommandComponent)list[i].GetComp("CommandComponent");
            SkillStatusComponent ssc = (SkillStatusComponent)list[i].GetComp("SkillStatusComponent");
            PlayerComponent      pc  = (PlayerComponent)list[i].GetComp("PlayerComponent");
            MoveComponent        mc  = (MoveComponent)list[i].GetComp("MoveComponent");
            LifeComponent        lc  = (LifeComponent)list[i].GetComp("LifeComponent");

            //CD
            for (int j = 0; j < ssc.m_skillList.Count; j++)
            {
                ssc.m_CDList[j] -= deltaTime;
            }

            if (ssc.skillDirCache.ToVector() != Vector3.zero &&
                cc.isFire &&
                !pc.GetIsDizziness() &&
                lc.Life > 0 &&
                cc.skillDir.ToVector() == Vector3.zero
                )
            {
                string    skillID = SkillUtils.GetSkillName(cc);
                SkillData data    = ssc.GetSkillData(skillID);

                if (ssc.GetSkillCDFinsih(skillID))
                {
                    //Debug.Log("FIRE!!! --> " + skillID);
                    ssc.m_skillTime        = 0;
                    ssc.m_skillStstus      = SkillStatusEnum.Before;
                    ssc.m_isTriggerSkill   = false;
                    ssc.m_currentSkillData = data;
                    ssc.m_currentSkillData.UpdateInfo();

                    ssc.SetSkillCD(skillID, data.CDSpace);

                    ssc.skillDir = ssc.skillDirCache.DeepCopy();
                    AreaDataGenerate areaData = DataGenerateManager <AreaDataGenerate> .GetData(ssc.m_currentSkillData.SkillInfo.m_EffectArea);

                    float distance = ssc.skillDir.ToVector().magnitude;
                    distance = areaData.m_SkewDistance + Mathf.Clamp(distance, 0, areaData.m_distance);

                    Vector3 aimPos = mc.pos.ToVector() + ssc.skillDir.ToVector().normalized *distance;
                    if (areaData.m_Shape != AreaType.Rectangle)
                    {
                        ssc.skillPos.FromVector(aimPos);
                    }
                    else
                    {
                        ssc.skillPos.FromVector(mc.pos.ToVector() + ssc.skillDir.ToVector().normalized *(areaData.m_SkewDistance - areaData.m_Length / 2));
                    }
                }
            }

            ssc.skillDirCache = cc.skillDir.DeepCopy();
        }
    }
示例#8
0
        public void PostManyWithCommand_Returns_expected()
        {
            //Arrange
            var availableCommands = new List <CommandComponent>();

            foreach (var val in Enum.GetValues(typeof(DieType)))
            {
                availableCommands.Add(new CommandComponent
                {
                    CommandName  = "RollDice",
                    FriendlyName = "Roll Dice",
                    IsEnabled    = true,
                    IsVisible    = true,
                    Payload      = new CommandPayload
                    {
                        ExecutionData = JObject.FromObject(new Dictionary <DieType, uint> {
                            { (DieType)val, 0 }
                        })
                    }
                });
            }

            var command = new CommandComponent
            {
                CommandName  = "RollDice",
                FriendlyName = "Roll Dice",
                IsEnabled    = true,
                IsVisible    = true,
                Payload      = new CommandPayload
                {
                    ExecutionData = JObject.FromObject(new Dictionary <DieType, uint> {
                        { DieType.D12, 0 }
                    })
                }
            };

            var request = new MultipleDiceRollComponent
            {
                SelectedCommand   = command,
                AvailableCommands = availableCommands
            };

            var rolls = _fixture.Create <DiceRolls>();

            _manager.Setup(x => x.RollDice(It.IsAny <Dictionary <string, uint> >())).Returns(rolls);

            var expected = request;



            //Act
            var actual = _sut.PostManyWithCommand(request);

            //Assert
            expected.RollValues = rolls;
            actual.Value.Should().BeEquivalentTo(expected);
        }
示例#9
0
        public void SingleComponentValueRollbackTest()
        {
            ResourcesConfigManager.Initialize();
            WorldManager.IntervalTime = 100;

            LockStepEntityTestWorld world = (LockStepEntityTestWorld)WorldManager.CreateWorld <LockStepEntityTestWorld>();

            world.IsClient = true;
            world.IsStart  = true;
            world.IsLocal  = true;

            ConnectStatusComponent csc = world.GetSingletonComp <ConnectStatusComponent>();

            csc.confirmFrame = 0; //从目标帧之后开始计算

            SelfComponent       sc = new SelfComponent();
            RealPlayerComponent rp = new RealPlayerComponent();
            EntityBase          c1 = world.CreateEntityImmediately("Test", sc, rp);

            world.CallRecalc();
            world.FixedLoop(WorldManager.IntervalTime);

            TestSingleComponent tc = world.GetSingletonComp <TestSingleComponent>();

            Assert.AreEqual(0, tc.testValue);

            CommandComponent cmd = new CommandComponent();

            cmd.frame  = 1;
            cmd.id     = c1.ID;
            cmd.isFire = true;
            GlobalEvent.DispatchTypeEvent(cmd);

            world.CallRecalc();
            world.FixedLoop(WorldManager.IntervalTime);

            tc = world.GetSingletonComp <TestSingleComponent>();
            Assert.AreEqual(1, tc.testValue);

            world.CallRecalc();
            world.FixedLoop(WorldManager.IntervalTime);

            tc = world.GetSingletonComp <TestSingleComponent>();
            Assert.AreEqual(1, tc.testValue);

            cmd        = new CommandComponent();
            cmd.frame  = 2;
            cmd.id     = c1.ID;
            cmd.isFire = true;
            GlobalEvent.DispatchTypeEvent(cmd);

            world.CallRecalc();
            world.FixedLoop(WorldManager.IntervalTime);

            tc = world.GetSingletonComp <TestSingleComponent>();
            Assert.AreEqual(2, tc.testValue);
        }
 /// <summary>
 /// LoadContent will be called once per game and is the place to load
 /// all of your content.
 /// </summary>
 protected override void LoadContent()
 {
     // Create a new SpriteBatch, which can be used to draw textures.
     TutorialWorld    tl    = new TutorialWorld(Game, "Game");
     CommandComponent cp    = new CommandComponent(Game, tl);
     InputDefinitions input = InputDefinitions.CreateInput(Game);
     Camera           cam   = new Camera(Game, input, tl);
     // TODO: use this.Content to load your game content here
 }
示例#11
0
    public override void NoRecalcLateFixedUpdate(int deltaTime)
    {
        if (!isDebug)
        {
            return;
        }

        DebugMsg msg = new DebugMsg();

        msg.frame = m_world.FrameCount;
        msg.infos = new List <EntityInfo>();

        for (int i = 0; i < m_world.m_entityList.Count; i++)
        {
            EntityBase eb    = m_world.m_entityList[i];
            EntityInfo einfo = new EntityInfo();
            einfo.id = eb.ID;

            einfo.infos = new List <ComponentInfo>();

            foreach (var item in eb.m_compDict)
            {
                if (item.Value.GetType().IsSubclassOf(typeof(PlayerCommandBase)))
                {
                    CommandComponent cc   = (CommandComponent)item.Value;
                    ComponentInfo    info = new ComponentInfo();
                    cc.time         = 0;
                    info.m_compName = item.Value.GetType().Name;
                    info.content    = Serializer.Serialize(item.Value);

                    einfo.infos.Add(info);
                }
                else if (IsFilter(item.Value.GetType().Name))
                {
                    ComponentInfo info = new ComponentInfo();
                    info.m_compName = item.Value.GetType().Name;
                    info.content    = Serializer.Serialize(item.Value);

                    einfo.infos.Add(info);
                }
            }

            if (einfo.infos.Count > 0)
            {
                msg.infos.Add(einfo);
            }
        }

        List <EntityBase> list = GetEntityList();

        for (int i = 0; i < list.Count; i++)
        {
            ConnectionComponent cc = list[i].GetComp <ConnectionComponent>();
            ProtocolAnalysisService.SendMsg(cc.m_session, msg);
        }
    }
示例#12
0
 public CharacterActor(GameObject prefab, GameObject parent, Entity character)
 {
     m_graphic = new CharacterGraphic();
     m_graphic.Init(prefab, parent);
     //初始化组件
     m_commandComponent = character.GetComponent <CommandComponent>();
     m_playerComponent  = character.GetComponent <PlayerComponent>();
     m_moveComponent    = character.GetComponent <MoveComponent>();
     m_fsmComponent     = character.GetComponent <FSMComponent>();
 }
示例#13
0
        public void ValueRollbackTest()
        {
            ResourcesConfigManager.Initialize();
            WorldManager.IntervalTime = 100;

            LockStepEntityTestWorld world = (LockStepEntityTestWorld)WorldManager.CreateWorld <LockStepEntityTestWorld>();

            world.IsClient = true;
            world.IsStart  = true;
            world.IsLocal  = true;

            ConnectStatusComponent csc = world.GetSingletonComp <ConnectStatusComponent>();

            csc.confirmFrame = 0; //从目标帧之后开始计算


            SelfComponent       sc = new SelfComponent();
            RealPlayerComponent rp = new RealPlayerComponent();
            EntityBase          c1 = world.CreateEntityImmediately("Test", sc, rp);

            LockStepInputSystem.commandCache.moveDir.x = FixedMath.Create(1000);

            world.CallRecalc();
            world.FixedLoop(WorldManager.IntervalTime);

            LockStepInputSystem.commandCache.moveDir.x = FixedMath.Create(0000);

            MoveComponent mc = c1.GetComp <MoveComponent>();

            //Debug.Log("mc.pos.x " + mc.pos.x + " frame " + world.FrameCount);

            Assert.AreEqual(399, mc.pos.x.ToInt());

            CommandComponent cmd = new CommandComponent();

            cmd.frame = 1;
            cmd.id    = c1.ID;
            GlobalEvent.DispatchTypeEvent(cmd);

            world.CallRecalc();
            world.FixedLoop(WorldManager.IntervalTime);

            mc = c1.GetComp <MoveComponent>();
            //Debug.Log("mc.pos.x " + mc.pos.x + " frame " + world.FrameCount);

            for (int i = 0; i < 10; i++)
            {
                world.CallRecalc();
                world.FixedLoop(WorldManager.IntervalTime);
                mc = c1.GetComp <MoveComponent>();
                //Debug.Log("mc.pos.x " + mc.pos.x + " frame " + world.FrameCount);
            }

            Assert.AreEqual(0, mc.pos.x.ToInt());
        }
示例#14
0
        public void FromCommand(CommandComponent comp)
        {
            //moveDir = comp.moveDir.DeepCopy();
            //skillDir = comp.skillDir.DeepCopy();

            //element1 = comp.element1;
            //element2 = comp.element2;
            //isFire = comp.isFire;

            //frame = comp.frame;
            //id = comp.id;
        }
        public void FromCommand(CommandComponent comp)
        {
            moveDir  = comp.moveDir.DeepCopy();
            skillDir = comp.skillDir.DeepCopy();

            element1 = comp.element1;
            element2 = comp.element2;
            isFire   = comp.isFire;

            frame = comp.frame;
            id    = comp.id;
        }
    public override PlayerCommandBase DeepCopy()
    {
        CommandComponent cc = new CommandComponent();

        cc.id    = id;
        cc.frame = frame;

        cc.isFire   = isFire;
        cc.moveDir  = moveDir.DeepCopy();
        cc.skillDir = skillDir.DeepCopy();

        return(cc);
    }
    public static void SendMsg(this SyncSession session, CommandComponent msg)
    {
        Dictionary <string, object> data = new Dictionary <string, object>();

        data.Add("isforward", msg.isForward);
        data.Add("isback", msg.isBack);
        data.Add("isright", msg.isRight);
        data.Add("isleft", msg.isLeft);
        data.Add("isfire", msg.isFire);
        data.Add("id", msg.id);
        data.Add("frame", msg.frame);
        session.SendMsg("commandcomponent", data);
    }
示例#18
0
    public override void OnPlayerJoin(EntityBase entity)
    {
        if (!entity.GetExistComp(ComponentType.MoveComponent))
        {
            MoveComponent c = new MoveComponent();
            entity.AddComp(c);
        }

        if (!entity.GetExistComp(ComponentType.CommandComponent))
        {
            CommandComponent c = new CommandComponent();
            entity.AddComp(c);
        }
    }
    static void SendCommandComponent(IProtocolMessageInterface msg)
    {
        CommandComponent            e    = (CommandComponent)msg;
        Dictionary <string, object> data = new Dictionary <string, object>();

        data.Add("isforward", e.isForward);
        data.Add("isback", e.isBack);
        data.Add("isright", e.isRight);
        data.Add("isleft", e.isLeft);
        data.Add("isfire", e.isFire);
        data.Add("id", e.id);
        data.Add("frame", e.frame);
        NetworkManager.SendMessage("commandcomponent", data);
    }
    static void ReceviceCommandComponent(InputNetworkMessageEvent e)
    {
        CommandComponent msg = new CommandComponent();

        msg.isForward = (bool)e.Data["isforward"];
        msg.isBack    = (bool)e.Data["isback"];
        msg.isRight   = (bool)e.Data["isright"];
        msg.isLeft    = (bool)e.Data["isleft"];
        msg.isFire    = (bool)e.Data["isfire"];
        msg.id        = (int)e.Data["id"];
        msg.frame     = (int)e.Data["frame"];

        GlobalEvent.DispatchTypeEvent(msg);
    }
    static void ReceviceCommandComponent(SyncSession session, ProtocolRequestBase e)
    {
        CommandComponent msg = new CommandComponent();

        msg.isForward = (bool)e.m_data["isforward"];
        msg.isBack    = (bool)e.m_data["isback"];
        msg.isRight   = (bool)e.m_data["isright"];
        msg.isLeft    = (bool)e.m_data["isleft"];
        msg.isFire    = (bool)e.m_data["isfire"];
        msg.id        = (int)e.m_data["id"];
        msg.frame     = (int)e.m_data["frame"];

        EventService.DispatchTypeEvent(session, msg);
    }
示例#22
0
    public override PlayerCommandBase DeepCopy()
    {
        CommandComponent cc = new CommandComponent();

        cc.id    = id;
        cc.frame = frame;

        cc.isFire    = isFire;
        cc.isForward = isForward;
        cc.isBack    = isBack;
        cc.isRight   = isRight;
        cc.isLeft    = isLeft;

        return(cc);
    }
    void UpdateMove(EntityBase entity, int deltaTime)
    {
        MoveComponent    mc = (MoveComponent)entity.GetComp("MoveComponent");
        CommandComponent cc = (CommandComponent)entity.GetComp("CommandComponent");

        mc.dir        = cc.moveDir;
        mc.m_velocity = 4000;

        Vector2d newPos = mc.pos;

        newPos += mc.dir * FixedMath.Create(deltaTime).Div(FixedMath.Create(1000)).Mul(FixedMath.Create(mc.m_velocity).Div(FixedMath.Create(1000)));

        mc.pos = newPos;

        //Debug.Log("dir " + mc.dir + " ");
    }
示例#24
0
 public override void Execute(CommandComponent uc)
 {
     if (units != null)
     {
         uc.Select(units);
     }
     else if (unit != null)
     {
         uc.Select(unit);
     }
     else
     {
         throw new Exception("no unit selected"); //This should never happen if it does throw error
     }
     base.Execute(uc);
 }
        public CommandComponent ToCommand()
        {
            CommandComponent cmd = new CommandComponent();

            cmd.moveDir  = moveDir.DeepCopy();
            cmd.skillDir = skillDir.DeepCopy();
            cmd.element1 = element1;
            cmd.element2 = element2;

            cmd.isFire = isFire;

            cmd.frame = frame;
            cmd.id    = id;

            return(cmd);
        }
示例#26
0
        public void ValueRollbackTest()
        {
            LockStepTestWorld world = (LockStepTestWorld)WorldManager.CreateWorld <LockStepTestWorld>();

            world.m_isLocal = true;
            world.IsStart   = true;

            ConnectStatusComponent csc = world.GetSingletonComp <ConnectStatusComponent>();

            csc.confirmFrame = 0; //从目标帧之后开始计算

            PlayerComponent pc = new PlayerComponent();
            SelfComponent   sc = new SelfComponent();

            EntityBase c1 = world.CreateEntityImmediately(1, pc, sc);

            world.CallRecalc();
            world.FixedLoop(1000);

            MoveComponent mc = c1.GetComp <MoveComponent>();

            Debug.Log("mc.pos.x " + mc.pos.x + " frame " + world.FrameCount);

            Assert.AreEqual(19000, mc.pos.x);

            CommandComponent cmd = new CommandComponent();

            cmd.frame = 1;
            cmd.id    = 1;
            GlobalEvent.DispatchTypeEvent(cmd);

            world.CallRecalc();
            world.FixedLoop(1000);

            mc = c1.GetComp <MoveComponent>();
            //Debug.Log("mc.pos.x " + mc.pos.x + " frame " + world.FrameCount);

            for (int i = 0; i < 10; i++)
            {
                world.CallRecalc();
                world.FixedLoop(1000);
                mc = c1.GetComp <MoveComponent>();
                //Debug.Log("mc.pos.x " + mc.pos.x + " frame " + world.FrameCount);
            }

            Assert.AreEqual(15000, mc.pos.x);
        }
示例#27
0
    public override bool EqualsCmd(PlayerCommandBase cmd)
    {
        if (!(cmd is CommandComponent))
        {
            return(false);
        }

        CommandComponent cc = cmd as CommandComponent;

        if (id != cc.id)
        {
            return(false);
        }

        if (frame != cc.frame)
        {
            return(false);
        }

        if (isFire != cc.isFire)
        {
            return(false);
        }

        if (isForward != cc.isForward)
        {
            return(false);
        }

        if (isBack != cc.isBack)
        {
            return(false);
        }

        if (isRight != cc.isRight)
        {
            return(false);
        }

        if (isLeft != cc.isLeft)
        {
            return(false);
        }

        return(true);
    }
示例#28
0
    public static string GetSkillName(CommandComponent cmd)
    {
        if (s_comboData == null)
        {
            s_comboData = DataManager.GetData("CombineData");
        }

        if (cmd.element1 == Element_NoChoice && cmd.element2 == Element_NoChoice)
        {
            return(DataGenerateManager <CombineDataGenerate> .GetData(s_comboData.TableIDs[0]).m_key);
        }

        for (int i = 0; i < s_comboData.TableIDs.Count; i++)
        {
            CombineDataGenerate data = DataGenerateManager <CombineDataGenerate> .GetData(s_comboData.TableIDs[i]);

            if (data.m_ele_1 != Element_NoChoice &&
                data.m_ele_2 != Element_NoChoice
                )
            {
                if ((data.m_ele_1 == cmd.element1 && data.m_ele_2 == cmd.element2) ||
                    (data.m_ele_2 == cmd.element1 && data.m_ele_1 == cmd.element2)
                    )
                {
                    return(data.m_key);
                }
            }
            else
            {
                if ((data.m_ele_1 == cmd.element1 && data.m_ele_2 == 0) ||
                    (data.m_ele_2 == cmd.element2 && data.m_ele_1 == 0)
                    )
                {
                    return(data.m_key);
                }
            }
        }

        return(null);

        //Error!
        throw new System.Exception("Not Find SkillName!");
    }
    public override void NoRecalcBeforeFixedUpdate(int deltaTime)
    {
        List <EntityBase> list = GetEntityList();

        for (int i = 0; i < list.Count; i++)
        {
            ConnectionComponent comp = list[i].GetComp <ConnectionComponent>();
            CommandComponent    cmd  = (CommandComponent)comp.GetCommand(m_world.FrameCount);
            cmd.id    = list[i].ID;
            cmd.frame = m_world.FrameCount;

            list[i].ChangeComp(cmd);

            //Debug.Log("USE cmd id "+ list[i].ID + " frame " + cmd.frame + " content " + Serializer.Serialize(cmd));

            //到了这一帧还没有发送命令的,给预测一个并广播给所有前端
            if (comp.LastInputFrame < m_world.FrameCount)
            {
                for (int j = 0; j < list.Count; j++)
                {
                    ConnectionComponent conn = list[j].GetComp <ConnectionComponent>();

                    //lock(conn.m_unConfirmFrame)
                    {
                        ////补发未确认的帧
                        //foreach (var item in conn.m_unConfirmFrame)
                        //{
                        //    CommandMsg info = item.Value;
                        //    ProtocolAnalysisService.SendMsg(conn.m_session, info);
                        //}

                        //cmsg.index = conn.GetSendIndex();

                        //conn.m_unConfirmFrame.Add(cmsg.index, cmd);

                        ProtocolAnalysisService.SendMsg(conn.m_session, cmd);

                        //Debug.Log("消息落后或掉线 预测一个 输入并派发 comp.lastInputFrame " + comp.lastInputFrame  + " m_world.FrameCount " + m_world.FrameCount +" ID " + comp.Entity.ID);
                    }
                }
            }
        }
    }
示例#30
0
    public override void FixedUpdate(int deltaTime)
    {
        List <EntityBase> list = GetEntityList();

        for (int i = 0; i < list.Count; i++)
        {
            CommandComponent cc = list[i].GetComp <CommandComponent>();
            if (cc.isFire)
            {
                Debug.Log("Fire " + m_world.FrameCount);

                TestSingleComponent tc = m_world.GetSingletonComp <TestSingleComponent>();
                tc.testValue++;

                LifeSpanComponent lsc = new LifeSpanComponent();
                lsc.lifeTime = 500;

                m_world.CreateEntity("FireObject" + cc.Entity.ID, lsc);
            }
        }
    }
        private CommandComponent EatParameterName(Queue<char> queue)
        {
            var comp = new CommandComponent(CommandComponent.ComponentType.Parameter);

            while (queue.Count != 0 && char.IsLetterOrDigit(queue.Peek()))
                comp.Text += queue.Dequeue();

            return comp;
        }
        private CommandComponent EatQuotedString(Queue<char> queue, char quoteChar)
        {
            var comp = new CommandComponent(CommandComponent.ComponentType.Text);

            comp.Text += queue.Dequeue();	// add first ' char

            bool inEscape = false;
            while (queue.Count != 0)
            {
                char c = queue.Peek();
                if (c == '\'')
                {
                    comp.Text += queue.Dequeue();
                    inEscape = !inEscape;
                }
                else
                {
                    if (inEscape)
                        return comp;

                    comp.Text += queue.Dequeue();
                }
            }

            if (!inEscape)
                throw new CqlException("command text contains unterminated strings");

            return comp;
        }
        private CommandComponent EatTextWhile(Queue<char> queue, Func<char, bool> predicate, CommandComponent.ComponentType type)
        {
            var comp = new CommandComponent(type);

            while (queue.Count != 0 && predicate(queue.Peek()))
                comp.Text += queue.Dequeue();

            return comp;
        }