public static void UpdateUnitList(this Trigger self) { ListComponent <long> deleteList = ListComponent <long> .Create(); DUnitComponent dUnitComponent = self.Domain.GetComponent <DUnitComponent>(); for (int i = 0; i < self.UnitList.List.Count; i++) { DUnit unit = dUnitComponent.Get(self.UnitList.List[i]); if (unit == null) { deleteList.List.Add(unit.Id); continue; } if (unit.GetComponent <UnitStateComponent>().UnitState == (int)UnitState.Death) { deleteList.List.Add(unit.Id); } } for (int i = 0; i < deleteList.List.Count; i++) { self.UnitList.List.Remove(deleteList.List[i]); } deleteList.List.Clear(); }
public static void InitShellNumberic(DUnit shell) { NumericComponent numeric = shell.AddComponent <NumericComponent>(); UShellConfig config = shell.GetComponent <UShellConfigComponent>().ShellConfig; // 速度 numeric.Set(NumericType.SpeedBase, config.MoveSpeed); }
public static void InitTrapNumberic(DUnit trap) { NumericComponent numeric = trap.AddComponent <NumericComponent>(); UTrapConfig config = trap.GetComponent <UTrapConfigComponent>().TrapConfig; // 攻速 numeric.Set(NumericType.AttackSpeedBase, config.AttackSpeed); // 攻击力 numeric.Set(NumericType.HPDamageBase, config.HPDamage); }
public static bool IsOperationer(DUnit unit) { if (unit.GetComponent <OperationerComponent>().OperationerId == unit.Domain.GetComponent <GamerComponent>().myGamer.Id) { return(true); } else { return(false); } }
public static int GetBattleRoleCount(DUnit tower) { NumericComponent numeric = tower.GetComponent <NumericComponent>(); int halfHpAdd = (numeric.GetAsInt(NumericType.Hp) - numeric.GetAsInt(NumericType.HpBase)) / 2; if (halfHpAdd <= 0) { return(0); } int RoleId = tower.GetComponent <UTowerConfigComponent>().TowerConfig.RoleId; URoleConfig RoleConfig = URoleConfigCategory.Instance.Get(RoleId); if (RoleConfig == null) { return(0); } return(halfHpAdd / RoleConfig.HP); }
public static void SummonRoles(DUnit tower, long gamerid, int count, long targetid) { // 自身血量检测 NumericComponent numeric = tower.GetComponent <NumericComponent>(); int hpAdd = (numeric.GetAsInt(NumericType.Hp) - numeric.GetAsInt(NumericType.HpBase)); if (hpAdd <= 0) { return; } // 召唤数量检测 int roleConfigId = tower.GetComponent <UTowerConfigComponent>().TowerConfig.RoleId; int roleHp = URoleConfigCategory.Instance.Get(roleConfigId).HP; if (roleHp * count > hpAdd) { count = hpAdd / roleHp; } // 包装召唤ROLE DUnitInfo roleinfo = new DUnitInfo(); roleinfo.GamerId = gamerid; roleinfo.UnitId = IdGenerater.Instance.GenerateUnitId(0); roleinfo.ConfigId = roleConfigId; roleinfo.Camp = (int)(tower.GetComponent <CampComponent>().Camp); roleinfo.PX = tower.Position.x; roleinfo.PY = tower.Position.y; roleinfo.PZ = tower.Position.z; roleinfo.RX = tower.Rotation.x; roleinfo.RY = tower.Rotation.y; roleinfo.RZ = tower.Rotation.z; roleinfo.RW = tower.Rotation.w; roleinfo.Count = count; roleinfo.TargetId = targetid; roleinfo.OperationerId = gamerid; RoleFactory.Create(tower.Domain, roleinfo); }
public void Run(EventType.NumbericChange args) { DUnit tower = args.Parent as DUnit; if (tower != null) { HPRegainComponent hPRegainComponent = tower.GetComponent <HPRegainComponent>(); if (hPRegainComponent != null) { hPRegainComponent.HpRegain = (int)args.New; } } }
public static void InitTowerNumberic(DUnit tower) { NumericComponent numeric = tower.AddComponent <NumericComponent>(); UTowerConfig config = tower.GetComponent <UTowerConfigComponent>().TowerConfig; // 最大血量 numeric.Set(NumericType.MaxHpBase, config.MaxHP); // 血量 numeric.Set(NumericType.HpBase, config.HP); // 攻速 numeric.Set(NumericType.AttackSpeedBase, config.AttackSpeed); // 血量恢复 numeric.Set(NumericType.HPRegainBase, config.HPRegain); // 攻击力 numeric.Set(NumericType.HPDamageBase, config.HPDamage); }
public static void InitRoleNumberic(DUnit role) { NumericComponent numeric = role.AddComponent <NumericComponent>(); URoleConfig config = role.GetComponent <URoleConfigComponent>().RoleConfig; // 最大血量 numeric.Set(NumericType.MaxHpBase, config.HP); // 血量 numeric.Set(NumericType.HpBase, config.HP); // 速度 numeric.Set(NumericType.SpeedBase, config.MoveSpeed); // 攻速 numeric.Set(NumericType.AttackSpeedBase, config.AttackSpeed); // 攻击力 numeric.Set(NumericType.HPDamageBase, config.HPDamage); // 警戒范围 numeric.Set(NumericType.AlertRadiusBase, config.AlertRadius); }
public static void SetUnitNumericActionImp(DUnit unit, NumericType numeric, float val) { NumericComponent numericComponent = unit.GetComponent <NumericComponent>(); numericComponent.Set(numeric, val); }