Ejemplo n.º 1
0
    private void Update()
    {
        repeatProtection += Time.deltaTime;

        if (transform.position.y >= -600)
        {
            transform.position = new Vector2(transform.position.x, transform.position.y - velocity);
        }
        else
        {
            Destroy(gameObject);
        }

        if (repeatProtection >= 0.1f && transform.parent != null && transform.position.y <= (transform.parent.position.y + 50f) && transform.position.y >= (transform.parent.position.y - 50f))
        {
            //cc.allCoins.Remove(transform.parent.gameObject);
            GameObject player = GameObject.FindGameObjectWithTag("Player");
            player.GetComponent <MeCoinMovement>().ContinuePlayerMovement();
            player.GetComponent <PlayerController>().canPressButtons = true;
            Transform wasParent = transform.parent;
            transform.parent = null;
            float value = 0f;
            if (wasParent.tag == "5 Dollars")
            {
                value = 5f;
            }
            else if (wasParent.tag == "1 Dollar")
            {
                value = 1f;
            }
            else if (wasParent.tag == "50 Cents")
            {
                value = 0.5f;
            }
            cc.DeSpawnMoney(wasParent.gameObject, value);
            repeatProtection = 0f;
            CanvasController.cac.UpdateCashText();
        }
    }
Ejemplo n.º 2
0
    private void OnTriggerStay(Collider other)
    {
        plusCooldown  += Time.deltaTime;
        minusCooldown += Time.deltaTime;

        if (Input.GetKeyDown(GameController.gc.interact) && canPressButtons)
        {
            if (other.tag == "Bank" && !bankUsed && cc.allCoins.Count > 1)
            {
                //run Bank code
                //if (cc.ReturnLeader().tag == "5 Dollars" && bankReturnValue == 0 && !bankUsed && cc.allCoins.Count > 1) {
                //    cc.DeSpawnMoney(cc.ReturnLeader(), 5f);
                //    bankReturnValue = 6f;
                //    bankUsed = true;

                //    SoundController.sc.PlaySound(SoundController.sc.chaChing);
                //}
                if (cc.ReturnLeader().tag == "5 Dollars")
                {
                    bankReturnValue += 7.5f;
                    cc.DeSpawnMoney(cc.allCoins[0], 5f);
                    bankUsed = true;
                }
                else if (cc.ReturnLeader().tag == "1 Dollar")
                {
                    bankReturnValue += 1.5f;
                    cc.DeSpawnMoney(cc.allCoins[0], 1f);
                    bankUsed = true;
                }
                else if (cc.ReturnLeader().tag == "50 Cents")
                {
                    return;
                }

                SoundController.sc.PlaySound(SoundController.sc.chaChing);
            }
            else if (other.tag == "Forex" && forexInvestedValue == 0 && cc.allCoins.Count > 1)
            {
                //run Forex code
                if (cc.ReturnLeader().tag == "5 Dollars")
                {
                    forexInvestedValue += 5f;
                    cc.DeSpawnMoney(cc.allCoins[0], 5f);
                }
                else if (cc.ReturnLeader().tag == "1 Dollar")
                {
                    forexInvestedValue += 1f;
                    cc.DeSpawnMoney(cc.allCoins[0], 1f);
                }
                else if (cc.ReturnLeader().tag == "50 Cents")
                {
                    forexInvestedValue += 0.5f;
                    cc.DeSpawnMoney(cc.allCoins[0], 0.5f);
                }

                SoundController.sc.PlaySound(SoundController.sc.chaChing);
            }
            else if (other.tag == "Beggar" && !beggarUsed && cc.allCoins.Count > 1)
            {
                //run Beggar code
                float value = 0f;
                if (cc.ReturnLeader().tag == "5 Dollars")
                {
                    value = 5f;
                }
                else if (cc.ReturnLeader().tag == "1 Dollar")
                {
                    value = 1f;
                }
                else if (cc.ReturnLeader().tag == "50 Cents")
                {
                    value = 0.5f;
                }
                cc.DeSpawnMoney(cc.ReturnLeader(), value);
                beggarUsed = true;
                Destroy(other.gameObject);

                SoundController.sc.PlaySound(SoundController.sc.chaChing);
            }
            // else if (other.tag == "Vending Machine") {
            //    //run Vending Machine Code
            //}
            //else if (other.tag == "Goal") {
            //    //run Goal code
            //    List<GameObject> temp = new List<GameObject>(lc.goal);
            //    for (int i = 0; i < cc.allCoins.Count; i++) {
            //        for (int j = 0; j < temp.Count; j++) {
            //            if (cc.allCoins[i] == temp[j]) {
            //                temp.Remove(temp[j]);
            //                j -= 1;
            //            }
            //        }
            //    }
            //    if (temp.Count == 0) {
            //        //You win
            //        //
            //    }
            //}
            else if (other.tag == "Life Changer Combine" && plusCooldown >= 0.25f)
            {
                cc.CombineValue();
                plusCooldown = 0f;
            }
            else if (other.tag == "Life Changer Split" && minusCooldown >= 0.25f)
            {
                cc.SplitValue();
                minusCooldown = 0f;
            }
            else if (other.tag == "Goal" && cc.totalMoneyValue == lc.goal /*&& dayCount >= lc.lastDay*/)
            {
                sc.YouWin();
            }
            CanvasController.cac.UpdateCashText();
        }
    }