Exemplo n.º 1
0
    // void LateUpdate()
    // {
    //   if (!(isCollidingFloor))
    //   {
    //     playerAnim.SetFloat("Speed", 1.0f);
    //   }
    // }

    void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.tag == "Goblin")
        {
            // decrease the health as long as the Goblin is in contact with the player
            bIsInContactWithGoblin = true;
        }
        else if (collision.gameObject.tag == "Ground")
        {
            isCollidingFloor = true;
            jumpBtn.GetComponent <JumpBtnHandler>().bIsClicked = false;
        }
        if (collision.gameObject.tag == "ManaStone")
        {
            // Increase mana score and set the text for the UI then destroy the pickup
            if (!(invCtrlObj.CheckInventory()))
            {
                manaScore++;
                gm.GetComponent <GM>().manaTxt.text = manaScore.ToString();
                invCtrlObj.AddToInv(collision.gameObject.GetComponent <ManaStoneController>().manaItem);
                GameObject.Destroy(collision.gameObject);
            }
            else
            {
                Debug.Log("Inventory is Full !!! ");
            }
        }
        else if (collision.gameObject.tag == "Coin")
        {
            // Increase coin score and set the text for the UI then destroy the pickup
            if (!(invCtrlObj.CheckInventory()))
            {
                coinScore++;
                gm.GetComponent <GM>().scoreTxt.text = coinScore.ToString();
                invCtrlObj.AddToInv(collision.gameObject.GetComponent <CoinController>().coinItem);
                GameObject.Destroy(collision.gameObject);
            }
            else
            {
                Debug.Log("Inventory is Full !!! ");
            }
        }
        if (collision.gameObject.tag == "BasicSword")
        {
            AddWeapon();
            // Destroy Object
            GameObject.Destroy(collision.gameObject);
        }
    }