Exemplo n.º 1
0
    public void PurchaseVehicle(VehicleCardConnector _vehicleCard)
    {
        if (player.Money >= _vehicleCard.vehicle.GetCost(_vehicleCard.costMultiplier) && !_vehicleCard.isPurchased)
        {
            player.Money            -= _vehicleCard.vehicle.GetCost(_vehicleCard.costMultiplier);
            _vehicleCard.isPurchased = true;
            _vehicleCard.purchaseVehicleButton.interactable = false;
            ColorBlock buttonColors = new ColorBlock();
            buttonColors.normalColor     = Color.red;
            buttonColors.disabledColor   = Color.red;
            buttonColors.colorMultiplier = 1;
            _vehicleCard.purchaseVehicleButton.colors = buttonColors;
            _vehicleCard.soldOutOverlay.SetActive(true);

            GameObject _newVehicle = Instantiate(vehiclePrefab, shipSpawnPosition.position, Quaternion.identity);
            _newVehicle.GetComponent <VehicleClass>().CreateSelf(_vehicleCard.vehicle);
            _newVehicle.GetComponent <VehicleClass>().MovementScript.AddTargetPoint(new Vector2(shipSpawnPosition.position.x, shipSpawnPosition.position.y - 0.5f));
            player.AddShip(_newVehicle.transform);
            uiAudio.PlaySound(UIsounds.Purchase);
        }
    }
Exemplo n.º 2
0
    void NewVehicleCard(TierProbability _tierChances)
    {
        VehicleCardConnector _newVehicleCard = Instantiate(vehicleCardPrefab, vehicleCardHolder).GetComponent <VehicleCardConnector>();

        _newVehicleCard.shopMain         = this;
        _newVehicleCard.vehicle          = _newVehicleCard.gameObject.AddComponent <VehicleClass>();
        _newVehicleCard.vehicle.ShipName = partDataHolder.ShipNames[UnityEngine.Random.Range(0, partDataHolder.ShipNames.Count)];
        _newVehicleCard.vehicle.AssignWorker(WorkStation.Cabin, vehicleStartingWorker);

        partDataHolder.GetRandomPart(_tierChances, out PartBody _body);
        _newVehicleCard.vehicle.InstallPart(_body);

        partDataHolder.GetRandomPart(_tierChances, out PartEngine _engine);
        _newVehicleCard.vehicle.InstallPart(_engine);

        partDataHolder.GetRandomPart(_tierChances, out PartWheel _wheels);
        _newVehicleCard.vehicle.InstallPart(_wheels);

        PartCabin _cabin = null;
        PartDrill _drill = null;

        //Cabin is nonessential so it is a random chance
        _newVehicleCard.vehicleVisualParts[2].sprite = null;
        _newVehicleCard.vehicleVisualParts[2].color  = new Color(0, 0, 0, 0);
        if (UnityEngine.Random.Range(0, 10) > 4)
        {
            partDataHolder.GetRandomPart(_tierChances, out _cabin);
            _newVehicleCard.vehicle.InstallPart(_cabin);
            _newVehicleCard.vehicleVisualParts[2].sprite = _cabin.Image;
            _newVehicleCard.vehicleVisualParts[2].color  = Color.white;
        }

        //Drill is nonessential so it is a random chance
        _newVehicleCard.vehicleVisualParts[5].sprite = null;
        _newVehicleCard.vehicleVisualParts[5].color  = new Color(0, 0, 0, 0);
        if (UnityEngine.Random.Range(0, 10) > 5)
        {
            partDataHolder.GetRandomPart(_tierChances, out _drill);
            _newVehicleCard.vehicle.InstallPart(_drill);
            _newVehicleCard.vehicleVisualParts[5].sprite = _drill.Image;
            _newVehicleCard.vehicleVisualParts[5].color  = Color.white;
        }

        _newVehicleCard.shipNameText.text    = _newVehicleCard.vehicle.ShipName;
        _newVehicleCard.costMultiplier       = UnityEngine.Random.Range(1, 3);
        _newVehicleCard.vehicleCostText.text = "Cost: $" + _newVehicleCard.vehicle.GetCost(_newVehicleCard.costMultiplier);
        _newVehicleCard.vehicle.Cost         = _newVehicleCard.vehicle.GetCost(_newVehicleCard.costMultiplier);

        _newVehicleCard.vehicleVisualParts[0].sprite = _body.Image;
        _newVehicleCard.vehicleVisualParts[1].sprite = _body.WindowSprite;
        //_newVehicleCard.vehicleVisualParts[2].sprite = _cabin.Image;
        //_newVehicleCard.vehicleVisualParts[3].sprite = _engine.Image;
        _newVehicleCard.vehicleVisualParts[4].sprite = _wheels.Image;

        //Stat text
        Text statText = Instantiate(vehicleStatPrefab, _newVehicleCard.shipStatList.transform).GetComponentInChildren <Text>();

        statText.text = "Hull: " + _body.PartName;
        statText      = Instantiate(vehicleStatPrefab, _newVehicleCard.shipStatList.transform).GetComponentInChildren <Text>();
        if (_cabin != null)
        {
            statText.text = "Observatory: " + _cabin.PartName;
        }
        else
        {
            statText.text = "Observatory: None";
        }
        statText      = Instantiate(vehicleStatPrefab, _newVehicleCard.shipStatList.transform).GetComponentInChildren <Text>();
        statText.text = "Engine: " + _engine.PartName;
        statText      = Instantiate(vehicleStatPrefab, _newVehicleCard.shipStatList.transform).GetComponentInChildren <Text>();
        if (_drill != null)
        {
            statText.text = "Drilling Module: " + _drill.PartName;
        }
        else
        {
            statText.text = "Drilling Module: None";
        }
        statText      = Instantiate(vehicleStatPrefab, _newVehicleCard.shipStatList.transform).GetComponentInChildren <Text>();
        statText.text = "Movement Module: " + _wheels.PartName;
    }