Ejemplo n.º 1
0
    void AttackPlayer(pentagon enemyTile)
    {
        int damage = 0;

        // Fire off an effect?
        GameObject newEffect    = Instantiate(sprayEffect, enemyTile.GetTile().transform);
        float      effectOffset = -0.8f;

        newEffect.transform.position = new Vector3(enemyTile.GetTile().transform.position.x, enemyTile.GetTile().transform.position.y, enemyTile.GetTile().transform.position.z + effectOffset);
        newEffect.transform.LookAt(playerObject.transform);
        Destroy(newEffect, 2.0f);

        List <string> damageMessages = new List <string>();
        // derive attack power from enemy type
        GameObject enemy = enemyTile.GetOccupier();

        if (enemy.transform.tag == "BlackToad")
        {
            damage = enemyStrengths[0];
            damageMessages.Add("The black toad spits a dark liquid at you and burns you for " + damage + " damage.");
            damageMessages.Add("The black toad attacks you for " + damage + " damage.");
            damageMessages.Add("The black toad jumps at you and before you can raise your hand it has dealt " + damage + " damage.");
        }
        if (enemy.transform.tag == "WhiteEagle")
        {
            damage = enemyStrengths[1];
            damageMessages.Add("The white eagle shrieks and tears at you causing " + damage + " damage.");
            damageMessages.Add("The eagle's cry makes your ears ring. You take " + damage + " damage.");
            damageMessages.Add("The quickened eagle gnaws at your face. You suffer " + damage + " damage.");
        }

        if (enemy.transform.tag == "GreenLion")
        {
            damage = enemyStrengths[2];
            damageMessages.Add("The green lion leaps at you with overwhelming force. You take " + damage + " damage.");
        }
        if (enemy.transform.tag == "RedPelican")
        {
            damage = enemyStrengths[3];
            damageMessages.Add("The pelican smashes its beak against you. " + damage + " damage.");
            damageMessages.Add("The red pelican swoops down at your face. You take " + damage + " damage.");
            damageMessages.Add("Angered, the red pelican takes a swipe at you. You take " + damage + " damage.");
        }

        damageMessages.Add("You take " + damage + " damage!");
        Log(damageMessages[Random.Range(0, damageMessages.Count())]);

        hp -= damage;
        GameObject.Find("HP").GetComponent <Text>().text = "HP: " + hp.ToString();

        // if player HP < 1
        if (hp < 1)
        {
            EndGame();
        }
    }
Ejemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        int startPhrase = Random.Range(0, 10);

        if (startPhrase < 5)
        {
            Log("The old unperishable urge overtakes you once more so you find yourself here.");
        }
        else
        {
            Log("You've made time for this so it had better count.");
        }
        // define tile network
        tileLinks.Add(new int[] { 2, 3, 4, 5, 6 });    // face 1
        tileLinks.Add(new int[] { 9, 3, 1, 6, 10 });   // face 2
        tileLinks.Add(new int[] { 8, 4, 1, 2, 9 });    // face 3
        tileLinks.Add(new int[] { 12, 5, 1, 3, 8 });   // face 4
        tileLinks.Add(new int[] { 11, 6, 1, 4, 12 });  // face 5
        tileLinks.Add(new int[] { 10, 2, 1, 5, 11 });  // face 6
        tileLinks.Add(new int[] { 8, 9, 10, 11, 12 }); // face 7
        tileLinks.Add(new int[] { 3, 9, 7, 12, 4 });   // face 8
        tileLinks.Add(new int[] { 2, 10, 7, 8, 3 });   // face 9
        tileLinks.Add(new int[] { 6, 11, 7, 9, 2 });   // face 10
        tileLinks.Add(new int[] { 5, 12, 7, 10, 6 });  // face 11
        tileLinks.Add(new int[] { 4, 8, 7, 11, 5 });   // face 12

        for (int i = 0; i < tileLinks.Count; i++)
        {
            pentagon p = new pentagon();
            p.SetTile(faces[i]);
            p.SetIndex(i);
            p.SetLinks(tileLinks[i]);
            p.SetState(0);
            p.SetOccupied(false);
            pentagons.Add(p);
        }

        foreach (pentagon p in pentagons)
        {
            p.PrintAll();
        }

        // Initialise player
        SpawnPlayer();

        SpawnEnemy(enemyTypes.toad, 2);
        SpawnEnemy(enemyTypes.gold, 2);
    }
Ejemplo n.º 3
0
    void MoveObject(pentagon sourceTile, pentagon targetTile, float offset = -0.1f)
    {
        GameObject s = sourceTile.GetOccupier();

        // move transform
        s.transform.position = (targetTile.GetTile().transform.position);
        s.transform.SetParent(targetTile.GetTile().transform);
        s.transform.rotation     = targetTile.GetTile().transform.rotation;
        s.transform.eulerAngles += new Vector3(0, 0, 180);
        s.transform.Translate(Vector3.forward * offset);

        // do tile handling
        sourceTile.SetOccupier(null);
        targetTile.SetOccupier(s);
        sourceTile.SetOccupied(false);
        targetTile.SetOccupied(true);
    }
Ejemplo n.º 4
0
    public void DropRetort(int dropTileIndex = 0)
    {
        pentagon dropTile = null;

        foreach (pentagon p in pentagons)
        {
            if (p.GetIndex() == dropTileIndex)
            {
                dropTile = p;
            }
        }

        // check if any aludels remain in the inventory
        if (retorts > 0)
        {
            // check player tile for existing trap
            if (dropTile.GetTrapped() != null)
            {
                // drops a trap where the player is and if an opponent steps on the trap then they blow up
                retorts--;
                GameObject retort = Instantiate(retortObject, transform);
                //PlaceOnFace(aludel, )
                GameObject.Find("RetortLabel").GetComponent <Text>().text = "[R] Drop a retort. (" + retorts + " remain)";
            }
            else
            {
                Log("There already is a retort on this face!");
            }
        }
        else
        {
            Log("You don't have any retorts left!");
        }



        // implement stepping onto aludel for enemies
    }
Ejemplo n.º 5
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.");
        }
    }
Ejemplo n.º 6
0
    void BasicAIMove(GameObject e)
    {
        // pick an enemy -> pass it in

        // check proximity to player
        int      enemyTileIndex  = 0;
        int      playerTileIndex = 0;
        pentagon enemyTile       = null;
        pentagon targetTile      = null;

        foreach (pentagon p in pentagons)
        {
            if (p.GetOccupier() == e)
            {
                enemyTileIndex = p.GetIndex();
                enemyTile      = p;
            }
            if (p.GetOccupier() == playerObject)
            {
                playerTileIndex = p.GetIndex();
            }
        }

        int proximity = ProximityCheck(enemyTileIndex, playerTileIndex);

        // if player is next door, attack them and they die
        if (proximity == 1)
        {
            AttackPlayer(enemyTile);
        }
        // if player is two steps away, check the proximity to the player from each neighbouring tile
        int[] possibleMoves = new int[5] {
            -1, -1, -1, -1, -1
        };

        if (proximity == 2)
        {
            for (int i = 0; i < 5; i++)
            {
                int s = tileLinks[enemyTileIndex][i] - 1;
                if (ProximityCheck(s, playerTileIndex) == 1)
                {
                    foreach (pentagon p in pentagons)
                    {
                        if (p.GetIndex() == s)
                        {
                            if (p.GetOccupier() == null)
                            {
                                possibleMoves[i] = s;
                            }
                        }
                    }
                }
            }
        }
        int chosenMove = -1;

        // Choose random move and make it
        if (Random.Range(0, 10) > 5)
        {
            for (int i = 0; i < 5; i++)
            {
                if (possibleMoves[i] != -1)
                {
                    chosenMove = possibleMoves[i];
                    break;
                }
            }
        }
        else
        {
            for (int i = 4; i >= 0; i--)
            {
                if (possibleMoves[i] != -1)
                {
                    chosenMove = possibleMoves[i];
                    break;
                }
            }
        }
        if (chosenMove != -1)
        {
            foreach (pentagon p in pentagons)
            {
                if (p.GetIndex() == chosenMove)
                {
                    targetTile = p;
                }
            }

            MoveObject(enemyTile, targetTile, -0.1f);
        }


        // if player is three steps away, plot course there - maybe it could just wait?
        int x = 1;
    }
Ejemplo n.º 7
0
    bool MovePlayerObject(int targetTile, float offset = -0.1f, bool attackOnly = false)
    {
        bool     validMove = true;
        bool     waiting   = false;
        pentagon p         = pentagons[targetTile - 1];

        if (p.GetOccupied())
        {
            validMove = false;
            // attack and destroy opponent if it can be destroyed
            GameObject o = p.GetOccupier();
            // Check tile status
            // blanks can come on blanks
            try
            {
                // pickup gold
                if (o.transform.tag == "GoldPiece")
                {
                    gold     += 1;
                    validMove = true;
                    p.SetOccupier(null);
                    allOpponents.Remove(o);
                    Destroy(o, 0.1f);
                    Log("You pick up some gold.");
                }

                else if (o.transform.tag == "BlackToad")
                {
                    if (p.GetState() == 0)
                    {
                        validMove = true;
                        p.SetOccupier(null);
                        p.SetState(1);
                        toads.Remove(o);
                        allOpponents.Remove(o);
                        Destroy(o, 0.1f);
                        // colour the tile black
                        SetPentagonColour(Color.black, p.GetTile());
                        Log("You stomp on the wretched black little thing and smush it to pieces.");
                    }
                    else
                    {
                        Log("You cannot best the toad there");
                    }
                }

                else if (o.transform.tag == "WhiteEagle")
                {
                    if (p.GetState() == 1)
                    {
                        validMove = true;
                        p.SetOccupier(null);
                        p.SetState(2);
                        allOpponents.Remove(o);
                        eagles.Remove(o);

                        Destroy(o, 0.1f);

                        // colour the tile bright white
                        SetPentagonColour(Color.white, p.GetTile());
                    }
                    else
                    {
                        Log("You cannot trap the eagle on that side.");
                    }
                }

                else if (o.transform.tag == "GreenLion")
                {
                    if (p.GetState() == 2)
                    {
                        validMove = true;
                        p.SetOccupier(null);
                        p.SetState(3);
                        allOpponents.Remove(o);
                        lions.Remove(o);

                        Destroy(o, 0.1f);
                        // colour the tile green
                        SetPentagonColour(Color.green, p.GetTile());
                    }
                    else
                    {
                        Log("The lion will yield only when stood upon a white base.");
                    }
                }
                else if (o.transform.tag == "RedPelican")
                {
                    if (p.GetState() == 3)
                    {
                        validMove = true;
                        p.SetOccupier(null);
                        p.SetState(4);
                        allOpponents.Remove(o);
                        pelicans.Remove(o);
                        Destroy(o, 0.1f);
                        // colour the tile golden
                        SetPentagonColour(Color.yellow, p.GetTile());
                        // Player gets gold
                        Log("The pelican left behind some gold. You pick it up.");
                        Log("This face is shining bright.");
                        gold += 2;
                        GameObject.Find("Gold").GetComponent <Text>().text = "Gold " + gold.ToString();
                    }
                    else
                    {
                        Log("The pelican needs to be on a green tile to be tamed.");
                    }
                }

                // staying still
                else if (p.GetOccupier() == playerObject)
                {
                    Log("You stand still.");
                    validMove = true;
                    waiting   = true;
                }
                else
                {
                    // if the opponent isn't standing on a proper tile then you can't move there
                    Debug.Log("Can't move there, wrong tile and opponent combination");
                    validMove = false;
                }
            }
            catch
            {
                Debug.Log("Couldn't access tile occupier");
                validMove = false;
            }
        }
        if (validMove)
        {
            pentagon source = null;
            foreach (pentagon p2 in pentagons)
            {
                if (p2.GetOccupier() == playerObject)
                {
                    source = p2;
                }
            }

            if (!attackOnly)
            {
                MoveObject(source, p);
            }
            else
            {
                if (!waiting)
                {
                    GameObject FX = Instantiate(sprayEffect, p.GetTile().transform);
                    FX.transform.position = p.GetTile().transform.position;
                    FX.transform.LookAt(-GameObject.Find("Dodecahedron").transform.position);
                    Destroy(FX, 2.0f);
                }
            }

            /*    playerObject.transform.position = (p.GetTile().transform.position);
             *  playerObject.transform.SetParent(p.GetTile().transform);
             *  playerObject.transform.rotation = p.GetTile().transform.rotation;
             *  playerObject.transform.eulerAngles += new Vector3(0, 0, 180);
             *  playerObject.transform.Translate(Vector3.forward * offset);
             *  // remove player from current tile and move them to the next tile in the pentagon list
             *  foreach(pentagon p2 in pentagons)
             *  {
             *      if(p2.GetOccupier() == playerObject)
             *      {
             *          p2.SetOccupier(null);
             *          Debug.Log("Setting player to tile index " + p.GetIndex());
             *
             *          p.SetOccupier(playerObject);
             *      }
             *  }
             */
        }
        return(validMove);
    }
Ejemplo n.º 8
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.");
        }
    }