Beispiel #1
0
    void Awake()
    {
        Instance = this;

        if (!PlayerPrefs.HasKey("Money"))
        {
            PlayerPrefs.SetInt("Money", 0);
            isX2 = false;
        }

        //for debug

        /*if (PlayerPrefs.GetInt("isX2") == 1) {
         *      isX2Text.text = "x2 True";
         * } else {
         *      isX2Text.text = "x2 False";
         * }*/

        MoneyText.text = PlayerPrefs.GetInt("Money").ToString();
        money          = PlayerPrefs.GetInt("Money");
        if (PlayerPrefs.GetInt("isX2") == 1)
        {
            isX2 = true;
        }
        else
        {
            isX2 = false;
        }
    }
Beispiel #2
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (!EventSystem.current.IsPointerOverGameObject())
            {
                if (Physics.Raycast(ray, out hit, 100, LayerMask.GetMask("Tile", "UI")))
                {
                    if (selectedTile != null)
                    {
                        selectedTile.Select(false);
                    }

                    selectedTile = hit.transform.gameObject.GetComponent <Tile>();
                    selectedTile.Select(true);

                    UIManager.GetUIManager().ShowMenu(true, selectedTile);
                    AudioManager.GetAudioManager().PlaySelect();
                }
                else
                {
                    if (selectedTile != null)
                    {
                        selectedTile.Select(false);
                        selectedTile = null;
                        UIManager.GetUIManager().ShowMenu(false, null);
                    }
                }
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            if (selectedTile != null)
            {
                if (!MoneyTracker.GetMoneyTracker().CanAfford(poleCost))
                {
                    AudioManager.GetAudioManager().PlayDenied();
                    return;
                }
                else
                {
                    if (selectedTile.CreateBuilding(pole))
                    {
                        MoneyTracker.GetMoneyTracker().BuyFor(poleCost);
                        pole.GetComponent <BuildSound>().Play();
                        UIManager.GetUIManager().ShowMenu(true, selectedTile);
                    }
                }
            }
        }

        if (Input.GetKey("escape"))
        {
            Application.Quit();
        }
    }
Beispiel #3
0
 public static void GetMoney()
 {
     PlayFab.ClientModels.GetUserInventoryRequest request = new PlayFab.ClientModels.GetUserInventoryRequest();
     PlayFabClientAPI.GetUserInventory(request, result => {
         MoneyTracker.SetMoneyText(result.VirtualCurrency["NM"]);
     }, error => {});
 }
Beispiel #4
0
    public void BuySelected()
    {
        //Called from button, so need to get variables from main gameManager ↓
        if (GetGameManager().selectedTile != null && UIManager.GetUIManager().currentSelection != -1)
        {
            float buildingCost = UIManager.GetUIManager().lastBuilding.GetComponent <BuildingCost>().cost;

            if (!MoneyTracker.GetMoneyTracker().CanAfford(buildingCost))
            {
                AudioManager.GetAudioManager().PlayDenied();
                return;
            }

            MoneyTracker.GetMoneyTracker().BuyFor(buildingCost);

            GameObject gameObject = UIManager.GetUIManager().lastBuilding;

            if (gameObject.name == "Nuclear Plant" && !GetGameManager().nuclearAlready)
            {
                SnapshotManager.GetSnapshotManager().FirstNuclear();
            }
            else
            {
                GetGameManager().nuclearAlready = true;
            }

            if (GetGameManager().selectedTile.CreateBuilding(UIManager.GetUIManager().lastBuilding))
            {
                UIManager.GetUIManager().lastBuilding.GetComponent <BuildSound>().Play();
            }
            UIManager.GetUIManager().ShowMenu(true, GetGameManager().selectedTile);
        }
    }
Beispiel #5
0
    public bool CreateBuilding(GameObject buildingPrefab)
    {
        if (building == null && type == Type.Grass)
        {
            building      = Instantiate(buildingPrefab, transform.position, buildingPrefab.transform.rotation);
            building.name = buildingPrefab.name;
            building.GetComponent <CableManager>().CheckBordering(gridPosition, true);

            EnergyConsumer ec = building.GetComponent <EnergyConsumer>();
            EnergyProducer ep = building.GetComponent <EnergyProducer>();

            if (ec != null)
            {
                PowerTracker.GetPowerTracker().totalConsumption += ec.energyConsumption;
                MoneyTracker.GetMoneyTracker().totalIncome      += ec.moneyPerSecond;
            }

            if (ep != null)
            {
                PowerTracker.GetPowerTracker().totalProduction += ep.energyProduction;
                MoneyTracker.GetMoneyTracker().totalUpkeep     += ep.moneyPerSecond;
            }
            return(true);
        }
        return(false);
    }
Beispiel #6
0
 public void Upgrade()
 {
     MoneyTracker.ChangeMoneyCount(-utensil.upgradeCost);
     utensil.upgradeNum++;
     utensil.cookTime    /= 2;
     utensil.upgradeCost *= 5;
     objectSprite.sprite  = RestaurantMain.GetUpgradeSprite(objectSprite.sprite);
 }
Beispiel #7
0
 // Update is called once per frame
 void Update()
 {
     moneyText.text       = "Money: " + Mathf.RoundToInt(MoneyTracker.GetMoneyTracker().money) + "₡";
     incomeText.text      = "Global Income: " + Mathf.RoundToInt(MoneyTracker.GetMoneyTracker().totalIncome) + "₡/s";
     upkeepText.text      = "Global Upkeep: " + Mathf.RoundToInt(MoneyTracker.GetMoneyTracker().totalUpkeep) + "₡/s";
     productioText.text   = "Global Production: " + Mathf.RoundToInt(PowerTracker.GetPowerTracker().totalProduction) + "PU/s";
     consumptionText.text = "Global Consumption: " + Mathf.RoundToInt(PowerTracker.GetPowerTracker().totalConsumption) + "PU/s";
 }
Beispiel #8
0
    public static MoneyTracker GetMoneyTracker()
    {
        if (moneyTracker == null)
        {
            moneyTracker = GameObject.FindGameObjectWithTag("GameManager").GetComponent <MoneyTracker>();
        }

        return(moneyTracker);
    }
 public Strategy(IAlpacaClient alpacaClient)
 {
     _alpacaClient = alpacaClient;
     MoneyTracker  = new MoneyTracker
     {
         CostOfLastPosition = 0,
         MoneyMade          = 0
     };
 }
Beispiel #10
0
    public void SellSelected()
    {
        float buildingCost = GetGameManager().selectedTile.building.GetComponent <BuildingCost>().cost;

        MoneyTracker.GetMoneyTracker().SellFor(buildingCost);

        GetGameManager().selectedTile.DestoryBuilding();
        AudioManager.GetAudioManager().PlaySell();
        UIManager.GetUIManager().ShowMenu(true, GetGameManager().selectedTile);
    }
Beispiel #11
0
 private void Awake()
 {
     if (main == null)
     {
         main = this;
     }
     else
     {
         Destroy(this.gameObject);
     }
 }
    void Start()
    {
        gm           = FindObjectOfType <GameManager>();
        customerLine = gm.GetComponent <CustomerLine>();
        moneyTracker = gm.GetMoneyTracker();

        customerAudio.ChangeCustomerAudio(CustomerAudio.CustomerAudioStates.Walking);

        currentOrderTime = startOrderTime + 1;

        head = gameObject.transform.GetChild(0).gameObject.transform.GetChild(3).gameObject.GetComponent <MeshRenderer>();
    }
Beispiel #13
0
    public void Train()
    {
        if (data.isTraining || data.timesTrained >= 10 || PlayerData.playerData.playerMoney < trainingCost)
        {
            return;
        }
        MoneyTracker.ChangeMoneyCount(-trainingCost);
        data.isTraining = true;
        float time = 5.0f + 10.0f * data.timesTrained;

        data.trainEndTime           = DateTime.Now.AddSeconds(time);
        trainingButton.interactable = false;
    }
Beispiel #14
0
 private void OnLoginSuccess(LoginResult result)
 {
     //for testing the customdata of items
     //Dictionary<string, string> i = new Dictionary<string, string>();
     //i.Add("outfit", "{\"hat\":\"wow\",\"glasses\":\"sunglasses\"}");
     //SetItemCutsomData(i, "891C2D292A879E29", "5055A279219519E2");
     Debug.Log("Logged in!");
     playerId = result.PlayFabId;
     CatInventory.catInv.GetPlayFabDecor();
     PremiumMoneyTracker.SetMoney(result.InfoResultPayload.UserVirtualCurrency["PM"]);
     MoneyTracker.SetMoneyText(result.InfoResultPayload.UserVirtualCurrency["NM"]);
     iap.RefreshIAPItems();
 }
Beispiel #15
0
 //collect the money from the shop
 public int CollectMoney()
 {
     //the money will be the time spent open * the added income of ever cat working there
     //adding up the income/min
     if (!data.isOpen)
     {
         MoneyTracker.ChangeMoneyCount(data.storedIncome);
         int toRet = data.storedIncome;
         data.storedIncome = 0;
         openText.text     = "Not Open";
         if (data.stars < Variables.MAX_STAR_LEVEL && data.starProgress > 1)
         {
             data.starProgress -= 1;
             AddStar();
         }
         return(toRet);
     }
     return(0);
 }
Beispiel #16
0
    public void DestoryBuilding()
    {
        EnergyConsumer ec = building.GetComponent <EnergyConsumer>();
        EnergyProducer ep = building.GetComponent <EnergyProducer>();

        if (ec != null)
        {
            PowerTracker.GetPowerTracker().totalConsumption -= ec.energyConsumption;
            MoneyTracker.GetMoneyTracker().totalIncome      -= ec.moneyPerSecond;
        }

        if (ep != null)
        {
            PowerTracker.GetPowerTracker().totalProduction -= ep.energyProduction;
            MoneyTracker.GetMoneyTracker().totalUpkeep     -= ep.moneyPerSecond;
        }

        building.GetComponent <CableManager>().Remove(gridPosition, -1);
        Destroy(building);
        building = null;
    }
Beispiel #17
0
    void OnTriggerEnter(Collider other)
    {
        if (other.tag != "Player")
        {
            return;
        }

        if (cost > 0)
        {
            MoneyTracker money = GameObject.FindGameObjectWithTag("GameController").GetComponent <MoneyTracker> ();
            if (money.PlayerBalance < cost)
            {
                AudioSource.PlayClipAtPoint(FailNoise, transform.position);
                return;
            }
            money.PlayerBalance -= cost;
        }

        InventoryController inventory = GameObject.FindGameObjectWithTag("Inventory").GetComponent <InventoryController> ();
        int new_quantity = inventory.AddItem(contents, quantity);

        if (quantity != new_quantity)
        {
            AudioSource.PlayClipAtPoint(PickupNoise, transform.position);
            quantity = new_quantity;
        }
        else
        {
            AudioSource.PlayClipAtPoint(FailNoise, transform.position);
        }

        if (quantity == 0)
        {
            Destroy(gameObject);
        }
    }
Beispiel #18
0
 void Start()
 {
     transmitter  = GetComponent <EnergyTransmitter>();
     moneyTracker = GameObject.FindGameObjectWithTag("GameManager").GetComponent <MoneyTracker>();
 }
Beispiel #19
0
 public override float GetAmount(MoneyTracker tracker)
 {
     return(Random.Range(low, high));
 }
Beispiel #20
0
 public static void AddMoney(int n)
 {
     MoneyTracker.ChangeMoneyCount(n);
 }
Beispiel #21
0
 private void Start()
 {
     mt = FindObjectOfType <MoneyTracker>();
 }
Beispiel #22
0
 public override float GetAmount(MoneyTracker tracker)
 {
     return(tracker.currentMoney * (percentage / 100.0f));
 }
Beispiel #23
0
 public abstract float GetAmount(MoneyTracker tracker);
    public override void OnInspectorGUI()
    {
        MoneyTracker mt = target as MoneyTracker;

        mt.money = (decimal)EditorGUILayout.FloatField(new GUIContent("Money"), (float)mt.money);
    }
Beispiel #25
0
 public override float GetAmount(MoneyTracker tracker)
 {
     return(amount);
 }