static void ReceviceDebugMsg(InputNetworkMessageEvent e)
    {
        Protocol.DebugMsg msg = new Protocol.DebugMsg();
        msg.frame = (int)e.Data["frame"];
        {
            List <Dictionary <string, object> > data2 = (List <Dictionary <string, object> >)e.Data["infos"];
            List <Protocol.EntityInfo>          list2 = new List <Protocol.EntityInfo>();
            for (int i2 = 0; i2 < data2.Count; i2++)
            {
                Protocol.EntityInfo tmp2 = new Protocol.EntityInfo();
                tmp2.id = (int)data2[i2]["id"];
                {
                    List <Dictionary <string, object> > data4 = (List <Dictionary <string, object> >)data2[i2]["infos"];
                    List <Protocol.ComponentInfo>       list4 = new List <Protocol.ComponentInfo>();
                    for (int i4 = 0; i4 < data4.Count; i4++)
                    {
                        Protocol.ComponentInfo tmp4 = new Protocol.ComponentInfo();
                        tmp4.m_compName = data4[i4]["m_compname"].ToString();
                        tmp4.content    = data4[i4]["content"].ToString();
                        list4.Add(tmp4);
                    }
                    tmp2.infos = list4;
                }
                list2.Add(tmp2);
            }
            msg.infos = list2;
        }

        GlobalEvent.DispatchTypeEvent(msg);
    }
    static void RecevicePursueMsg(InputNetworkMessageEvent e)
    {
        Protocol.PursueMsg msg = new Protocol.PursueMsg();
        msg.frame        = (int)e.Data["frame"];
        msg.advanceCount = (int)e.Data["advancecount"];

        GlobalEvent.DispatchTypeEvent(msg);
    }
Пример #3
0
    static void ReceviceDestroyEntityMsg(InputNetworkMessageEvent e)
    {
        Protocol.DestroyEntityMsg msg = new Protocol.DestroyEntityMsg();
        msg.frame = (int)e.Data["frame"];
        msg.id    = (int)e.Data["id"];

        GlobalEvent.DispatchTypeEvent(msg);
    }
    static void ReceviceStartSyncMsg(InputNetworkMessageEvent e)
    {
        Protocol.StartSyncMsg msg = new Protocol.StartSyncMsg();
        msg.frame        = (int)e.Data["frame"];
        msg.intervalTime = (int)e.Data["intervaltime"];

        GlobalEvent.DispatchTypeEvent(msg);
    }
        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();

            /*EntityBase c1 =*/ world.CreateEntityImmediately("1", sc);

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

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

            Assert.AreEqual(0, tc.testValue);

            TestCommandComponent cmd = new TestCommandComponent();

            cmd.frame  = 1;
            cmd.id     = 1;
            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 TestCommandComponent();
            cmd.frame  = 2;
            cmd.id     = 1;
            cmd.isFire = true;
            GlobalEvent.DispatchTypeEvent(cmd);

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

            tc = world.GetSingletonComp <TestSingleComponent>();
            Assert.AreEqual(2, tc.testValue);
        }
Пример #6
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());
        }
    static void ReceviceStartSyncMsg(InputNetworkMessageEvent e)
    {
        Protocol.StartSyncMsg msg = new Protocol.StartSyncMsg();
        msg.frame             = (int)e.Data["frame"];
        msg.advanceCount      = (int)e.Data["advancecount"];
        msg.intervalTime      = (int)e.Data["intervaltime"];
        msg.createEntityIndex = (int)e.Data["createentityindex"];
        msg.SyncRule          = (SyncRule)e.Data["syncrule"];

        GlobalEvent.DispatchTypeEvent(msg);
    }
Пример #8
0
    public override void Init()
    {
        m_SDKName = "PublicPayClass";

        GlobalEvent.AddTypeEvent <PrePay2Client>(OnPrePay);
        GlobalEvent.DispatchTypeEvent <InputUIOnClickEvent>(null);
        GlobalEvent.AddTypeEvent <InputUIOnClickEvent>((e, objs) => {
        });

        SDKManager.GoodsInfoCallBack     += OnGoodsInfoCallBack;
        StorePayController.OnPayCallBack += OnPayResultCallBack;
    }
Пример #9
0
    static void ReceviceChangeSingletonComponentMsg(InputNetworkMessageEvent e)
    {
        Protocol.ChangeSingletonComponentMsg msg = new Protocol.ChangeSingletonComponentMsg();
        msg.frame = (int)e.Data["frame"];
        {
            Dictionary <string, object> data2 = (Dictionary <string, object>)e.Data["info"];
            Protocol.ComponentInfo      tmp2  = new Protocol.ComponentInfo();
            tmp2.m_compName = data2["m_compname"].ToString();
            tmp2.content    = data2["content"].ToString();
            msg.info        = tmp2;
        }

        GlobalEvent.DispatchTypeEvent(msg);
    }
    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);
    }
Пример #11
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);
        }
Пример #12
0
    public override void Init()
    {
        m_SDKName = "PublicPayClass";
        //storeName =(StoreName)Enum.Parse( typeof(StoreName),SDKManager.GetProperties(SDKInterfaceDefine.PropertiesKey_StoreName, "None"));

        GlobalEvent.AddTypeEvent <PrePay2Client>(OnPrePay);



        //GlobalEvent.DispatchEvent("Fight",)

        GlobalEvent.DispatchTypeEvent <InputUIOnClickEvent>(null);

        GlobalEvent.AddTypeEvent <InputUIOnClickEvent>((e, objs) => {
        });

        SDKManager.GoodsInfoCallBack     += OnGoodsInfoCallBack;
        StorePayController.OnPayCallBack += OnPayResultCallBack;
    }
Пример #13
0
    public override void Init()
    {
        m_SDKName = "PublicPayClass";
        //storeName =(StoreName)Enum.Parse( typeof(StoreName),SDKManager.GetProperties(SDKInterfaceDefine.PropertiesKey_StoreName, "None"));

        //有其他的payClass符合就不启动public pay
        if (!SDKManager.GetHasPayService(storeName.ToString()))
        {
            GlobalEvent.AddTypeEvent <PrePay2Client>(OnPrePay);

            //Debug.Log("PublicPayClass Init m_SDKName:>" + m_SDKName + "<");
        }

        //GlobalEvent.DispatchEvent("Fight",)

        GlobalEvent.DispatchTypeEvent <InputUIOnClickEvent>(null);

        GlobalEvent.AddTypeEvent <InputUIOnClickEvent>((e, objs) => {
        });

        SDKManager.GoodsInfoCallBack     += OnGoodsInfoCallBack;
        StorePayController.OnPayCallBack += OnPayResultCallBack;
    }
Пример #14
0
 public override void DispatchMessage()
 {
     GlobalEvent.DispatchTypeEvent(this);
 }
    static public void Dispatch(int l_onlineTime, bool l_isNight, bool l_canPlay, RealNameStatus l_realNameStatus, bool l_isAdult)
    {
        RealNameData realNameData = new RealNameData(l_canPlay, l_realNameStatus, l_isAdult, l_onlineTime, l_isNight);

        GlobalEvent.DispatchTypeEvent(new RealNameLimitEvent(realNameData));
    }
Пример #16
0
    static void ReceviceWaitSyncComponent(InputNetworkMessageEvent e)
    {
        LockStepDemo.GameLogic.Component.WaitSyncComponent msg = new LockStepDemo.GameLogic.Component.WaitSyncComponent();

        GlobalEvent.DispatchTypeEvent(msg);
    }
Пример #17
0
 static public void Dispatch(int l_payAmount, PayLimitType l_payLimitType)
 {
     GlobalEvent.DispatchTypeEvent <CheckPayLimitResultEvent>(new CheckPayLimitResultEvent(l_payAmount, l_payLimitType));
 }
        public void SameMsgTest_1()
        {
            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();

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

            LockStepInputSystem.commandCache.moveDir.x = 0;

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

            world.CallRecalc();
            world.FixedLoop(WorldManager.IntervalTime);
            TestMoveComponent mc = c1.GetComp <TestMoveComponent>();

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

            LockStepInputSystem.commandCache.moveDir.x = 1000;

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

            mc = c1.GetComp <TestMoveComponent>();

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

            TestCommandComponent cmd = new TestCommandComponent();

            cmd.frame     = 1;
            cmd.id        = 1;
            cmd.moveDir.x = 1000;
            GlobalEvent.DispatchTypeEvent(cmd);

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

            mc = c1.GetComp <TestMoveComponent>();

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

            SameCommand sameMsg = new SameCommand();

            sameMsg.id    = 1;
            sameMsg.frame = 2;

            GlobalEvent.DispatchTypeEvent(sameMsg);

            mc = c1.GetComp <TestMoveComponent>();

            world.CallRecalc();
            world.FixedLoop(WorldManager.IntervalTime);
            mc = c1.GetComp <TestMoveComponent>();


            Assert.AreEqual(0, mc.pos.x);
        }
        public void EnityRollBackTest_4()
        {
            WorldManager.IntervalTime = 100;

            ResourcesConfigManager.Initialize();

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

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

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

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

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

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

            int createFrame  = -1;
            int destroyFrame = -1;

            string tmp = (1 + "FireObject" + 1);
            int    id  = tmp.ToHash();

            string tmp2 = (2 + "FireObject" + 1);
            int    id2  = tmp2.ToHash();

            world.OnEntityOptimizeCreated += (entity) =>
            {
                //Debug.Log("OnEntityCreate " + entity.ID + " frame " + world.FrameCount);

                if (entity.ID == id2)
                {
                    createFrame = world.FrameCount;
                }
            };

            world.OnEntityOptimizeDestroyed += (entity) =>
            {
                if (entity.ID == id2)
                {
                    destroyFrame = world.FrameCount;
                }
            };

            Assert.AreEqual(false, world.GetEntityIsExist(id));  //没执行前不存在这个对象
            Assert.AreEqual(false, world.GetEntityIsExist(id2)); //没执行前不存在这个对象

            LockStepInputSystem.commandCache.isFire = true;

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

            //id1 存在 id2 不存在
            Assert.AreEqual(true, world.GetEntityIsExist(id));
            Assert.AreEqual(false, world.GetEntityIsExist(id2));

            LockStepInputSystem.commandCache.isFire = false;

            for (int i = 0; i < 10; i++)
            {
                world.CallRecalc();
                world.FixedLoop(WorldManager.IntervalTime);
            }

            TestCommandComponent cmd = new TestCommandComponent();

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

            cmd        = new TestCommandComponent();
            cmd.frame  = 2;
            cmd.id     = 1;
            cmd.isFire = true;
            GlobalEvent.DispatchTypeEvent(cmd);

            world.CallRecalc();

            //id2 不存在 id1 不存在
            Assert.AreEqual(false, world.GetEntityIsExist(id2));
            Assert.AreEqual(false, world.GetEntityIsExist(id));

            Assert.AreEqual(-1, createFrame);  //应该不派发
            Assert.AreEqual(-1, destroyFrame); //不派发
        }
        public void EnityRollBackTest_2()
        {
            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; //从目标帧之后开始计算

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

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

            int createFrame  = -1;
            int destroyFrame = -1;

            world.OnEntityOptimizeCreated += (entity) =>
            {
                //Debug.Log("OnEntityCreate " + entity.ID + " frame " + world.FrameCount);

                createFrame = world.FrameCount;
            };

            world.OnEntityOptimizeDestroyed += (entity) =>
            {
                //Debug.Log("OnEntityDestroyed " + entity.ID + " frame " + world.FrameCount);
                destroyFrame = world.FrameCount;
            };

            string tmp = (1 + "FireObject" + 1);
            int    id  = tmp.ToHash();

            Assert.AreEqual(false, world.GetEntityIsExist(id)); //没执行前不存在这个对象

            LockStepInputSystem.commandCache.isFire = false;

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

            Assert.AreEqual(false, world.GetEntityIsExist(id)); //执行完也不存在这个对象

            TestCommandComponent cmd = new TestCommandComponent();

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

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

            Assert.AreEqual(true, world.GetEntityIsExist(id)); //重计算后对象出现

            Assert.AreEqual(1, createFrame);                   //应该立即创建处这个对象
            Assert.AreEqual(-1, destroyFrame);                 //这个对象不销毁
        }
Пример #21
0
 static public void Dispatch(int l_payAmount)
 {
     GlobalEvent.DispatchTypeEvent <CheckPayLimitEvent>(new CheckPayLimitEvent(l_payAmount));
 }