private void AddVisibleBehaviour(GameObject unit) { var unitBehaviour = unit.GetComponent <UnitBehaviour>(); VisibleBehavior vis = new VisibleBehavior(unit, unitBehaviour); unitBehaviour.VisibleBehavior = vis; }
/*private bool notDetected(VisibleBehavior enemy, VisibleBehavior unit) * { * * if (TerrainBuilder.visionScore(unit.transform, enemy.transform,maxViewDistance)) * { * detectedHostile.Add(enemy); * enemy.setDetected(unit); * return true; * } * else * { * enemy.setDetected(null); * return false; * } * }*/ /*private bool detected(VisibleBehavior vis) * { * if (TerrainBuilder.visionScore(vis.getDetectedBy().transform, vis.transform, maxViewDistance)) * { * return false; * } * else * { * var region=vis.getRegion(); * visionCells[region.x, region.y].Add(vis); * return true; * } * }*/ public static void updateUnitRegion(VisibleBehavior unit, Point newRegion) { var currentPoint = unit.getRegion(); getVisionCells(unit.team)[currentPoint.x, currentPoint.y].Remove(unit); getVisionCells(unit.team)[newRegion.x, newRegion.y].Add(unit); }
/*public override int GetHashCode() * { * return hashCode; * } * public bool Equals(VisibleBehavior obj) * { * return obj != null && obj.hashCode == this.hashCode; * }*/ internal void addHostile(VisibleBehavior b) { if (!spottedBy.ContainsKey(b)) { spottedBy.Add(b, false); } if (!spotting.ContainsKey(b)) { spotting.Add(b, false); } }
// It is the responsibility of the defender to // reveal themselves if necessary. This is done here. private void MaybeReveal(VisibleBehavior spotter) { if (spotter.CanDetect(this)) { if (_spotters.Count == 0) { ToggleUnitVisibility(true); } _spotters.Add(spotter); } }
public void RegisterUnitBirth(UnitBehaviour unit) { VisibleBehavior visibleBehavior = unit.VisibleBehavior; if (unit.Platoon.Owner.Team == LocalTeam) { AllyUnits.Add(visibleBehavior); } else { EnemyUnits.Add(visibleBehavior); visibleBehavior.ToggleUnitVisibility(false); } }
internal void setSpotting(VisibleBehavior enemy, bool p) { if (enemy == this) { Debug.LogError("error"); } if (p && !spotting[enemy]) { spotting[enemy] = true; } else { spotting[enemy] = false; } }
public static void addVisibleBehaviour(VisibleBehavior b) { var members = getTeamMembers(b.team); if (!members.Contains(b)) { members.Add(b); } var t = Team.Blue; if (t == b.team) { t = Team.Red; } getTeamMembers(t).ForEach(x => x.addHostile(b)); }
public void RegisterUnitDeath(UnitBehaviour unit) { VisibleBehavior visibleBehavior = unit.VisibleBehavior; if (visibleBehavior == null) { return; } if (unit.Platoon.Owner.Team == LocalTeam) { AllyUnits.Remove(visibleBehavior); } else { EnemyUnits.Remove(visibleBehavior); } }
internal void setSpottedBy(VisibleBehavior unit, bool p) { if (p && !spottedBy[unit]) { if (spottedByCount == 0) { setDetected(true); } spottedByCount += 1; spottedBy[unit] = true;; } if (!p && spottedBy[unit]) { spottedByCount -= 1; if (spottedByCount == 0) { setDetected(false); } spottedBy[unit] = false; } }
public static void UpdateUnitRegion(VisibleBehavior unit, Point newRegion) { //var currentPoint = unit.GetRegion(); }
private bool CanDetect(VisibleBehavior target) { float distance = Vector3.Distance(_gameObject.transform.position, target._gameObject.transform.position); return(distance < max_spot_range && distance < max_spot_range * stealth_pen_factor / target.stealth_factor); }