/** * Work out what the next waypoint is going to be * */ private void NextWaypoint() { if (isCircular) { if (!inReverse) { currentIndex = (currentIndex + 1 >= wayPoints.Length) ? 0 : currentIndex + 1; } else { currentIndex = (currentIndex == 0) ? wayPoints.Length - 1 : currentIndex - 1; } } else { // If at the start or the end then reverse if ((!inReverse && currentIndex + 1 >= wayPoints.Length) || (inReverse && currentIndex == 0)) { inReverse = !inReverse; } currentIndex = (!inReverse) ? currentIndex + 1 : currentIndex - 1; } currentWaypoint = wayPoints[currentIndex]; if (currentWaypoint.CompareTag("Despawn")) { Destroy(this.gameObject); } }
/// <summary> /// Gold cost === how do I find a variable on an object not yet instantiated? for finding tower gold cost. /// </summary> public void AddTower(Tower tower) { int currentGold = FindObjectOfType <GoldManagement>().CurrentGold(); int cost = (int)FindGoldCost(tower); if (lastWaypoint.isAvailable && currentGold >= cost) { var newTower = Instantiate(tower, lastWaypoint.transform.position, Quaternion.identity); newTower.transform.parent = towerParentTransform; lastWaypoint.isAvailable = false; FindObjectOfType <GoldManagement>().TowerCost(cost); if (lastWaypoint.CompareTag("Buff Tile")) { newTower.TowerBuff(); } //CheckWhichUpgradesAreApplicable(tower); } else { print("Unable to build here."); } }
/** * Work out what the next waypoint is going to be * */ private void NextWaypoint() { if (isCircular) { if (!inReverse) { currentIndex = (currentIndex + 1 >= wayPoints.Length) ? 0 : currentIndex + 1; } else { currentIndex = (currentIndex == 0) ? wayPoints.Length - 1 : currentIndex - 1; } } else { // If at the start or the end then reverse if ((!inReverse && currentIndex + 1 >= wayPoints.Length) || (inReverse && currentIndex == 0)) { inReverse = !inReverse; } currentIndex = (!inReverse) ? currentIndex + 1 : currentIndex - 1; } currentWaypoint = wayPoints[currentIndex]; if (currentWaypoint.CompareTag("Despawn")) { //spawn ghost //animator.SetTrigger ("tombOpen"); Destroy(this.gameObject); Instantiate(ghost, transform.position, Quaternion.identity); } }
/** * Work out what the next waypoint is going to be * */ private void NextWaypoint() { if (isCircular) { if (!inReverse) { currentIndex = (currentIndex + 1 >= wayPoints.Length) ? 0 : currentIndex + 1; } else { currentIndex = (currentIndex == 0) ? wayPoints.Length - 1 : currentIndex - 1; } } else { // If at the start or the end then reverse if ((!inReverse && currentIndex + 1 >= wayPoints.Length) || (inReverse && currentIndex == 0)) { inReverse = !inReverse; } currentIndex = (!inReverse) ? currentIndex + 1 : currentIndex - 1; } if (currentWaypoint == wayPoints[1] && randomInt == 1) { currentWaypoint = wayPoints[7]; currentIndex = 7; } else if (currentWaypoint == wayPoints[2] && randomInt == 1) { currentWaypoint = wayPoints[6]; currentIndex = 6; } else if (currentWaypoint == wayPoints[8] && randomInt == 1) { currentWaypoint = wayPoints[15]; currentIndex = 15; } else if (currentWaypoint == wayPoints[9] && randomInt == 1) { currentWaypoint = wayPoints[13]; currentIndex = 13; } else if (currentWaypoint == wayPoints[14] && randomInt == 1) { currentWaypoint = wayPoints[24]; currentIndex = 24; } else if (currentWaypoint == wayPoints[16] && randomInt == 1) { currentWaypoint = wayPoints[22]; currentIndex = 22; } else if (currentWaypoint == wayPoints[17] && randomInt == 1) { currentWaypoint = wayPoints[21]; currentIndex = 21; } else if (currentWaypoint == wayPoints[23] && randomInt == 1) { currentWaypoint = wayPoints[31]; currentIndex = 31; } else if (currentWaypoint == wayPoints[25] && randomInt == 1) { currentWaypoint = wayPoints[29]; currentIndex = 29; } else if (currentWaypoint == wayPoints[30] && randomInt == 1) { currentWaypoint = wayPoints[37]; currentIndex = 37; } else if (currentWaypoint == wayPoints[32] && randomInt == 1) { currentWaypoint = wayPoints[36]; currentIndex = 36; } else { currentWaypoint = wayPoints[currentIndex]; } if (currentWaypoint.CompareTag("Despawn")) { Destroy(this.gameObject); } }