コード例 #1
0
        public static void AddGameObjects(Universe universe, Player player)
        {
            EventHandler destroyObject = new EventHandler(delegate(object sender, EventArgs e)
            {
                if (sender is GameObject && universe.GameObjects.Contains(sender as GameObject))
                {
                    universe.GameObjects.Remove(sender as GameObject);
                }
            });

            EventHandler giveExperience = new EventHandler(delegate(object sender, EventArgs e)
            {
                if (sender is GameObject)
                {
                    player.AddExperience((sender as GameObject).ExperienceReward);
                }
            });

            universe.GameObjects.Add(new GameObject()
            {
                Name              = "Unit C132A",
                Description       = "Height 1.9m \nColor: #CCCCCC \nTexture: Smooth\nHypothesis: In Sync Mode \nAdding Analysis to Memory Store",
                CurrentLocation   = Locations.syncArea,
                ExperienceReward  = 15,
                DestroyOnAnalysis = true
            });

            universe.GameObjects.Add(new GameObject()
            {
                Name              = "Unit C135B",
                Description       = "Height 1.9m \nColor: #CCCCCC \nTexture: Smooth\nHypothesis: In Construction \nAdding Analysis to Memory Store",
                CurrentLocation   = Locations.starterFactory,
                ExperienceReward  = 15,
                DestroyOnAnalysis = true
            });



            GameObject compass = new GameObject()
            {
                Name              = "Spirit Matter Compass",
                Description       = "Size 10 cm \nColor: #A52A2A \nTexture: Smooth\nAnalysis: Points to the nearest source of spirit matter",
                CurrentLocation   = Locations.safeStarterArea,
                ExperienceReward  = 10,
                DestroyOnAnalysis = true
            };

            universe.GameObjects.Add(compass);

            GameObject mirror = new GameObject()
            {
                Name              = "Reflector Shards",
                Description       = "Size 5 cm \nColor: Reflective \nTexture: Very Sharp\nAnalysis: Reflects all energy that hits the surface",
                CurrentLocation   = Locations.observationAreaStart,
                ExperienceReward  = 10,
                DestroyOnAnalysis = true
            };

            mirror.OnAnalyze += new EventHandler(delegate(object sender, EventArgs e)
            {
                Ability manufactureMirror = Abilities.CreateObjectManufactureAbility(universe, player, mirror);
                manufactureMirror.OnProc += new EventHandler(delegate(object sender2, EventArgs e2)
                {
                    if (Npcs.enemyElf != null && player.CurrentLocation == Npcs.enemyElf.CurrentLocation)
                    {
                        Npcs.enemyElf.Level = 5;
                        Npcs.enemyElf.Damage(Npcs.enemyElf.Health - 10);
                    }
                });
                player.Abilities.Add(manufactureMirror);
            });
            universe.GameObjects.Add(mirror);

            GameObject dwarvenCannon = new GameObject()
            {
                Name        = "Explosive Dwarven Cannon",
                Description = "Length: .5m \nCondition: Rusty, made of low-quality metal \nEnergy Output: Very High \n" +
                              "Suitable for Approaching the Dwarven Village",
                CurrentLocation   = Locations.observationAreaShip,
                DestroyOnAnalysis = true
            };

            dwarvenCannon.OnAnalyze += new EventHandler(delegate(object sender, EventArgs e)
            {
                player.Abilities.Add(Abilities.CreateDamageAbility(universe, player, "Dwarven Cannon", 20));
                player.CurrentQuest = "Enter the Dwarven Village and Neutralize the Threats";
                universe.Map.AddConnection(Locations.observationAreaShip, Locations.observationAreaDwarfOutskirts);
            });
            universe.GameObjects.Add(dwarvenCannon);

            GameObject armorPlating = new GameObject()
            {
                Name              = "Spare Armor Plating",
                Description       = "Height 2.2m \nColor: #EEEEEE \nTexture: Shiny and Smooth, Very Hard\nEffect: Increases Armor",
                CurrentLocation   = Locations.starterFactory,
                DestroyOnAnalysis = true
            };

            armorPlating.OnAnalyze += new EventHandler(delegate(object sender, EventArgs e)
            {
                player.MaxHealth += 10;
                player.Damage(-10);
            });
            universe.GameObjects.Add(armorPlating);

            foreach (GameObject go in universe.GameObjects)
            {
                if (go.DestroyOnAnalysis)
                {
                    go.OnAnalyze += destroyObject;
                }

                if (go.ExperienceReward > 0)
                {
                    go.OnAnalyze += giveExperience;
                }
            }
        }
コード例 #2
0
        public static void AddNpcs(Universe universe, Player player)
        {
            EventHandler rewardExperience = new EventHandler(delegate(object sender, EventArgs e)
            {
                if (sender is Npc)
                {
                    player.AddExperience((sender as Npc).ExperienceReward);
                }
            });

            EventHandler fullHeal = new EventHandler(delegate(object sender, EventArgs e)
            {
                if (sender is Npc)
                {
                    Npc npc = sender as Npc;
                    npc.Damage(npc.Health - npc.Level);
                }
            });
            EventHandler removeNpc = new EventHandler(delegate(object sender, EventArgs e)
            {
                if (sender is Npc)
                {
                    universe.Npcs.Remove(sender as Npc);
                }
            });

            guideSentinel =
                new RegularNpc("Guide Sentinel", Character.RaceType.ExMachina, 100)
            {
                CurrentLocation  = Locations.starterFactory,
                ExperienceReward = 10,
                Messages         = new List <string>()
                {
                    $"Observation: Unit Alias [{player.Name}] has completed manufacturing\n" +
                    "Recommended Action: Travel through Front Line Sector to Main Sync Zone\n" +
                    "Recommended: Interact and observe with the environment at all times"
                }
            };
            guideSentinel.OnSpeak += new EventHandler(delegate(object sender, EventArgs e)
            {
                player.CurrentQuest = "Travel to the Sync Zone";
                universe.Map.AddConnection(Locations.starterFactory, Locations.safeStarterArea);
            });
            universe.Npcs.Add(guideSentinel);

            enemyDwarf =
                new CombatNpc($"Dwarf: ID [{Text.GetRandomHexCharacters(4)}]", Character.RaceType.Dwarf, 20)
            {
                CurrentLocation  = Locations.observationAreaDwarfOutskirts,
                ExperienceReward = 10,
                VictoryText      = "Analysis: Valuable combat data gained.\n" +
                                   "Recommended Action: Move to find and neutralize Dwarven leader"
            };
            enemyDwarf.OnLoss += new EventHandler(delegate(object sender, EventArgs e)
            {
                player.AddExperience(100);
            });
            universe.Npcs.Add(enemyDwarf);


            dwarfNonthreat =
                new RegularNpc($"Dwarf Child: ID [{Text.GetRandomHexCharacters(4)}]", Character.RaceType.Dwarf, 2)
            {
                CurrentLocation = Locations.dwarfAreaVillage,
                Messages        = new List <string>
                {
                    "Please don't hurt me",
                    "What are you?"
                }
            };
            universe.Npcs.Add(dwarfNonthreat);

            enemyDwarfBoss =
                new CombatNpc($"Dwarf Chieftan: ID [{Text.GetRandomHexCharacters(4)}]", Character.RaceType.Dwarf, 30)
            {
                CurrentLocation  = Locations.dwarfAreaVillage,
                ExperienceReward = 200,
                VictoryText      = "Analysis: Valuable combat data gained.\n" +
                                   "Observation: Dwarven threat in this sector has been fully neutralized"
            };
            universe.Npcs.Add(enemyDwarfBoss);

            enemyElf =
                new CombatNpc($"Elf: ID [{Text.GetRandomHexCharacters(4)}]", Character.RaceType.Elf, 40)
            {
                CurrentLocation  = Locations.observationAreaVillage,
                ExperienceReward = 10,
                VictoryText      = "Analysis: Valuable combat data gained.\n" +
                                   "Recommended Action: Attempt placing reflectors on the field to reflect magic."
            };
            enemyElf.OnLoss += new EventHandler(delegate(object sender, EventArgs e)
            {
                player.AddExperience(100);
            });
            universe.Npcs.Add(enemyElf);

            combatSentinel =
                new CombatNpc("Combat Sentinel", Character.RaceType.ExMachina, 5)
            {
                CurrentLocation  = Locations.safeStarterArea,
                ExperienceReward = 10,
                VictoryText      = "Analysis: Valuable combat data gained.\n" +
                                   "Recommended Action: Attempt battle again."
            };
            combatSentinel.OnVictory += new EventHandler(delegate(object sender, EventArgs e)
            {
                player.CombatCapability += 10;
            });
            combatSentinel.OnLoss += new EventHandler(delegate(object sender, EventArgs e)
            {
                player.AddExperience(50);
            });
            universe.Npcs.Add(combatSentinel);

            foreach (Npc npc in universe.Npcs)
            {
                if (npc is ISpeak)
                {
                    (npc as ISpeak).OnSpeak += rewardExperience;
                }

                if (npc is CombatNpc)
                {
                    (npc as CombatNpc).OnLoss    += removeNpc;
                    (npc as CombatNpc).OnVictory += fullHeal;
                }
            }
        }
コード例 #3
0
 public Controller()
 {
     universe = new Universe();
     view     = new ConsoleView();
     Initialize();
 }