Пример #1
0
    public void BuyAttack()
    {
        int cost = 3;

        if (gold >= cost)
        {
            gold -= cost;
            // effect: attack all adjacent tiles
            pentagon player = null;
            foreach (pentagon p in pentagons)
            {
                try
                {
                    if (p.GetOccupier().transform.tag == "Player")
                    {
                        player = p;
                    }
                }
                catch
                {
                }
            }

            int[] adjacentTiles = new int[5];
            adjacentTiles = player.GetLinks();
            for (int i = 0; i < 5; i++)
            {
                MovePlayerObject(tileLinks[player.GetIndex()][i], -0.1f, true);
            }

            GameObject.Find("HP").GetComponent <Text>().text   = "HP " + hp.ToString();
            GameObject.Find("Gold").GetComponent <Text>().text = "Gold: " + gold.ToString();
        }
        else
        {
            Log("You do not have enough gold to be so vigorous and stir everything nearby.");
        }
    }
Пример #2
0
    // Items
    public void BuyDrillThrough()
    {
        int cost = 1;

        // effect: transport to other side of the map, if you can
        // Check first before buying
        int[]    opposites = { 7, 12, 11, 10, 9, 8, 1, 2, 3, 4, 5, 6 };
        pentagon player    = null;
        pentagon opposite;

        foreach (pentagon p in pentagons)
        {
            try
            {
                if (p.GetOccupier().transform.tag == "Player")
                {
                    player = p;
                }
            }
            catch
            {
                Debug.Log("Had an issue accessing the occupier");
            }
        }
        foreach (pentagon p in pentagons)
        {
            try
            {
                if (p.GetIndex() == opposites[player.GetIndex()] - 1)
                {
                    Debug.Log("The opposite of your tile is tile " + (opposites[player.GetIndex()]).ToString());
                    try
                    {
                    }
                    catch
                    {
                    }
                }
            }
            catch
            {
                Debug.Log("Couldn't find the index of the opposite side tile");
            }
        }

        if (gold >= cost)
        {
            if (MovePlayerObject(opposites[player.GetIndex()]))
            {
                gold -= cost;
                Log("You spend some gold to travel further");
                GameObject.Find("Gold").GetComponent <Text>().text = "Gold " + gold.ToString();
            }
            else
            {
                Log("You cannot travel far because the destination is blocked.");
            }
        }
        else
        {
            Log("You do not have enough gold to travel far.");
        }
    }