예제 #1
0
    //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");
        }
    }
예제 #2
0
    public void SpawnEnemy(Ship.shipType shipType)
    {
        GameObject shipToSpawn = enemyShipDtb.GetEnemyShip(shipType);
        GameObject spawnedShip = shipSpawnMng.SpawnEnemy(shipToSpawn);

        shipSetUp.InitShip(spawnedShip, difficulty);
    }
예제 #3
0
    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;
    }
예제 #4
0
    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;
    }
예제 #5
0
 public void SpawnEnemy(Ship.shipType _shipType)
 {
     eventMng.SpawnEnemy(_shipType);
 }