Exemplo n.º 1
0
    void Update()
    {
        hud.UpdateCoins(coins);

        coinTime -= Time.deltaTime;
        if (coinTime <= 0)
        {
            MakeMoney((int)coinPerProc);
            coinTime = coinCooldown;
        }

        if (isPlacingItem)
        {
            Vector3 mousePos = Input.mousePosition;
            mousePos.z = Camera.main.transform.position.z * -1;
            itemBeingBought.ItemInstance.transform.position = Camera.main.ScreenToWorldPoint(mousePos);
            if (Input.GetMouseButtonDown(0))
            {
                if (itemBeingBought.Item.Placed())
                {
                    coins        -= itemBeingBought.Item.GetCost();
                    isPlacingItem = false;
                    logManager.AddEvent($"Bought {itemBeingBought.Item.GetName().ToLower()}");
                }
            }
            if (Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.Escape))
            {
                Destroy(itemBeingBought.ItemInstance);
                isPlacingItem = false;
            }
        }
    }
Exemplo n.º 2
0
    void UpdateHunger()
    {
        hungerTime -= Time.deltaTime;
        if (hungerTime <= 0)
        {
            currentHunger -= Random.Range(hungerTick / 2, hungerTick);
            hungerTime     = Random.Range(hungerCooldown / 2, hungerCooldown * 1.5f);

            if (currentHunger <= 0)
            {
                float hit = Random.Range(5, 10);
                currentHP -= hit;
                chonk     -= hit / 50;
                if (chonk <= 1)
                {
                    chonk = 1;
                }
                log.AddEvent($"{blobbyName} is starving!");
            }

            if (currentHunger >= maxHunger)
            {
                currentHP += Random.Range(5, 10);
            }

            isHungry = currentHunger < maxHunger;
            if (isHungry)
            {
                log.AddEvent($"{blobbyName} is getting hungry.");
            }
        }
    }
Exemplo n.º 3
0
    void Update()
    {
        foreach (QueuedBlobby b in queuedBlobbies)
        {
            float progress = b.PercentComplete();

            if (b.Label != null)
            {
                b.Label.UpdateProgress(progress);
            }

            if (progress >= 1)
            {
                doneBlobbys.Add(b);
            }

            b.CurrentTime += Time.deltaTime;
        }

        bool didOne = false;

        foreach (QueuedBlobby b in doneBlobbys)
        {
            GameObject objBlobby   = Instantiate(blobbyPrefab);
            Blobby     freshBlobby = objBlobby.GetComponent <Blobby>();
            freshBlobby.transform.position = new Vector2(transform.position.x, transform.position.y) + Random.insideUnitCircle.normalized * 3;
            freshBlobby.color      = b.Color;
            freshBlobby.blobbyName = b.Name;
            log.AddEvent($"{b.Name} is born!");
            queuedBlobbies.Remove(b);
            didOne = true;
            sound.PlayNameClip(b.NameIndex);
        }

        doneBlobbys.Clear();

        if (didOne && hud.currentMenu == Menu.Spawner)
        {
            hud.ToggleMenu(Menu.None, new List <GameObject>());
            CleanGameObjectRefs();
            UpdateMenu();
        }

        if (queuedBlobbies.Count > 0)
        {
            StartSpawner();
        }
        else
        {
            StopSpawner();
        }
    }