/// <summary> /// Checking if station was clicked /// </summary> public void CheckForStationClicked(PlayerStation station) { if (!cam.moving && playerReady) { for (int i = 0; i < players.Count; i++) { if (players[i] == station) { if (cam.currState == CameraScript.CameraState.Start) { cam.SetNextPlayer(i); cam.currState = CameraScript.CameraState.Base; players[i].GetComponent <PlayerStation>().labelOffset = 2; zoomed = true; camBase = i; } else { ZoomOut(); } return; } } } }
/// <summary> /// Checks state of station, changes missile and station variables accordingly, and relaunches missile if necessary /// </summary> /// <param name="target">Station to check for impact</param> public void CheckStation(PlayerStation target) { if (target.Action == "Reflect") { //missle boop bounces++; Launch(target, target.Target); AudioManager.Instance.PlayOneShot("radar_Beep", 1); } else if (target.Action == "Shield") { //missle explosion //GameManager.Instance.missiles.Remove(this); GameManager.Instance.numMissiles--; AudioManager.Instance.PlayOneShot("forcefield_Hit", 1); Destroy(gameObject); } else { //missle and base explosion target.TakeDamage(); GameManager.Instance.numMissiles--; AudioManager.Instance.PlayOneShot("missile_Hit", 1); Explode(); Destroy(gameObject); } }
/// <summary> /// sets values if using manager /// </summary> public void UseManagerStart() { playerCount = manager.players.Count; playerNum = 0; currPlayer = manager.players[playerNum]; nextPlayer = manager.players[playerNum + 1]; degrees = new Vector3(0, 0, 360 / playerCount); }
void DisplayResources(PlayerStation player) { for (int i = 0; i < resourceList.Count; i++) { if (i < player.Resources) { resourceList[i].enabled = true; } else { resourceList[i].enabled = false; } } }
void DisplayHealth(PlayerStation player) { for (int i = 0; i < healthList.Count; i++) { if (i < player.Health) { healthList[i].enabled = true; } else { healthList[i].enabled = false; } } }
/// <summary> /// Finds the target of attack, accounting for target reflections /// Preventing Reflection loops /// </summary> /// <returns> Whether a target was found before missle dies off </returns> public bool FindTarget() { int reflections = 0; while (Target.Action == "Reflect" && reflections < 8) { reflections++; PlayerStation newTarget = Target.Target; Target = newTarget; } if (reflections < 8) { return(true); } else { Debug.Log("Missle ran out of fuel!"); } return(false); }
/// <summary> /// Sets up the missile arc and puts it into play /// </summary> /// <param name="origin">Station at beginning of arc</param> /// <param name="destination">Station at end of arc</param> public void Launch(PlayerStation origin, PlayerStation destination) { this.origin = origin; this.destination = destination; //Distance is set to the angle between origin/destination stations float distance = Vector3.SignedAngle(origin.Direction, destination.Direction, Vector3.forward); //Tells missile which direction is forward if (distance > 0) { angle = 90; } else { angle = -90; } //Sets speed based on distance between origin/destination if (maxSpeed <= 0) { maxSpeed = 3.5f; } speed = (Mathf.Abs(distance) / 180) * maxSpeed; //Changes the destination station's direction by half a degree to avoid 180 arc problem if (distance == 180) { destination.Direction = Quaternion.AngleAxis(-0.5f, Vector3.forward) * destination.Direction; } else if (distance == -180) { destination.Direction = Quaternion.AngleAxis(0.5f, Vector3.forward) * destination.Direction; } timer = 0; inFlight = true; }
//Constructor public MissileData(PlayerStation origin, PlayerStation destination) { InFlight = false; this.Origin = origin; this.Destination = destination; }