コード例 #1
0
ファイル: TowerFactory.cs プロジェクト: chengxu-yh/ET
        public static DUnit Create(Entity domain, DUnitInfo unitInfo)
        {
            DUnit tower = DUnitFactory.Create(domain, unitInfo.UnitId);

            // 位置信息
            tower.Position = new Vector3(unitInfo.PX, unitInfo.PY, unitInfo.PZ);
            tower.Rotation = new Quaternion(unitInfo.RX, unitInfo.RY, unitInfo.RZ, unitInfo.RW);
            // 类型信息
            tower.AddComponent <UnitTypeComponent, UnitType>(UnitType.UnitTower);
            // 配置信息
            tower.AddComponent <UTowerConfigComponent, int>(unitInfo.ConfigId);
            // 运算者
            tower.AddComponent <OperationerComponent, long>(unitInfo.OperationerId);
            // 阵营信息
            tower.AddComponent <CampComponent, long, CampType>(unitInfo.GamerId, (CampType)unitInfo.Camp);
            // 数值信息
            TowerHelper.InitTowerNumberic(tower);
            // 血量恢复
            NumericComponent numeric = tower.GetComponent <NumericComponent>();

            tower.AddComponent <HPRegainComponent, int>(numeric.GetAsInt(NumericType.HPRegain));

            // 触发创建完成事件
            Game.EventSystem.Publish(new AppEventType.AfterTowerCreate()
            {
                Unit = tower
            }).Coroutine();

            return(tower);
        }
コード例 #2
0
        public static DUnit Create(Entity domain, DUnitInfo unitInfo)
        {
            DUnit trap = DUnitFactory.Create(domain, unitInfo.UnitId);

            // 位置信息
            trap.Position = new Vector3(unitInfo.PX, unitInfo.PY, unitInfo.PZ);
            trap.Rotation = new Quaternion(unitInfo.RX, unitInfo.RY, unitInfo.RZ, unitInfo.RW);
            // 类型信息
            trap.AddComponent <UnitTypeComponent, UnitType>(UnitType.UnitTrap);
            // 配置信息
            trap.AddComponent <UTrapConfigComponent, int>(unitInfo.ConfigId);
            // 运算者
            trap.AddComponent <OperationerComponent, long>(unitInfo.OperationerId);
            // 阵营信息
            trap.AddComponent <CampComponent, long, CampType>(unitInfo.GamerId, (CampType)unitInfo.Camp);
            // 旋转组件
            trap.AddComponent <TurnComponent>();
            // 数值信息
            TrapHelper.InitTrapNumberic(trap);

            // 触发创建完成事件
            Game.EventSystem.Publish(new AppEventType.AfterTrapCreate()
            {
                Unit = trap
            }).Coroutine();

            return(trap);
        }
コード例 #3
0
        public static DUnit Create(Entity domain, DUnitInfo unitInfo)
        {
            DUnit shell = DUnitFactory.Create(domain, unitInfo.UnitId);

            // 位置信息
            shell.Position = new Vector3(unitInfo.PX, unitInfo.PY, unitInfo.PZ);
            shell.Rotation = new Quaternion(unitInfo.RX, unitInfo.RY, unitInfo.RZ, unitInfo.RW);
            // 类型信息
            shell.AddComponent <UnitTypeComponent, UnitType>(UnitType.UnitShell);
            // 配置信息
            shell.AddComponent <UShellConfigComponent, int>(unitInfo.ConfigId);
            // 运算者
            shell.AddComponent <OperationerComponent, long>(unitInfo.OperationerId);
            // 阵营信息
            shell.AddComponent <CampComponent, long, CampType>(unitInfo.GamerId, (CampType)unitInfo.Camp);
            // 数值信息
            ShellHelper.InitShellNumberic(shell);

            // 触发创建完成事件
            Game.EventSystem.Publish(new AppEventType.AfterShellCreate()
            {
                Unit = shell
            }).Coroutine();

            return(shell);
        }
コード例 #4
0
ファイル: RoleFactory.cs プロジェクト: chengxu-yh/ET
        public static DUnit Create(Entity domain, DUnitInfo unitInfo)
        {
            DUnit role = DUnitFactory.Create(domain, unitInfo.UnitId);

            // 位置信息
            role.Position = new Vector3(unitInfo.PX, unitInfo.PY, unitInfo.PZ);
            role.Rotation = new Quaternion(unitInfo.RX, unitInfo.RY, unitInfo.RZ, unitInfo.RW);
            // 类型信息
            role.AddComponent <UnitTypeComponent, UnitType>(UnitType.UnitRole);
            // 配置信息
            role.AddComponent <URoleConfigComponent, int>(unitInfo.ConfigId);
            // 运算者
            role.AddComponent <OperationerComponent, long>(unitInfo.OperationerId);
            // 阵营信息
            role.AddComponent <CampComponent, long, CampType>(unitInfo.GamerId, (CampType)unitInfo.Camp);
            // 移动组件
            role.AddComponent <DMoveComponent>();
            // 旋转组件
            role.AddComponent <TurnComponent>();
            // 寻路组件
            role.AddComponent <PathComponent>();
            // 数值信息
            RoleHelper.InitRoleNumberic(role);
            // 技能组件
            role.AddComponent <SkillComponent>();

            // 触发创建完成事件
            Game.EventSystem.Publish(new AppEventType.AfterRoleCreate()
            {
                Unit = role
            }).Coroutine();

            return(role);
        }
コード例 #5
0
        public static async ETTask EnterLevelAsync(Scene zoneScene, int levelid)
        {
            try
            {
                // 1 服务器通信

                // 2 切换地图
                string scene = "Map";
                await Game.EventSystem.Publish(new AppEventType.EnterSceneStart()
                {
                    ZoneScene = zoneScene, SceneName = scene
                });

                // 3 创建场景元素

                // 4 创建城堡
                DUnitInfo roleinfo1 = new DUnitInfo();
                roleinfo1.GamerId       = zoneScene.Domain.GetComponent <GamerComponent>().myGamer.Id;
                roleinfo1.UnitId        = IdGenerater.Instance.GenerateUnitId(0);
                roleinfo1.ConfigId      = 1001;
                roleinfo1.Camp          = (int)(CampType.CampRed);
                roleinfo1.PX            = 25;
                roleinfo1.PY            = 0;
                roleinfo1.PZ            = 0;
                roleinfo1.RX            = 0;
                roleinfo1.RY            = 0;
                roleinfo1.RZ            = 0;
                roleinfo1.RW            = 1;
                roleinfo1.OperationerId = zoneScene.Domain.GetComponent <GamerComponent>().myGamer.Id;
                TowerFactory.Create(zoneScene.Domain, roleinfo1);

                DUnitInfo roleinfo2 = new DUnitInfo();
                roleinfo2.GamerId       = zoneScene.Domain.GetComponent <GamerComponent>().myGamer.Id;
                roleinfo2.UnitId        = IdGenerater.Instance.GenerateUnitId(0);
                roleinfo2.ConfigId      = 1001;
                roleinfo2.Camp          = (int)(CampType.CampGreen);
                roleinfo2.PX            = -25;
                roleinfo2.PY            = 0;
                roleinfo2.PZ            = 0;
                roleinfo2.RX            = 0;
                roleinfo2.RY            = 0;
                roleinfo2.RZ            = 0;
                roleinfo2.RW            = 1;
                roleinfo2.OperationerId = zoneScene.Domain.GetComponent <GamerComponent>().myGamer.Id;
                TowerFactory.Create(zoneScene.Domain, roleinfo2);

                // 5 通知成功
                //await Game.EventSystem.Publish(new AppEventType.EnterLevelFinish());
            }
            catch (Exception e)
            {
                Log.Error(e);
            }
        }