public void onClick() { if (HexGM.isShoppingRound()) { if (unit != null) { if (GameObject.ReferenceEquals(player.activeUnitObject, this.gameObject)) { // deselect player.clearActiveUnit(); this.gameObject.GetComponent <Image>().color = unit.getTierColor(); } else { player.SetActiveUnit(unit, this.gameObject); player.rgo = new Player.ResetGameObject(resetDefault); } } else if (player.getActiveUnit() != null) { ally.checkBoardForThreeUnits(player.getActiveUnit()); setUnit(player.getActiveUnit()); player.clearActiveUnit(); player.rgo(); supply.setCurrentSupply(ally.getTotalActiveUnits()); } } }
public void takeDamage(Unit attacker) { if (!HexGM.isShoppingRound() && this.unit != null) { attacker.dealDamage(this.unit); if (unit.currentHealth <= 0) { this.resetDefault(); } } }
public void setState() { isShowing = !isShowing; if (isShowing) { shop.transform.localScale = Vector3.zero; ally.transform.localScale = boardScale; if (!HexGM.isShoppingRound()) { enemy.transform.localScale = boardScale; } } else { shop.transform.localScale = shopScale; ally.transform.localScale = Vector3.zero; if (!HexGM.isShoppingRound()) { enemy.transform.localScale = Vector3.zero; } } }
// Update is called once per frame void Update() { timer.text = Mathf.FloorToInt((float)HexGM.getRoundTimer()).ToString(); }
// Update is called once per frame void Update() { if (HexGM.isBattleRound()) { /* * Check whether to display health bars */ if (unit != null && !barsActive) { activateBars(true); } if (barsActive && unit == null) { activateBars(false); } else if (barsActive && unit != null) { setHealthColor(unit.isAlly); healthBar.value = (float)unit.currentHealth / unit.health; manaBar.value = (float)unit.currentMana / unit.mana; } /* * Combat logic here */ if (unit != null && unit.readyToAttack()) { // figure out which tile to attack List <BaseTileHandler> bthl = battlefield.getClosestEnemy(coordinate, unit.isAlly); if (bthl != null) { BaseTileHandler bth = bthl[0]; int distance = Battlefield.getDistance(this.coordinate, bth.getCoordinate()); if (!(distance <= unit.range)) { // it's out of range, move instead, we already got the shortest path so try to move along the path // the first unit is the target, so we want to start with the furthest possible range from the target for (int i = unit.range; i > 0; i--) { if (bthl[i].getCurrentUnit() == null) { if (bthl[i].setUnit(this.unit)) { this.resetDefault(); return; } } } for (int i = unit.range; i < bthl.Count; i++) { if (bthl[i].getCurrentUnit() == null) { if (bthl[i].setUnit(this.unit)) { this.resetDefault(); return; } } } } else { // Create the bullet, it'll be responsible for it's own destruction var newBullet = Instantiate(AllyBullet, this.transform.position, Quaternion.identity); newBullet.transform.SetParent(this.transform.parent.parent); if (!unit.isAlly) { newBullet.GetComponent <Image>().color = Color.red; } BulletHandler b = newBullet.gameObject.GetComponent <BulletHandler>(); b.setDestination(this.transform.position, bth, unit); } } } } else if (barsActive) { activateBars(false); } }