void Awake() { // register with game context so this game object can be accessed everywhere _gameManager = GameManager.instance; Logger.Info("Playercontroller awoke and added to game context instance."); boxCollider = GetComponent <BoxCollider2D>(); boxColliderOffsetDefault = boxCollider.offset; boxColliderSizeDefault = boxCollider.size; #region set up special purpose child transforms Transform childTransform; // TODO (Roman): these checks should come from an inherited class as not all playable characters will share the same special transforms childTransform = this.transform.FindChild("SpinMeleeAttackBoxCollider"); if (childTransform != null) { Logger.Assert(childTransform != null, "Player controller is expected to have a SpinMeleeAttackBoxCollider child object. If this is no longer needed, remove this line in code."); spinMeleeAttackBoxCollider = childTransform.gameObject; spinMeleeAttackBoxCollider.SetActive(false); // we only want to activate this when the player performs the attack. } childTransform = this.transform.FindChild("LaserGunAim"); if (childTransform != null) { laserGunAimContainer = new LaserGunAimContainer(); laserGunAimContainer.Initialize(childTransform); } childTransform = this.transform.FindChild("SpriteAndAnimator"); Logger.Assert(childTransform != null, "Player controller is expected to have a SpriteAndAnimator child object. If this is no longer needed, remove this line in code."); sprite = childTransform.gameObject; animator = childTransform.gameObject.GetComponent <Animator>(); #endregion characterPhysicsManager = GetComponent <CharacterPhysicsManager>(); //animator = this.transform.GetComponent<Animator>(); // listen to some events for illustration purposes characterPhysicsManager.onControllerCollidedEvent += onControllerCollider; characterPhysicsManager.onTriggerEnterEvent += onTriggerEnterEvent; characterPhysicsManager.onControllerLostGround += characterPhysicsManager_onControllerLostGround; characterPhysicsManager.onControllerBecameGrounded += characterPhysicsManager_onControllerBecameGrounded; _reusableWallJumpControlHandler = new WallJumpControlHandler(this); _reusableWallJumpEvaluationControlHandler = new WallJumpEvaluationControlHandler(this); PushControlHandler(new GoodHealthPlayerControlHandler(this)); _gameManager.powerUpManager.PowerMeter = 1; adjustedGravity = jumpSettings.gravity; }
void Awake() { _gameManager = GameManager.Instance; PlayerHealth = new PlayerHealth(this); InitializeBoxCollider(); InitializeSpriteAndAnimator(); InitializeCharacterPhysicsManager(); InitializeWeapons(); _reusableWallJumpControlHandler = new WallJumpControlHandler(this); _reusableWallJumpEvaluationControlHandler = new WallJumpEvaluationControlHandler(this); PushControlHandler(new DefaultPlayerControlHandler(this)); AdjustedGravity = JumpSettings.Gravity; }