public override void Step(float deltaTime) { base.Step(deltaTime); timer -= deltaTime; if (timer <= 0) { timer = span; List <int> unitIDs = physics.GetUnit(visionRadius, unitRoot.GetChild <Transform>().Position); foreach (int unitID in unitIDs) { Unit unit = Root.GetChild <WorldEntity>().GetUnit(unitID); if (unit != null && unit.Team != unitRoot.Team) { if (physics.CheckLightOfSight(unitRoot.UnitID, unit.UnitID)) { Sight sight = unit.GetChild <Sight>(); if (sight != null) { sight.SetSight(unitRoot.Team); } } } } } }
public Sight(bool isBuilding, Unit unitRoot, Entity root) : base(CombatType.Sight, unitRoot, root) { AddInheritedType(typeof(Sight)); Duration = GetYAMLObject().GetData <float>("Duration"); IsBuilding = isBuilding; foreach (Team team in Enum.GetValues(typeof(Team))) { if (isBuilding || team == unitRoot.Team) { timers.Add(team, Duration); } else { if (unitRoot.UnitID != unitRoot.OwnerUnitID) { Unit ownerUnit = Root.GetChild <WorldEntity>().GetUnit(unitRoot.OwnerUnitID); if (ownerUnit != null) { Sight sight = ownerUnit.GetChild <Sight>(); if (sight != null && sight.GetSight(team)) { timers.Add(team, Duration); continue; } } } timers.Add(team, 0); } } }
public void Damage(int unitID, bool isDamage, float amount) { hpDamageHistories.Add(new DamageHistory(unitID, isDamage, amount)); Unit enemyUnit = Root.GetChild <WorldEntity>().GetUnit(unitID); if (enemyUnit != null && enemyUnit.Team != Team) { Sight enemySight = enemyUnit.GetChild <Sight>(); if (enemySight != null) { enemySight.SetSight(Team); } Sight sight = GetChild <Sight>(); if (sight != null) { sight.SetSight(enemyUnit.Team); } } }