Ejemplo n.º 1
0
Archivo: Scene.cs Proyecto: Ysovuka/RPG
        public void SetLocations()
        {
            Location lakeView = new Location(1000, "Lake View");

            //all of these data might be instantiated randomly and according to experience level of player
            lakeView.Monsters.Add(MonsterFactory.CreateMonster());
            lakeView.Monsters.Add(MonsterFactory.CreateMonster());


            Location tower = new Location(1001, "Tower");

            tower.Monsters.Add(MonsterFactory.CreateMonster());


            Location postOffice = new Location(1002, "Post Office");
            Location bridge     = new Location(1003, "Bridge");

            bridge.Monsters.Add(MonsterFactory.CreateMonster());

            //directions (surrounding places)
            bridge.SurroundingLocations.Add(0, postOffice);
            bridge.SurroundingLocations.Add(90, tower);
            tower.SurroundingLocations.Add(270, bridge);
            postOffice.SurroundingLocations.Add(180, bridge);
            postOffice.SurroundingLocations.Add(0, lakeView);
            lakeView.SurroundingLocations.Add(180, postOffice);


            StartingLocation = bridge;
            EndLocation      = lakeView;
        }
Ejemplo n.º 2
0
        public void Load()
        {
            // Save player level for later
            var playerLevel = AccountManager.CurrentUser.Level;

            List <PointSpot> points = WorldGen.LoadChunk(X, Y);

            for (int i = 0; i < points.Count; i++)
            {
                LatLng coord = points[i].ToLatLng();
                if (!MapHandler.Visited.ContainsKey(coord.GetHashCode()))
                {
                    double val   = points[i].Value;
                    IEnemy enemy = MonsterFactory.CreateMonster(val);

                    enemy.Level += (int)playerLevel;
                    if (enemy.Level < 1)
                    {
                        enemy.Level = 1;
                    }

                    var m = MapHandler.AddMarker(coord, enemy.Name, AssetLoader.GetEnemyBitmap(enemy).ToBitmapDescriptor());
                    m.Tag = new EnemyTag(enemy.GetType(), enemy.Level);
                    Markers.Add(m);
                }
            }
        }
        public void Test_BitingMonster()
        {
            Monster crocodile = MonsterFactory.CreateMonster(MonsterFactory.MonsterType.Crocodile);

            Assert.IsTrue(crocodile.CanBite);
            Assert.IsFalse(crocodile.CanKick);
            Assert.IsFalse(crocodile.CanPunch);
        }
        public void Test_BitingKickingMonster()
        {
            Monster horse = MonsterFactory.CreateMonster(MonsterFactory.MonsterType.Horse);

            Assert.IsTrue(horse.CanBite);
            Assert.IsTrue(horse.CanKick);
            Assert.IsFalse(horse.CanPunch);
        }
Ejemplo n.º 5
0
        public void Test_BitingKickingMonster()
        {
            Monster horse = MonsterFactory.CreateMonster(MonsterFactory.MonsterType.Horse);

            Assert.IsTrue(horse is BitingMonster);

            // This test will fail in, because we cannot inherit from multiple base classes.
            Assert.IsTrue(horse is KickingMonster);
        }
        public void Horse_IsBitingKickingMonster()
        {
            var horse = MonsterFactory.CreateMonster(MonsterType.Horse);

            Assert.IsTrue(horse is BitingMonster);

            // this will fail, becasue we cannot inherit from multiples base classes in C#
            Assert.IsTrue(horse is KickingMonster);
        }
Ejemplo n.º 7
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++;
        }
    }
        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
        }
Ejemplo n.º 9
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();
        }
    }
    private GameObject CreateRandomMonster(GameObject nullObject)
    {
        int        value   = Random.Range(0, 100);
        GameObject monster = nullObject;

        if (value > 80)
        {
            Destroy(nullObject.gameObject);
            monster = monsterFactory.CreateMonster(MonsterType.Monster1);
        }
        else if (value > 50)
        {
            Destroy(nullObject.gameObject);
            monster = Instantiate(coinObject);
        }

        return(monster);
    }
        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");
        }
Ejemplo n.º 12
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();
            }
        }
Ejemplo n.º 13
0
        public void Test_BitingMonster()
        {
            Monster crocodile = MonsterFactory.CreateMonster(MonsterFactory.MonsterType.Crocodile);

            Assert.IsTrue(crocodile is BitingMonster);
        }
Ejemplo n.º 14
0
 static void Main(string[] args)
 {
     Monster newMonster  = MonsterFactory.CreateMonster(MonsterType.Horse);
     Monster new1Monster = MonsterFactory.CreateMonster(MonsterType.Kangaroo);
     Monster new2Monster = MonsterFactory.CreateMonster(MonsterType.Orc);
 }
        public void Crocodile_IsBitingMonster()
        {
            var crocodile = MonsterFactory.CreateMonster(MonsterType.Crocodile);

            Assert.IsTrue(crocodile is BitingMonster);
        }