示例#1
0
    public override void Use(S_Player player, S_Tile tile)
    {
        S_Enemy swappee = (S_Enemy)tile.occupier;

        float time   = 0.2f;
        Color col    = Colours.GREEN;
        int   width  = (S_Tile.width - S_Camera.scale) / S_Camera.scale;
        int   height = S_Tile.height / S_Camera.scale;

        GameObject flasher = S_Flasher.CreateFlasher(width, height, col, time);

        Util.SetLayer(flasher, Util.LayerName.UI, 0);
        flasher.transform.SetParent(tile.transform, false);

        flasher = S_Flasher.CreateFlasher(width, height, col, time);
        Util.SetLayer(flasher, Util.LayerName.UI, 0);
        flasher.transform.SetParent(player.currentTile.transform, false);

        swappee.CancelMove();
        swappee.MoveToTile(player.currentTile, true);
        player.MoveToTile(tile, true);
        swappee.Stun(1);
        Sounds.PlaySound(Sounds.teleport);
        SuccessfulUse();
        Level.Get(gameObject).EnemyTurn();
    }
示例#2
0
 public override void Use(S_Player player, S_Tile tile)
 {
     if (!GetValidTiles(player.currentTile).Contains(tile))
     {
         return;
     }
     player.MoveToTile(tile, false);
     Sounds.PlaySound(Sounds.move, 1, Random.Range(1.4f, 1.6f));
     SuccessfulUse();
 }
示例#3
0
    void InitTilesAndEntities()
    {
        //init tiles array
        int tilesAcross = levelData.width;
        int tilesDown   = levelData.height - 1;

        tiles      = new S_Tile[tilesAcross, tilesDown];
        gridWidth  = (int)(tilesAcross * (S_Tile.BASE_TILE_SIZE + 1) * S_Camera.scale + S_Camera.scale);
        gridHeight = (int)(tilesDown * (S_Tile.BASE_TILE_SIZE + 1) * S_Camera.scale + S_Camera.scale);

        //use colours in leveldata to setup entities
        for (int x = 0; x < tilesAcross; x++)
        {
            for (int y = 0; y < tilesDown; y++)
            {
                S_Tile tile;
                switch (FromColour(levelData.GetPixel(x, y)))
                {
                case LevelContent.wall:
                    break;

                case LevelContent.blank:
                    tile = MakeTile(x, y);
                    break;

                case LevelContent.food:
                    tile = MakeTile(x, y);
                    tile.AddPickup();
                    pickupsRemaining++;
                    totalPickups++;
                    break;

                case LevelContent.player:
                    tile = MakeTile(x, y);
                    GameObject playerObject = (GameObject)(GameObject.Instantiate(Resources.Load("prefabs/player")));
                    player = playerObject.GetComponent <S_Player>();
                    player.Init();
                    entities.Add(player);
                    player.MoveToTile(tile, true);
                    break;

                case LevelContent.charger:
                    tile = MakeTile(x, y);
                    GameObject chargerObject = (GameObject)(GameObject.Instantiate(Resources.Load("prefabs/charger")));
                    S_Entity   charger       = chargerObject.GetComponent <S_Charger>();
                    charger.Init();
                    entities.Add(charger);
                    charger.MoveToTile(tile, true);
                    break;

                case LevelContent.enemy:
                    tile = MakeTile(x, y);
                    GameObject pincerObject = (GameObject)(GameObject.Instantiate(Resources.Load("prefabs/pincer")));
                    S_Entity   enemy        = pincerObject.GetComponent <S_Pincer>();
                    enemy.Init();
                    entities.Add(enemy);
                    enemy.MoveToTile(tile, true);
                    break;
                }
            }
        }

        //hierarchy object for entities
        GameObject entityParent = new GameObject("entities");

        entityParent.transform.SetParent(mapObject.transform, false);
        foreach (S_Entity e in entities)
        {
            e.positionSetter.transform.SetParent(entityParent.transform, false);
        }

        //setup map border
        GameObject rect = Primitives.CreateRectangle(tilesAcross * S_Tile.width + S_Camera.scale, tilesDown * S_Tile.height + S_Camera.scale, Colours.RED);

        rect.transform.SetParent(mapObject.transform, false);
        rect.GetComponent <SpriteRenderer>().sortingLayerName = "Tiles";
        rect.GetComponent <SpriteRenderer>().sortingOrder     = 0;
        rect.name = "level_background";

        //add level number (rethink into something symbolic maybe?)

        /*levelNumberObject = Primitives.CreateText(("level " + (Game.Get().levelNumber)));
         * S_Follower follow = levelNumberObject.AddComponent<S_Follower>();
         * follow.Follow(slider.gameObject, 2 * S_Camera.scale, Screen.height - 28 * S_Camera.scale);*/
    }