public override void Awake() { base.Awake(); if (this.defenseController == null) { this.defenseController = this.transform.parent.GetComponentInParent<DefenseController>(); } }
public ADController(AttackController attackController, DefenseController defenseController) { this.state = ADStateAlt.None; this.attackController = attackController; this.defenseController = defenseController; }
void Start() { this.restartController = new RestartController(this, this.dataCenter, this.inputProviderPlayer1); movementeControllerPlayer1 = new MovementController(this.inputProviderPlayer1, this.moverPlayer1, this); movementeControllerPlayer2 = new MovementController(this.inputProviderPlayer2, this.moverPlayer2, this); shootControllerPlayer1 = new ShootController(inputProviderPlayer1, dataCenter.fireRate, dataCenter.laser1, dataCenter.ship1, this); shootControllerPlayer2 = new ShootController(inputProviderPlayer2, dataCenter.fireRate, dataCenter.laser2, dataCenter.ship2, this); defenseControllerPlayer1 = new DefenseController(inputProviderPlayer1, dataCenter.ship1, dataCenter.tower1, dataCenter.barrier1, dataCenter.towerPrice, dataCenter.barrierPrice, dataCenter.pointPlayer1, this); defenseControllerPlayer2 = new DefenseController(inputProviderPlayer2, dataCenter.ship2, dataCenter.tower2, dataCenter.barrier2, dataCenter.towerPrice, dataCenter.barrierPrice, dataCenter.pointPlayer2, this); ///-------------------------------------------------------------------------------------------------- ///Criadas por Lael this.colliderControllerPlayer1 = new ColliderController(this.dataCenter.colliderCheckerPlayer1, this.dataCenter.lifePlayer1, this.pointsPlayer2, this); this.colliderControllerPlayer2 = new ColliderController(this.dataCenter.colliderCheckerPlayer2, this.dataCenter.lifePlayer2, this.pointsPlayer1, this); this.gameOverController = new GameOverController(this.dataCenter.lifePlayer1, this.dataCenter.lifePlayer2, this); ///-------------------------------------------------------------------------------------------------- this.guiControllerPlayer1 = new GUIController(dataCenter.guiContainerPlayer1.points, dataCenter.guiContainerPlayer1.healh, dataCenter.pointPlayer1, dataCenter.lifePlayer1, this); this.guiControllerPlayer2 = new GUIController(dataCenter.guiContainerPlayer2.points, dataCenter.guiContainerPlayer2.healh, dataCenter.pointPlayer2, dataCenter.lifePlayer2, this); }
private void Initialize() { tower = GameObject.FindWithTag("Tower"); towerController = tower.GetComponent <DefenseController>(); enemy = GameObject.FindWithTag("Enemy"); enemyController = enemy.GetComponent <EnemyController>(); enemyLifePoints = ENEMY_LIFE; towerLifePoints = TOWER_LIFE; enemyTurnText.color = Color.red; playerTurnText.color = Color.green; enemyTurnText.text = "Turn: Computer"; playerTurnText.text = "Turn: Player"; countDownTurnText.gameObject.SetActive(false); countDownTimeText.gameObject.SetActive(false); }
void updateTarg() { UnitController targUnit = null; float targUnitDis = Mathf.Infinity; StructureController targStruc = null; float targStrucDis = Mathf.Infinity; DefenseController targBase = null; float targBaseDis = Mathf.Infinity; float targDis = Mathf.Infinity; targ = null; //Set targUnit UnitController[] allUnits = FindObjectsOfType <UnitController>(); foreach (UnitController u in allUnits) { if (u.atGuard()) { continue; } float dis = getDistanceFrom(u.transform); if ((dis < targUnitDis)) { targUnit = u; targUnitDis = dis; } } //Set targStruc StructureController[] allStrucs = FindObjectsOfType <StructureController>(); foreach (StructureController s in allStrucs) { float dis = getDistanceFrom(s.transform); if ((dis < targStrucDis)) { targStruc = s; targStrucDis = dis; } } //Set targBase DefenseController[] allBases = FindObjectsOfType <DefenseController>(); foreach (DefenseController s in allBases) { float dis = getDistanceFrom(s.transform); if ((dis < targBaseDis)) { targBase = s; targBaseDis = dis; } } //Debug.Log("Units Found:"+(targUnit!=null ? targUnit.ToString():"No Units") + " " + (targStruc !=null ? targStruc.ToString():"No Strucs" )+ " " + (targBase != null ? targBase.ToString(): "No bases")); //Set targ if (targUnitDis < targDis && targUnit != null) { targ = targUnit.transform; targDis = targUnitDis; } if (targStrucDis < targDis && targStruc != null) { targ = targStruc.transform; targDis = targStrucDis; } if (targBaseDis < targDis && targBase != null) { targ = targBase.transform; targDis = targBaseDis; } }