public HeroBaseState(GameObject noum) { if (noum != null) { Noumenon = noum; NoumenonT = noum.transform; MHeroController = noum.GetComponent <HeroController>(); MMachine = MHeroController.MMachine; MCharacter = noum.GetComponent <CharacterController>(); MHeroAnimator = noum.GetComponent <HeroAnimatorController>(); } }
// ---------- INITIALIZATIONS AND UPDATE ----------------------------------------------------+ #region INITIALIZE public void Initialize(float _basePositionY, float _speed) { // Allow player input playerInputDenied = true; playerJumpDenied = true; // ----- STATE ----- heroState = HeroStates.AWAY; // ----- GAME OBJECTS ----- // Instantiate and activate hero hero = Instantiate(heroPrefab); hero.SetActive(true); // Get and deactivate sword sword = hero.transform.GetChild(0).gameObject; sword.SetActive(false); // Get and deactivate hoverboard hoverboard = hero.transform.GetChild(1).gameObject; hoverboard.SetActive(false); // ----- COMPONENTS ----- // Rigidbody heroRigidbody = hero.GetComponent <Rigidbody2D>(); // Polygon collider fullCollider = hero.GetComponent <PolygonCollider2D>(); fullCollider.isTrigger = false; // Capsule collider bottomCollider = hero.GetComponent <CapsuleCollider2D>(); bottomCollider.isTrigger = false; // Collision system CollisionSystem heroCollisions = hero.GetComponent <CollisionSystem>(); heroCollisions.InitializeHero(this); // Animator controller animatorController = hero.GetComponent <HeroAnimatorController>(); // Sword rigidbody swordRigidbody = sword.GetComponent <Rigidbody2D>(); swordRigidbody.gravityScale = deathGravityScale; // Hoverboard rigidbody hoverboardRigidbody = hoverboard.GetComponent <Rigidbody2D>(); hoverboardRigidbody.gravityScale = deathGravityScale; // ----- SET DEFAULT ANIMATION (running) ----- // Start iddle animation animatorController.StartDefaultAnimation(); // ----- SET BASE POSITION ----- basePosition = new Vector2(0, _basePositionY); // Set hero position hero.transform.position = basePosition; // ----- RESET JUMPING FLAGS ----- heroIsJumping = false; // ----- INITIALIZE DROP VELOCITIES ----- InitializeDropVelocitiesManually(); }