void updateSelectionIsAvailable() { if (this._selectedPosition.isEqualTo(this._homePosition) || this._selectedPosition.isEqualTo(this._doorPosition)) { this.setSelectionIsAvailable(false); } else { DefenseScript d; if (CreateDefensesScript.sharedInstance().anyDefenseAtPosition(this._selectedPosition, out d)) { this.setSelectionIsAvailable(false); } else { ArrayList pathPositions; if (PathScript.sharedInstance().existsPathFromPosToPosIfBlockingPosition(this.getDoorPosition(), this.getHomePosition(), this._selectedPosition, out pathPositions)) { this.setSelectionIsAvailable(true); } else { this.setSelectionIsAvailable(false); } } } }
public bool tryToBlockPosition(Position pos) { DefenseScript defense; bool anyDefense = CreateDefensesScript.sharedInstance().anyDefenseAtPosition(pos, out defense); if (anyDefense) { return(false); } else { bool pathCanBlockPosition = PathScript.sharedInstance().blockPosition(pos); return(pathCanBlockPosition); } }
private bool positionIsBlocked(Position pos) { bool blockedBySelf = false; bool anyDefense = false; if (this._blockedPositions != null) { int i = 0; while (!blockedBySelf && i < this._blockedPositions.Count) { Position next = (Position)this._blockedPositions [i]; blockedBySelf = pos.isEqualTo(next); i++; } } if (!blockedBySelf) { DefenseScript def; anyDefense = CreateDefensesScript.sharedInstance().anyDefenseAtPosition(pos, out def); } return(blockedBySelf || anyDefense); }
void OnDestroy() { singleton = null; }
void Awake() { singleton = this; }