Esempio n. 1
0
        public MonsterWave(Dictionary<string, int> monsters, int releaseTime, Vector2 positionModifier)
        {
            this.monsters = monsters;
            ReleaseTime = releaseTime;
            PositionModifier = positionModifier;

            factory = new MonsterFactory("JamGame.GameObjects.Monsters");
        }
        static void Main(string[] args)
        {
            Console.WriteLine("Creating a new Monster -> Horse");
            var horse = MonsterFactory.CreateMonster(MonsterType.Horse);

            Console.WriteLine($"Horse kick damage: {horse.KickDamage}");
            Console.WriteLine($"Horse punch damage: {horse.PunchDamage}");  // <--- Exception

            Console.WriteLine("Creating a new Hero -> Guile");
            var guile = HeroFactory.CreateHero(HeroType.Guile);

            Console.WriteLine($"Guile kick damage: {guile.KickDamage}");
            Console.WriteLine($"Guile Tektektuguem damage: {guile.TektektuguemDamage}");  // <--- Exception
        }
Esempio n. 3
0
 private void OldHut_RightDoor(object sender, RoutedEventArgs e)
 {
     SetLocation(3);
     UpdateActions();
     if (FightRat == false)
     {
         Fight = true;
         _gameSession.CurrentMonster = MonsterFactory.GetMonsterByID(00);
         SetEncounter(2);
         UpdateEncounters();
         HideActions();
         FightRat = true;
     }
 }
Esempio n. 4
0
 // Start is called before the first frame update
 void Start()
 {
     blood         = 100;
     speed         = 2.0f;
     dead          = false;
     patroling     = true;
     patrolTime    = 5.0f;
     disappearTime = 0.0f;
     animator      = GetComponent <Animator>();
     animator.SetBool("run", false);
     animator.SetBool("dead", false);
     monsterFactory     = MonsterFactory.getInstance();
     Player.deathEvent += die;
 }
Esempio n. 5
0
    private void SpawnNextMonster()
    {
        if (monstersSpawned < waveService.CurrentWave.Monsters.Count && monsterSpawnCooldown.IsOver && waveSpawnCooldown.IsOver)
        {
            WaveData          currentWaveData = wavesData.Data[waveService.WavesSpawned - 1];
            MonsterType       monsterType     = currentWaveData.MonsterTypes[monstersSpawned];
            MonsterController controller      = MonsterFactory.CreateMonster(monsterType, waveService.CurrentWave.Monsters[monstersSpawned]);
            controller.UpdateView();
            controllers.Add(controller);

            monsterSpawnCooldown.Reset();
            monstersSpawned++;
        }
    }
Esempio n. 6
0
        void Awake()
        {
            NPC_Factory.InitialFactory(NPC_Factory.LoadFactory("NPC_Factory"));
            SkillFactory.InitialFactory(SkillFactory.LoadFactory("SkillFactory"));
            MonsterFactory.InitialFactory(MonsterFactory.LoadFactory("MonsterFactory"));
            ItemFactory.InitialFactory(ItemFactory.LoadFactory("ItemFactory"));
            StoreFactory.InitialFactory(StoreFactory.LoadFactory("StoreFactory"));
            World.Initial(World.LoadWorld("World"));
            StoryManager.InitialManager(Story.LoadStory("MainStory"));
            InputManager.InitialManager(new UnityInputManager());
            PlayerManager.InitialManager(new Player());

            PlayerManager.Instance.Player.Inventory.AddItem(ItemFactory.Instance.FindItem(6), 100);
        }
Esempio n. 7
0
    public void LoadResources()
    {
        GameObject temp1 = MonsterFactory.getInstance().getMonster();

        temp1.transform.position = new Vector3(3, 0, 0);
        GameObject temp2 = MonsterFactory.getInstance().getMonster();

        temp2.transform.position = new Vector3(-3, 0, 0);
        GameObject temp3 = MonsterFactory.getInstance().getMonster();

        temp3.transform.position = new Vector3(3, 0, 10);
        GameObject temp4 = MonsterFactory.getInstance().getMonster();

        temp4.transform.position = new Vector3(-3, 0, 10);
    }
Esempio n. 8
0
    public void GenerateMonster(MonsterFactory monsterFactory, int positionIndex = -1)
    {
        positionIndex
            = positionIndex != -1
            ? positionIndex
            : Random.Range(0, monsterSpawnPoint.Length);

        BaseMonster createdMonster;

        if (monsterFactory.CreateMonster(out createdMonster))
        {
            monsterSpawnPoint[positionIndex].SetMonsterSpeed(createdMonster);
            createdMonster.gameObject.transform.position = monsterSpawnPoint[positionIndex].gameObject.transform.position;
            createdMonster.ActiveMonster();
        }
    }
Esempio n. 9
0
 /***************
 * CONSTRUCTOR *
 ***************/
 public Library(
     RoomId id                     = RoomId.Library,
     string name                   = RoomDescriptions.LibraryName,
     string description            = RoomDescriptions.Library,
     string firstSearchDescription = RoomDescriptions.LibraryFirstSearch,
     bool hasBeenSearched          = false)
     : base(id, name, description, firstSearchDescription, hasBeenSearched)
 {
     AddItem(new Knife());
     AddItem(new Flashlight());
     if (Game.admin == true)
     {
         AddItem(new Excalibur());
     }
     monster = MonsterFactory.GenerateMonster(MonsterType.Gremlin);
 }
Esempio n. 10
0
        public Landblock(LandblockId id)
        {
            this.id = id;

            // initialize adjacency array
            this.adjacencies.Add(Adjacency.North, null);
            this.adjacencies.Add(Adjacency.NorthEast, null);
            this.adjacencies.Add(Adjacency.East, null);
            this.adjacencies.Add(Adjacency.SouthEast, null);
            this.adjacencies.Add(Adjacency.South, null);
            this.adjacencies.Add(Adjacency.SouthWest, null);
            this.adjacencies.Add(Adjacency.West, null);
            this.adjacencies.Add(Adjacency.NorthWest, null);

            // TODO: Load cell.dat contents
            //   1. landblock cell structure
            //   2. terrain data
            // TODO: Load portal.dat contents (as/if needed)
            // TODO: Load spawn data

            // TODO: load objects from world database such as lifestones, doors, player corpses, NPCs, Vendors
            var objects        = DatabaseManager.World.GetObjectsByLandblock(this.id.Landblock);
            var factoryObjects = GenericObjectFactory.CreateWorldObjects(objects);

            factoryObjects.ForEach(fo => worldObjects.Add(fo.Guid, fo));

            // Load static creature spawns from DB
            var creatures = DatabaseManager.World.GetCreaturesByLandblock(this.id.Landblock);

            foreach (var c in creatures)
            {
                Creature cwo = new Creature(c);
                worldObjects.Add(cwo.Guid, cwo);
            }

            // Load generator creature spawns from DB
            var creatureGenerators = DatabaseManager.World.GetCreatureGeneratorsByLandblock(this.id.Landblock);

            foreach (var cg in creatureGenerators)
            {
                List <Creature> creatureList = MonsterFactory.SpawnCreaturesFromGenerator(cg);
                foreach (var c in creatureList)
                {
                    worldObjects.Add(c.Guid, c);
                }
            }
        }
Esempio n. 11
0
        public void OnMonsterSpawn(MonsterPacket packet)
        {
            MonsterFactory.BuildAndInstantiate(new MonsterFactoryOpts()
            {
                Position = packet.Position,
                Packet   = packet
            });

            if (packet.SpawnAnimation)
            {
                AnimationFactory.BuildAndInstantiate(new AnimationOpts()
                {
                    AnimationImageName = DefaultAssets.ANM_SMOKE,
                    MapPosition        = packet.Position
                });
            }
        }
Esempio n. 12
0
    public void SpawnMobsInRooms()
    {
        foreach (RoomInstnace room in LevelMap.Rooms)
        {
            // monster spawning

            // pick a monster type for the room
            // TODO, walk an enum of monster types and pick them, or let the factory decide on a weighted chance
            bool bandits  = UnityEngine.Random.Range(1, 4) == 1;
            bool skelleys = false;
            bool orks     = false;

            if (!bandits)
            {
                skelleys = UnityEngine.Random.Range(1, 4) == 1;

                if (!skelleys)
                {
                    orks = true;
                }
            }

            for (int i = 0; i < room.gameObject.transform.childCount; i++)
            {
                GameObject child = room.gameObject.transform.GetChild(i).gameObject;
                if (child.tag == "MobSpawn")
                {
                    if (UnityEngine.Random.value <= 0.8f)
                    {
                        if (orks)
                        {
                            MonsterFactory.NewOrc(child.transform.position);
                        }
                        else if (skelleys)
                        {
                            MonsterFactory.NewBandit(child.transform.position);
                        }
                        else if (bandits)
                        {
                            MonsterFactory.NewSkellymans(child.transform.position);
                        }
                    }
                }
            }
        }
    }
Esempio n. 13
0
 public Game(MonsterFactory monsterFactory,
             HealerFactory healerFactory,
             WeaponDealerFactory weaponDealerFactory,
             ClothesDealerFactory clothesDealerFactory,
             BotFactory botFactory,
             Gamer gamer)
 {
     _gamer   = gamer;
     _actions = new Dictionary <ConsoleKey, Func <Personage> >
     {
         { ConsoleKey.W, monsterFactory.GetPersonage },
         { ConsoleKey.S, healerFactory.GetPersonage },
         { ConsoleKey.A, weaponDealerFactory.GetPersonage },
         { ConsoleKey.D, clothesDealerFactory.GetPersonage },
         { ConsoleKey.E, botFactory.GetPersonage }
     };
 }
Esempio n. 14
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            this.spriteBatch = new SpriteBatch(this.GraphicsDevice);
            this.background  = new BackgroundObject(this.Content, "bg1");
            this.startMenu.LoadContent(this.Content);
            this.font = this.Content.Load <SpriteFont>("MyFont");

            IDrawableGameObject barbarian   = CharacterFactory.Create("Barbarian", this.Content, 100, 400);
            IDrawableGameObject goblin      = MonsterFactory.Create("Goblin", this.Content, 500, 400);
            IDrawableGameObject blackDragon = MonsterFactory.Create("BlackDragon", this.Content, 1200, 450);

            this.player = (ICharacter)barbarian;

            this.gameObjects.Add(barbarian);
            this.gameObjects.Add(goblin);
            this.gameObjects.Add(blackDragon);
        }
Esempio n. 15
0
    public void LoadResources()
    {
        MonsterFactory mFactory = MonsterFactory.Instance;

        for (int i = 0; i < 10; i++)
        {
            GameObject mon = mFactory.GetMonster();
            mon.transform.position = new Vector3(Random.Range(-20, 20), 0, Random.Range(-20, 20));
            mons.Add(mon);
        }

        TombFactory tFactory = TombFactory.Instance;

        for (int i = 0; i < 5; i++)
        {
            GameObject tom = tFactory.GetTomb();
            tom.transform.position = new Vector3(Random.Range(-20, 20), 0, Random.Range(-20, 20));
        }
    }
        public void LoadPrototypeAndPlaceMonster()
        {
            string monsterJson = "{\"SpriteId\": \"ASSASSIN\", \"Description\": \"Assassin\", \"Health\": 5, \"BaseAtk\": 17, \"BaseDef\": 6, \"BaseDmg\": 15 }";

            MonsterFactory.AddPrototype("TEST1",
                                        JsonConvert.DeserializeObject <JObject>(monsterJson));
            var testMonster = MonsterFactory.CreateMonster(null, OpenDungeon, "TEST1",
                                                           new XY(3, 3));

            // Test in dungeon
            Assert.Contains(testMonster, OpenDungeon.Actors, "Monster not added");

            // Test valid results
            Assert.AreEqual("ASSASSIN", testMonster.SpriteId, "SpriteID not set correctly");
            Assert.AreEqual(5, testMonster.MaxHealth, "Health not set correctly");
            Assert.AreEqual(17, testMonster.BaseAtk, "BaseAtk not set correctly");
            Assert.AreEqual(6, testMonster.BaseDef, "BaseDef not set correctly");
            Assert.AreEqual(15, testMonster.BaseDmg, "BaseDmg not set correctly");
        }
Esempio n. 17
0
        public static void CreateStaticCreature(Session session, params string[] parameters)
        {
            Creature newC = null;

            if (!(parameters?.Length > 0))
            {
                ChatPacket.SendServerMessage(session, "Usage: @createcreature [static] weenieClassId",
                                             ChatMessageType.Broadcast);
                return;
            }
            if (parameters?[0] == "static")
            {
                if (parameters?.Length > 1)
                {
                    uint weenie = Convert.ToUInt32(parameters[1]);
                    newC = MonsterFactory.SpawnCreature(weenie, true, session.Player.Location.InFrontOf(2.0f));
                }
                else
                {
                    ChatPacket.SendServerMessage(session, "Specify a valid weenieClassId after the static option.",
                                                 ChatMessageType.Broadcast);
                    return;
                }
            }
            else
            {
                uint weenie = Convert.ToUInt32(parameters[0]);
                newC = MonsterFactory.SpawnCreature(weenie, false, session.Player.Location.InFrontOf(2.0f));
            }

            if (newC != null)
            {
                ChatPacket.SendServerMessage(session, $"Now spawning {newC.Name}.",
                                             ChatMessageType.Broadcast);
                LandblockManager.AddObject(newC);
            }
            else
            {
                ChatPacket.SendServerMessage(session, "Couldn't find that creature in the database or save it's location.",
                                             ChatMessageType.Broadcast);
            }
        }
Esempio n. 18
0
        public void OnMonsterSpawn(MonsterSpawnPacket packet)
        {
            MonsterFactory.BuildAndInstantiate(new MonsterFactoryOpts()
            {
                MonsterName = packet.MonsterName,
                MonsterUid  = packet.MonsterUid,
                Position    = packet.Position,
                SpriteIndex = packet.SpriteIndex,
                MoveSpeed   = packet.MoveSpeed
            });

            if (packet.SpawnAnimation)
            {
                AnimationFactory.BuildAndInstantiate(new AnimationOpts()
                {
                    AnimationImageName = DefaultAssets.ANM_SMOKE,
                    MapPosition        = packet.Position
                });
            }
        }
        public static void Valid()
        {
            var path = Path.Combine(
                TestContext.CurrentContext.TestDirectory, @"data\monsters.json");

            // Following is copied almost verbatim from Game.cs
            // Load the data from Monsters.Json into the Monster Factory
            using (var monsterFileReader = new System.IO.StreamReader(path))
            {
                var monsterFileText = monsterFileReader.ReadToEnd();
                var deserializedMonsterPrototypes =
                    JsonConvert.DeserializeObject <Dictionary <String, JObject> >(monsterFileText);
                foreach (var prototype in deserializedMonsterPrototypes)
                {
                    MonsterFactory.AddPrototype(prototype.Key, prototype.Value);
                }
            }

            // If we're here - it's valid!
        }
Esempio n. 20
0
        public virtual void Enter()
        {
            var      monsterFactory = MonsterFactory.Instance();
            ICommand action         = null;

            while (true)
            {
                display();
                var choice = UserInterface.GetInput("Choose an action: ");
                action = Commands.FirstOrDefault(c => c.Keys.ToLower() == choice.ToLower());
                if (action == null)
                {
                    Feedback = "Invalid Choice!";
                }
                else
                {
                    action.Action();
                }
            }
        }
Esempio n. 21
0
        public Monster GetMonster()
        {
            if (!MonstersHere.Any())
            {
                return(null);
            }
            int totalChance  = MonstersHere.Sum(x => x.ChanceOfEncounter);
            int randomNumber = RandomNumberGenerator.NumberBetween(1, totalChance);

            int runningTotal = 0;

            foreach (MonsterEncounter monsterEncounter in MonstersHere)
            {
                runningTotal += monsterEncounter.ChanceOfEncounter;
                if (randomNumber <= runningTotal)
                {
                    MonsterFactory.GetMonster(monsterEncounter.MonsterID);
                }
            }
            return(MonsterFactory.GetMonster(MonstersHere.Last().MonsterID));
            //if there was a problem, get the monster from the last of list
        }
Esempio n. 22
0
        public async Task AddMonsters(string id)
        {
            using (var dbContext = ApplicationDbContext.Create())
            {
                var map = await Task.Run(() => dbContext.Locations.Where(l => l.Character.UserId == id).ToList());

                foreach (var location in map)
                {
                    if (location is StartingLocation || location is Town)
                    {
                        continue;
                    }
                    else if (location is Lair)
                    {
                        var monster = new TheGreatDragonKraltock(location);
                        await Task.Run(() => dbContext.Monsters.Add(monster));

                        location.Monster = monster;
                        continue;
                    }
                    else
                    {
                        var monster = MonsterFactory.CreateMonster(location);
                        if (monster != null)
                        {
                            var item = ItemFactory.CreateItem();
                            if (item != null)
                            {
                                monster.Loot = item;
                            }
                            await Task.Run(() => dbContext.Monsters.Add(monster));

                            location.Monster = monster;
                        }
                    }
                }
                await dbContext.SaveChangesAsync();
            }
        }
Esempio n. 23
0
        void Awake()
        {
            GameActive  = false;
            Ingredients = new List <IngredientController>(FindObjectsOfType <IngredientController>());

            MonsterFactory       monsterFactory   = FindObjectOfType <MonsterFactory>();
            GameNarrativeManager narrativeManager = FindObjectOfType <GameNarrativeManager>();

            uint numPlates;
            List <IngredientType> ingredientTypes;

            try
            {
                Guid monsterID = narrativeManager.CurrentStage.MonsterID;
                MonsterData = monsterFactory.LoadMonster(monsterID);

                numPlates       = (uint)MonsterData.DesiredIngredients.Count;
                ingredientTypes = MonsterData.DesiredIngredients;
            }
            catch (Exception)
            {
                Debug.LogWarning("Could not load persistent objects -- Defaulting to shake");
                numPlates = 3;

                ingredientTypes = new List <IngredientType>
                {
                    IngredientType.AlgaeSlime, IngredientType.IceCream, IngredientType.AquariumGravel
                };
            }

            Plates = SetPlates(numPlates, Space);

            Ingredients.ForEach((ingredient) =>
            {
                IngredientType type = ingredient.Type;
                ingredient.InRecipe = ingredientTypes.Contains(type);
                ingredient.Plates   = Plates;
            });
        }
Esempio n. 24
0
 private static void CreateMonsters(Scene scene)
 {
     try
     {
         Log.Debug("CreateMonsters");
         var comp     = scene.GetComponent <MonsterComponent>();
         var monster1 = MonsterFactory.Create(scene);
         monster1.Position = new UnityEngine.Vector3(0, 0, 0);
         monster1.GetComponent <MoveComponent>().Speed = 1f;
         comp.Add(monster1);
         var monster2 = MonsterFactory.Create(scene);
         monster2.GetComponent <MoveComponent>().Speed = 1f;
         monster2.Position = new UnityEngine.Vector3(4, 0, 0);
         comp.Add(monster2);
         //monster1.GetComponent<MoveComponent>().MoveTo(monster2.Position).Coroutine();
         monster2.GetComponent <MoveComponent>().MoveTo(new UnityEngine.Vector3(-2, 0, 0)).Coroutine();
     }
     catch (System.Exception e)
     {
         Log.Error(e);
     }
 }
Esempio n. 25
0
        static void Main(string[] args)
        {
            var playerFactory  = new PlayerFactory();
            var monsterFactory = new MonsterFactory();

            var knight = playerFactory.Create(PlayerType.Knight);
            var wizard = playerFactory.Create(PlayerType.Wizard);

            Console.WriteLine("{0}:", knight.GetType().Name);
            Console.WriteLine("{0} = {1}", nameof(knight.ExperiencePoints), knight.ExperiencePoints);
            Console.WriteLine("{0} = {1}", nameof(knight.HitPoints), knight.HitPoints);
            Console.WriteLine("{0} = {1}", nameof(knight.Gold), knight.Gold);
            Console.WriteLine();

            Console.WriteLine("{0}:", wizard.GetType().Name);
            Console.WriteLine("{0} = {1}", nameof(wizard.ExperiencePoints), wizard.ExperiencePoints);
            Console.WriteLine("{0} = {1}", nameof(wizard.HitPoints), wizard.HitPoints);
            Console.WriteLine("{0} = {1}", nameof(wizard.Gold), wizard.Gold);
            Console.WriteLine();

            var aerialMonster      = monsterFactory.Create(MonsterType.Aerial);
            var terrestrialMonster = monsterFactory.Create(MonsterType.Terrestrial);
            var aquaticMonster     = monsterFactory.Create(MonsterType.Aquatic);

            Console.WriteLine("{0}:", aerialMonster.GetType().Name);
            Console.WriteLine("{0} = {1}", nameof(aerialMonster.HitPoints), aerialMonster.HitPoints);
            Console.WriteLine();

            Console.WriteLine("{0}:", terrestrialMonster.GetType().Name);
            Console.WriteLine("{0} = {1}", nameof(terrestrialMonster.HitPoints), terrestrialMonster.HitPoints);
            Console.WriteLine();

            Console.WriteLine("{0}:", aquaticMonster.GetType().Name);
            Console.WriteLine("{0} = {1}", nameof(aquaticMonster.HitPoints), aquaticMonster.HitPoints);
            Console.WriteLine();

            Console.ReadKey();
        }
Esempio n. 26
0
        public Monster GetMonster()
        {
            if (!MonstersHere.Any())
            {
                return(null);
            }

            int chances      = MonstersHere.Sum(m => m.ChanceOfEncounter);
            int randomNumber = RandomNumberGenerator.NumberBetween(1, chances);
            int total        = 0;

            foreach (MonsterEncounter monsterEncounter in MonstersHere)
            {
                total += monsterEncounter.ChanceOfEncounter;

                if (randomNumber <= total)
                {
                    return(MonsterFactory.GetMonster(monsterEncounter.MonsterID));
                }
            }

            return(MonsterFactory.GetMonster(MonstersHere.Last().MonsterID));
        }
Esempio n. 27
0
        public static void CreateStaticCreature(Session session, params string[] parameters)
        {
            if (!(parameters?.Length > 0))
            {
                ChatPacket.SendServerMessage(session, "Usage: @createstaticcreature weenieClassId",
                                             ChatMessageType.Broadcast);
                return;
            }
            uint     weenie = Convert.ToUInt32(parameters[0]);
            Creature newC   = MonsterFactory.SpawnStaticCreature(weenie, session.Player.Location.InFrontOf(2.0f));

            if (newC != null)
            {
                ChatPacket.SendServerMessage(session, $"Now spawning {newC.Name}",
                                             ChatMessageType.Broadcast);
                LandblockManager.AddObject(newC);
            }
            else
            {
                ChatPacket.SendServerMessage(session, "Couldn't find that creature in the database or save it's location.",
                                             ChatMessageType.Broadcast);
            }
        }
Esempio n. 28
0
 public UpgradeSystem(IGameContext context, MonsterFactory monsterFactory, Grid grid) : base(context)
 {
     _context = context;
     _grid    = grid;
     upgrade  = new Dictionary <CreatureType, Action <Vector3Int> >()
     {
         // white
         { CreatureType.Statue, monsterFactory.CreateHuman },
         { CreatureType.Human, (pos) =>
           {
               if (UnityEngine.Random.Range(0, 2) < 0.5)
               {
                   monsterFactory.CreateWarrior(pos);
               }
               else
               {
                   monsterFactory.CreateWorker(pos);
               }
           } },
         { CreatureType.Worker, monsterFactory.CreatePrist },
         { CreatureType.Warrior, monsterFactory.CreateHealer },
         // black
         { CreatureType.BlackStatue, monsterFactory.CreateSkeleton },
         { CreatureType.Skeleton, (pos) =>
           {
               if (UnityEngine.Random.Range(0, 2) < 0.5)
               {
                   monsterFactory.CreateBlackWorker(pos);
               }
               else
               {
                   monsterFactory.CreateZombie(pos);
               }
           } },
         { CreatureType.BlackWorker, monsterFactory.CreateLich },
     };
 }
Esempio n. 29
0
        /// Over time, new monsters will appear in unexplored areas of the dungeon.
        /// This is to encourage players to not waste time: the more they linger, the
        /// more dangerous the remaining areas become.
        public void TrySpawnMonster()
        {
            if (!Rng.Instance.OneIn(Option.SpawnMonsterChance))
            {
                return;
            }

            // Try to place a new monster in unexplored areas.
            VectorBase pos = Rng.Instance.vectorInRect(CurrentStage.Bounds());

            var tile = CurrentStage[pos];

            if (tile.Visible || tile.IsExplored || !tile.IsPassable)
            {
                return;
            }
            if (CurrentStage.ActorAt(pos) != null)
            {
                return;
            }
            var breedForMonster = MonsterFactory.GenerateBreedOfMonster(CurrentStage.StageNumber);

            CurrentStage.SpawnMonster(this, breedForMonster, pos);
        }
Esempio n. 30
0
        // Parsii ja luo jokaisen waven.
        private List<MonsterWave> ParseWaves(XElement waveElements)
        {
            List<MonsterWave> waves = new List<MonsterWave>();
            MonsterFactory factory = new MonsterFactory("JamGame.GameObjects.Monsters");

            foreach (XElement waveElement in waveElements.Descendants("Wave"))
            {
                // Lukee waven releasetimen.
                int releaseTime = int.Parse(waveElement.Attribute("ReleaseTime").Value);

                // Hakee kaikki monsterit wavesta ja projektaa ne anonyymeiksi olioiksi.
                Dictionary<string, int> monsterDatasets = (from monsterElements in waveElement.Descendants("Monsters")
                                                           from monsterElement in monsterElements.Descendants()
                                                           select new KeyValuePair<string, int>(monsterElement.Attribute("Type").Value, int.Parse(monsterElement.Attribute("Count").Value)))
                                                           .ToDictionary(v => v.Key, v => v.Value);

                // Lukee position modifierin wavesta.
                Vector2 positionModifier = new Vector2(ReadAttribute(waveElement, "XModifier"), ReadAttribute(waveElement, "YModifier"));

                waves.Add(new MonsterWave(monsterDatasets, releaseTime, positionModifier));
            }

            return waves;
        }
Esempio n. 31
0
        public Scene(string title, string description, int difficulty, MapPosition position, params List <ICommand>[] commands)
        {
            items = new List <IComposite>();

            Title       = title;
            Description = description;
            Difficulty  = difficulty;
            MapPosition = position;
            Commands    = new List <ICommand>();

            foreach (var collection in commands)
            {
                Commands.AddRange(collection);
            }

            setCommandEvents();

            var monsters = MonsterFactory.Instance().CreateMonsters(this);

            foreach (var monster in monsters)
            {
                AddItem("Monsters", monster);
            }
        }
Esempio n. 32
0
        public Monster GetEncounter()
        {
            if (!Encounters.Any())
            {
                return(null);
            }

            var totalChance = Encounters.Sum(x => x.Percentage);
            var result      = Rng.Between(1, totalChance);

            var total = 0;

            foreach (var encounter in Encounters)
            {
                total += encounter.Percentage;
                if (result <= total)
                {
                    return(MonsterFactory.Get(encounter.Id));
                }
            }
            ;

            return(null);
        }