Esempio n. 1
0
        protected override async ETTask Run(DCET.Model.Session session, M2C_CreateUnits message)
        {
            UnitComponent unitComponent = DCET.Model.Game.Scene.GetComponent <UnitComponent>();

            foreach (UnitInfo unitInfo in message.Units)
            {
                if (unitComponent.Get(unitInfo.UnitId) != null)
                {
                    continue;
                }
                Unit unit = UnitFactory.Create(DCET.Model.Game.Scene, unitInfo.UnitId);
                unit.Position = new Vector3(unitInfo.X, unitInfo.Y, unitInfo.Z);
            }

            await ETTask.CompletedTask;
        }
Esempio n. 2
0
        public static async ETVoid OnLoginAsync(Entity domain, string account)
        {
            try
            {
                // 创建一个ETModel层的Session
                DCET.Model.Session session = DCET.Model.Game.Scene.GetComponent <NetOuterComponent>().Create(GlobalConfigComponent.Instance.GlobalProto.Address);

                // 创建一个ETHotfix层的Session, ETHotfix的Session会通过ETModel层的Session发送消息
                Session   realmSession = EntityFactory.Create <Session, DCET.Model.Session>(domain, session);
                R2C_Login r2CLogin     = (R2C_Login)await realmSession.Call(new C2R_Login()
                {
                    Account = account, Password = "******"
                });

                realmSession.Dispose();

                // 创建一个ETModel层的Session,并且保存到ETModel.SessionComponent中
                DCET.Model.Session gateSession = DCET.Model.Game.Scene.GetComponent <NetOuterComponent>().Create(r2CLogin.Address);
                DCET.Model.Game.Scene.AddComponent <DCET.Model.SessionComponent>().Session = gateSession;

                // 创建一个ETHotfix层的Session, 并且保存到ETHotfix.SessionComponent中
                Game.Scene.AddComponent <SessionComponent>().Session = EntityFactory.Create <Session, DCET.Model.Session>(Game.Scene, gateSession);

                G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await SessionComponent.Instance.Session.Call(
                    new C2G_LoginGate()
                {
                    Key = r2CLogin.Key, GateId = r2CLogin.GateId
                });

                Log.Info("登陆gate成功!");

                // 创建Player
                Player          player          = DCET.Model.EntityFactory.CreateWithId <Player>(DCET.Model.Game.Scene, g2CLoginGate.PlayerId);
                PlayerComponent playerComponent = DCET.Model.Game.Scene.GetComponent <PlayerComponent>();
                playerComponent.MyPlayer = player;

                Game.EventSystem.Run(EventIdType.LoginFinish);

                // 测试消息有成员是class类型
                G2C_PlayerInfo g2CPlayerInfo = (G2C_PlayerInfo)await SessionComponent.Instance.Session.Call(new C2G_PlayerInfo());
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }
Esempio n. 3
0
        protected override async ETTask Run(DCET.Model.Session session, M2C_PathfindingResult message)
        {
            Unit unit = DCET.Model.Game.Scene.GetComponent <UnitComponent>().Get(message.Id);


            unit.GetComponent <AnimatorComponent>().SetFloatValue("Speed", 5f);
            UnitPathComponent unitPathComponent = unit.GetComponent <UnitPathComponent>();

            unitPathComponent.StartMove(message).Coroutine();

            GizmosDebug.Instance.Path.Clear();
            GizmosDebug.Instance.Path.Add(new Vector3(message.X, message.Y, message.Z));
            for (int i = 0; i < message.Xs.Count; ++i)
            {
                GizmosDebug.Instance.Path.Add(new Vector3(message.Xs[i], message.Ys[i], message.Zs[i]));
            }

            await ETTask.CompletedTask;
        }
Esempio n. 4
0
 protected override async ETTask Run(DCET.Model.Session session, G2C_TestHotfixMessage message)
 {
     Log.Debug(message.Info);
     await ETTask.CompletedTask;
 }