예제 #1
0
    public IEnumerator WaitForFade()
    {
        gameOver = true;

        ScenesManager.ins.transition = true;

        for (int y = BoardManager.BOARD_SIZE - 1; y >= 0; y--)
        {
            for (int x = 0; x < BoardManager.BOARD_SIZE; x++)
            {
                BlockTile b = BoardManager.ins.boardBlocks[x, y];
                if (b)
                {
                    b.Fade(0.25f, new Color(0.09f, 0.122f, 0.153f));
                }

                if (x % 2 == 0)
                {
                    yield return(new WaitForSeconds(0.01f));
                }
            }
        }

        yield return(new WaitForSeconds(0.25f));

        ScenesManager.ins.LoadGameOverScreen();
    }
예제 #2
0
    public void FaceDataYNegative(CubeBlock block, Vector3 pos, bool dropItem = false)
    {
        float half_block_size = block.blockSize / 2.0f;

        this.AddVertex(new Vector3(pos.x - half_block_size, pos.y - half_block_size, pos.z - half_block_size));
        this.AddVertex(new Vector3(pos.x + half_block_size, pos.y - half_block_size, pos.z - half_block_size));
        this.AddVertex(new Vector3(pos.x + half_block_size, pos.y - half_block_size, pos.z + half_block_size));
        this.AddVertex(new Vector3(pos.x - half_block_size, pos.y - half_block_size, pos.z + half_block_size));

        // add normals
        Vector3 down = Vector3.down;

        this.normals.Add(down);
        this.normals.Add(down);
        this.normals.Add(down);
        this.normals.Add(down);

        // add triangles
        this.AddQuadTriangles();

        // add textures
        BlockTile blockTile = dropItem ? block.getDropBlockTile() : block.getBlockTile();
        Vector2   _00       = blockTile.bottom_00;
        Vector2   _10       = blockTile.bottom_10;
        Vector2   _01       = blockTile.bottom_01;
        Vector2   _11       = blockTile.bottom_11;

        this.uvs.Add(_11);
        this.uvs.Add(_01);
        this.uvs.Add(_00);
        this.uvs.Add(_10);
    }
예제 #3
0
    public void FaceDataZPositive(CubeBlock block, Vector3 pos, bool dropItem = false)
    {
        float half_block_size = block.blockSize / 2.0f;

        this.AddVertex(new Vector3(pos.x - half_block_size, pos.y - half_block_size, pos.z - half_block_size));
        this.AddVertex(new Vector3(pos.x - half_block_size, pos.y + half_block_size, pos.z - half_block_size));
        this.AddVertex(new Vector3(pos.x + half_block_size, pos.y + half_block_size, pos.z - half_block_size));
        this.AddVertex(new Vector3(pos.x + half_block_size, pos.y - half_block_size, pos.z - half_block_size));

        // add normals
        Vector3 front = Vector3.forward;

        this.normals.Add(front);
        this.normals.Add(front);
        this.normals.Add(front);
        this.normals.Add(front);

        // add triangles
        this.AddQuadTriangles();

        // add textures
        BlockTile blockTile = dropItem ? block.getDropBlockTile() : block.getBlockTile();
        Vector2   _00       = blockTile.front_00;
        Vector2   _10       = blockTile.front_10;
        Vector2   _01       = blockTile.front_01;
        Vector2   _11       = blockTile.front_11;

        this.uvs.Add(_10);
        this.uvs.Add(_11);
        this.uvs.Add(_01);
        this.uvs.Add(_00);
    }
예제 #4
0
    /// <summary>
    /// The method called whenever an object is removed.
    /// </summmary>
    /// <param name="foreground"> Whether or not the block to be destroyed is in the foreground. </param>
    /// <param name="tilePosition"> The position of the block to destroy (grid coords) </param>
    public static void BreakBlockCell(bool foreground, Vector3Int tilePosition)
    {
        if (foreground && Globals.foregroundTilemap.HasTile(tilePosition))
        {
            BlockTile prevTile = (BlockTile)Globals.foregroundTilemap.GetTile(tilePosition);
            prevTile.sourceBlock.OnBreak(tilePosition, true);

            Globals.foregroundTilemap.SetTile(tilePosition, null);
            currentWorld[tilePosition.x, tilePosition.y, 0] = 0;
        }
        else if (!foreground && Globals.backgroundTilemap.HasTile(tilePosition))
        {
            BlockTile prevTile = (BlockTile)Globals.backgroundTilemap.GetTile(tilePosition);
            prevTile.sourceBlock.OnBreak(tilePosition, false);

            Globals.backgroundTilemap.SetTile(tilePosition, null);
            currentWorld[tilePosition.x, tilePosition.y, 1] = 0;
        }

        Tilemap tilemap = foreground ? Globals.foregroundTilemap : Globals.backgroundTilemap;

        foreach (Vector3Int loc in new List <Vector3Int>()
        {
            Vector3Int.up, Vector3Int.down, Vector3Int.left, Vector3Int.right
        })                                                                                                                      // Refreshes all blocks in cardinal dirs
        {
            tilemap.RefreshTile(tilePosition + loc);
        }
    }
예제 #5
0
    public void Init(int id)
    {
        spriteRenderer = GetComponent <SpriteRenderer> ();
        blockTile      = null;
        block          = null;

        this.id = id;
        if (0 != id)
        {
            spriteRenderer.color = color;
        }
        else
        {
            //spriteRenderer.color = deactiveColor;
            gameObject.SetActive(false);
        }

#if UNITY_EDITOR
        if (true == Map.Instance.editMode)
        {
            gameObject.SetActive(true);
            spriteRenderer.color = Color.white;
            if (0 != id)
            {
                spriteRenderer.color = Color.gray;
            }
            TouchInput touch = gameObject.AddComponent <TouchInput>();
            touch.onTouchUp += (Vector3 position) => {
                Editor.Instance.OnClickMapTile(this);
            };
        }
#endif
    }
예제 #6
0
 // 回收所画矩形
 public void RecycleTileRectByTile(BlockTile tile)
 {
     if (tile.drawRect != null)
     {
         RecycleDrawRectObj(tile.drawRect);
         tile.drawRect = null;
     }
 }
예제 #7
0
 // 画矩形
 public void DrawTileRect(BlockTile tile)
 {
     if (tile.drawRect == null)
     {
         MyDrawRect drawRect = GetFreeDrawRectObj();
         drawRect.SetGreenRectInfo(tile.size);
         drawRect.transform.parent        = tile.img.transform;
         drawRect.transform.localPosition = new Vector3(0, -tile.size.y / 2);
         drawRect.transform.localScale    = Vector3.one;
         drawRect.SetRectColor(new Color(0, 1, 0, 0.2f));
         tile.drawRect = drawRect;
     }
 }
예제 #8
0
        public void DestructableSettings()
        {
            var tile = new SurfaceTile();

            tile.AllowEntrance(digger)
            .Should()
            .BeTrue();

            var block = new BlockTile();

            block.AllowEntrance(digger)
            .Should()
            .BeFalse();
        }
예제 #9
0
 public void ClearColliderRectIgnoreTile(BlockTile tile)
 {
     for (int i = 0; i < colliderRect.Count; i++)
     {
         ColliderRect cInfo = colliderRect[i];
         if (tile != cInfo.tile1)
         {
             RecycleTileRectByTile(cInfo.tile1);
         }
         if (tile != cInfo.tile2)
         {
             RecycleTileRectByTile(cInfo.tile2);
         }
     }
 }
예제 #10
0
    public virtual void Init(BlockSaveData saveData)
    {
        blockTiles = new List <BlockTile>();
        foreach (Vector3 tilePosition in saveData.tilePositions)
        {
            BlockTile blockTile = GameObject.Instantiate <BlockTile> (blockTilePrefab);
            blockTile.transform.localPosition = tilePosition;
            blockTile.Init(this);
            blockTiles.Add(blockTile);
        }

        id        = saveData.id;
        name      = saveData.name;
        tileColor = saveData.tileColor;
    }
예제 #11
0
    private void CheckVLine(int x, bool h = false)
    {
        if (h)
        {
            BlockTile[,] b = new BlockTile[BOARD_SIZE, BOARD_SIZE];
            Array.Copy(boardBlocks, b, boardBlocks.Length);

            Block      db = InputManager.ins.draggedBlock;
            Vector2Int c  = db.GetFirstCoords();
            for (int i = 0; i < db.structure.Length; i++)
            {
                if (db.transform.GetChild(i).name == "Block tile")
                {
                    BlockTile bt = db.transform.GetChild(i).GetComponent <BlockTile>();
                    b[c.x + db.structure[i].x, c.y + db.structure[i].y] = bt;
                }
            }

            for (int y = 0; y < BOARD_SIZE; y++)
            {
                if (!b[x, y])
                {
                    return;
                }
            }

            for (int y = 0; y < BOARD_SIZE; y++)
            {
                if (boardBlocks[x, y])
                {
                    boardBlocks[x, y].Fade(0.2f, db.defaultColor);
                }
            }
        }
        else
        {
            for (int y = 0; y < BOARD_SIZE; y++)
            {
                if (!boardBlocks[x, y])
                {
                    return;
                }
            }

            DestroyManager.ins.PrepareToDestroy(x, true);
        }
    }
예제 #12
0
    // 返回两个家具相交的矩形的左上角的点和矩形范围
    public Rect TileOverlapRect(BlockTile tile1, BlockTile tile2)
    {
        // 当前点击的矩形的左上角坐标 左下角0,0坐标系y+矩形位置的/2+矩形大小的一半
        float curX1 = tile1.realPos.x - tile1.size.x / 2;
        float curY1 = tile1.realPos.y - tile1.size.y / 2 + tile1.show_size.y;

        // 当前点击的矩形的右下角坐标
        float curX2 = tile1.realPos.x + tile1.size.x / 2;
        float curY2 = tile1.realPos.y - tile1.size.y / 2;

        Rect rect = new Rect();

        if (tile1.id != tile2.id)
        {
            float x1 = tile2.realPos.x - tile2.size.x / 2; // 矩形左上角的x坐标
            float y1 = tile2.realPos.y - tile2.size.y / 2 +
                       tile2.show_size.y;                  // 矩形左上角的y坐标

            float x2 = tile2.realPos.x + tile2.size.x / 2; // 矩形右下角的x坐标
            float y2 = tile2.realPos.y - tile2.size.y / 2; //矩形右下角的y坐标

            float StartX    = Math.Min(x1, curX1);
            float EndX      = Math.Max(x2, curX2);
            float StartY    = Math.Max(y1, curY1);
            float EndY      = Math.Min(y2, curY2);
            float CurWidth  = (x2 - x1) + (curX2 - curX1) - (EndX - StartX); // 宽度
            float CurHeight = (y1 - y2) + (curY1 - curY2) - (StartY - EndY); // 高度

            if (CurWidth <= 0 || CurHeight <= 0)
            {
//                Debug.Log(" ------没有相交--------------- ");
            }
            else
            {
                float   tempX  = Math.Max(x1, curX1); // 有相交则相交区域位置为:小中取大为左上角,大中取小为右下角
                float   tempY  = Math.Min(y1, curY1);
                Vector2 curPos = FloorPointChange(new Vector2(tempX, tempY));
                rect.position = curPos;
                rect.size     = new Vector2(CurWidth, CurHeight);
            }
        }

        return(rect);
    }
예제 #13
0
    void CreateBlockSprite()
    {
        bColor = GridScript.Instance.blocksColor[bNumber];

        int x = (int)rotPos[rotIndex].x;
        int y = (int)rotPos[rotIndex].y;

        for (int n = 0; n < rotID[rotIndex].Length; n++)
        {
            if (rotID[rotIndex][n] == '1')
            {
                GameObject baseSquare = Instantiate(Resources.Load("Prefabs/Base Block Square")) as GameObject;
                baseSquare.transform.localPosition = new Vector3(x, y, 0);
                baseSquare.GetComponent <SpriteRenderer>().color = bColor;
                baseSquare.transform.parent = transform;

                BlockTile bTile = baseSquare.GetComponent <BlockTile>();
                bTile.relativePos = new Vector2(x, y);
                bTile.parentBlock = this;
                bTile.bNumber     = bNumber;
                baseSquare.name   = this.gameObject.name + bTile.relativePos.ToString();
                tileList.Add(bTile);
            }

            x++;
            if (x >= 3 && y >= 0)
            {
                x = 0;
                y--;
            }
        }


        this.transform.localScale = new Vector3(SpawnScript.Instance.blockScale, SpawnScript.Instance.blockScale, 1f);
        bPlaced = false;

        foreach (BlockTile bTile in tileList)
        {
            bTile.GetComponent <SpriteRenderer>().color = bColor;
            bTile.transform.localPosition = bTile.relativePos;
            bTile.transform.localScale    = new Vector3(0.9f, 0.9f, 0);
        }
    }
예제 #14
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            BlockTile blockTileScript = (BlockTile)target;

            tileX = EditorGUILayout.FloatField("xPosition", tileX);
            tileY = EditorGUILayout.FloatField("yPosition", tileY);
            if (GUILayout.Button("Set UVs"))
            {
                blockTileScript.uvs = new Vector2[]
                {
                    new Vector2(tileX / 16f, tileY / 16),
                    new Vector2(tileX / 16f, (tileY + 1) / 16f),
                    new Vector2((tileX + 1) / 16f, (tileY + 1) / 16f),
                    new Vector2((tileX + 1) / 16f, tileY / 16f),
                };
                Debug.Log("Set " + blockTileScript.name + " UVs: " + tileX + ", " + tileY);
            }
        }
예제 #15
0
    // 判断两个家具是否相交
    public bool IsTileOverlap(BlockTile tile1, BlockTile tile2)
    {
        // 当前点击的矩形的左上角坐标 左下角0,0坐标系y+矩形位置的/2+矩形大小的一半
        float curX1 = tile1.realPos.x - tile1.size.x / 2;
        float curY1 = tile1.realPos.y - tile1.size.y / 2 + tile1.show_size.y;

        // 当前点击的矩形的右下角坐标
        float curX2 = tile1.realPos.x + tile1.size.x / 2;
        float curY2 = tile1.realPos.y - tile1.size.y / 2;

        bool flag = false;

        if (tile1.id != tile2.id)
        {
            float x1 = tile2.realPos.x - tile2.size.x / 2; // 矩形左上角的x坐标
            float y1 = tile2.realPos.y - tile2.size.y / 2 +
                       tile2.show_size.y;                  // 矩形左上角的y坐标

            float x2 = tile2.realPos.x + tile2.size.x / 2; // 矩形右下角的x坐标
            float y2 = tile2.realPos.y - tile2.size.y / 2; //矩形右下角的y坐标

            float StartX    = Math.Min(x1, curX1);
            float EndX      = Math.Max(x2, curX2);
            float StartY    = Math.Max(y1, curY1);
            float EndY      = Math.Min(y2, curY2);
            float CurWidth  = (x2 - x1) + (curX2 - curX1) - (EndX - StartX); // 宽度
            float CurHeight = (y1 - y2) + (curY1 - curY2) - (StartY - EndY); // 高度

            if (CurWidth <= 0 || CurHeight <= 0)
            {
//                Debug.Log(" ------没有相交--------------- ");
                flag = false;
            }
            else
            {
                flag = true;
            }
        }

        return(flag);
    }
예제 #16
0
    //
    // Summary:
    //      The method called whenever a block is placed.
    // Parameters:
    //      toPlace:
    //          The block type to place.
    //      foreground:
    //          Whether or not the block should be placed in the foreground.
    //      position:
    //          The position of the placed block
    public static void PlaceBlockCell(Block toPlace, bool foreground, Vector3Int tilePosition)
    {
        BlockTile newTile = BlockTile.CreateInstance <BlockTile>();

        newTile.sourceBlock = toPlace;
        newTile.sprite      = toPlace.blockSprite;
        newTile.name        = toPlace.blockName;

        if (foreground)
        {
            newTile.colliderType = Tile.ColliderType.Grid;
            Globals.foregroundTilemap.SetTile(tilePosition, newTile);
            currentWorld[tilePosition.x, tilePosition.y, 0] = toPlace.blockID + 1;
        }
        else
        {
            newTile.color = new Color(0.5f, 0.5f, 0.5f, 1f);
            Globals.backgroundTilemap.SetTile(tilePosition, newTile);
            currentWorld[tilePosition.x, tilePosition.y, 1] = toPlace.blockID + 1;
        }
    }
예제 #17
0
    public void DestroyBlocks()
    {
        int a = (int)Random.Range(0, BoardManager.BOARD_SIZE - 2.001f);

        if (BoardManager.ins.blocks[0].size.x >= BoardManager.ins.blocks[0].size.y)
        {
            for (int y = a; y < a + 3; y++)
            {
                for (int x = 0; x < BoardManager.BOARD_SIZE; x++)
                {
                    BlockTile b = BoardManager.ins.boardBlocks[x, y];
                    if (b)
                    {
                        b.Destroy(0.25f);
                    }

                    BoardManager.ins.boardBlocks[x, y] = null;
                }
            }
        }
        else
        {
            for (int x = a; x < a + 3; x++)
            {
                for (int y = 0; y < BoardManager.BOARD_SIZE; y++)
                {
                    BlockTile b = BoardManager.ins.boardBlocks[x, y];
                    if (b)
                    {
                        b.Destroy(0.25f);
                    }

                    BoardManager.ins.boardBlocks[x, y] = null;
                }
            }
        }

        BoardManager.ins.CheckBoard();
    }
예제 #18
0
    private void Update()
    {
        if (screenOrientation != Screen.orientation || GameManager.ins.paused)
        {
            ResetBlock();
        }

        if (Input.touchCount > 0)
        {
            Touch t = Input.GetTouch(0);

            // // // // // // // // //      BEGAN      // // // // // // // // //
            if (t.phase == TouchPhase.Began && !GameManager.ins.paused)
            {
                Ray        ray = Camera.main.ScreenPointToRay(t.position);
                RaycastHit hit;

                if (Physics.Raycast(ray, out hit, 15))
                {
                    screenOrientation = Screen.orientation;

                    Collider c = hit.collider;

                    if (c.tag == "Block" && c.GetComponent <Block>().movable&& !c.GetComponent <Block>().IsMoving())
                    {
                        draggedBlock = c.GetComponent <Block>();

                        draggedBlock.Scale(true, 0.2f);

                        Color cl = draggedBlock.defaultColor; cl.a = 0.66f;
                        draggedBlock.ChangeColor(cl);

                        Vector3 p = draggedBlock.transform.position;
                        startPos = Camera.main.ScreenToWorldPoint(t.position);
                        startPos = new Vector3(startPos.x - p.x, startPos.y - p.y, 0);
                    }
                }
            }

            // // // // // // // // //      MOVED      // // // // // // // // //
            else if (t.phase == TouchPhase.Moved && draggedBlock)
            {
                Vector3 pos = Camera.main.ScreenToWorldPoint(t.position);
                pos = new Vector3(pos.x, pos.y, -2);

                draggedBlock.transform.position = pos - startPos;

                Vector3 size = draggedBlock.GetComponent <Block>().size;
                size = new Vector3(size.x - 1, size.y - 1, 0);

                Vector2 origin = draggedBlock.transform.GetChild(0).position;
                Vector2 end    = draggedBlock.transform.GetChild(0).position + size;

                if (IsInRange(origin, end) && IsEmpty(draggedBlock, RoundVector2(origin)))
                {
                    Vector2Int start = RoundVector2(origin);

                    if (lastPos != start)
                    {
                        RemoveAllHighlights();
                        BoardManager.ins.HighlightBlocks();

                        for (int i = 0; i < draggedBlock.structure.Length; i++)
                        {
                            if (draggedBlock.transform.GetChild(i).name == "Block tile")
                            {
                                Vector2Int coords = draggedBlock.structure[i];
                                highlightedTiles[i]       = BoardManager.ins.boardTiles[start.x + coords.x, start.y + coords.y];
                                highlightedTiles[i].color = BoardManager.ins.highlightColor;
                            }
                        }
                    }

                    lastPos = start;
                }
                else
                {
                    RemoveAllHighlights();
                    lastPos = new Vector2Int(-1, -1);
                }
            }

            // // // // // // // // //      ENDED      // // // // // // // // //
            else if (t.phase == TouchPhase.Ended && draggedBlock)
            {
                Vector3 size = draggedBlock.size;
                size = new Vector3(size.x - 1, size.y - 1, 0);

                Vector2 origin = draggedBlock.transform.GetChild(0).position;
                Vector2 end    = draggedBlock.transform.GetChild(0).position + size;

                // // // // // // // // //  CAN PUT ON BOARD  // // // // // // // // //
                if (IsInRange(origin, end) && IsEmpty(draggedBlock, RoundVector2(origin)))
                {
                    lastPosition = BlockPosition(origin, size);

                    draggedBlock.Move(0.08f, lastPosition);
                    draggedBlock.ChangeColor(draggedBlock.defaultColor);
                    draggedBlock.GetComponent <BoxCollider>().enabled = false;
                    draggedBlock.enabled = false;

                    Vector2Int start = RoundVector2(origin);

                    for (int i = 0; i < draggedBlock.structure.Length; i++)
                    {
                        Vector2Int coords = draggedBlock.structure[i];

                        if (draggedBlock.transform.GetChild(i).name == "Block tile")
                        {
                            BlockTile b = draggedBlock.transform.GetChild(i).GetComponent <BlockTile>();
                            BoardManager.ins.boardBlocks[start.x + coords.x, start.y + coords.y] = b;
                        }
                    }

                    AudioManager.ins.PlayBlockSound();

                    BoardManager.ins.MoveBlocks(draggedBlock.posIndex);
                    BoardManager.ins.CheckBoard();
                }
                // // // // // // // // // CANNOT PUT ON BOARD // // // // // // // // //
                else
                {
                    MoveDraggedBlock();
                }

                ResetDraggedBlock();
            }
        }
    }
예제 #19
0
        public static void ParseRoomCSVFile()
        {
            string cwdPath = Directory.GetCurrentDirectory();

            string roomPath = "";

            if (roomNumber < storage.singleDigitRoomCap)
            {
                roomPath = @"0" + (roomNumber.ToString()) + ".csv";
            }
            else
            {
                roomPath = @"" + (roomNumber.ToString()) + ".csv";
            }

            cwdPath = cwdPath.Replace(@"\bin\Debug\netcoreapp3.1", @"\Classes\Level\RoomCSV");
            cwdPath = Path.Combine(cwdPath, roomPath);
            string[] lines = System.IO.File.ReadAllLines(cwdPath);

            foreach (string line in lines)
            {
                string[] segments = line.Split(new string[] { "," },
                                               StringSplitOptions.None);
                Vector2 position = new Vector2(0, 0);
                switch (segments[0])
                {
                case "Block":
                    position = utility.GetBlockSecondaryItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    BlockTile block;
                    tiles.Add(block    = new BlockTile(game, new TileSpriteFactory(game), position));
                    block.drawLocation = position;
                    break;

                case "Event":
                    position = utility.GetBlockSecondaryItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    EventTile eventTile;
                    tiles.Add(eventTile    = new EventTile(game, new TileSpriteFactory(game), position));
                    eventTile.drawLocation = position;
                    break;

                case "Pushable":
                    position = utility.GetPushablePosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    PushableTile pushable;
                    tiles.Add(pushable    = new PushableTile(game, new TileSpriteFactory(game), position));
                    pushable.drawLocation = position;
                    break;

                case "Stair":
                    position = utility.GetBlockSecondaryItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    TPTile stair;
                    tiles.Add(stair    = new TPTile(game, new TileSpriteFactory(game), position));
                    stair.drawLocation = position;
                    break;

                case "Compass":
                    position = utility.GetBlockSecondaryItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    Compass compass;
                    items.Add(compass    = new Compass(game, new ItemSpriteFactory(game), position));
                    compass.drawLocation = position;
                    break;

                case "Heart":
                    position = utility.GetHeartPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    Heart heart;
                    items.Add(heart = new Heart(game, new ItemSpriteFactory(game), position));
                    heart.position  = position;
                    break;

                case "Key":
                    position = utility.GetCommonItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    Key key;
                    items.Add(key = new Key(game, new ItemSpriteFactory(game), position));
                    key.position  = position;
                    break;

                case "BlueRupee":
                    position = utility.GetCommonItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    BlueRupee blueRupee;
                    items.Add(blueRupee = new BlueRupee(game, new ItemSpriteFactory(game), position));
                    blueRupee.position  = position;
                    break;

                case "Bomb":
                    position = utility.GetBombPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    Bomb bomb;
                    items.Add(bomb = new Bomb(game, new ItemSpriteFactory(game), position));
                    bomb.position  = position;
                    break;

                case "Boomerang":
                    position = utility.GetCommonItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    Boomerang boomerang;
                    items.Add(boomerang = new Boomerang(game, new ItemSpriteFactory(game), position));
                    boomerang.position  = position;
                    break;

                case "Bow":
                    position = utility.GetCommonItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    Bow bow;
                    items.Add(bow = new Bow(game, new ItemSpriteFactory(game), position));
                    bow.position  = position;
                    break;

                case "HeartContainer":
                    position = utility.GetHeartContainerPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    HeartContainer heartContainer;
                    items.Add(heartContainer = new HeartContainer(game, new ItemSpriteFactory(game), position));
                    heartContainer.position  = position;
                    break;

                case "Map":
                    position = utility.GetCommonItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    Map map;
                    items.Add(map = new Map(game, new ItemSpriteFactory(game), position));
                    map.position  = position;
                    break;

                case "Fairy":
                    position = utility.GetCommonItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    Fairy fairy;
                    items.Add(fairy = new Fairy(game, new ItemSpriteFactory(game), position));
                    fairy.position  = position;
                    break;

                case "Triforce":
                    position = utility.GetTriforceOldPosition(windowWidth, windowHeightFloor);
                    Triforce triforce;
                    items.Add(triforce = new Triforce(game, new ItemSpriteFactory(game), position));
                    triforce.position  = position;
                    break;

                case "YellowRupee":
                    position = utility.GetCommonItemPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    YellowRupee yellowRupee;
                    items.Add(yellowRupee = new YellowRupee(game, new ItemSpriteFactory(game), position));
                    yellowRupee.position  = position;
                    break;

                case "Goriya":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemyGoriya(game, position));
                    break;

                case "Aquamentus":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemyAquamentus(game, position));
                    break;

                case "Roshi":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemyRoshi(game, position));
                    break;

                case "BladeTrap":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemyBladeTrap(game, position, new Vector2(storage.bladeTrapX, storage.bladeTrapY), game.link));
                    break;

                case "Gel":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemySlime(game, position));
                    break;

                case "Keese":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemyKeese(game, position));
                    break;

                case "Stalfos":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemyStalfos(game, position));
                    break;

                case "Wallmaster":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemyWallmaster(game, position));
                    break;

                case "Redead":
                    position = utility.GetEnemyPosition(windowWidthFloor, windowHeightFloor, float.Parse(segments[2]), float.Parse(segments[1]));
                    enemies.Add(new EnemyRedead(game, position));
                    break;

                case "FogOfWar":
                    enemies.Add(new FogOfWar(game));
                    break;

                default:
                    break;
                }
            }
        }
예제 #20
0
    public static void LoadProgress()
    {
        bool[]  audioMutes   = GetAudioMutes();
        float[] audioVolumes = GetAudioVolumes();

        AudioManager.ins.ChangeMusicVolume(audioVolumes[0]);
        AudioManager.ins.ChangeSoundVolume(audioVolumes[1]);
        AudioManager.ins.ChangeSliderValues(audioVolumes);

        if (audioMutes[0])
        {
            AudioManager.ins.MuteMusic();
        }
        else
        {
            AudioManager.ins.UnmuteMusic();
        }
        if (audioMutes[1])
        {
            AudioManager.ins.MuteSound();
        }
        else
        {
            AudioManager.ins.UnmuteSound();
        }

        GameManager.ins.firstBeatenScore   = PlayerPrefs.HasKey("firstBeatenScore") ? GetBool("firstBeatenScore") : true;
        GameManager.ins.continueGame       = PlayerPrefs.HasKey("continueGame") ? GetBool("continueGame") : true;
        GameManager.ins.score              = PlayerPrefs.GetInt("score");
        GameManager.ins.scoreText.text     = GameManager.ins.score.ToString();
        GameManager.ins.bestScore          = GetBestScore();
        GameManager.ins.bestScoreText.text = GameManager.ins.bestScore.ToString();

        if (!GameManager.ins.firstBeatenScore)
        {
            GameManager.ins.bestScoreIconLayer.GetComponent <Animator>().Play("Beaten score");
        }

        for (int y = 0; y < BoardManager.BOARD_SIZE; y++)
        {
            for (int x = 0; x < BoardManager.BOARD_SIZE; x++)
            {
                Color color = GetColor(GetBlockKey(x, y));

                if (color != Color.black)
                {
                    BlockTile b = BoardManager.ins.SpawnBlockTile(x, y);
                    b.GetComponent <SpriteRenderer>().color = color;
                    b.defaultColor = color;
                }
            }
        }

        for (int i = 0; i < BoardManager.BLOCKS_AMOUNT; i++)
        {
            if (PlayerPrefs.HasKey(i + "block"))
            {
                int prefabIndex = PlayerPrefs.GetInt(i + "block");
                BoardManager.ins.blocks[i] = BoardManager.ins.SpawnBlock(i, prefabIndex);
            }
        }
    }