/// <summary> /// If controlling the player, switches to controlling the current minion. Responsible for enabling the required components on the minion in order to control it correctly /// </summary> private void SwitchControlledEntity() { if (_currentEntity == CurrentlyControlledEntity.Player) { if (_currentMinion == null) { return; } if (_currentMinion.GetComponent <Feet>() == null && _currentMinion.GetComponent <Arms>() == null && _currentMinion.GetComponent <Brain>() == null && _currentMinion.GetComponent <Eyes>() == null) { return; } this.Player.GetComponent <UserControlledMovement>().enabled = false; this.Player.GetComponent <BeamEmitter>().enabled = false; this.Player.GetComponent <Blink>().enabled = false; if (_currentMinion.GetComponent <UserControlledMovement>() != null) { _currentMinion.GetComponent <UserControlledMovement>().enabled = true; } _currentEntity = CurrentlyControlledEntity.Minion; EventHandler.Instance.Raise(new UnlockActorEvent() { Actor = _currentMinion }); // _currentMinion.gameObject.AddComponent<MinionAbilities>(); GenericScripts.Events.EventHandler.Instance.Raise(new ControlledEntityChangedEvent() { controlledEntity = _currentMinion }); } else if (_currentEntity == CurrentlyControlledEntity.Minion) { this.SwitchFromMinionToPlayer(); } }
// Use this for initialization void Start() { _activeDevice = InputManager.ActiveDevice; _currentEntity = CurrentlyControlledEntity.Player; if (this.Player == null) { throw new MissingReferenceException("Missing player"); } }
private void SwitchFromMinionToPlayer() { if (this.Player == null) { return; } this.Player.GetComponent <UserControlledMovement>().enabled = true; this.Player.GetComponent <BeamEmitter>().enabled = true; this.Player.GetComponent <Blink>().enabled = true; if (this._currentMinion) { if (this._currentMinion.GetComponent <UserControlledMovement>() != null) { this._currentMinion.GetComponent <UserControlledMovement>().enabled = false; } } _currentEntity = CurrentlyControlledEntity.Player; GenericScripts.Events.EventHandler.Instance.Raise(new ControlledEntityChangedEvent() { controlledEntity = this.Player }); }