Example #1
0
    // 타일의 종류와 위치 설정
    void SetTileKindWithPosition(int x, int y, TileKind tileKind)
    {
        for (int i = 0; i < boardLayout.Count; i++)
        {
            if (boardLayout[i].x == x && boardLayout[i].y == y)
            {
                if (boardLayout[i].tileKind != tileKind)
                {
                    boardLayout[i].tileKind = tileKind;
                    Debug.Log(boardLayout.Count);
                }
                return;
            }
        }

        TileType tile = new TileType();

        tile.x        = (int)x;
        tile.y        = (int)y;
        tile.tileKind = tileKind;

        boardLayout.Add(tile);

        Debug.Log(boardLayout.Count);
        SetBoardLayouts();
    }
 private void SetTileAt(int x, int y, TileKind newTile)
 {
     if (!this.IsOutOfBounds(x, y))
     {
         this._tiles[this.CoordToTileIndex(x, y)] = newTile;
     }
 }
Example #3
0
    private void MountainTileChange()
    {
        gameObject.GetComponent <Transform>().localScale    = new Vector3(1, 1, 1);
        gameObject.GetComponent <Transform>().localPosition = new Vector3(0, 1.502358f, 0);
        for (int i = 0; i < gameObject.GetComponent <Renderer>().materials.Length; i++)
        {
            gameObject.GetComponent <Renderer>().materials[i] = null;
        }
        gameObject.GetComponent <Renderer>().material.color = pave.color;

        Mesh mesh  = tileforpave.GetComponent <MeshFilter>().sharedMesh;
        Mesh mesh2 = Instantiate(mesh);

        gameObject.GetComponent <MeshFilter>().sharedMesh = mesh2;

        tileColor = pave.color;

        Kind_Of_This = TileKind.PAVED;
        Price       *= 2;
        Description  = "포장된 지역, 더 많은 건물들을 건설 할 수있다.";

        lineh = 2;
        for (int i = 0; i < points.Length; i++)
        {
            float x = Mathf.Sin(Mathf.Deg2Rad * (60 * i)) * radius;
            float z = Mathf.Cos(Mathf.Deg2Rad * (60 * i)) * radius;
            points[i] = Instantiate(for_vertices);
            points[i].transform.parent        = gameObject.transform;
            points[i].transform.localPosition = new Vector3(x, lineh, z);
        }

        mountainChange = false;
    }
Example #4
0
 public static void Add(List<mvLeszedettLapka> lapkak, TileKind tileKind)
 {
     if (lapkak != null)
     {
         var lapka = lapkak.FirstOrDefault(l => l.TileKind == tileKind);
         if (lapka != null) lapka.Count++;
         else lapkak.Add(new mvLeszedettLapka { TileKind = tileKind, Count = 1 });
     }
 }
Example #5
0
    // more to come...

    public Tile(TileKind kind, Vector3 worldPos)
    {
        this.kind     = kind;
        this.worldPos = worldPos;
        this.mapPos   = new int[2] {
            Mathf.FloorToInt(worldPos.x),
            Mathf.FloorToInt(worldPos.z)
        };
    }
Example #6
0
    private void DetermineMesh(TileKind kind)
    {
        GameObject meshPrefab;

        if (MeshMap.TryGetValue(kind, out meshPrefab))
        {
            mesh = Instantiate(meshPrefab);
            mesh.transform.SetParent(this.transform);
        }
    }
Example #7
0
    // Load Prefab references.
    //void Awake() {
    //    tileRendererPrefab = (GameObject)Resources.Load("/Prefabs/TileRenderer");
    //}

    // Use this for initialization
    void Start()
    {
        mapGraphPrefab     = (GameObject)Resources.Load("Prefabs/MapGraph");
        tileRendererPrefab = (GameObject)Resources.Load("Prefabs/TileRenderer");
        alphaWalkPrefab    = (GameObject)Resources.Load("Prefabs/AlphaWalk");

        for (int col = 0; col < COL_COUNT; col++)
        {
            List <TileData> rowData = new List <TileData>();
            for (int row = 0; row < ROW_COUNT; row++)
            {
                //TileKind k = (rand(0, 7) > 1) ? TileKind.GROUND : TileKind.HALF_GROUND;
                TileKind k = TileKind.GROUND;

                if (row % 2 != 0)
                {
                    k = TileKind.HALF_GROUND;
                }

                Vector3  worldPos = new Vector3(col, 0, row);
                TileData td       = new TileData(worldPos, k);

                rowData.Add(td);
            }
            testMap.AddRange(rowData);
        }

        GameObject tileContainer = new GameObject();

        tileContainer.name = "TilesContainer";

        mapGraph = InitMapGraph();

        // probably an unnecessary loop
        foreach (TileData td in testMap)
        {
            Tile         tile         = new Tile(td.kind, td.worldPos);
            TileRenderer tileRenderer = Instantiate(tileRendererPrefab)
                                        .GetComponent <TileRenderer>();

            tileRenderer.SetTile(tile);
            tileRenderer.transform.SetParent(tileContainer.transform);

            mapGraph.AddNode(tile.WorldPosition, tile.Kind);
        }
        mapGraph.FinalizeMap();
        FinalizeMapGraph();
    }
Example #8
0
        public Texture2D GetTexture2D(TileKind tile)
        {
            switch (tile)
            {
            case TileKind.Air:
                return(Air);

            case TileKind.Start:
                return(Start);

            case TileKind.Exit:
                return(Exit);

            case TileKind.PlatformBlock:
                return(PlatformBlock);

            case TileKind.PassableBlock:
                return(PassableBlock);

            case TileKind.ImpassableBlock:
                return(ImpassableBlock);

            case TileKind.MonsterA:
                return(MonsterA);

            case TileKind.MonsterB:
                return(MonsterB);

            case TileKind.MonsterC:
                return(MonsterC);

            case TileKind.MonsterD:
                return(MonsterD);

            case TileKind.Gem:
                return(Gem);

            default:
                throw new ArgumentOutOfRangeException(nameof(tile), tile, null);
            }
        }
Example #9
0
        public TileKind[,] Parse(string text)
        {
            var width  = GetWidth(text);
            var height = GetHeight(text, width);

            var grid        = new TileKind[height, width];
            var currentTile = 0;

            foreach (var c in text)
            {
                if (c == '\n' || c == '\r')
                {
                    continue;
                }

                grid[currentTile / width, currentTile % width] = ParseTile(c);
                currentTile += 1;
            }

            return(grid);
        }
Example #10
0
    void SetupTilesProperties()
    {
        int sum    = 0;
        int length = tileKinds.Length;

        foreach (TileKind tileKind in tileKinds)
        {
            sum += tileKind.probabilityRating;
        }

        int[] intervals = new int[length + 1];
        int   counter   = 0;

        intervals[0] = 0;

        for (int i = 1; i < length + 1; i++)
        {
            counter     += tileKinds[i - 1].probabilityRating;
            intervals[i] = counter;
        }

        foreach (GameObject tile in tiles)
        {
            float randomPick = sum * Random.value;
            for (int i = 0; i < length; i++)
            {
                if (randomPick >= intervals[i] && randomPick <= intervals[i + 1])
                {
                    TileKind         tileKind         = tileKinds[i];
                    MyTileProperties propertiesScript = tile.AddComponent <MyTileProperties>();
                    tileScripts[i] = propertiesScript;
                    propertiesScript.InitProperties(tileKind.color, tileKind.scoreChange, tileKind.healthChange, player);
                    break;
                }
            }
        }
    }
Example #11
0
 public static Image GetTileImage(
     TileKind inputKind,
     bool highlighted)
 {
     if (inputKind == TileKind.Black)
     {
         return(highlighted
             ? AzulGame.Properties.Resources.BlackTileH
             : AzulGame.Properties.Resources.BlackTile);
     }
     else if (inputKind == TileKind.Blue)
     {
         return(highlighted
             ? AzulGame.Properties.Resources.BlueTileH
             : AzulGame.Properties.Resources.BlueTile);
     }
     else if (inputKind == TileKind.Cyan)
     {
         return(highlighted
             ? AzulGame.Properties.Resources.CyanTileH
             : AzulGame.Properties.Resources.CyanTile);
     }
     else if (inputKind == TileKind.Red)
     {
         return(highlighted
             ? AzulGame.Properties.Resources.RedTileH
             : AzulGame.Properties.Resources.RedTile);
     }
     else if (inputKind == TileKind.Yellow)
     {
         return(highlighted
             ? AzulGame.Properties.Resources.YellowTileH
             : AzulGame.Properties.Resources.YellowTile);
     }
     throw new NotImplementedException();
 }
Example #12
0
 public TileData(Vector3 worldPos, TileKind kind)
 {
     this.worldPos = worldPos;
     this.kind     = kind;
 }
Example #13
0
 public void OnPlaneCrashed(Plane plane, TileKind tileKind)
 {
     levelView.OnPlaneCrashed(plane, tileKind);
 }
Example #14
0
 internal void Init()
 {
     tileKind = TileKind.Init;
     //szomszedok = new List<int>();
 }
Example #15
0
 public MapNode(TileKind kind, XY mapPos, float worldHeight)
 {
     this.kind        = kind;
     this.mapPos      = mapPos;
     this.worldHeight = worldHeight;
 }
Example #16
0
 /// <summary>
 /// Komunikat o rozbiciu samolotu.
 /// </summary>
 /// <param name="plane"></param>
 /// <param name="tileKind">W jaki teren uderzył samolot.</param>
 public void OnPlaneCrashed(Plane plane, TileKind tileKind)
 {
     AddJob(MethodBase.GetCurrentMethod().Name, new object[] { plane, tileKind });
 }
Example #17
0
        bool IsPartOfFourInARow(Tile tile)
        {
            int GetNrOfElementsHavingThisKindInDirection(TileKind theKind, int startRow, int startCol, int rowDelta,
                                                         int colDelta)
            {
                int count  = 1;
                int theRow = startRow + rowDelta;
                int theCol = startCol + colDelta;

                while (theRow >= 0 && theRow < ROWS && theCol >= 0 && theCol < COLS)
                {
                    if (tiles[theRow, theCol].TheKind != theKind)
                    {
                        break;
                    }
                    theRow += rowDelta;
                    theCol += colDelta;
                    count  += 1;
                }
                theRow = startRow - rowDelta;
                theCol = startCol - colDelta;
                while (theRow >= 0 && theRow < ROWS && theCol >= 0 && theCol < COLS)
                {
                    if (tiles[theRow, theCol].TheKind != theKind)
                    {
                        break;
                    }
                    theRow -= rowDelta;
                    theCol -= colDelta;
                    count  += 1;
                }
                return(count);
            }

            void MarkTiles(TileKind theKind, int startRow, int startCol, int rowDelta,
                           int colDelta)
            {
                int theRow = startRow + rowDelta;
                int theCol = startCol + colDelta;

                while (theRow >= 0 && theRow < ROWS && theCol >= 0 && theCol < COLS)
                {
                    if (tiles[theRow, theCol].TheKind != theKind)
                    {
                        break;
                    }
                    tiles[theRow, theCol].TheKind = theKind == TileKind.Red ? TileKind.RedMarked : TileKind.BlueMarked;
                    theRow += rowDelta;
                    theCol += colDelta;
                }
                theRow = startRow - rowDelta;
                theCol = startCol - colDelta;
                while (theRow >= 0 && theRow < ROWS && theCol >= 0 && theCol < COLS)
                {
                    if (tiles[theRow, theCol].TheKind != theKind)
                    {
                        break;
                    }
                    tiles[theRow, theCol].TheKind = theKind == TileKind.Red ? TileKind.RedMarked : TileKind.BlueMarked;
                    theRow -= rowDelta;
                    theCol -= colDelta;
                }
                tiles[startRow, startCol].TheKind = theKind == TileKind.Red ? TileKind.RedMarked : TileKind.BlueMarked;
            }

            TileKind kind = tile.TheKind;

            if (kind != TileKind.Blue && kind != TileKind.Red)
            {
                return(false);
            }
            var(row, col) = (tile.Row, tile.Col);

            // first look for horizontals
            int horizontal
                = GetNrOfElementsHavingThisKindInDirection(kind, row, col, 0, 1);

            if (horizontal >= 4)
            {
                MarkTiles(kind, row, col, 0, 1);
                return(true);
            }
            // vertical
            int vertical
                = GetNrOfElementsHavingThisKindInDirection(kind, row, col, 1, 0);

            if (vertical >= 4)
            {
                MarkTiles(kind, row, col, 1, 0);
                return(true);
            }
            // diagonal, two ways
            int diagonal1
                = GetNrOfElementsHavingThisKindInDirection(kind, row, col, 1, 1);

            if (diagonal1 >= 4)
            {
                MarkTiles(kind, row, col, 1, 1);
                return(true);
            }
            int diagonal2
                = GetNrOfElementsHavingThisKindInDirection(kind, row, col, 1, -1);

            if (diagonal2 >= 4)
            {
                MarkTiles(kind, row, col, 1, -1);
                return(true);
            }
            return(false);
        }
Example #18
0
    public void AddNode(Vector3 worldPosition, TileKind k)
    {
        XY xy = XYPos(worldPosition);

        mapNodes[xy.x, xy.y] = new MapNode(k, xy, worldPosition.y);
    }