//Player Actions public void SpawnUnit(Ship.shipType unitType /*, GameObject waypoint*/) { GameObject shipPrefab = StarShipUtilities.Instance.ShipDictionary[unitType].gameObject; //Instantiate Ship Prefab, subtract resources if (Resources[Resource.ResourceKind.metal].amount >= shipPrefab.GetComponent <Ship>().price.metal&& Resources[Resource.ResourceKind.fuel].amount >= shipPrefab.GetComponent <Ship>().price.fuel) //this needs to be changed to reflect { Vector2 CircleAdjust = UnityEngine.Random.insideUnitCircle.normalized * 10; Vector3 spawnPos = new Vector3(playerBase.transform.position.x + CircleAdjust.x, playerBase.transform.position.y, playerBase.transform.position.z + CircleAdjust.y); Resources[Resource.ResourceKind.metal].amount -= (int)shipPrefab.GetComponent <Ship>().price.metal; Resources[Resource.ResourceKind.fuel].amount -= (int)shipPrefab.GetComponent <Ship>().price.fuel; GameObject ship = GameObject.Instantiate(shipPrefab, spawnPos, playerBase.transform.rotation, this.transform); ship.GetComponent <Ship>().SetOwner(this); if (this is ControlledPlayer) { ship.layer = 8; // 8 is the player layer } else { ship.layer = 9; // 9 is the AI layer DisplayEnemySprite(ship); } } else { Debug.Log("Not enough resources"); } }
public void SpawnEnemy(Ship.shipType shipType) { GameObject shipToSpawn = enemyShipDtb.GetEnemyShip(shipType); GameObject spawnedShip = shipSpawnMng.SpawnEnemy(shipToSpawn); shipSetUp.InitShip(spawnedShip, difficulty); }
public GameObject GetEnemyShip(Ship.shipType _type) { List<Ship> shipOfType = new List<Ship>(); foreach(Ship ship in ships) { if(ship.type == _type) { shipOfType.Add(ship); } } int rdm = Random.Range(0, shipOfType.Count); if(shipOfType.Count > 0) { return shipOfType[rdm].shipGO; } return null; }
public void UpdateSelection(BuyMenuButton selectedButton) { _selectedButton = selectedButton; costText.text = selectedButton.fuelCost + " Fuel\n" + selectedButton.metalCost + " Metal"; _ship = _selectedButton.ship; _shipName.text = selectedButton.shipName; _shipDesc.text = selectedButton.shipDesc; _shipImage.sprite = selectedButton.shipImage; _shipImage.color = selectedButton.shipImageColor; attackSlider.value = selectedButton.attackPts; atkSpeedSlider.value = selectedButton.attackPts; rangeSlider.value = selectedButton.attackPts; defenseSlider.value = selectedButton.defensePts; moveSpeedSlider.value = selectedButton.moveSpeedPts; }
public void SpawnEnemy(Ship.shipType _shipType) { eventMng.SpawnEnemy(_shipType); }