public void CreateBoards(Player_ID ID) { if (isLocalPlayer) { playerIdentity = ID; playerTeam = playerIdentity.playerTeam; createBoard (POS_BOARD1_X, POS_BOARD1_Y, LEN_BOARD_X, LEN_BOARD_Y, e_player.PLAYER1); createBoard (POS_BOARD2_X, POS_BOARD2_Y, LEN_BOARD_X, LEN_BOARD_Y, e_player.PLAYER2); } }
void createBoard(int x, int z, int dimx, int dimz, e_player player) { Vector3 tmpPos; bool isSlot; int id = 0; dimx += 2; dimz += 2; tmpPos.y = 0; tmpPos.x = 0; tmpPos.z = 0; for (int dim1 = 0; dim1 < dimx; ++dim1) { for (int dim2 = 0; dim2 < dimz; ++dim2){ GameObject objectSlot = new GameObject(); tmpPos.x = x + dim1; tmpPos.z = z + dim2; tmpPos.y = 0f; if (dim1 == 0 || dim2 == 0 || dim1 == dimx - 1 || dim2 == dimz - 1){ if (dim2 == dimz - 1 && dim1 == (dimx - 1) / 2){ if (playerIdentity.playerTeam == player){ mobSpawnCubeEnemy = Instantiate(mobSpawnCubeEnemy, tmpPos, Quaternion.identity) as GameObject; mobSpawnCubeEnemy.transform.name = player.ToString() + "-MOBSPAWN"; } else{ mobSpawnCubeAllied = Instantiate(mobSpawnCubeAllied, tmpPos, Quaternion.identity) as GameObject; mobSpawnCubeAllied.transform.name = player.ToString() + "-MOBSPAWN"; } } else if (dim2 == 0 && dim1 == (dimx - 1) / 2){ objectSlot = Instantiate(borderNexus, tmpPos, Quaternion.identity) as GameObject; objectSlot.transform.name = player.ToString() + "-NEXUS"; } else{ if (playerIdentity.playerTeam == player) objectSlot = Instantiate(borderObjectAllied, tmpPos, Quaternion.identity) as GameObject; else objectSlot = Instantiate(borderObjectEnemy, tmpPos, Quaternion.identity) as GameObject; objectSlot.transform.name = player.ToString() + "-Border"; } isSlot = false; } else{ objectSlot = Instantiate(slotObject, tmpPos, Quaternion.identity) as GameObject; isSlot = true; } if (isSlot){ t_infoSlot newInfosSLot = new t_infoSlot(); newInfosSLot.player = player; newInfosSLot.x = tmpPos.x; newInfosSLot.z = tmpPos.z; newInfosSLot.tower = e_tower.NONE; newInfosSLot.color = e_color.NONE; newInfosSLot.level = 0; newInfosSLot.name = player.ToString() + "-" + id.ToString(); newInfosSLot.id = id; newInfosSLot.refTower = null; objectSlot.GetComponent<FocusingSlot>().setInfos(newInfosSLot); if (playerIdentity.playerTeam != player) objectSlot.GetComponent<FocusingSlot>().enableSlot(false); objectSlot.transform.name = newInfosSLot.name; id++; } } } }
void RpcPutTower(e_tower tower, t_infoSlot slot, e_player playerPlaying) { Upgrade.TurretInfos info = GameObject.Find ("Board").GetComponent<Upgrade> ().getNewStats (tower, Player_Board.e_color.NONE, 1); Debug.Log("info.cost RpcPutTower = " + info.cost); GameObject newTowerObject = new GameObject (); Vector3 newPos = new Vector3 (); newPos.x = slot.x; newPos.z = slot.z; newPos.y = 0f; switch (tower) { case e_tower.STANDARD: newTowerObject = Instantiate(towerStandard, newPos, Quaternion.identity) as GameObject; break; case e_tower.GATLING: newTowerObject = Instantiate(towerGatling, newPos, Quaternion.identity) as GameObject; break; case e_tower.ANTIAIR: newTowerObject = Instantiate(towerAntiAir, newPos, Quaternion.identity) as GameObject; break; case e_tower.MELEE: newTowerObject = Instantiate(towerMelee, newPos, Quaternion.identity) as GameObject; break; case e_tower.SPLASH: newTowerObject = Instantiate(towerSplash, newPos, Quaternion.identity) as GameObject; break; case e_tower.SNIPER: newTowerObject = Instantiate(towerSniper, newPos, Quaternion.identity) as GameObject; break; } if (!gridController.isTowerPutable (newTowerObject, playerPlaying)) { GameObject.Destroy(newTowerObject); return; } else { slot.tower = tower; slot.refTower = newTowerObject; FocusingSlot SlotScript = GameObject.Find (slot.player.ToString () + "-" + slot.id.ToString ()).GetComponent<FocusingSlot> (); SlotScript.setInfos (slot); newTowerObject.GetComponent<Tower> ().upgrade (Player_Board.e_color.NONE); if (playerIdentity != null) { money -= info.cost; Debug.Log("info.cost RpcPutTower 2 = " + info.cost); } gridController.updateGraph (newTowerObject, true); } }
void CmdPutTower(e_tower tower, t_infoSlot slot, e_player playerPlaying) { RpcPutTower(tower, slot, playerPlaying); }