private void Start() { snapToObject = null; player = GetComponent <Player>(); playerMovement = GetComponent <IPlayerMovement>(); stateManager = GetComponent <PlayerStateManager>(); rb2d = GetComponent <Rigidbody2D>(); if (playerMovement != null && stateManager != null) { stateManager.CallOnStateEnter( State.Posession, playerMovement.FreezePlayer); stateManager.CallOnStateExit( State.Posession, playerMovement.UnFreezePlayer); PlayerMovement actualPlayerMovement = playerMovement as PlayerMovement; if (actualPlayerMovement != null) { ballTurnSpeed = actualPlayerMovement.rotationSpeed / 250; } } laserGuide = this.GetComponent <LaserGuide>(); this.FrameDelayCall(() => { GetGoal(); GetTeammate(); }, 2); NotificationManager notificationManager = GameManager.instance.notificationManager; notificationManager.CallOnMessage(Message.GoalScored, HandleGoalScored); }
private void Start() { playerMovement = this.EnsureComponent <PlayerMovement>(); ballCarrier = this.EnsureComponent <BallCarrier>(); stateManager = this.EnsureComponent <PlayerStateManager>(); player = this.EnsureComponent <Player>(); stateManager.CallOnStateEnter(State.Posession, StartTimer); stateManager.CallOnStateExit( State.Posession, () => StopShootBallCoroutines()); GameManager.instance.notificationManager.CallOnMessageIfSameObject( Message.PlayerPressedShoot, OnShootPressed, gameObject); GameManager.instance.notificationManager.CallOnMessageIfSameObject( Message.PlayerReleasedShoot, OnShootReleased, gameObject); Ball ball = GameObject.FindObjectOfType <Ball>(); InitializeCircularIndicators(); // This is for team selection screen // In this situation, maxChargeShotTime is irrelevant => change it to // make later logic more elegant. NOTE: If removing this, also change // the comment above (by the declaration of maxChargeShotTime) if (maxChargeShotTime <= 0.0f) { maxChargeShotTime = forcedShotTime; } }
private void Start() { PlayerStateManager stateManager = this.EnsureComponent <PlayerStateManager>(); stateManager.CallOnStateEnter( State.Stun, () => StartCoroutine(StunEffectRoutine())); stateManager.CallOnStateExit(State.Stun, () => stopEffect = true); }
public void RegisterPlayer(PlayerStateManager player) { Player playerComponent = player.GetComponent <Player>(); foreach (State state in (State[])System.Enum.GetValues(typeof(State))) { player.CallOnStateEnter( state, () => onAnyPlayerStartSubscribers[state](playerComponent)); player.CallOnStateExit( state, () => onAnyPlayerEndSubscribers[state](playerComponent)); player.CallOnAnyStateChange( (State start, State end) => onAnyChangeSubscribers(playerComponent, start, end)); } }
private void Start() { stateManager = this.EnsureComponent <PlayerStateManager>(); stateManager.CallOnStateEnter(triggerState, StateStart); stateManager.CallOnStateExit(triggerState, StateEnd); }