コード例 #1
0
ファイル: GameManager.cs プロジェクト: LeonardA-L/ide-GameJam
        private void RegisterModule(string _moduleName, string _outputName, string _fuelName, double _maxHealth, double _frequency, double _efficiency, double _damageRate, double _damageFreq, double _repairCost, double _repairFreq)
        {
            // The module
            Generator waterModule = new Generator(_moduleName, new GenerationIntervalUtils.IntervalPowered(_frequency), new GenerationUtils.GenerateLinear(), new CostsUtils.CostsStandard(), false, false);

            waterModule.AddFuel(_fuelName, 1, m_globalStorage);
            waterModule.AddOutput(_outputName, _efficiency, m_globalStorage);
            GeneratorManager.Instance.RegisterGeneratorClass(_moduleName, waterModule);

            // Health stuff
            GeneratorManager.Instance.RegisterGeneratorClass(_moduleName + Constants.MODULE_HEALTH_SUFFIX, new Generator(_moduleName + Constants.MODULE_HEALTH_SUFFIX, null, new GenerationUtils.GenerateLinear(), new CostsUtils.CostsStandard(0, 0), false, false, null, null, 0.0f, _maxHealth));

            // Repairing unit
            Generator waterModuleRepair = new Generator(_moduleName + Constants.MODULE_HEALTH_REPAIR, new GenerationIntervalUtils.IntervalPowered(_repairFreq), new GenerationUtils.GenerateLinear(), new CostsUtils.CostsStandard(), false, true);

            waterModuleRepair.AddFuel(Constants.DUCTTAPE, _repairCost, m_globalStorage);
            waterModuleRepair.AddOutput(_moduleName + Constants.MODULE_HEALTH_SUFFIX, 1, m_globalStorage);
            GeneratorManager.Instance.RegisterGeneratorClass(_moduleName + Constants.MODULE_HEALTH_REPAIR, waterModuleRepair);

            // Damaging unit
            Generator waterModuleDamage = new Generator(_moduleName + Constants.MODULE_HEALTH_DAMAGE, new GenerationIntervalUtils.IntervalPowered(_damageFreq), new GenerationUtils.GenerateLinear(), new CostsUtils.CostsStandard(), false, false);

            waterModuleDamage.AddFuel(_moduleName + Constants.MODULE_HEALTH_SUFFIX, _damageRate, m_globalStorage);
            GeneratorManager.Instance.RegisterGeneratorClass(_moduleName + Constants.MODULE_HEALTH_DAMAGE, waterModuleDamage);
        }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: LeonardA-L/ide-GameJam
        private void _InitNewGame()
        {
            PopulateData.Init(_gameState);

            m_globalStorage = new Storage(Constants.STORAGE_MAIN);

            const double maxModuleHealth = 5;
            const double moduleFrequency = 2 * 1000.0f;

            // Primary resources
            GeneratorManager.Instance.RegisterGeneratorClass(Constants.WATER, new Generator(Constants.WATER, null, new GenerationUtils.GenerateLinear(), new CostsUtils.CostsStandard(0, 0), false, false, null, null, 0));
            GeneratorManager.Instance.RegisterGeneratorClass(Constants.POTATO, new Generator(Constants.POTATO, null, new GenerationUtils.GenerateLinear(), new CostsUtils.CostsStandard(0, 0), false, false, null, null, 0));
            GeneratorManager.Instance.RegisterGeneratorClass(Constants.ELECTRICITY, new Generator(Constants.ELECTRICITY, null, new GenerationUtils.GenerateLinear(), new CostsUtils.CostsStandard(0, 0), false, false, null, null, 0));

            GeneratorManager.Instance.RegisterGeneratorClass(Constants.DUCTTAPE, new Generator(Constants.DUCTTAPE, null, new GenerationUtils.GenerateLinear(), new CostsUtils.CostsStandard(0, 0), false, false, null, null, 0));
            GeneratorManager.Instance.RegisterGeneratorClass(Constants.SCRAP, new Generator(Constants.SCRAP, null, new GenerationUtils.GenerateLinear(), new CostsUtils.CostsStandard(0, 0), false, false, null, null, 0));

            // Generators Modules
            RegisterModule(Constants.WATER + Constants.MODULE, Constants.WATER, Constants.ELECTRICITY, maxModuleHealth, moduleFrequency, 1.8f, 0.1f, 2 * 1000.0f, 5, 3.0f * 1000.0f);
            RegisterModule(Constants.POTATO + Constants.MODULE, Constants.POTATO, Constants.WATER, maxModuleHealth, moduleFrequency, 1.9f, 0.1f, 2 * 1000.0f, 5, 6.0f * 1000.0f);
            RegisterModule(Constants.ELECTRICITY + Constants.MODULE, Constants.ELECTRICITY, Constants.POTATO, maxModuleHealth, moduleFrequency, 1.8f, 0.1f, 2 * 1000.0f, 5, 3.0f * 1000.0f);

            // Player Health stats
            Generator playerConsumptionHunger = new Generator(Constants.PLAYER_CONSUMPTION + Constants.POTATO, new GenerationIntervalUtils.IntervalPowered(moduleFrequency), new GenerationUtils.GenerateLinear(0, 1), new CostsUtils.CostsStandard(), false, false);

            playerConsumptionHunger.AddFuel(Constants.POTATO, 0.7f, m_globalStorage);
            playerConsumptionHunger.SetAllowPartialConsumption(true);
            GeneratorManager.Instance.RegisterGeneratorClass(Constants.PLAYER_CONSUMPTION + Constants.POTATO, playerConsumptionHunger);

            Generator playerConsumptionThirst = new Generator(Constants.PLAYER_CONSUMPTION + Constants.WATER, new GenerationIntervalUtils.IntervalPowered(moduleFrequency), new GenerationUtils.GenerateLinear(0, 1), new CostsUtils.CostsStandard(), false, false);

            playerConsumptionThirst.AddFuel(Constants.WATER, 0.7f, m_globalStorage);
            playerConsumptionThirst.SetAllowPartialConsumption(true);
            GeneratorManager.Instance.RegisterGeneratorClass(Constants.PLAYER_CONSUMPTION + Constants.WATER, playerConsumptionThirst);

            Generator hunger = new Generator(Constants.HUNGER, new GenerationIntervalUtils.IntervalPowered(2.0f * 1000), new GenerationUtils.GenerateLinear(0, 1), new CostsUtils.CostsStandard(), false, false);

            hunger.AddFuel(Constants.HUNGER, _gameState.starvationDecay, m_globalStorage);
            hunger.SetAllowPartialConsumption(true);
            hunger.SetClampingValues(0, _gameState.playerHungerStart);
            GeneratorManager.Instance.RegisterGeneratorClass(Constants.HUNGER, hunger);

            Generator thirst = new Generator(Constants.THIRST, new GenerationIntervalUtils.IntervalPowered(2.0f * 1000), new GenerationUtils.GenerateLinear(0, 1), new CostsUtils.CostsStandard(), false, false);

            thirst.AddFuel(Constants.THIRST, _gameState.starvationDecay, m_globalStorage);
            thirst.SetAllowPartialConsumption(true);
            thirst.SetClampingValues(0, _gameState.playerThirstStart);
            GeneratorManager.Instance.RegisterGeneratorClass(Constants.THIRST, thirst);

            Generator regen = new Generator(Constants.REGEN_THIRST, new GenerationIntervalUtils.IntervalPowered(2.0f * 1000), new GenerationUtils.GenerateLinear(), new CostsUtils.CostsStandard(), true, false);

            regen.AddOutput(Constants.THIRST, _gameState.playerRegen, m_globalStorage);
            GeneratorManager.Instance.RegisterGeneratorClass(Constants.REGEN_THIRST, regen);

            Generator regenHunger = new Generator(Constants.REGEN_HUNGER, new GenerationIntervalUtils.IntervalPowered(2.0f * 1000), new GenerationUtils.GenerateLinear(), new CostsUtils.CostsStandard(), true, false);

            regenHunger.AddOutput(Constants.HUNGER, _gameState.playerRegen, m_globalStorage);
            GeneratorManager.Instance.RegisterGeneratorClass(Constants.REGEN_HUNGER, regenHunger);

            // Add Start values
            m_globalStorage.Add(Constants.WATER, 20);
            m_globalStorage.Add(Constants.POTATO, 15);
            m_globalStorage.Add(Constants.ELECTRICITY, 20);

            m_globalStorage.Add(Constants.DUCTTAPE, 50);
            m_globalStorage.Add(Constants.SCRAP, 75);

            m_globalStorage.Add(Constants.HUNGER, _gameState.playerHungerStart);
            m_globalStorage.Add(Constants.THIRST, _gameState.playerThirstStart);

            m_globalStorage.Add(Constants.WATER + Constants.MODULE, 1);
            m_globalStorage.Add(Constants.POTATO + Constants.MODULE, 1);
            m_globalStorage.Add(Constants.ELECTRICITY + Constants.MODULE, 1);

            m_globalStorage.Add(Constants.WATER + Constants.MODULE + Constants.MODULE_HEALTH_SUFFIX, 5);
            m_globalStorage.Add(Constants.POTATO + Constants.MODULE + Constants.MODULE_HEALTH_SUFFIX, 5);
            m_globalStorage.Add(Constants.ELECTRICITY + Constants.MODULE + Constants.MODULE_HEALTH_SUFFIX, 5);

            m_globalStorage.Add(Constants.WATER + Constants.MODULE + Constants.MODULE_HEALTH_REPAIR, 1);
            m_globalStorage.Add(Constants.POTATO + Constants.MODULE + Constants.MODULE_HEALTH_REPAIR, 1);
            m_globalStorage.Add(Constants.ELECTRICITY + Constants.MODULE + Constants.MODULE_HEALTH_REPAIR, 1);

            m_globalStorage.Add(Constants.WATER + Constants.MODULE + Constants.MODULE_HEALTH_DAMAGE, 1);
            m_globalStorage.Add(Constants.POTATO + Constants.MODULE + Constants.MODULE_HEALTH_DAMAGE, 1);
            m_globalStorage.Add(Constants.ELECTRICITY + Constants.MODULE + Constants.MODULE_HEALTH_DAMAGE, 1);

            m_globalStorage.Add(Constants.REGEN_HUNGER, 1);
            m_globalStorage.Add(Constants.REGEN_THIRST, 1);
            m_globalStorage.Add(Constants.PLAYER_CONSUMPTION + Constants.POTATO, 1);
            m_globalStorage.Add(Constants.PLAYER_CONSUMPTION + Constants.WATER, 1);
        }