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); }
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); }
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); }
protected async ETTask CreateTrapViewAsync(DUnit trap) { URoleConfig config = trap.GetComponent <URoleConfigComponent>().RoleConfig; GameObject go = trap.AddComponent <DGameObjectComponent>().Init("Trap.unity3d", "Trap", config.Model, GlobalComponent.Instance.Unit); go.AddComponent <ComponentView>().Component = trap; go.transform.position = trap.Position; trap.AddComponent <DAnimatorComponent>(); await ETTask.CompletedTask; }
private async ETTask CreateTowerViewAsync(DUnit role) { UTowerConfig config = role.GetComponent <UTowerConfigComponent>().TowerConfig; GameObject go = role.AddComponent <DGameObjectComponent>().Init("Tower.unity3d", "Tower", config.Model, GlobalComponent.Instance.Unit); go.AddComponent <ComponentView>().Component = role; go.transform.position = role.Position; // 声音组件 role.AddComponent <SoundComponent>(); await ETTask.CompletedTask; }
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); }
private async ETTask CreateShellViewAsync(DUnit shell) { UShellConfig config = shell.GetComponent <UShellConfigComponent>().ShellConfig; GameObject go = shell.AddComponent <DGameObjectComponent>().Init("Shell.unity3d", "Shell", config.Model, GlobalComponent.Instance.Unit); go.AddComponent <ComponentView>().Component = shell; go.transform.position = shell.Position; await ETTask.CompletedTask; }