void OnDestroy() { if (Instance == this) { Instance = null; } }
public void InitializeNewGame() { //---<resourses init>---// //---<resourses init>---// //---<Ship init>---// AvailableShips.AddShip(_yellowShips, "Yellow"); AvailableShips.AddShip(_bleuShips, "Blue"); AvailableShips.AddShip(_greenShips, "Green"); AvailableShips.AddShip(_minerShips, "Miner"); //---<Ship init>---// }
public void Resume() { string json = File.ReadAllText(Application.persistentDataPath + "/Save.gm"); var go = JsonUtility.FromJson <PersistentData>(json); AvailableShips.AddShip(go.yellowShips, "Yellow"); AvailableShips.AddShip(go.blueShips, "Blue"); AvailableShips.AddShip(go.greenShips, "Green"); AvailableShips.AddShip(go.minerShips, "Miner"); Werehouses.AddResours(ResoursesType.Metal, go.metal); Werehouses.AddResours(ResoursesType.YellowGem, go.yellowGem); Werehouses.AddResours(ResoursesType.BlueGem, go.blueGem); Werehouses.AddResours(ResoursesType.GreenGem, go.greenGem); SceneManager.LoadScene("ArkBase"); }
private void Start() { //===============================// for (int i = 0; i < 6; i++) { AvailableShips.AddShip(1, UnitsType[Random.Range(0, 3)].WeaponType); } //===============================// AddAvailableShip(UnitsType[0], AvailableShips.YellowShips); AddAvailableShip(UnitsType[1], AvailableShips.BlueShips); AddAvailableShip(UnitsType[2], AvailableShips.GreenShips); Init(); }
public static void LoadContent(ContentManager content, Random random) { for (int i = 0; i < shipNumber; i++) { AvailableShips.Add(new Ship(1)); } playerShip = availableShips[random.Next(0, shipNumber)]; //playerShip.SpawnShip(new Vector3(random.Next(-1000, 1000), random.Next(-1000, 1000), random.Next(-1000, 1000)), 0f); //busyShips.Add(playerShip); //availableShips.Remove(playerShip); SpawnPlayer(new Vector3(random.Next(-1000, 1000), random.Next(-1000, 1000), random.Next(-1000, 1000))); playerShip.MaxSpeed = 10f; for (int i = 0; i < shipNumber / 2; i++) { SpawnShip(random, content); } }
private void FinishBuildingShip(GameObject client, string type) { RemoveShipFromConstruct(client); AvailableShips.AddShip(1, type); }
private void Init() { showInfoPanel = true; gameObject.SetActive(false); ToggleInfoPanels(); PlayModeOn = true; PlayerGroup.GatherAGroup(_teamForm.PlayerSquad); _playerSquad = _teamForm.PlayerSquad; //=================== DEBUG =====================// EnemySquad.GatherASquad(DebugEnemySquadCreated()); //===============================================// int i = 0; foreach (var unit in _playerSquad) { AvailableShips.SubShip(1, unit.WeaponType); i++; var freeTile = GetFreeTile().gameObject; if (freeTile == null) { return; //not enough space } var ship = Instantiate(unit.Ship, _playerSquadParent.transform); float halfShipHeight = ship.GetComponent <Collider>().bounds.extents.y; float halfTileHeight = freeTile.GetComponent <Collider>().bounds.extents.y; Vector3 freeCell = freeTile.transform.position; freeCell.y += halfTileHeight + halfShipHeight; ship.name = unit.Name + " Player " + i; ship.tag = "PlayerUnit"; ship.transform.position = freeCell; ship.AddComponent <PlayerMove>(); ship.AddComponent <CharInfo>(); ship.GetComponent <CharInfo>().Init(unit); _playerSquadGO.Add(ship.GetComponent <PlayerMove>()); AddShipInfoPonel(ship, true); ship.GetComponent <PlayerMove>().PreInit(); } TurnManager.AddTeam(_playerSquadGO); i = 0; foreach (var unit in EnemySquad.Squad) { i++; var freeTile = GetFreeTileForEnemy().gameObject; if (freeTile == null) { return; //not enough space } var ship = Instantiate(unit.Ship, _enemySquadParent.transform); float halfShipHeight = ship.GetComponent <Collider>().bounds.extents.y; float halfTileHeight = freeTile.GetComponent <Collider>().bounds.extents.y; Vector3 freeCell = freeTile.transform.position; freeCell.y += halfTileHeight + halfShipHeight; ship.name = unit.Name + " Enemy " + i; ship.tag = "EnemyUnit"; ship.transform.position = freeCell; ship.AddComponent <NPCmove>(); ship.AddComponent <CharInfo>(); ship.GetComponent <CharInfo>().Init(unit); _enemySquadGO.Add(ship.GetComponent <NPCmove>()); AddShipInfoPonel(ship, false); ship.GetComponent <NPCmove>().PreInit(); } TurnManager.AddTeam(_enemySquadGO); }
void OnDestroy() { if (Instance == this) Instance = null; }
void Start() { Instance = this; }
/// <summary> /// Unassigns the specified ship from this trade route. /// </summary> public void UnassignShip(AvailableShips.Owned ship) { if (ship.tradeRoute == this) { ships.Remove(ship); ship.tradeRoute = null; if (ship.asset != null) { Object.Destroy(ship.asset); ship.asset = null; } } }
/// <summary> /// Assigns the specified ship to this trade route. /// </summary> public void AssignShip(AvailableShips.Owned ship) { if (ship.tradeRoute != this) { if (ship.tradeRoute != null) ship.tradeRoute.UnassignShip(ship); ship.tradeRoute = this; ships.Add(ship); if (ship.prefab != null) { Vector3 start = mOriginal.Sample(0f, SplineV.SampleType.Linear); Vector3 next = mOriginal.Sample(1f, SplineV.SampleType.Linear); GameObject go = Instantiate(ship.prefab.prefab, start, Quaternion.LookRotation(next - start)) as GameObject; if (go != null) { // Replace the possible multiple colliders with a single one residing at root Collider[] cols = go.GetComponentsInChildren<Collider>(); if (cols.Length > 1) { foreach (Collider col in cols) Destroy(col); go.AddComponent<BoxCollider>(); } ship.asset = go; go.AddComponent<Highlightable>(); TradeShip script = go.AddComponent<TradeShip>(); script.tradeRoute = this; script.prefab = ship.prefab; script.speed = ship.prefab.speed; } } } }
void Start() { Instance = this; }