Exemplo n.º 1
0
    private bool Buy(string name, int cost)
    {
        if (PlayerCoin.Get() > cost)
        {
            Debug.Log("Player buy: " + name + " at cost " + cost);
            PlayerMonster.Add(name, 0);
            PlayerCoin.Spend(cost);

            return(true);
        }

        return(false);
    }
Exemplo n.º 2
0
    public static void Save()
    {
        StreamWriter file = new StreamWriter(savePath);

        file.WriteLine("gold;" + PlayerCoin.Get());

        for (int i = 0; i < PlayerMonster.Count; i++)
        {
            file.WriteLine("monster;" + PlayerMonster.Get(i).monsterName + ";" + PlayerMonster.Get(i).exp);
        }

        foreach (KeyValuePair <string, int> pair in PlayerItems.Items)
        {
            file.WriteLine("item;" + pair.Key + ";" + pair.Value);
        }

        for (int i = 0; PlayerField.Has(i); i++)
        {
            switch (PlayerField.Get(i))
            {
            case FieldStatus.FIELD_EMPTY:
                file.WriteLine("field;" + i.ToString() + ";-1");
                break;

            case FieldStatus.FIELD_FAILED:
                file.WriteLine("field;" + i.ToString() + ";0");
                break;

            case FieldStatus.FIELD_1STAR:
                file.WriteLine("field;" + i.ToString() + ";1");
                break;

            case FieldStatus.FIELD_2STAR:
                file.WriteLine("field;" + i.ToString() + ";2");
                break;

            case FieldStatus.FIELD_3STAR:
                file.WriteLine("field;" + i.ToString() + ";3");
                break;
            }
        }

        file.Close();
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonUp(0))
        {
            RaycastHit2D hit = Physics2D.Raycast(Camera.main.ScreenToWorldPoint(Input.mousePosition),
                                                 Vector2.zero);

            if (hit.transform != null)
            {
                for (int i = 0; i < colliderList.Count; i++)
                {
                    if (hit.transform.gameObject == colliderList[i].gameObject)
                    {
                        if (PlayerCoin.Get() >= itemList[i].GetComponent <Item>().Cost)
                        {
                            PlayerCoin.Spend(itemList[i].GetComponent <Item>().Cost);
                            PlayerItems.Add(itemList[i].name, 1);
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 4
0
 void OnGUI()
 {
     GUI.Label(new Rect(screenPos.x, Screen.height - screenPos.y, 40, 25),
               PlayerCoin.Get().ToString(),
               textStyle);
 }