/** * Removes a power orb from the board * Resets its status on orbsOnBoard array * @param p The orb to remove */ public void RemoveOrb(PowerOrb p) { for (int i = 0; i < Constants.POWER_ORB_SCRIPTS.Length; i++) { if (Constants.POWER_ORB_SCRIPTS[i].ToString() == p.ToString()) { orbsOnBoard[i] = false; numOrbsLeft++; return; } } }
/** * Removes a power orb from the player's effects * @param p The power orb to remove */ public void RemovePower(PowerOrb p) { // Get rid of power orb p.EndOrb(); effects.Remove(p); Destroy(p.gameObject); UpdateEffectsUI(); angle = trueLastAngle; // Reset angle ApplyEffects(); // Apply any remaining effects playerPointer.rotation = Quaternion.Euler(0, 0, angle); // Then set the player's pointer }
/** * Adds a power orb to the player's effects * @param orb The power orb to add */ public void AddPower(GameObject orb) { PowerOrb p = orb.GetComponent <PowerOrb>(); PrepareForPowerOrb(p); // Add the power orb p.SetPlayer(this); effects.Insert(0, p); orb.transform.parent = transform; orb.transform.localScale *= 2; UpdateEffectsUI(); }
/** * Prepares to insert a power orb * If we have a duplicate, delete the existing power orb * else, if we have too many, delete the first effect * @param power The power orb that is attempting to be added */ private void PrepareForPowerOrb(PowerOrb power) { // Check for duplicates foreach (PowerOrb p in effects) { if (p.ToString() == power.ToString()) { RemovePower(p); return; } } // Check for overflow if (effects.Count >= MAX_EFFECTS) { RemovePower(effects[0]); } }