public override void OnManagerRemove() { // Make the player vulnerable again if (Health != null) { Health.Invincible = false; Health = null; } // If we disabled shields before, reenable them if (DisableShields) { foreach (var shield in Manager.GetAll <Shield>()) { shield.gameObject.SetActive(true); } MoveManager.Enable <InstaShield>(); Manager.OnAdd.RemoveListener(OnAddPowerup); } // Make non-attack hitboxes harmless foreach (var hitbox in Hitboxes) { hitbox.Harmful = false; } }
public void NotifyManagerRemove(PowerupManager manager) { if (Animator != null && AddedBoolHash != 0) { var logWarnings = Animator.logWarnings; Animator.logWarnings = false; Animator.SetBool(AddedBoolHash, false); Animator.logWarnings = logWarnings; } if (Dependents.Count > 0) { foreach (var dependent in Dependents) { if (dependent.Manager == Manager) { dependent.Remove(); } } } OnManagerRemove(); Manager = null; MoveManager = null; Controller = null; OnRemove.Invoke(); Destroy(this); }
public override void OnManagerAdd() { // Make the health system invulnerable Health = Controller.GetComponent <HealthSystem>(); if (Health != null) { Health.Invincible = true; } // Disable shields for the duration of the powerup if (DisableShields) { foreach (var shield in Manager.GetAll <Shield>()) { shield.gameObject.SetActive(false); } MoveManager.Disable <InstaShield>(); // Listen for when the player gets powerups to disable shields on addition Manager.OnAdd.AddListener(OnAddPowerup); } // Make non-attack hitboxes to make them harmful Hitboxes = Controller.GetComponentsInChildren <SonicHitbox>().Where( hitbox => !hitbox.IsAttackHitbox).ToArray(); foreach (var hitbox in Hitboxes) { hitbox.Harmful = true; } }
public void Reset() { Controller = GetComponent <HedgehogController>(); MoveManager = GetComponent <MoveManager>(); OnAdd = new PowerupEvent(); OnRemove = new PowerupEvent(); }
public void NotifyManagerAdd(PowerupManager manager) { Manager = manager; MoveManager = manager.MoveManager; Controller = manager.Controller; if (Controller != null && Animator == null) { Animator = Controller.Animator; } if (Duration > 0f) { TimeRemaining = Duration; } if (Animator != null && AddedBoolHash != 0) { var logWarnings = Animator.logWarnings; Animator.logWarnings = false; Animator.SetBool(AddedBoolHash, true); Animator.logWarnings = logWarnings; } OnManagerAdd(); OnAdd.Invoke(); }
public void NotifyManagerAdd(MoveManager manager) { enabled = true; Manager = manager; PowerupManager = manager.GetComponent <PowerupManager>(); Controller = manager.Controller; if (!Animator && Controller) { Animator = Controller.Animator; } // Pretend the move is available to see if it wants to be performed on init CurrentState = State.Available; OnManagerAdd(); OnAdd.Invoke(); // If it performed itself we can exit here if (Active) { return; } if (!Available) { CurrentState = State.Unavailable; } }
public void Awake() { Controller = Controller ?? GetComponent <HedgehogController>(); MoveManager = GetComponent <MoveManager>(); Powerups = new List <Powerup>(); OnAdd = OnAdd ?? new PowerupEvent(); OnRemove = OnRemove ?? new PowerupEvent(); }
public void NotifyManagerRemove(MoveManager manager) { OnManagerRemove(); if (Controller && Animator == Controller.Animator) { Animator = null; } Manager = null; Controller = null; enabled = false; }
/// <summary> /// Adds the move to the specified move manager. /// </summary> /// <param name="manager">The specified move manager.</param> public void Add(MoveManager manager) { manager.Add(this); }
public virtual void Start() { Controller = Controller ? Controller : GetComponentInParent <HedgehogController>(); Animator = Animator ? Animator : Controller.Animator; Manager = Manager ? Manager : Controller.GetComponent <MoveManager>(); }