Пример #1
0
    public void step()
    {
        if (myCell != null)
        {
            switch (myCell.loot)
            {
            case LootType.PIRATE_WITH_SWORD:
            case LootType.PIRATE:
                Sounds.Play(SoundType.DIE);
                TheMap.PlayerDie();
                break;

            case LootType.SCORE:
                Sounds.Play(SoundType.SCORE);
                TheMap.instance.Score += 3;
                TheMap.UpdateCell(myCellNo, myCell.nextSprite.name, this);
                break;

            case LootType.SWORD:
                Sounds.Play(SoundType.SCORE);
                Player.instance.HaveSword = true;
                TheMap.UpdateCell(myCellNo, myCell.nextSprite.name, this);
                break;

            case LootType.NONE:
                break;

            default:
                Debug.LogError("unknow loot " + myCell.loot.ToString());
                break;
            }
        }
    }
Пример #2
0
    void checkPoint(float pX, float pY)
    {
        int XX = pX < 0 ? -1 : (int)(pX / TheMap.cellSize);
        int YY = pY < 0 ? -1 : (int)(pY / TheMap.cellSize);

        // сначала проверяем не ударилось ли в препятствие
        hitType ht = hitType.NONE;

        if (XX < 0 || XX > 7 || YY < 0 || YY > 5)
        {
            ht = hitType.FOREST;
        }
        else
        {
            ht = TheMap.instance.rows [YY].columns[XX].hit(playerBy);
        }

        if (playerBy)
        {
            switch (ht)
            {
            case hitType.FOREST:
                Sounds.Play(SoundType.DIE);
                Destroy(gameObject);
                break;

            case hitType.NONE:
                break;

            case hitType.PIRATE:
                TheMap.instance.Score += 1;
                Destroy(gameObject);
                break;
            }
        }
        else
        {
            if (flying)
            {
                switch (ht)
                {
                case hitType.FOREST:
                    Sounds.Play(SoundType.DIE);
                    flying = false;
                    break;

                case hitType.NONE:
                    break;

                case hitType.PIRATE:
                    break;
                }

                if (Intersection(Player.instance.Position, Position))
                {
                    TheMap.PlayerDie();
                    Sounds.Play(SoundType.DIE);
                    Destroy(gameObject);
                }
            }
            else
            {
                if (Intersection(Player.instance.Position, Position))
                {
                    Player.instance.HaveSword = true;
                    Sounds.Play(SoundType.SCORE);
                    playerBy = true;
                    if (myOwner != null)
                    {
                        myOwner.nextState();
                    }
                    Destroy(gameObject);
                }
            }
        }
    }