public string ModuleCommand(IList <string> arguments)
        {
            int    reactorId           = int.Parse(arguments[0]);
            string moduleType          = arguments[1];
            int    additionalParameter = int.Parse(arguments[2]);

            switch (moduleType)
            {
            case "CryogenRod":
                IEnergyModule cryogenRod = new CryogenRod(this.currentId, additionalParameter);
                this.reactors[reactorId].AddEnergyModule(cryogenRod);
                this.identifiableObjects.Add(cryogenRod.Id, cryogenRod);
                this.modules.Add(cryogenRod.Id, cryogenRod);
                break;

            case "HeatProcessor":
                IAbsorbingModule heatProcessor = new HeatProcessor(this.currentId, additionalParameter);
                this.reactors[reactorId].AddAbsorbingModule(heatProcessor);
                this.identifiableObjects.Add(heatProcessor.Id, heatProcessor);
                this.modules.Add(heatProcessor.Id, heatProcessor);
                break;

            case "CooldownSystem":
                IAbsorbingModule coolDownSystem = new CooldownSystem(this.currentId, additionalParameter);
                this.reactors[reactorId].AddAbsorbingModule(coolDownSystem);
                this.identifiableObjects.Add(coolDownSystem.Id, coolDownSystem);
                this.modules.Add(coolDownSystem.Id, coolDownSystem);
                break;
            }


            string result = string.Format(Constants.ModuleCreateMessage, moduleType, this.currentId++, reactorId);

            return(result);
        }
Exemple #2
0
        // change owner param type to StatsSystemBehaviour since we REQUIRE it?
        // just init castCircle or also instantiate it here? think init fits more
        public virtual void Init(GameObject owner, StatsSystem statsSys, CooldownSystem cooldownSys
                                 , Guid id, Transform castCirclePlacement, CastPlaceholder castCircle, BaseSpellCastData data, SpellBase spellPrefab
                                 , params MonoBehaviour[] movementScripts)
        {
            // Debug.Log($"{owner} | NEXT: | {statsSys} | NEXT: | {cooldownSys} | NEXT: | {id} | NEXT: |" +
            //           $" {castCircle} | NEXT: | {data} | NEXT: | {spellPrefab} | NEXT: | {movementScripts.Length}");

            Owner   = owner;
            element = spellPrefab.SpellElement;

            this.id = id;
            this.movementScripts     = movementScripts.ToList();
            this.cooldownSys         = cooldownSys;
            this.statsSys            = statsSys;
            this.castCirclePlacement = castCirclePlacement;
            this.castCircle          = castCircle;
            this.spellPrefab         = spellPrefab;

            this.castCircle.onCastEnd += FinishSpellCast;
            castCircleAnimator         = castCircle.GetComponent <Animator>();

            Data = data;

            prevEnableStates = new bool[movementScripts.Length];

            InitTimer();
        }
Exemple #3
0
        public void Test1()
        {
            var moduleContainer       = new ModuleContainer(3);
            var absorbingModule       = new CooldownSystem(2, 0);
            var secondabsorbingModule = new CooldownSystem(5, 100);
            var energyModule          = new CryogenRod(3, 200);
            var secondEnergyModule    = new CryogenRod(4, 100);

            moduleContainer.AddAbsorbingModule(absorbingModule);
            moduleContainer.AddAbsorbingModule(secondabsorbingModule);
            moduleContainer.AddEnergyModule(energyModule);

            moduleContainer.AddEnergyModule(secondEnergyModule);

            var actualTotalHeatAbsorbingResult = moduleContainer.TotalHeatAbsorbing;
            var actualTotalEnergyOutput        = moduleContainer.TotalEnergyOutput;

            var expectedTotalHeatAbsorbingResult = 100;
            var expectedTotalEnergyOutput        = 300;


            var actualModulesByInputCount   = moduleContainer.ModulesByInput.Count;
            var expectedModulesByInputCount = 3;

            Assert.AreEqual(expectedTotalHeatAbsorbingResult, actualTotalHeatAbsorbingResult);
            Assert.AreEqual(expectedTotalEnergyOutput, actualTotalEnergyOutput);
            Assert.AreEqual(expectedModulesByInputCount, actualModulesByInputCount);

            //Assert.AreEqual(actualModulesByInputCount, expectedModulesByInputCount);
            //Assert.Throws<ArgumentException>(() => moduleContainer.AddAbsorbingModule(null));
        }
 private void Awake()
 {
     if (input == null)
     {
         input = GetComponent <XRInputManager>();
     }
     if (cooldownSystem == null)
     {
         cooldownSystem = FindObjectOfType <CooldownSystem>();
     }
 }
        public void TestHeatModule()
        {
            int moduleCapacity = 1;
            var cdSystem       = new CooldownSystem(1, 1000);

            ModuleContainer testContainer = new ModuleContainer(moduleCapacity);

            testContainer.AddAbsorbingModule(cdSystem);

            Assert.AreEqual(testContainer.ModulesByInput.Count, 1);
            Assert.AreEqual(testContainer.TotalEnergyOutput, 0);
            Assert.AreEqual(testContainer.TotalHeatAbsorbing, 1000);
        }
        public void TestAddAbsorbingModulesWithOverCapacity()
        {
            var             capacity        = 1;
            ModuleContainer moduleContainer = new ModuleContainer(capacity);

            var module1 = new HeatProcessor(1, 100);
            var modele2 = new CooldownSystem(2, 200);

            var actual   = moduleContainer.TotalHeatAbsorbing;
            var expected = 0;

            Assert.That(actual, Is.EqualTo(expected));
        }
Exemple #7
0
        public void TestingHeat()
        {
            var moduleContainer = new ModuleContainer(2);

            var cooldown = new CooldownSystem(13, 41);
            var heatProc = new HeatProcessor(3, 14);

            moduleContainer.AddEnergyModule(new CryogenRod(31, 41));
            moduleContainer.AddAbsorbingModule(heatProc);
            moduleContainer.AddAbsorbingModule(cooldown);

            var expectedAbsorbing = 55;

            Assert.That(expectedAbsorbing, Is.EqualTo(moduleContainer.TotalHeatAbsorbing));
        }
Exemple #8
0
        public void WhenModuleIsFullRemovesFirst()
        {
            var moduleContainer = new ModuleContainer(3);
            var energy          = new CryogenRod(3, 13);
            var heatProc        = new HeatProcessor(4, 14);
            var prces           = new HeatProcessor(7, 14);
            var cooldown        = new CooldownSystem(1, 2);

            moduleContainer.AddAbsorbingModule(heatProc);
            moduleContainer.AddEnergyModule(energy);
            moduleContainer.AddAbsorbingModule(prces);
            moduleContainer.AddAbsorbingModule(cooldown);


            Assert.That(3, Is.EqualTo(moduleContainer.ModulesByInput.Count));
        }
        //  Parameters – reactorId(int), type(string), additionalParameter(int).
        public string ModuleCommand(IList <string> arguments)
        {
            int    reactorId           = int.Parse(arguments[0]);
            string moduleType          = arguments[1];
            int    additionalParameter = int.Parse(arguments[2]);


            // Creates a Module of the given type with the next id and adds
            // it to the ModuleContainer of the Reactor with the given reactorId.
            // The type will either be “CryogenRod”, “HeatProcessor” or “CoolingSystem
            int currentId = this.currentId;

            // System.Console.WriteLine("CNT (BEFORE): " + this.modules.Count);
            switch (moduleType)
            {
            case "CryogenRod":
                IEnergyModule cryogenRod = new CryogenRod(this.currentId, additionalParameter);
                // this.currentId++;
                this.reactors[reactorId].AddEnergyModule(cryogenRod);
                this.identifiableObjects.Add(cryogenRod.Id, cryogenRod);
                this.modules.Add(cryogenRod.Id, cryogenRod);
                break;

            case "HeatProcessor":
                IAbsorbingModule heatProcessor = new HeatProcessor(this.currentId, additionalParameter);
                // this.currentId++;
                this.reactors[reactorId].AddAbsorbingModule(heatProcessor);
                this.identifiableObjects.Add(heatProcessor.Id, heatProcessor);
                this.modules.Add(heatProcessor.Id, heatProcessor);
                break;

            case "CooldownSystem":
                IAbsorbingModule cooldownSystem = new CooldownSystem(this.currentId, additionalParameter);
                // this.currentId++;
                this.reactors[reactorId].AddAbsorbingModule(cooldownSystem);
                this.identifiableObjects.Add(cooldownSystem.Id, cooldownSystem);
                this.modules.Add(cooldownSystem.Id, cooldownSystem);
                break;
            }

            //System.Console.WriteLine("CNT (AFTER): " + this.modules.Count);
            string result = string.Format(Constants.ModuleCreateMessage, moduleType, this.currentId++, reactorId);

            return(result);
        }
        public void TestProperties()
        {
            var             capacity        = 10;
            ModuleContainer moduleContainer = new ModuleContainer(capacity);

            var modele1 = new CryogenRod(1, 100);
            var module2 = new HeatProcessor(2, 200);
            var module3 = new CooldownSystem(3, 300);

            moduleContainer.AddEnergyModule(modele1);
            moduleContainer.AddAbsorbingModule(module2);
            moduleContainer.AddAbsorbingModule(module3);


            var actual   = moduleContainer.ModulesByInput.Count;
            var expected = 3;

            Assert.That(actual, Is.EqualTo(expected));
            Assert.That(moduleContainer.TotalEnergyOutput, Is.EqualTo(100));
            Assert.That(moduleContainer.TotalHeatAbsorbing, Is.EqualTo(500));
        }