Example #1
0
    //if player holds down button, spawns a fort in front of them
    IEnumerator gatherSnow()
    {
        gatheringSnow = true;
        float time = 0f;

        CollectingUI.transform.parent.gameObject.SetActive(true);
        while (inputDevice.Action2.IsPressed)
        {
            if (!touchingSnowPile)
            {
                break;
            }

            if (snowPile.snow_amount < snowPile.amount_needed_for_fort)
            {
                break;
            }


            time += Time.deltaTime;
            CollectingUI.fillAmount = time;
            if (time >= timeToCollect)
            {
                //create fort in front of player and remove snow
                if (snowPile != null)
                {
                    snowPile.removeSnow(amountOfSnowNeeded);
                    Vector3    startingOffset = this.transform.forward * distanceFromPlayer;
                    GameObject newFort        = (GameObject)Instantiate(Fort,
                                                                        this.transform.position + startingOffset, camera.transform.rotation);
                    float test = 0f;
                    newFort.transform.position = new Vector3(newFort.transform.position.x,
                                                             .5f, newFort.transform.position.z);
                }
                break;
            }
            yield return(null);
        }


        gatheringSnow = false;
        CollectingUI.transform.parent.gameObject.SetActive(false);
    }
Example #2
0
    IEnumerator gatherSnow()
    {
        gatheringSnow = true;
        float time = 0f;

        CollectingUI.transform.parent.gameObject.SetActive(true);
        while (inputDevice.Action1.IsPressed)
        {
            if (!touchingSnowPile)
            {
                break;
            }

            if (shooting.snowAmount == shooting.maxSnowAmount)
            {
                break;
            }

            if (shooting.isShooting)
            {
                break;
            }
            time += Time.deltaTime;
            CollectingUI.fillAmount = time;
            if (time >= timeToCollect)
            {
                shooting.addSnowBall(1);
                if (snowPile != null)
                {
                    snowPile.removeSnow(1);
                }
                time = 0;
            }
            yield return(null);
        }


        gatheringSnow = false;
        CollectingUI.transform.parent.gameObject.SetActive(false);
    }