public void Shrink()
    {
        if (marioForm != null)
        {
            marioForm = marioForm.Exit(marioForm.prevMario);
        }

        if (marioForm == null)
        {
            uiManager.TakeLife();
            gameObject.SetActive(false);
        }
        else
        {
            StartCoroutine("Invulnerable");
        }
    }
 // Use this for initialization
 void Start()
 {
     marioGO           = GameObject.Find("Little Mario");
     superMarioGO      = GameObject.Find("Super Mario");
     duckingMarioGO    = GameObject.Find("Ducking Mario");
     ssMarioGO         = GameObject.Find("SS Mario");
     uiManager         = UIManager.uiManager;
     rb                = gameObject.GetComponent <Rigidbody2D>();
     rb.freezeRotation = true;
     //Initialize Mario forms
     littleMarioForm = new MarioForm(this, marioGO);
     superMarioForm  = new SuperMarioForm(this, superMarioGO, littleMarioForm);
     ssMarioForm     = new SSMarioForm(this, ssMarioGO, superMarioForm);
     //Set initial form and action state
     myState   = new Walking(this);
     marioForm = littleMarioForm;
     marioForm.Enter();
     //Always start in Little Mario
     duckingMarioGO.SetActive(false);
     superMarioGO.SetActive(false);
     ssMarioGO.SetActive(false);
 }
 public MarioForm Exit(MarioForm newState)
 {
     gameObject.SetActive(false);
     return(newState);
 }
 public MarioForm(PlayerController controller, GameObject gameObject, MarioForm prevMario = null)
 {
     this.controller = controller;
     this.gameObject = gameObject;
     this.prevMario  = prevMario;
 }
 //Transition to the next Mario form. Called by the Item with which the
 //player collides, with the next Mario form as the argument.
 public void Grow(MarioForm nextMario)
 {
     marioForm = marioForm.Exit(nextMario);
     marioForm.Enter();
 }
 public SuperMarioForm(PlayerController controller, GameObject myGameObject, MarioForm prevMario) : base(controller, myGameObject, prevMario)
 {
     this.canDuck = true;
 }