public void LineupBoardGenerator(BoardAttributes board) { string address = "Board/" + board.Name + "/Images/"; for (int x = 0; x <= board.allyField; x++) { for (int y = 0; y < board.boardWidth; y++) { Location location = new Location(y, x); GameObject obj = Instantiate(gridPanel, transform); string image = address; if (location == new Location(board.palaceLeft, board.palaceDown)) { image += "pdl"; } else if (location == new Location(board.palaceRight, board.palaceUp)) { image += "pur"; } else if (location == new Location(board.palaceRight, board.palaceDown)) { image += "prd"; } else if (location == new Location(board.palaceLeft, board.palaceUp)) { image += "plu"; } else if (location.Between(new Location(board.palaceLeft, board.palaceDown), new Location(board.palaceRight, board.palaceDown), "X")) { image += "pd"; } else if (location.Between(new Location(board.palaceLeft, board.palaceUp), new Location(board.palaceRight, board.palaceUp), "X")) { image += "pu"; } else if (location.Between(new Location(board.palaceRight, board.palaceDown), new Location(board.palaceRight, board.palaceUp), "Y")) { image += "pr"; } else if (location.Between(new Location(board.palaceLeft, board.palaceDown), new Location(board.palaceLeft, board.palaceUp), "Y")) { image += "pl"; } else if (board.AllyCastles().Contains(location)) { image += "castle"; } else { image += "grid"; } if (board.AllyCastles().Contains(location)) { obj.AddComponent <MouseOverPiece>(); } obj.GetComponent <Image>().sprite = Resources.Load <Sprite>(image); obj.name = location.ToString(); } } }
public void LoadBoard(BoardAttributes attributes, Dictionary <Location, Collection> newLocations = null) { loadedBoard = Instantiate(Resources.Load <GameObject>("Board/" + attributes.Name + "/LineupBoard"), board.transform); loadedBoard.transform.localPosition = new Vector3(0, 0, 0); loadedBoard.SetActive(true); loadedBoard.GetComponent <BoardInfo>().SetAttributes(attributes, newLocations); }
private void FindAttributes() { //WriteDirectories(); ReadDirectories(); foreach (string type in loadType) { foreach (string folder in directories[type]) { if (type == "Standard Piece") { PieceAttributes attributes = LoadPieceAttributes(folder); standardAttributes.Add(attributes.Name, attributes); } else if (type == "Piece") { PieceAttributes attributes = LoadPieceAttributes(folder); pieces.Add(attributes.Name, attributes); pieceList.Add(attributes.Name); pieceListDict[attributes.type].Add(attributes.Name); } else if (type == "Tactic") { TacticAttributes attributes = LoadTacticAttributes(folder); tactics.Add(attributes.Name, attributes); tacticList.Add(attributes.Name); } else if (type == "Board") { BoardAttributes attributes = LoadBoardAttributes(folder); boards.Add(attributes.Name, attributes); boardList.Add(attributes.Name); } else if (type == "Trap") { TrapAttributes attributes = LoadTrapAttributes(folder); traps.Add(attributes.Name, attributes); trapList.Add(attributes.Name); } else if (type == "Contract") { ContractAttributes attributes = LoadContractAttributes(folder); contracts.Add(attributes.Name, attributes); contractList.Add(attributes.Name); } else if (type == "Mission") { MissionAttributes attributes = LoadMissionAttributes(folder); missions.Add(attributes.Name, attributes); missionList.Add(attributes.Name); } } } }
private void Awake() { GameObject UIPanel = GameObject.Find("UIPanel"); boardCanvas = transform.Find("Canvas"); onEnterGame = UIPanel.GetComponent <OnEnterGame>(); scale = transform.localScale.x; boardSetup = GetComponent <BoardSetup>(); boardAttributes = boardSetup.boardAttributes; oldLocation = onEnterGame.oldLocation; pathDot = onEnterGame.pathDot; }
public void SetAttributes(BoardAttributes board, Dictionary <Location, Collection> newLocations = null) { attributes = board; if (standardLocations == null) { SetupStandardLocation(); } DataSetup(newLocations); Color tmpColor; foreach (KeyValuePair <string, PieceAttributes> pair in attributesDict) { Image image = transform.Find(pair.Key).Find("CardImage").GetComponent <Image>(); image.sprite = pair.Value.image; tmpColor = image.color; tmpColor.a = 255; image.color = tmpColor; } }
public void BoardGenerator(BoardAttributes board) { string address = "Board/" + board.Name + "/Images/"; for (int x = 0; x < board.boardHeight; x++) { for (int y = 0; y < board.boardWidth; y++) { Location location = new Location(y, x); GameObject obj = Instantiate(grid, transform); obj.transform.localPosition = new Vector3(y, x); string image = address; if (location == new Location(board.palaceLeft, board.palaceDown) || location == new Location(board.epalaceLeft, board.epalaceDown)) { image += "pdl"; } else if (location == new Location(board.palaceRight, board.palaceUp) || location == new Location(board.epalaceRight, board.epalaceUp)) { image += "pur"; } else if (location == new Location(board.palaceRight, board.palaceDown) || location == new Location(board.epalaceRight, board.epalaceDown)) { image += "prd"; } else if (location == new Location(board.palaceLeft, board.palaceUp) || location == new Location(board.epalaceLeft, board.epalaceUp)) { image += "plu"; } else if (location.Between(new Location(board.palaceLeft, board.palaceDown), new Location(board.palaceRight, board.palaceDown), "X") || location.Between(new Location(board.epalaceLeft, board.epalaceDown), new Location(board.epalaceRight, board.epalaceDown), "X")) { image += "pd"; } else if (location.Between(new Location(board.palaceLeft, board.palaceUp), new Location(board.palaceRight, board.palaceUp), "X") || location.Between(new Location(board.epalaceLeft, board.epalaceUp), new Location(board.epalaceRight, board.epalaceUp), "X")) { image += "pu"; } else if (location.Between(new Location(board.palaceRight, board.palaceDown), new Location(board.palaceRight, board.palaceUp), "Y") || location.Between(new Location(board.epalaceRight, board.epalaceDown), new Location(board.epalaceRight, board.epalaceUp), "Y")) { image += "pr"; } else if (location.Between(new Location(board.palaceLeft, board.palaceDown), new Location(board.palaceLeft, board.palaceUp), "Y") || location.Between(new Location(board.epalaceLeft, board.epalaceDown), new Location(board.epalaceLeft, board.epalaceUp), "Y")) { image += "pl"; } else if (board.AllyCastles().Contains(location) || board.EnemyCastles().Contains(location)) { image += "castle"; } else { image += "grid"; } obj.transform.Find("Image").GetComponent <Image>().sprite = Resources.Load <Sprite>(image); obj.name = location.ToString(); if (board.AllyCastles().Contains(location) || board.EnemyCastles().Contains(location)) { GameObject piececlone = Instantiate(piece, obj.transform); piececlone.name = "Piece"; piececlone.transform.localScale = new Vector3(grid.transform.localScale.x * 0.8f, grid.transform.localScale.y * 0.8f, grid.transform.localScale.z); } } } }
public static void SetBoard(BoardAttributes boardAttributes) { width = boardAttributes.boardWidth - 1; height = boardAttributes.boardHeight - 1; }