Exemplo n.º 1
0
        public void TryToEat_VictimIsNull_ThrowsException()
        {
            var predator = new Ogre(200, 100);
            var eater    = new Eater(predator);

            Assert.Throws <ArgumentNullException>(() => eater.TryToEat(null));
        }
Exemplo n.º 2
0
Arquivo: Map.cs Projeto: pp33gt/Dojon
        private void Init(int width, int height)
        {
            Width  = width;
            Height = height;
            CreateMap();

            var heroPos = new Position(1, 1);

            Hero = new Hero(50, 1, System.ConsoleColor.Cyan);
            SetCreaturePosition(Hero, null, new Position(1, 1));

            var ogre = new Ogre("o", System.ConsoleColor.Red, 10, 2);

            AddCreature(ogre, new Position(5, 5));

            var dragon = new Dragon("D", 100, 4, System.ConsoleColor.Red);

            AddCreature(dragon, new Position(7, 19));

            SetItemPosition(new Knife(5), 2, 5);
            SetItemPosition(Item.Sock(), 2, 5);

            SetItemPosition(new DoubleAxe(20), 5, 5);

            SetItemPosition(Item.PotionOfHealing(), 6, 6);
        }
Exemplo n.º 3
0
        // Returns an enemy based on the current probability
        public Enemy GetEnemy()
        {
            Random r         = new Random();
            int    randomNum = r.Next(101);
            Enemy  enemy;

            if (randomNum <= curSlimeProb)
            {
                enemy = new Slime();
            }
            else if (randomNum <= curSlimeProb + curGoblinProb)
            {
                enemy = new Goblin();
            }
            else if (randomNum <= curSlimeProb + curGoblinProb + curOgreProb)
            {
                enemy = new Ogre();
            }
            else
            {
                enemy = new Dragon();
            }

            curSlimeProb  = Math.Max(0, curSlimeProb - 5);
            curGoblinProb = Math.Max(0, curGoblinProb - 5);
            curOgreProb   = Math.Max(0, curOgreProb - 5);

            return(enemy);
        }
Exemplo n.º 4
0
    private void SpawnHerde()
    {
        sheep = new Sheep[sheepCount];

        //gizmo
        gizmoBool = true;

        for (int i = 0; i < sheep.Length; i++)
        {
            Vector3 sheepPos = transform.position + new Vector3(Random.Range(-10f, 10f), 1f, Random.Range(-10f, 10f));
            sheepPos.y = 1;
            sheep[i]   = Instantiate(sheepPrefab, sheepPos, Quaternion.identity);
        }

        Vector3 position = Random.insideUnitSphere;

        position.y = 1;
        ogre       = Instantiate(ogrePrefab, position, Quaternion.identity);

        CameraMovement camera = Instantiate(cameraPrefab, Vector3.zero, Quaternion.identity);

        camera.target = ogre.transform;

        position   = Random.insideUnitSphere;
        position.y = 1;
        wolf       = Instantiate(wolfPrefab, position * 50.0f, Quaternion.identity);

        ogre.Init(this);
        wolf.Init(this);

        for (int i = 0; i < sheep.Length; i++)
        {
            sheep[i].Init(this);
        }
    }
Exemplo n.º 5
0
        public virtual int Defend(Ogre ogre)
        {
            int damage = 0;

            damage += strength;
            Console.WriteLine($"{nameof(Warrior)} {name} attacks Ogre {ogre.Name}, Damage:-{strength}\n");
            return(damage);
        }
Exemplo n.º 6
0
        public override int Defend(Ogre ogre)
        {
            arrows -= 1;
            int damage = 0;

            damage += strength;
            Console.WriteLine($"{nameof(Archer)} {name} shoots 1 arrow to Ogre {ogre.Name}, Damage:-{damage}\n");
            return(damage);
        }
Exemplo n.º 7
0
 public virtual void Attack(Ogre enemy)
 {
     if (CanCastSpell())
     {
         Console.WriteLine($"Mage {name} attacked an ogre {enemy.Name} and dealt {spellPower}dmg");
         enemy.GetDmg(spellPower);
         mana -= spellPower;
     }
 }
Exemplo n.º 8
0
        public GroundSlamAbility(Ogre player, Vector2 position, float speed, double direction) : base(position, speed, direction, 10)
        {
            this.player = player;

            Type             = AbilityOutline.AbilityType.AbilityOne;
            currentAnimation = new SpriteAnimation(AssetManager.groundSmashCrackle, new Vector2(0, 0), new Vector2(4, 0), new Vector2(71, 71), new Vector2(4, 0), 500);

            this.position = player.Position - new Vector2(71, 71);
        }
Exemplo n.º 9
0
        public void TryToEat_Ogre_Fails()
        {
            var goblin = new Goblin(200, 100);
            var ogre   = new Ogre(200, 100);

            var success = goblin.TryToEat(ogre);

            Assert.IsFalse(success);
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            Creature creature1 = new Goblin(1);
            Creature creature2 = new Ogre(1);
            Creature creature3 = new Hydra(1);

            creature1.LevelUp();
            creature2.LevelUp();
            creature3.LevelUp();
        }
Exemplo n.º 11
0
        public void TryToEat_WeakPredatorAndStrongVictimHaveNoParties_Fails()
        {
            var predator = new Ogre(200, 100);
            var victim   = new Goblin(2000, 100);

            var  eater   = new Eater(predator);
            bool success = eater.TryToEat(victim);

            Assert.IsFalse(success);
        }
Exemplo n.º 12
0
        public void TryToEat_StrongPredatorAndWeakVictimHaveNoParties_Suceeds()
        {
            var predator = new Ogre(200, 100);
            var victim   = new Ogre(200, 100);

            var  eater   = new Eater(predator);
            bool success = eater.TryToEat(victim);

            Assert.IsTrue(success);
        }
Exemplo n.º 13
0
        public void OgreTriesToEatGoblinWithParty_Fails()
        {
            var ogre            = new Ogre(150, 50);
            var weakGoblins     = new[] { new Goblin(75, 30), new Goblin(75, 30), new Goblin(75, 30) };
            var weakGoblinParty = new Party(weakGoblins);

            var success = ogre.TryToEat(weakGoblins.First());

            Assert.IsFalse(success);
        }
Exemplo n.º 14
0
    // protected Animator anim;

    protected override void Start()
    {
        if (enemyStatistics != null)
        {
            GetComponent <CircleCollider2D>().radius = enemyStatistics.chaseDistance.Value;
        }
        attacking = false;
        base.Start();
        myRenderer = gameObject.transform.parent.GetComponent <SpriteRenderer>();
        ogre       = gameObject.transform.parent.GetComponent <Ogre>();
        anim       = gameObject.transform.parent.GetComponent <Animator>();
    }
Exemplo n.º 15
0
 public override int Attack(Ogre attacker)
 {
     if (rng.NextDouble() < killChance)
     {
         Console.WriteLine($"FireMage {name} performs an insta kill on an Ogre {attacker.Name}");
         return(attacker.HP + attacker.Armor);
     }
     else
     {
         Console.WriteLine($"FireMage {name} attacks an Ogre {attacker.Name} dealing {spellPower}");
         return(spellPower);
     }
 }
Exemplo n.º 16
0
 public void Attack(Ogre enemy)
 {
     if (hasRat)
     {
         Console.WriteLine($"RatCatcher {name} threw a rat on ogre {enemy.Name}!");
         enemy.GetDmg(enemy.HP);
         hasRat = false;
     }
     else
     {
         Console.WriteLine($"RatCatcher {name} met an ogre {enemy.Name}, but doesn't have a rat");
     }
 }
Exemplo n.º 17
0
 public override void Attack(Ogre enemy)
 {
     if (arrows > 0)
     {
         Console.WriteLine($"Archer {name} attacked an ogre {enemy.Name} and dealt {Math.Max(1, strength - enemy.Armor)}dmg!");
         enemy.GetDmg(strength);
         arrows -= 2;
     }
     else
     {
         Console.WriteLine($"Archer {name} has no arrows left!");
     }
 }
Exemplo n.º 18
0
 public virtual int Attack(Ogre attacker)
 {
     if (CanCastSpell())
     {
         Console.WriteLine($"Mage {name} attacks an Ogre {attacker.Name} dealing {spellPower}");
         return(spellPower);
     }
     else
     {
         //There is a notfication in CanCastSpell already so I guess these are redundant
         // Console.WriteLine($"Mage {name} has too little mana to attack an Ogre {attacker.Name}");
         return(0);
     }
 }
Exemplo n.º 19
0
 int IDefender.Attack(Ogre attacker)
 {
     if (hasRat)
     {
         Console.WriteLine($"RatCatcher {name} scares an Ogre {attacker.Name} away with a Rat");
         hasRat = false;
         return(attacker.HP + attacker.Armor);
     }
     else
     {
         Console.WriteLine($"RatCatcher {name} stumbles upon an Ogre {attacker.Name} but there is no rat to throw");
         return(0);
     }
 }
Exemplo n.º 20
0
 public override int Attack(Ogre attacker)
 {
     if (arrows > 0)
     {
         Console.WriteLine($"Archer {name} attacks an Ogre {attacker.Name} dealing {strength} with an arrow");
         arrows--;
         return(strength);
     }
     else
     {
         Console.WriteLine($"Archer {name} is out of arrows");
         return(0);
     }
 }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            var sorcerer = new Sorcerer(new ElementsImmunityPoisonVulnerability());
            var knight   = new Knight(new DefoultHitBehavior());
            var ogre     = new Ogre(new DefoultHitBehavior());

            sorcerer.EquipWeapon(new Firebolt());
            knight.EquipWeapon(new Sword());
            ogre.EquipWeapon(new Club());


            Fight(sorcerer, ogre);
            Console.WriteLine();

            Console.ReadKey();
        }
Exemplo n.º 22
0
 public Level(int[,] map, int size, Texture2D background, Ghost ghost, Ogre ogre, Boss boss, Item potion, Introduction introduction, ContentManager Content)
 {
     this.background   = background;
     this.ogre         = ogre;
     this.ghost        = ghost;
     this.boss         = boss;
     this.potion       = potion;
     this.introduction = introduction;
     text          = Content.Load <SpriteFont>("text");
     width         = map.GetLength(1) * size;
     height        = map.GetLength(0) * size;
     ogreSpawner   = new Spawner <Ogre>();
     ghostSpawner  = new Spawner <Ghost>();
     potionSpawner = new Spawner <Item>();
     currentStage  = Stage.Introduction;
 }
Exemplo n.º 23
0
 public override void Attack(Ogre enemy)
 {
     if (rng.NextDouble() < killChance)
     {
         Console.WriteLine($"FireMage {name} instantly killed an ogre {enemy.Name}");
         enemy.GetDmg(enemy.HP + enemy.Armor);
     }
     else
     {
         if (CanCastSpell())
         {
             Console.WriteLine($"FireMage {name} attacked an ogre {enemy.Name} and dealt {spellPower}dmg");
             enemy.GetDmg(spellPower);
             mana -= spellPower;
         }
     }
 }
Exemplo n.º 24
0
        public int Defend(Ogre ogre)
        {
            int damage = 0;

            if (hasRat)
            {
                damage += 100000;
                hasRat  = false;
                Console.WriteLine($"{nameof(RatCatcher)} {name} has rat's body and kills(run away) Ogre {ogre.Name} \n");
                return(damage);
            }
            else
            {
                Console.WriteLine($"{nameof(RatCatcher)} {name} doesn't have rat's body and ignore Ogre {ogre.Name} \n");
                return(damage);
            }
        }
Exemplo n.º 25
0
        private void Level1Load()
        {
            MediaPlayer.Stop();
            ghost = new Ghost(Content.Load <Texture2D>("ghost_walking"), Content.Load <Texture2D>("ghost_attack"), Content.Load <Texture2D>("ghost_rip"), new Vector2(0, 0));
            ogre  = new Ogre(Content.Load <Texture2D>("ogre_walking"), Content.Load <Texture2D>("ogre_attack"), Content.Load <Texture2D>("ogre_death"), new Vector2(0, 0));
            item  = new Item(Content.Load <Texture2D>("bottle1"), new Rectangle(0, 0, 30, 30), new Vector2(0, -10));
            boss  = new Boss(Content.Load <Texture2D>("boss/bossIdle"), Content.Load <Texture2D>("boss/bossAttack"), new Vector2(1000, 700), Content.Load <Texture2D>("boss/bossFireball"));
            Introduction introduction = new Introduction(Content.Load <Texture2D>("int"), Content.Load <Texture2D>("OKBUTTON"));

            Tiles.Content = Content;
            level1        = mapGenerator.Generate(new int[, ] {
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, 0, 0, 0, 0, 0, 0, 5, 6, 6, 6 },
                { 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 5, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 6, 6 },
                { 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 6, 6, 6 },
                { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6 },
                { 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 },
            }, 32, Content.Load <Texture2D>("backgrounds/background0"), ghost, ogre, boss, item, introduction, Content);
            player.Load(Content);
            spriteBatch      = new SpriteBatch(GraphicsDevice);
            currentGameState = GameState.Level1;
            // MediaPlayer.Play(battleTheme);
            isLoading = true;
            player.GetOnMap(new Vector2(0, 700));
        }
Exemplo n.º 26
0
        public void SupprimerPlatTest()
        {
            // Creation de la liste
            var data = new List <Plat>()
            {
                new Plat {
                    TypePlat = "Carnivore", NbrBouchee = 5, PlatId = 1001
                },
                new Plat {
                    TypePlat = "Sucrerie", NbrBouchee = 3, PlatId = 1002
                },
            }.AsQueryable();

            Plat p = new Plat
            {
                TypePlat   = "Carnivore",
                PlatId     = 1001,
                NbrBouchee = 5
            };

            // Mocking le contexte
            var mockSet = new Mock <DbSet <Plat> >();

            mockSet.As <IQueryable <Plat> >().Setup(m => m.Provider).Returns(data.Provider);
            mockSet.As <IQueryable <Plat> >().Setup(m => m.Expression).Returns(data.Expression);
            mockSet.As <IQueryable <Plat> >().Setup(m => m.ElementType).Returns(data.ElementType);
            mockSet.As <IQueryable <Plat> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator());

            var mockContexte = new Mock <PlatBDContext>();

            mockContexte.Setup(m => m.Plats).Returns(mockSet.Object);
            mockContexte.Setup(m => m.SaveChanges());

            Ogre ogreTest = new Ogre()
            {
                platContexte = mockContexte.Object
            };

            ogreTest.SupprimerPlat();

            mockContexte.Verify(m => m.Plats.Remove(p), Times.Once);
            mockContexte.Verify(m => m.Plats.Remove(It.IsAny <Plat>()), Times.Once);
            mockContexte.Verify(m => m.SaveChanges());
        }
Exemplo n.º 27
0
        public Character GetRandomMonster()
        {
            Character result;           //Gets a random monster to fight

            switch (rand.Next(0, 9))
            {
            default:
            case 0:
            case 1:
                result = new Kobold();
                break;

            case 2:
                result = new Bombomb();
                break;

            case 3:
                result = new Ogre();
                break;

            case 4:
                result = new Imp();
                break;

            case 5:
                result = new Baby_Dragon();
                break;

            case 6:
                result = new Treasure_Goblin();
                break;

            case 7:
                result = new Turtle();
                break;

            case 8:
                result = new Zombie();
                break;
            }
            return(result);
        }
Exemplo n.º 28
0
    protected override void Update()
    {
        // Allows this script to use the everything in the Update function in Enemy
        base.Update();

        // Calls on the EnemyPos Function
        EnemyPos();

        if (health <= 0)
        {
            if (allowSpawn)
            {
                // Spawns a new Ogre and makes it contuine on its way points
                GameObject clone   = Instantiate(ogrePrefab, enemyPosition, Quaternion.identity);
                Ogre       newOgre = clone.GetComponent <Ogre>();
                newOgre.path       = path;
                newOgre.allowSpawn = false;
            }
            Destroy(gameObject);
        }
    }
Exemplo n.º 29
0
    // Start is called before the first frame update
    void Start()
    {
        Ogre   ogre   = new Ogre();
        Goblin goblin = new Goblin();

        Sorcerer    sorcerer    = new Sorcerer();
        Warrior     warrior     = new Warrior();
        Necromancer necromancer = new Necromancer();

        Debug.Log("//////////////////////////////");
        ogre.Bash();
        ogre.Retreat();
        ogre.DisplayStatus();
        ogre.Move();

        Debug.Log("//////////////////////////////");
        goblin.ThrowBombs();
        goblin.Retreat();
        goblin.DisplayStatus();
        goblin.Move();

        Debug.Log("//////////////////////////////");
        sorcerer.DisplayStats();
        sorcerer.CastFireball();
        sorcerer.CastIceStorm();
        sorcerer.Move();

        Debug.Log("//////////////////////////////");
        warrior.DisplayStats();
        warrior.Whirlewind();
        warrior.Cleave();
        warrior.Move();

        Debug.Log("//////////////////////////////");
        necromancer.DisplayStats();
        necromancer.SummonSkeleton();
        necromancer.Drainlife();
        necromancer.Move();
    }
Exemplo n.º 30
0
        public override void Update(GameTime gameTime, ref States state, ref Character player)
        {
            if (MouseKeyboardManager.LeftClick)
            {
                if (wizardRect.Contains(MouseKeyboardManager.MousePosition.ToPoint()))
                {
                    player = new Wizard(new Vector2(Window.ClientBounds.Width / 2, Window.ClientBounds.Height / 2), 3f, 0.0);
                    state  = States.Lobby;
                    networkManager.SendClassChange(Player.ClassType.Wizard);
                }
                else if (ogreRect.Contains(MouseKeyboardManager.MousePosition.ToPoint()))
                {
                    player = new Ogre(new Vector2(Window.ClientBounds.Width / 2, Window.ClientBounds.Height / 2), 3f, 0.0);
                    state  = States.Lobby;
                    networkManager.SendClassChange(Player.ClassType.Ogre);
                }
                else if (huntressRect.Contains(MouseKeyboardManager.MousePosition.ToPoint()))
                {
                    player = new Huntress(new Vector2(Window.ClientBounds.Width / 2, Window.ClientBounds.Height / 2), 3f, 0.0, Window.ClientBounds);
                    state  = States.Lobby;
                    networkManager.SendClassChange(Player.ClassType.Huntress);
                }

                else if (knightRect.Contains(MouseKeyboardManager.MousePosition.ToPoint()))
                {
                    player = new Knight(new Vector2(Window.ClientBounds.Width / 2, Window.ClientBounds.Height / 2), 3f, 0.0);
                    state  = States.Lobby;
                    networkManager.SendClassChange(Player.ClassType.Knight);
                }

                else if (travelerRect.Contains(MouseKeyboardManager.MousePosition.ToPoint()))
                {
                    player = new TimeTraveler(new Vector2(Window.ClientBounds.Width / 2, Window.ClientBounds.Height / 2), 3f, 0.0);
                    state  = States.Lobby;
                    networkManager.SendClassChange(Player.ClassType.TimeTraveler);
                }
            }
        }