Ejemplo n.º 1
0
    void OnMouseDown()
    {
        pickupSound       = world.GetComponent <AudioSource>();
        playerVariables   = world.GetComponent <PlayerVariableHolder>();
        choppingBarCanvas = this.gameObject.transform.GetChild(1).gameObject;
        choppingBarSlider = choppingBarCanvas.GetComponentInChildren <Slider>();

        if (clicked == false)
        {
            woodPileInitialSize = Mathf.Ceil(Random.Range(minWoodPileSize, maxWoodPileSize));
            woodPileSize        = woodPileInitialSize;

            clicked = true;
        }

        if (playerVariables.isPlayerInventoryFull == true)
        {
            playerVariables.displayInventoryFullWarning = true;
            failSound.Play(0);
        }

        if (playerVariables.isPlayerInventoryFull == false)
        {
            if (playerVariables.maxWood - playerVariables.wood >= woodPileSize)
            {
                //mover o jogador a pilha

                playerVariables.wood += woodPileSize;
                if (playerVariables.soundEffects == true)
                {
                    pickupSound.Play(0);
                }
                Destroy(gameObject);
            }


            else
            {
                //mover o jogador a pilha

                choppingBarCanvas.SetActive(true);
                woodPileSize           -= playerVariables.maxWood - playerVariables.wood;
                choppingBarSlider.value = woodPileSize / woodPileInitialSize;
                playerVariables.wood   += playerVariables.maxWood - playerVariables.wood;
                if (playerVariables.soundEffects == true)
                {
                    pickupSound.Play(0);
                }
            }
        }
    }
Ejemplo n.º 2
0
 void Start()
 {
     world                  = GameObject.Find("World");
     player                 = world.GetComponent <World>().player;
     torch                  = world.GetComponent <World>().torch;
     fireplaceText          = world.GetComponent <World>().fireplaceText;
     fireplaceTextBackimage = world.GetComponent <World>().fireplaceTextBackimage;
     fuel            = fireplaceInitialFuel;
     luz             = GetComponentInChildren <Light>();
     playerVariables = world.GetComponent <PlayerVariableHolder>();
     torch.SetActive(false);
     torchScript     = torch.GetComponent <TorchLight>();
     fireplaceStatus = fireplaceText.GetComponent <Text>();
     pickupSound     = world.GetComponent <AudioSource>();
 }
Ejemplo n.º 3
0
    void OnMouseDown()
    {
        //some changes here too
        world             = GameObject.Find("World");
        playerVariables   = world.GetComponent <PlayerVariableHolder>();
        choppingBarCanvas = this.gameObject.transform.GetChild(1).gameObject;
        choppingBarSlider = choppingBarCanvas.GetComponentInChildren <Slider>();
        pickupSound       = world.GetComponent <AudioSource>();

        if (playerVariables.isPlayerInventoryFull == true)
        {
            playerVariables.displayInventoryFullWarning = true;
            failSound.Play(0);
        }

        if (playerVariables.isPlayerChopping == false && playerVariables.isPlayerInventoryFull == false)
        {
            EventManager.Instance.DispatchEvent(voxel);

            isReady = true;
        }
    }
Ejemplo n.º 4
0
 // Start is called before the first frame update
 void Start()
 {
     world           = GameObject.Find("World");
     playerVariables = world.GetComponent <PlayerVariableHolder>();
 }