/// <summary>
 /// Function for checking if the CauldronCrafting component is null and assumes a none null value means a cauldron.
 /// </summary>
 /// <param name="cauldron">CauldronCrafting component of cauldron.</param>
 /// <returns>Returns whether the CauldronCrafting component is owned by the player.</returns>
 private bool CauldronCheckAndRun(CauldronController cauldron)
 {
     // Does the collided object contain a CauldronCrafting component? I.e. is it a cauldron.
     if (cauldron == playerCauldron)
     {
         Debug.Log("I Have Collided with my cauldron!");
         if (Input.GetButtonDown("LeftFace" + _mPlayerNumber))
         {
             // Give left inventory slot to cauldron (even if empty)
             _leftInventorySlot = cauldron.AddIngredient(_leftInventorySlot);
         }
         else if (Input.GetButtonDown("UpFace" + _mPlayerNumber))
         {
             // Give up inventory slot to cauldron (even if empty)
             _upInventorySlot = cauldron.AddIngredient(_upInventorySlot);
         }
         else if (Input.GetButtonDown("RightFace" + _mPlayerNumber))
         {
             // Give right inventory slot to cauldron (even if empty)
             _rightInventorySlot = cauldron.AddIngredient(_rightInventorySlot);
         }
         else if (Input.GetButtonDown("DownFace" + _mPlayerNumber))
         {
             // Give down inventory slot to cauldron (even if empty)
             _downInventorySlot = cauldron.AddIngredient(_downInventorySlot);
         }
         // Collision is with a cauldron.
         return(true);
     }
     // Collision is not with a cauldron.
     return(false);
 }
Exemplo n.º 2
0
    // private bool actionDone = false;

    void Start()
    {
        GameObject theCauldron = GameObject.Find("Cauldron");

        cauldronController = theCauldron.GetComponent <CauldronController>();

        GameObject theBed = GameObject.Find("bed_controller");

        bedController = theBed.GetComponent <BedController>();

        player = GetComponent <Rigidbody2D>();
    }
Exemplo n.º 3
0
    void Start()
    {
        GameObject theCauldron = GameObject.Find("Cauldron");

        cauldronController = theCauldron.GetComponent <CauldronController>();

        GameObject theBed = GameObject.Find("bed_controller");

        bedController = theBed.GetComponent <BedController>();

        player = GetComponent <Rigidbody2D>();

        lifeText.text       = "Life: " + life;
        lifeShadowText.text = "Life: " + life;
    }
    // On trigger stay (used instead of enter since buttons are also checked).
    void OnTriggerStay(Collider other)
    {
        if (other.isTrigger)
        {
            // Check to see if collided with cauldron.
            CauldronController cauldron = other.GetComponent <CauldronController>();
            bool cauldronCollision      = false;
            if (cauldron != null)
            {
                cauldronCollision = CauldronCheckAndRun(cauldron);
            }

            Debug.Log("Colliding with my cauldron: " + cauldronCollision);

            // Check to see if collided with ingredient
            IngredientInformation ingredient = other.GetComponent <IngredientInformation>();
            bool ingredientCollision         = ingredient != null;
            if (!cauldronCollision && ingredientCollision)
            {
                IngredientCheckAndRun(ingredient);
            }

            Debug.Log("Colliding with ingredient: " + ingredientCollision);

            collidingWithInteractiveObject = cauldronCollision || ingredientCollision;

            // EXPLOSION
            if (other.gameObject.tag == "Explosion" && playerExploded == false)
            {
                print("Oh dear i'm dead");
                playerExploded = true;
                PlayerDeath();
                playerExploded = false;
            }
        }
    }