Esempio 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();
        }
    }
Esempio n. 2
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);
    }
Esempio n. 3
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);
    }