Ejemplo n.º 1
0
    public void CallInPlantingTip(int index)
    {
        plantingTip.gameObject.SetActive(true);
        if (plantingTip.transform.localPosition.y > 1 || plantingTip.transform.localPosition.y < -1)
        {
            plantingTip.localPosition = new Vector3(150, 0, 0);
        }
        int plantType = GameData._playerData.Farms [index].plantType;

        plantingTip.gameObject.name = index.ToString();
        Text[] t = plantingTip.gameObject.GetComponentsInChildren <Text> ();

        switch (plantType)
        {
        case 0:
            t [0].text = "Crops";
            break;

        case 1:
            t [0].text = "Wine";
            break;

        case 2:
            t [0].text = "Beer";
            break;

        case 3:
            t [0].text = "Whiskey";
            break;

        default:
            break;
        }

        int  i          = 2;
        bool canPrepare = true;

        Plants p = LoadTxt.GetPlant(plantType);
        Dictionary <int, int> d = p.plantReq;

        foreach (int key in d.Keys)
        {
            t[i].text = LoadTxt.MatDic [key].name + " ×" + d [key];
            if (_gameData.CountInHome(key) < d[key])
            {
                t[i].color = Color.red;
                canPrepare = false;
            }
            else
            {
                t[i].color = Color.green;
            }
            i++;
        }
        plantingTip.GetComponentInChildren <Button>().interactable = canPrepare;

        t[5].text = p.plantTime + " h";
        t[7].text = p.plantGrowCycle + " day";
        t[8].text = "Prepare";
    }
Ejemplo n.º 2
0
    public void Prepare()
    {
        int    index     = int.Parse(plantingTip.gameObject.name);
        int    plantType = GameData._playerData.Farms [index].plantType;;
        Plants p         = LoadTxt.GetPlant(plantType);

        foreach (int key in p.plantReq.Keys)
        {
            if (_gameData.CountInHome(key) < p.plantReq[key])
            {
                return;
            }
        }

        int t = _loading.CallInLoadingBar(60);

        StartCoroutine(GetPrepared(p, index, t));
    }
Ejemplo n.º 3
0
    public void ChargeCrop(int index)
    {
        Dictionary <int, int> r = new Dictionary <int, int> ();
        Plants p = LoadTxt.GetPlant(GameData._playerData.Farms [index].plantType);
        int    num;

        switch (p.plantType)
        {
        case 0:
            foreach (int key in p.plantObtain.Keys)
            {
                num = (int)(p.plantObtain [key] * Algorithms.GetIndexByRange(80, 120) / 100 * GameData._playerData.HarvestIncrease);
                if (num > 0)
                {
                    r.Add(key, num);
                }
            }
            break;

        default:
            foreach (int key in p.plantObtain.Keys)
            {
                num = (int)(p.plantObtain [key] * Algorithms.GetIndexByRange(75, 125) / 100 * GameData._playerData.OenologyIncrease);
                if (num > 0)
                {
                    r.Add(key, num);
                }
            }
            break;
        }

        foreach (int key in r.Keys)
        {
            _gameData.AddItem(key * 10000, r [key]);
            _floating.CallInFloating(LoadTxt.MatDic [key].name + " +" + r [key], 0);
        }
        GameData._playerData.Farms [index].plantTime = 0;
        _gameData.StoreData("Farms", _gameData.GetStrFromFarmState(GameData._playerData.Farms));
        UpdateFarm();
    }
Ejemplo n.º 4
0
    void SetFarmState(GameObject o, FarmState f, int j, int key)
    {
        Text[] t = o.GetComponentsInChildren <Text> ();
        Button b = o.GetComponentInChildren <Button> ();
        Plants p = LoadTxt.GetPlant(f.plantType);

        if (f.plantType == 0)
        {
            t[0].text = "Farm";
        }
        else
        {
            t[0].text = "Wine Cellar";
        }

        if (f.plantTime <= 0)
        {
            t [1].text  = "(Empty)";
            t [1].color = Color.grey;
            if (f.plantType == 0)
            {
                t [2].text = "Grow crops here.";
            }
            else if (f.plantType == 1)
            {
                t [2].text = "Make wine here.";
            }
            else if (f.plantType == 2)
            {
                t [2].text = "Make beer here.";
            }
            else if (f.plantType == 3)
            {
                t [2].text = "Make whiskey here.";
            }
            else
            {
                Debug.Log("wrong plantType!!");
            }
            b.interactable = true;
            b.name         = key.ToString() + "|Prepare";
            t [3].text     = "Prepare";
        }
        else
        {
            bool isMature = IsMature(f.plantTime, p);
            t [1].text  = isMature ? "(Collect)" : "(Wait)";
            t [1].color = isMature ? Color.green : Color.black;
            if (isMature)
            {
                if (f.plantType == 0)
                {
                    t [2].text = "Crops are ready.";
                }
                else if (f.plantType == 1)
                {
                    t [2].text = "Wine is ready.";
                }
                else if (f.plantType == 2)
                {
                    t [2].text = "Beer is ready.";
                }
                else if (f.plantType == 3)
                {
                    t [2].text = "Whiskey is ready.";
                }
                else
                {
                    Debug.Log("wrong plantType!!");
                }

                b.interactable = true;
                b.name         = key.ToString() + "|Charge";
                t [3].text     = "Collect";
            }
            else
            {
                t [2].text     = "Time: " + GetLeftTime(f.plantTime, p);
                b.interactable = false;
                b.name         = key.ToString() + "|Charge";
                t [3].text     = "Collect";
            }
        }
    }