public void SetUpPirate() { PirateManager pirateManager = activePlayer.GetComponent <PirateManager> (); if (pirateManager.piratesCreated < pirateManager.crewSize) { pirateToDeploy = pirateManager.CreatePirate(this.transform); } }
private void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Debug.Log("Instance already exists, destroying object!"); Destroy(this); } }
void CreatePirates(GameObject player) { PirateManager pirateManager = player.GetComponent <PirateManager> (); Vector3[] positions = GetPiratePositions(player); for (int i = 0; i < pirateManager.crewSize; i++) { GameObject pirateToDeploy = pirateManager.CreatePirate(player.transform); int xPos = (int)positions [i].x; int zPos = (int)positions [i].z; pirateToDeploy.GetComponent <Pirate>().PlacePirate(player.GetComponent <DeckManager>().RetrieveTile(xPos, zPos)); pirateManager.piratesCreated += 1; } }
void Update() { DepotManager depotManager = activePlayer.GetComponent <DepotManager> (); CannonManager cannonManager = activePlayer.GetComponent <CannonManager> (); PirateManager pirateManager = activePlayer.GetComponent <PirateManager> (); cannons.text = cannonManager.cannonsCreated.ToString(); pirates.text = activePlayer.GetComponent <PirateManager> ().piratesCreated.ToString(); ammoDepots.text = depotManager.ammoDepotsCreated.ToString(); woodDepots.text = depotManager.woodDepotsCreated.ToString(); if (!buildingDone) { if (playerOne.GetComponent <PirateManager>().BuildUpDone() && playerOne.GetComponent <CannonManager>().BuildUpDone() && playerOne.GetComponent <DepotManager>().BuildUpDone()) { if (playerTwo.GetComponent <PirateManager>().BuildUpDone() && playerTwo.GetComponent <CannonManager>().BuildUpDone() && playerTwo.GetComponent <DepotManager>().BuildUpDone()) { buildingDone = true; GetComponent <GameManager> ().EndBuildPhase(); } } } }
public void ClickedOn(GameObject clicked) { activePlayer = GetComponent <GameManager> ().activeShip; previousSelection = currentSelection; currentSelection = clicked; if (battlePhase) { if (currentSelection.CompareTag("Tile")) { if (previousSelection.CompareTag("Pirate")) { if (previousSelection.GetComponent <Pirate> ().BelongsToPlayer(activePlayer)) { if (turnManager.CanMove(GetComponent <MovementCost> ().GetMovementCost("Walk"))) { GetComponent <PirateMove> ().SelectTile(currentSelection); GetComponent <PirateMove> ().MovePirate(); } } } } if (currentSelection.CompareTag("Cannon")) { Cannon cannon = currentSelection.GetComponent <Cannon> (); if (previousSelection.CompareTag("Pirate")) { Pirate pirate = previousSelection.GetComponent <Pirate> (); if (GetComponent <PirateMove> ().CheckNeighbor(previousSelection, currentSelection)) { if (turnManager.CanMove(GetComponent <MovementCost>().GetMovementCost("Load Cannon"))) { if (pirate.BelongsToPlayer(activePlayer)) { if (pirate.hasAmmo) { if (cannon.ammo < 4) { pirate.DropAmmo(); cannon.AddAmmo(); turnManager.SpendMoves(GetComponent <MovementCost> ().GetMovementCost("Load Cannon")); } } } } } } else if (cannon.BelongsToPlayer(activePlayer)) { activePlayer.GetComponent <CannonManager> ().SelectCannon(currentSelection, activePlayer); activePlayer.GetComponent <CannonManager> ().ShowCannonMenu(); } } if (currentSelection.CompareTag("Pirate")) { PirateManager pirateManager = activePlayer.GetComponent <PirateManager> (); if (currentSelection.GetComponent <Pirate> ().BelongsToPlayer(activePlayer)) { GetComponent <PirateMove> ().SelectPirate(currentSelection); pirateManager.SelectPirate(currentSelection, activePlayer); if (pirateManager.CanRepair(currentSelection)) { pirateManager.ShowPirateMenu(); } } } if (currentSelection.CompareTag("Depot")) { if (previousSelection.CompareTag("Pirate")) { if (previousSelection.GetComponent <Pirate> ().BelongsToPlayer(activePlayer)) { if (GetComponent <PirateMove> ().CheckNeighbor(previousSelection, currentSelection)) { currentSelection.GetComponent <Depot> ().Distribute(previousSelection); } } } } } if (!battlePhase) { if (currentSelection.CompareTag("Tile")) { GetComponent <BuildManager> ().Deploy(currentSelection); } } }
private void FixedUpdate() { PirateManager.SendPiratePositions(); }
public void Init(GameObject lane, float speed, PirateManager manager) { SetLane(lane); movementSpeed = speed; this.manager = manager; }