public void HitPlayerBase(float damage) { BasePlanet hq = System.Array.Find(followers, (planet) => planet is HQPlanet); if (hq) { hq.Hit(damage); } }
// Update is called once per frame void Update() { if (!manager.running || manager.Paused) { return; } if (shipState != ShipState.Orbiting && shipState != ShipState.Moving) { return; } if (shipState == ShipState.Orbiting) { degree += angularSpeed * Time.deltaTime; Debug.Log("Angle: " + degree + ", degrees: " + Mathf.Rad2Deg * degree); Vector2 polarPos = (Vector2)rootPlanet.transform.position + new Vector2(orbitDistance * Mathf.Cos(degree), orbitDistance * Mathf.Sin(degree)); transform.rotation = Quaternion.AngleAxis(-90 + Mathf.Rad2Deg * degree, Vector3.forward); transform.position = polarPos + orbitOffset; } else { //Vector3 axis; //float deg; //transform.rotation.ToAngleAxis(out deg, out axis); //if (Mathf.Abs(targetOrientation - deg ) < 2.0f) //{ velocity = (targetPlanet.transform.position - transform.position).normalized; transform.position += (Vector3)(((float)manager.activeMetronome.TimeBetweenBeats * speedMultiplier * Time.deltaTime) * velocity); if (Vector2.Distance(transform.position, targetPlanet.transform.position) < 1) { float multiplierBonus = 1f; multipliers.ForEach((value) => multiplierBonus += value); targetPlanet.Hit(damage * multiplierBonus); multipliers.Clear(); Hit(hp); } //} //else //{ // Vector2 targetVector = targetPlanet.transform.position - transform.position; // transform.rotation = Quaternion.RotateTowards(transform.rotation, Quaternion.AngleAxis(targetOrientation, Vector3.forward), Time.deltaTime * 5.0f); //} } }