Exemplo n.º 1
0
        //--------------------------------------------------
        // private
        //--------------------------------------------------
        private int GetTotalPurchase()
        {
            int _total = 0;

            for (int a = 0; a < DATA_PACKAGE.serviceSignalPatterns.Length + 2; ++a)
            {
                switch (a)
                {
                case 0:
                    _total += purchaseLog.tmMachineCount * DATA_PACKAGE.tmMachineRates.price;
                    break;

                case 1:
                    _total += purchaseLog.satDishCount * DATA_PACKAGE.satDishRates.price;
                    break;

                default:
                    ServiceSignalPattern _ssp = DATA_PACKAGE.serviceSignalPatterns[a - 2];
                    if (purchaseLog.newServices.Contains(_ssp.service))
                    {
                        _total += _ssp.price;
                    }
                    break;
                }
            }
            return(_total);
        }
Exemplo n.º 2
0
        //--------------------------------------------------
        // private
        //--------------------------------------------------

        //--------------------------------------------------
        // public
        //--------------------------------------------------

        //--------------------------------------------------
        // protected
        //--------------------------------------------------
        protected void OnEnable()
        {
            if (GAME == null)
            {
                return;
            }

            for (int a = 0; a < DATA_PACKAGE.serviceSignalPatterns.Length; ++a)
            {
                ServiceSignalPattern ssp = DATA_PACKAGE.serviceSignalPatterns[a];
                if (!DATA_PACKAGE.ServiceIsEnabled(ssp.service))
                {
                    labels[a].text = "";
                    continue;
                }

                labels[a].text = "<size=25><b>" + ssp.service + " (" + ssp.signalPatterns.Length + ")</b></size>";
                for (int b = 0; b < ssp.signalPatterns.Length; ++b)
                {
                    SignalPattern sp = ssp.signalPatterns[b];
                    labels[a].text += "\n  frequency " + b + ":";
                    labels[a].text += "\n    signal strength: " + sp.strength;
                    labels[a].text += "\n    signal speed: " + sp.speed;
                }
            }
        }
Exemplo n.º 3
0
        public Result GetFinalResult()
        {
            Result _result = new Result();

            _result.result0 = "<size=25><b>total data transmitted:</b> " + transmittedData.Count + "</size>";

            int[] _dataCount   = new int[serviceSignalPatterns.Length];
            int[] _commissions = new int[serviceSignalPatterns.Length];
            _result.totalEarnings = 0;
            for (int a = 0; a < serviceSignalPatterns.Length; ++a)
            {
                ServiceSignalPattern ssp = serviceSignalPatterns[a];
                int _totalDataSize       = 0;
                foreach (DataPackage data in transmittedData)
                {
                    if (data.service == ssp.service)
                    {
                        ++_dataCount[a];
                        _totalDataSize += Mathf.RoundToInt(data.size * data.multiplier);
                    }
                }
                if (_dataCount[a] > 0)
                {
                    _result.result0 += "\n  " + ssp.service + ": " + _dataCount[a];
                }
                _commissions[a]        = _dataCount[a] * ssp.commission * _totalDataSize;
                _result.totalEarnings += _commissions[a];
            }

            _result.result0 += "\n\n<size=25><b>total commissions:</b> $" + _result.totalEarnings + "</size>";

            for (int a = 0; a < serviceSignalPatterns.Length; ++a)
            {
                if (_commissions[a] > 0)
                {
                    _result.result0 += "\n  " + serviceSignalPatterns[a].service + ": $" + _commissions[a];
                }
            }

            int    _totalBills   = 0;
            int    _tmBills      = GAME.enabledTmMachineCount * tmMachineRates.dailyRates;
            int    _satDishBills = GAME.enabledSatDishCount * satDishRates.dailyRates;
            string _billsResult  = "\n  tmMachine_electric_bills: $-" + _tmBills;

            _billsResult += "\n  satDish_electric_bills: $-" + _satDishBills;

            _totalBills -= _tmBills;
            _totalBills -= _satDishBills;
            if (enabledServices != null)
            {
                foreach (DataPackage.Service es in enabledServices)
                {
                    if (es == DataPackage.Service.unaffiliated)
                    {
                        continue;
                    }

                    foreach (ServiceSignalPattern ssp in serviceSignalPatterns)
                    {
                        if (ssp.service == es)
                        {
                            _totalBills  -= ssp.dailyRates;
                            _billsResult += "\n  " + ssp.service + "_licensing_daily: $-" + ssp.dailyRates;
                            break;
                        }
                    }
                }
            }

            _result.result0 += "\n\n<size=25><b>total bills:</b> $" + _totalBills + "</size>";
            _result.result0 += _billsResult;

            _result.totalEarnings += _totalBills;
            _result.result0       += "\n\n<size=25><b>total earnings:</b> $" + _result.totalEarnings + "</size>";

            _result.result1  = "<size=25><b>current funds:</b> $" + PLAYER_STATS.funds + "</size>";
            _result.result1 += "\n  + earnings: $" + _result.totalEarnings;

            PLAYER_STATS.funds += _result.totalEarnings;
            _result.result1    += "\n\n<size=25><b>total funds:</b> $" + (PLAYER_STATS.funds) + "</size>";
            return(_result);
        }
Exemplo n.º 4
0
        private void State_purchases()
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                AudioController.Play("ui_btn_direction_section");
                PLAYER_STATS.funds -= GetTotalPurchase();

                // if ( PLAYER_STATS.funds > 0 ) {
                GAME.enabledTmMachineCount += purchaseLog.tmMachineCount;
                GAME.enabledSatDishCount   += purchaseLog.satDishCount;
                foreach (DataPackage.Service ns in purchaseLog.newServices)
                {
                    DATA_PACKAGE.EnableService(ns);
                }
                GAME.StartGame();
                // }
                // else {
                //   currentState = State.game_over;
                // }
            }

            int _maxSelection = DATA_PACKAGE.serviceSignalPatterns.Length + 2;

            if (Input.GetKeyDown(KeyCode.W) ||
                Input.GetKeyDown(KeyCode.UpArrow))
            {
                AudioController.Play("ui_btn_direction");
                --purchaseLog.selectionIndex;
                if (purchaseLog.selectionIndex <= 0)
                {
                    purchaseLog.selectionIndex = 0;
                }
            }

            if (Input.GetKeyDown(KeyCode.S) ||
                Input.GetKeyDown(KeyCode.DownArrow))
            {
                AudioController.Play("ui_btn_direction");
                ++purchaseLog.selectionIndex;
                if (purchaseLog.selectionIndex >= _maxSelection)
                {
                    purchaseLog.selectionIndex = _maxSelection - 1;
                }
            }

            int _maxTmMachinesCount = GAME.tmMachines.Length - GAME.enabledTmMachineCount;
            int _maxSatDishCount    = GAME.satDishes.Length - GAME.enabledSatDishCount;

            if (Input.GetKeyDown(KeyCode.A) ||
                Input.GetKeyDown(KeyCode.LeftArrow))
            {
                switch (purchaseLog.selectionIndex)
                {
                case 0:
                    if (_maxTmMachinesCount > 0)
                    {
                        --purchaseLog.tmMachineCount;
                        if (purchaseLog.tmMachineCount < 0)
                        {
                            purchaseLog.tmMachineCount = 0;
                            AudioController.Play("ui_btn_reject");
                        }
                        else
                        {
                            AudioController.Play("ui_btn_toggle");
                        }
                    }
                    break;

                case 1:
                    if (_maxSatDishCount > 0)
                    {
                        --purchaseLog.satDishCount;
                        if (purchaseLog.satDishCount < 0)
                        {
                            purchaseLog.satDishCount = 0;
                        }
                        else
                        {
                            AudioController.Play("ui_btn_toggle");
                        }
                    }
                    break;

                default:
                    ServiceSignalPattern _ssp = DATA_PACKAGE.serviceSignalPatterns[purchaseLog.selectionIndex - 2];
                    if (purchaseLog.newServices.Contains(_ssp.service))
                    {
                        purchaseLog.newServices.Remove(_ssp.service);
                        AudioController.Play("ui_btn_toggle");
                    }
                    break;
                }
            }

            if (Input.GetKeyDown(KeyCode.D) ||
                Input.GetKeyDown(KeyCode.RightArrow))
            {
                switch (purchaseLog.selectionIndex)
                {
                case 0:
                    if (_maxTmMachinesCount > 0)
                    {
                        ++purchaseLog.tmMachineCount;
                        if (purchaseLog.tmMachineCount > _maxTmMachinesCount)
                        {
                            purchaseLog.tmMachineCount = _maxTmMachinesCount;
                            AudioController.Play("ui_btn_reject");
                        }
                        else
                        {
                            AudioController.Play("ui_btn_toggle");
                        }
                    }
                    break;

                case 1:
                    if (_maxSatDishCount > 0)
                    {
                        ++purchaseLog.satDishCount;
                        if (purchaseLog.satDishCount > _maxSatDishCount)
                        {
                            purchaseLog.satDishCount = _maxSatDishCount;
                        }
                        else
                        {
                            AudioController.Play("ui_btn_toggle");
                        }
                    }
                    break;

                default:
                    ServiceSignalPattern _ssp = DATA_PACKAGE.serviceSignalPatterns[purchaseLog.selectionIndex - 2];
                    if (!purchaseLog.newServices.Contains(_ssp.service) &&
                        !DATA_PACKAGE.ServiceIsEnabled(_ssp.service))
                    {
                        purchaseLog.newServices.Add(_ssp.service);
                        AudioController.Play("ui_btn_toggle");
                    }
                    break;
                }
            }

            purchasesLabels[0].text = "";
            purchasesLabels[1].text = "";
            for (int a = 0; a < _maxSelection; ++a)
            {
                string _prefix = (a > 0) ? "\n" : "";
                if (purchaseLog.selectionIndex == a)
                {
                    _prefix += "> ";
                }

                switch (a)
                {
                case 0:
                    purchasesLabels[0].text += _prefix + "transmission_machine - ";
                    if (_maxTmMachinesCount <= 0)
                    {
                        purchasesLabels[0].text += "[full]";
                        purchasesLabels[1].text += "-";
                    }
                    else
                    {
                        purchasesLabels[0].text += "$" + DATA_PACKAGE.tmMachineRates.price;
                        purchasesLabels[1].text += "x " + purchaseLog.tmMachineCount;
                    }
                    break;

                case 1:
                    // purchasesLabels[0].text += _prefix + "satelite_dish - $" + DATA_PACKAGE.satDishRates.price;
                    // purchasesLabels[1].text += "\nx " + purchaseLog.satDishCount;
                    purchasesLabels[0].text += _prefix + "satelite_dish - ";
                    if (_maxSatDishCount <= 0)
                    {
                        purchasesLabels[0].text += "[full]";
                        purchasesLabels[1].text += "\n-";
                    }
                    else
                    {
                        purchasesLabels[0].text += "$" + DATA_PACKAGE.satDishRates.price;
                        purchasesLabels[1].text += "\nx " + purchaseLog.satDishCount;
                    }
                    purchasesLabels[0].text += "\n\n";
                    purchasesLabels[1].text += "\n\n";
                    break;

                default:
                    ServiceSignalPattern _ssp = DATA_PACKAGE.serviceSignalPatterns[a - 2];
                    purchasesLabels[0].text += _prefix + _ssp.service + "_licensing - ";
                    if (DATA_PACKAGE.ServiceIsEnabled(_ssp.service))
                    {
                        purchasesLabels[0].text += "[purchased]";
                        purchasesLabels[1].text += "\n";
                    }
                    else
                    {
                        purchasesLabels[0].text += "$" + _ssp.price;
                        if (purchaseLog.newServices.Contains(_ssp.service))
                        {
                            purchasesLabels[1].text += "\nselected";
                        }
                        else
                        {
                            purchasesLabels[1].text += "\n-";
                        }
                    }
                    break;
                }
            }

            purchasesLabels[0].text += "\n\n-------------------------\n";
            purchasesLabels[0].text += "\nTotal Price";
            purchasesLabels[0].text += "\nFunds Left After Purchase";
            purchasesLabels[0].text  = purchasesLabels[0].text.ToLower();

            int _totalPrice = GetTotalPurchase();

            purchasesLabels[1].text += "\n\n-------------------------\n";
            purchasesLabels[1].text += "\n$" + _totalPrice;
            purchasesLabels[1].text += "\n$" + (PLAYER_STATS.funds - _totalPrice);
        }