public BattleManager(PlayerFleet p_Fleet, EnemyFleet e_Fleet) { Player = p_Fleet; Enemy = e_Fleet; P_Ship_Array = Player.get_Fleet(); E_Ship_Array = Enemy.get_Fleet(); }
public void setFleets(PlayerFleet p_Fleet, EnemyFleet e_Fleet) { Player = p_Fleet; Enemy = e_Fleet; P_Ship_Array = Player.get_Fleet(); E_Ship_Array = Enemy.get_Fleet(); }
// Use this for initialization void Start() { m_player_inven = GameObject.Find("P_Inven").GetComponent <PlayerInventory>(); currentPlayerFleet = this.gameObject.AddComponent <PlayerFleet>(); //currentPlayerFleet. Debug.Log(currentPlayerFleet); }
private void CellClicked(int cell) { var coord = new Coordinate(cell % 10, cell / 10); switch (GameState) { case GameState.HumanPlayerPlacingPatrol: var ptVertical = PlayerShipVisibility[Constants.PatrolBoat]; if (PlayerFleet.PlaceShip(coord, ptVertical, Constants.PatrolBoat)) { GameState = GameState.HumanPlayerPlacingDestroyer; PlayerShipVisibility[Constants.Destroyer] = true; } break; case GameState.HumanPlayerPlacingDestroyer: var destVertical = PlayerShipVisibility[Constants.Destroyer]; if (PlayerFleet.PlaceShip(coord, destVertical, Constants.Destroyer)) { GameState = GameState.HumanPlayerPlacingSubmarine; PlayerShipVisibility[Constants.Submarine] = true; } break; case GameState.HumanPlayerPlacingSubmarine: var subVertical = PlayerShipVisibility[Constants.Submarine]; if (PlayerFleet.PlaceShip(coord, subVertical, Constants.Submarine)) { GameState = GameState.HumanPlayerPlacingBattleship; PlayerShipVisibility[Constants.Battleship] = true; } break; case GameState.HumanPlayerPlacingBattleship: var batVertical = PlayerShipVisibility[Constants.Battleship]; if (PlayerFleet.PlaceShip(coord, batVertical, Constants.Battleship)) { GameState = GameState.HumanPlayerPlacingAircraftCarrier; PlayerShipVisibility[Constants.AircraftCarrier] = true; } break; case GameState.HumanPlayerPlacingAircraftCarrier: var airVertical = PlayerShipVisibility[Constants.AircraftCarrier]; if (PlayerFleet.PlaceShip(coord, airVertical, Constants.AircraftCarrier)) { GameState = GameState.ReadyWaitingToStart; } break; } //var x = cell % 10; //var y = cell / 10; //Grid.SetRow(); }
private Planet createPlanetWithShip(int x, int y, Star star) { Planet planet = new Planet(x, y); Ship ship = new Ship(15, 15); PlayerFleet.AddShip(ship, star, planet); return(planet); }
// Use this for initialization void Start() { planet = GameContext.CurrentPlanet; Instantiate(planetLargePrefab, new Vector3(0, 0, 0), Quaternion.identity); List <Ship> ships = PlayerFleet.GetShipsForPlanet(planet); foreach (Ship ship in ships) { Transform shipObject = Instantiate(shipPrefab, new Vector3(ship.x, ship.y, 0), Quaternion.identity) as Transform; shipObject.gameObject.GetComponent <ShipScript>().ship = ship; } }
// Update is called once per frame void Update() { PlayerFleet.UpdateShipPositions(); List <Ship> ships = PlayerFleet.GetShipsForPlanet(planet); foreach (GameObject shipObject in GameObject.FindGameObjectsWithTag("Ship")) { foreach (Ship ship in ships) { if (shipObject.GetComponent <ShipScript>().ship.id == ship.id) { shipObject.transform.position = new Vector3(ship.x, ship.y, 0f); } } } }
private void PlayerCellClicked(int cell) { if (GameState != GameState.HumansTurn) { return; } var x = cell % 10; var y = cell / 10; var attackedCell = new Coordinate(x, y); _captain.OpponentAttack(attackedCell); var result = AiFleet.Attacked(attackedCell); PlayerGameBoard[x][y] = result; if (result == Constants.Defeated) { MessageBox.Show("You win!"); AILosses++; GameState = GameState.Waiting; return; } GameState = GameState.AIsTurn; var aiAttack = _captain.MakeAttack(); result = PlayerFleet.Attacked(aiAttack); _captain.ResultOfAttack(result); AIGameBoard[aiAttack.X][aiAttack.Y] = result; if (result == Constants.Defeated) { MessageBox.Show("You lose :("); AIWins++; GameState = GameState.Waiting; return; } GameState = GameState.HumansTurn; }
public void SetShipCourse(PlayerTag playerTag, ID shipID, ushort course) { PlayerFleet fleet = fleets.Find(f => f.PlayerTag == playerTag); if (fleet != null) { Ship ship = fleet.Ships.Find(s => s.ID == shipID); if (ship != null) { ship.Autopilot.Course = course; } else { Debug.LogWarning("Ship with ID " + shipID + " not found"); } } else { Debug.LogWarning("Fleet of player tag " + playerTag + " not found"); } }
public void SetShipChadburn(PlayerTag playerTag, ID shipID, Autopilot.ChadburnSetting chadburnSetting) { PlayerFleet fleet = fleets.Find(f => f.PlayerTag == playerTag); if (fleet != null) { Ship ship = fleet.Ships.Find(s => s.ID == shipID); if (ship != null) { ship.Autopilot.Chadburn = chadburnSetting; } else { Debug.LogWarning("Ship with ID " + shipID + " not found"); } } else { Debug.LogWarning("Fleet of player tag " + playerTag + " not found"); } }
Star createFirstStar() { List <Planet> planets = new List <Planet> (); Planet planet = new Planet(10, 10); planets.Add(planet); planets.Add(new Planet(0, 10)); planets.Add(new Planet(10, 0)); Star star = new Star(-10, -10, planets); Ship myShip = new Ship(10, 10); myShip.Player = GameContext.CurrentPlayer; PlayerFleet.AddShip(myShip, star, planet); Ship anotherShip = new Ship(0, 30); anotherShip.Player = new Player(); PlayerFleet.AddShip(anotherShip, star, planet); return(star); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0) && selected && GUIUtility.hotControl == 0 && ship.IsOwner(GameContext.CurrentPlayer)) { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { //clicked the ship if (hit.transform == transform) { } } else { Vector3 newPosition = ray.GetPoint(-Camera.main.transform.position.z); newPosition.z = 0; ship = PlayerFleet.UpdateShipDestination(ship, newPosition); } } }
public void SetShipTarget(PlayerTag playerTag, ID shipID, bool hasTarget, ID targetShipID) { PlayerFleet fleet = fleets.Find(f => f.PlayerTag == playerTag); if (fleet != null) { Ship ship = fleet.Ships.Find(s => s.ID == shipID); if (ship != null) { if (hasTarget) { Ship target = FindShipByID(targetShipID); if (target != null) { ship.Targeting.Target = target; } else { Debug.LogWarning(("Target ship ID " + targetShipID + " not found")); } } else { ship.Targeting.Target = null; } } else { Debug.LogWarning("Ship with ID " + shipID + " not found"); } } else { Debug.LogWarning("Fleet of player tag " + playerTag + " not found"); } }
void nullifier() { Player = null; Enemy = null; isActive = false; Turns = null; CurrentTurn.c_Ship = null; CurrentTurn.c_Wep = null; CurrentTurn.t_Ship = null; P_Ship_Array = null; E_Ship_Array = null; active_Ship = null; act_Ship = 0; en_Ship = null; en_Turn = null; TurnTransScript = null; thisScene = null; set_Action = false; c_Action_Set = false; playerSets = false; c_Battle = battle_State.bNull; aSelect = null; }
public ShipBase GetShip(Planet planet, ShipType type) => PlayerFleet.First(s => s.BelongsTo.Id == planet.Id && s.Type == type);
// Update is called once per frame void Update() { PlayerFleet.UpdateShipPositions(); }