Inheritance: Enemy
Ejemplo n.º 1
0
            public void ManyGoblinsTest()
            {
                var game   = new Game();
                var goblin = new Goblin(game);

                game.Creatures.Add(goblin);

                Assert.That(goblin.Attack, Is.EqualTo(1));
                Assert.That(goblin.Defense, Is.EqualTo(1));

                var goblin2 = new Goblin(game);

                game.Creatures.Add(goblin2);

                Assert.That(goblin.Attack, Is.EqualTo(1));
                Assert.That(goblin.Defense, Is.EqualTo(2));

                var goblin3 = new GoblinKing(game);

                game.Creatures.Add(goblin3);

                Assert.That(goblin.Attack, Is.EqualTo(2));
                Assert.That(goblin.Defense, Is.EqualTo(3));
            }
Ejemplo n.º 2
0
        public void Try_New_Direction()
        {
            Arena arena = new Arena();
            Team  team  = arena.CreateTeam("red");

            Goblin Pal = new Goblin(arena, team, 1);

            Random rdm1 = new Random();
            double x    = rdm1.NextDouble() * 2 - 1;
            double y    = rdm1.NextDouble() * 2 - 1;

            Pal.Location = new Vector(x, y);

            Goblin target = new Goblin(arena, team, 1);

            double x2 = rdm1.NextDouble() * 2 - 1;
            double y2 = rdm1.NextDouble() * 2 - 1;

            target.Location = new Vector(x2, y2);
            Pal.Target      = target;

            Pal.NewDirection();
            Assert.That(Pal.Direction, Is.EqualTo(new Vector(x2 - x, y2 - y)));
        }
Ejemplo n.º 3
0
            public override void Create()
            {
                Name = "Mountain";

                var fire   = new Fire();
                var air    = new Air();
                var earth1 = new Earth();
                var earth2 = new Earth();

                Elements = new Element[]
                {
                    air, earth1, earth2, fire
                };

                foreach (var element in Elements)
                {
                    element.Create();
                }

                var goblin = new Goblin();
                var human  = new Human();
                var animal = new Animal();
                var orc    = new Orc();
                var dwarf1 = new Dwarf();
                var dwarf2 = new Dwarf();

                Creatures = new Creature[]
                {
                    goblin, human, animal, orc, dwarf1, dwarf2
                };

                foreach (var creature in Creatures)
                {
                    creature.Create();
                }
            }
Ejemplo n.º 4
0
            public override void Create()
            {
                Name = "Swamp";

                var three  = new Tree();
                var water1 = new Water();
                var water2 = new Water();
                var earth1 = new Earth();
                var earth2 = new Earth();

                Elements = new Element[]
                {
                    three, water1, water2, earth1, earth2
                };

                foreach (var element in Elements)
                {
                    element.Create();
                }

                var goblin  = new Goblin();
                var human   = new Human();
                var animal  = new Animal();
                var orc1    = new Orc();
                var merfolk = new Merfolk();

                Creatures = new Creature[]
                {
                    goblin, human, animal, orc1, merfolk
                };

                foreach (var creature in Creatures)
                {
                    creature.Create();
                }
            }
        public static Monster CreateMonster(int level, Point location)
        {
            Pool <Monster> monsterPool = new Pool <Monster>();

            if (level <= 2)
            {
                monsterPool.Add(Rat.Create(level), 20);
                monsterPool.Add(Lichen.Create(level), 30);
                monsterPool.Add(Jackal.Create(level), 25);
                monsterPool.Add(Kobold.Create(level), 25);
            }
            else if (level <= 4)
            {
                monsterPool.Add(Lichen.Create(level), 15);
                monsterPool.Add(Rat.Create(level), 16);
                monsterPool.Add(Jackal.Create(level), 25);
                monsterPool.Add(Kobold.Create(level), 25);
                monsterPool.Add(Goblin.Create(level), 15);
                monsterPool.Add(Sludge.Create(level), 3);
                monsterPool.Add(Wolf.Create(level), 1);
            }
            else if (level <= 6)
            {
                monsterPool.Add(Jackal.Create(level), 5);
                monsterPool.Add(Wolf.Create(level), 10);
                monsterPool.Add(Kobold.Create(level), 15);
                monsterPool.Add(Goblin.Create(level), 30);
                monsterPool.Add(Sludge.Create(level), 25);
                monsterPool.Add(Gnoll.Create(level), 5);
                monsterPool.Add(Viper.Create(level), 10);
            }
            else if (level <= 8)
            {
                monsterPool.Add(Goblin.Create(level), 8);
                monsterPool.Add(Slime.Create(level), 15);
                monsterPool.Add(Viper.Create(level), 8);
                monsterPool.Add(Wolf.Create(level), 20);
                monsterPool.Add(Gnoll.Create(level), 25);
                monsterPool.Add(LizardMan.Create(level), 10);
                monsterPool.Add(Werewolf.Create(level), 4);
            }
            else if (level <= 10)
            {
                monsterPool.Add(Ogre.Create(level), 10);
                monsterPool.Add(Gnoll.Create(level), 10);
                monsterPool.Add(Werewolf.Create(level), 20);
                monsterPool.Add(LizardMan.Create(level), 30);
                monsterPool.Add(Orc.Create(level), 20);
                monsterPool.Add(Dragon.Create(level), 10);
            }
            else
            {
                monsterPool.Add(Werewolf.Create(level), 20);
                monsterPool.Add(Ogre.Create(level), 20);
                monsterPool.Add(LizardMan.Create(level), 20);
                monsterPool.Add(Orc.Create(level), 20);
                monsterPool.Add(Dragon.Create(level), 30);
            }

            Monster monster = monsterPool.Get();

            monster.X = location.X;
            monster.Y = location.Y;

            return(monster);
        }
Ejemplo n.º 6
0
        public void Load(string savename, ref MainHero mainHero, ref Boss boss)
        {
            using (StreamReader sr = new StreamReader($"saves/{savename}"))
            {
                //Поиск размера
                string buff = sr.ReadLine();
                buff     = buff.Remove(0, (buff.IndexOf("-") + 2));
                Map.Size = Convert.ToInt32(buff);
                //

                //Поиск всего, что лежит на карте
                for (int i = 0; !sr.EndOfStream; i++)
                {
                    buff = sr.ReadLine();
                    if (buff.Contains("null"))
                    {
                        Map[i] = null;
                    }
                    else
                    {
                        string typeOfObject_Main = buff.Substring(0, buff.IndexOf("/"));
                        buff = buff.Remove(0, (buff.IndexOf("/") + 1));
                        string typeOfObject_1 = "", typeOfObject_2 = ""; //Если создаются новые ветки наследования объектов, то сюда просто новое
                        if (typeOfObject_Main == "Unit")
                        {
                            typeOfObject_1 = buff.Substring(0, buff.IndexOf("/"));
                            buff           = buff.Remove(0, (buff.IndexOf(":") + 2));
                        }
                        else if (typeOfObject_Main == "Loot")
                        {
                            typeOfObject_1 = buff.Substring(0, buff.IndexOf("/"));
                            if (typeOfObject_1 == "Chest")
                            {
                                buff = buff.Remove(0, (buff.IndexOf(":") + 2));
                            }
                            else if (typeOfObject_1 == "Aura")
                            {
                                buff           = buff.Remove(0, (buff.IndexOf("/") + 1));
                                typeOfObject_2 = buff.Substring(0, buff.IndexOf("/"));
                                if (typeOfObject_2 == "AttackAura")
                                {
                                    buff = buff.Remove(0, (buff.IndexOf(":") + 2));
                                }
                            }
                        }
                        List <string> attributes = new List <string>();
                        for (int j = 0; buff != ""; j++)
                        {
                            buff = buff.Remove(0, (buff.IndexOf("-") + 2));
                            attributes.Add(buff.Substring(0, buff.IndexOf(",")));
                            buff = buff.Remove(0, (buff.IndexOf(",") + 2));
                        }


                        if (typeOfObject_Main == "Unit")
                        {
                            if (typeOfObject_1 == "MainHero")
                            {
                                MainHero temp = (MainHero)Map[i];
                                temp     = new MainHero(attributes[0], Convert.ToInt32(attributes[1]), Convert.ToInt32(attributes[2]), Convert.ToInt32(attributes[3]), Convert.ToInt32(attributes[4]), Convert.ToInt32(attributes[5]), Convert.ToInt32(attributes[6]));
                                Map[i]   = temp;
                                mainHero = temp;
                            }
                            else if (typeOfObject_1 == "Boss")
                            {
                                Boss temp = (Boss)Map[i];
                                temp   = new Boss(attributes[0], Convert.ToInt32(attributes[1]), Convert.ToInt32(attributes[2]), Convert.ToInt32(attributes[3]), Convert.ToInt32(attributes[4]), Convert.ToInt32(attributes[5]));
                                Map[i] = temp;
                                boss   = temp;
                            }
                            else
                            {
                                if (typeOfObject_1 == "Goblin")
                                {
                                    Goblin temp = (Goblin)Map[i];
                                    temp   = new Goblin(attributes[0], Convert.ToInt32(attributes[1]), Convert.ToInt32(attributes[2]), Convert.ToInt32(attributes[3]), Convert.ToInt32(attributes[4]), Convert.ToInt32(attributes[5]), Convert.ToInt32(attributes[6]));
                                    Map[i] = temp;
                                }
                                else if (typeOfObject_1 == "Spider")
                                {
                                    Spider temp = (Spider)Map[i];
                                    temp   = new Spider(attributes[0], Convert.ToInt32(attributes[1]), Convert.ToInt32(attributes[2]), Convert.ToInt32(attributes[3]), Convert.ToInt32(attributes[4]), Convert.ToInt32(attributes[5]));
                                    Map[i] = temp;
                                }
                            }
                        }
                        else if (typeOfObject_Main == "Loot")
                        {
                            if (typeOfObject_1 == "Chest")
                            {
                                Chest temp = (Chest)Map[i];
                                temp   = new Chest(Convert.ToInt32(attributes[0]), Convert.ToInt32(attributes[1]));
                                Map[i] = temp;
                            }
                            else if (typeOfObject_1 == "Aura")
                            {
                                if (typeOfObject_2 == "AttackAura")
                                {
                                    AttackAura temp = (AttackAura)Map[i];
                                    temp   = new AttackAura(Convert.ToInt32(attributes[0]), Convert.ToInt32(attributes[1]));
                                    Map[i] = temp;
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
    void Update()
    {
        if (currentWaveIndex == waves.Count - 1 && phase != SpawnPhase.Spawning)
        {
            bool finished = true;
            foreach (var go in GameObject.FindGameObjectsWithTag("Goblin"))
            {
                Goblin goblin = go.GetComponent <Goblin>();
                if (goblin.IsAlive())
                {
                    finished = false;
                    break;
                }
            }
            if (finished)
            {
                UIManager.main.ShowTheEnd();
            }
        }

        if (currentWaveIndex == waves.Count - 1)
        {
            UIManager.main.HideIntermissionInfo();
            UIManager.main.HideIntermissionTimer();
        }

        if (phase == SpawnPhase.Spawning)
        {
            //Debug.Log("Starting to spawn " + Time.fixedTime);
            if (!spawningOnGoing)
            {
                for (int i = 0; i < 4; i++)
                {
                    WaveSpawn wave = currentWave.GetSpawn(i);
                    //Batch batch = currentBatch[i];
                    if (wave.batches.Count > 0)
                    {
                        spawnPoints[i].SetWaveSpawn(wave);
                    }
                }

                spawningOnGoing = true;
            }

            // next wave when all the spawners have spawned their enemies
            if (spawnPoints.Aggregate(true, (prod, next) => prod && next.GetHasEnded()))
            {
                spawningOnGoing = false;
                phase           = SpawnPhase.Waiting;
                waitStarted     = Time.fixedTime;
            }
        }
        else if (phase == SpawnPhase.Waiting && (Time.fixedTime - waitStarted > currentWave.WaveEndWaitTime))
        {
            phase = SpawnPhase.Ended;
            UIManager.main.HideIntermissionInfo();
        }
        else if (phase == SpawnPhase.Waiting)
        {
            if (Input.GetKeyDown(KeyCode.Space) && TutorialManager.main.GetFinished())
            {
                skipWaveWaitingPeriod();
                UIManager.main.HideIntermissionInfo();
            }
            else
            {
                UIManager.main.UpdateIntermissionInfo("Wave " + (currentWaveIndex + 2) + " spawns in:");
                UIManager.main.UpdateIntermissionTimer(currentWave.WaveEndWaitTime - (Time.fixedTime - waitStarted));
            }
        }
        else if (phase == SpawnPhase.Ended)
        {
            waveEndStuff();
        }
    }
Ejemplo n.º 8
0
 public Coffrier(Emploi emploi, int salaire, Goblin collegue, Goblin superieur, Goblin employe)
 {
     super(emploi, salaire, collegue, superieur, employe);
 }
Ejemplo n.º 9
0
 public void setCollegue(Goblin collegue)
 {
     this.collegue = collegue;
 }
Ejemplo n.º 10
0
 public Equip(Goblin goblin)
 {
     this.goblin = goblin;
 }
Ejemplo n.º 11
0
        private string Round(ref CardDeck deck1, ref CardDeck deck2, string username1, string username2)
        {
            Card card1Deck = deck1.GetRandomCard();
            Card card2Deck = deck2.GetRandomCard();

            // create new cards instead of references
            Card card1 = card1Deck switch
            {
                Dragon d => new Dragon(card1Deck.ID, card1Deck.Name, card1Deck.Damage, card1Deck.Type),
                Elve e => new Elve(card1Deck.ID, card1Deck.Name, card1Deck.Damage, card1Deck.Type),
                Goblin g => new Goblin(card1Deck.ID, card1Deck.Name, card1Deck.Damage, card1Deck.Type),
                Knight k => new Knight(card1Deck.ID, card1Deck.Name, card1Deck.Damage, card1Deck.Type),
                Kraken k => new Kraken(card1Deck.ID, card1Deck.Name, card1Deck.Damage, card1Deck.Type),
                Orc o => new Orc(card1Deck.ID, card1Deck.Name, card1Deck.Damage, card1Deck.Type),
                Wizard w => new Wizard(card1Deck.ID, card1Deck.Name, card1Deck.Damage, card1Deck.Type),
                FireSpell f => new FireSpell(card1Deck.ID, card1Deck.Name, card1Deck.Damage),
                NormalSpell n => new NormalSpell(card1Deck.ID, card1Deck.Name, card1Deck.Damage),
                WaterSpell w => new WaterSpell(card1Deck.ID, card1Deck.Name, card1Deck.Damage),
            };
            Card card2 = card2Deck switch
            {
                Dragon d => new Dragon(card2Deck.ID, card2Deck.Name, card2Deck.Damage, card2Deck.Type),
                Elve e => new Elve(card2Deck.ID, card2Deck.Name, card2Deck.Damage, card2Deck.Type),
                Goblin g => new Goblin(card2Deck.ID, card2Deck.Name, card2Deck.Damage, card2Deck.Type),
                Knight k => new Knight(card2Deck.ID, card2Deck.Name, card2Deck.Damage, card2Deck.Type),
                Kraken k => new Kraken(card2Deck.ID, card2Deck.Name, card2Deck.Damage, card2Deck.Type),
                Orc o => new Orc(card2Deck.ID, card2Deck.Name, card2Deck.Damage, card2Deck.Type),
                Wizard w => new Wizard(card2Deck.ID, card2Deck.Name, card2Deck.Damage, card2Deck.Type),
                FireSpell f => new FireSpell(card2Deck.ID, card2Deck.Name, card2Deck.Damage),
                NormalSpell n => new NormalSpell(card2Deck.ID, card2Deck.Name, card2Deck.Damage),
                WaterSpell w => new WaterSpell(card2Deck.ID, card2Deck.Name, card2Deck.Damage),
            };

            //card1.Damage = card1.Damage * _elementEffectivenessService.CompareElements(card1.Type, card2.Type);
            //card2.Damage = card2.Damage * _elementEffectivenessService.CompareElements(card2.Type, card1.Type);
            card1.EnhanceDamage(_elementEffectivenessService.CompareElements(card1.Type, card2.Type));
            card2.EnhanceDamage(_elementEffectivenessService.CompareElements(card2.Type, card1.Type));

            // without special abilities

            /*int card1wins = card1 switch
             * {
             *  IMonster monster => monster.CompareDamage(card2.Damage) ? 1 : -1,
             *  ISpell spell => spell.CompareDamage(card2.Damage) ? 1 : -1,
             *  _ => 0
             * };*/

            Random random       = new Random();
            bool   boosterCard1 = (random.Next(1, 21) == 20);

            if (boosterCard1)
            {
                //card1.Damage = card1.Damage * 10;
                card1.EnhanceDamage(10);
            }

            int card1wins = card1 switch
            {
                IMonster _ when card2 is IMonster => FightMonsterMonster(card1, card2),
                IMonster _ when card1 is ISpell => FightMonsterSpell(card1, card2),
                ISpell _ when card2 is IMonster => FightSpellMonster(card2, card1),
                _ => FightSpellSpell(card1, card2)
            };

            string roundLog;

            if (card1wins == 1)
            {
                deck1.AddCard(card2Deck, true);
                deck2.RemoveCard(card2Deck);
                if (boosterCard1)
                {
                    roundLog = (card1Deck.ToBattleString() + " (" + username1 + ") won with a booster against " + card2Deck.ToBattleString() + " (" + username2 + ")");
                }
                else
                {
                    roundLog = (card1Deck.ToBattleString() + " (" + username1 + ") won against " + card2Deck.ToBattleString() + " (" + username2 + ")");
                }
            }
            else if (card1wins == -1)
            {
                deck2.AddCard(card1Deck, true);
                deck1.RemoveCard(card1Deck);
                if (boosterCard1)
                {
                    roundLog = (card1Deck.ToBattleString() + " (" + username1 + ") lost although a booster to " + card2Deck.ToBattleString() + " (" + username2 + ")");
                }
                else
                {
                    roundLog = (card1Deck.ToBattleString() + " (" + username1 + ") lost to " + card2Deck.ToBattleString() + " (" + username2 + ")");
                }
            }
            else
            {
                if (boosterCard1)
                {
                    roundLog = (card1Deck.ToBattleString() + " (" + username1 + ") drew although a booster with " + card2Deck.ToBattleString() + " (" + username2 + ")");
                }
                else
                {
                    roundLog = (card1Deck.ToBattleString() + " (" + username1 + ") drew with " + card2Deck.ToBattleString() + " (" + username2 + ")");
                }
            }

            return(roundLog);
        }
Ejemplo n.º 12
0
 private void SelectClass(Goblin c, Goblin.Class cl)
 {
     c.SelectClass(cl);
 }
Ejemplo n.º 13
0
 public Hunting(Goblin goblin)
 {
     this.goblin = goblin;
 }
Ejemplo n.º 14
0
 public GoblinData(Goblin goblin)
 {
     Health   = goblin.Health;
     Manapool = goblin.Manapool;
     Level    = goblin.Level;
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Generates the monsters for the map
        /// </summary>
        protected void AddRandomMonster(Rectangle area)
        {
            if (type == MapType.dungeon)
            {
                int mt = rnd.Next(1, 4);
                Actor m = null;

                if (mt == 1)
                    m = new Kobold(1, new Vector2(rnd.Next(area.Left, area.Right) + 0.5f, rnd.Next(area.Top, area.Bottom) + 0.5f));
                else if (mt == 2)
                    m = new Rat(1, new Vector2(rnd.Next(area.Left, area.Right) + 0.5f, rnd.Next(area.Top, area.Bottom) + 0.5f));
                else if (mt == 3)
                    m = new Goblin(1, new Vector2(rnd.Next(area.Left, area.Right) + 0.5f, rnd.Next(area.Top, area.Bottom) + 0.5f));

                if (m != null) map.AddEntity(m);
            }
        }
Ejemplo n.º 16
0
 private void MoveToGoblin(Goblin g)
 {
     currentZoomLevel = ZoomLevel.GoblinView;
     camMoveRoutine   = StartCoroutine(MoveCamera(g.transform, GoblinViewSize));
 }
Ejemplo n.º 17
0
 //TODO: move to character or game manager
 private void LevelUp(Goblin gob, Character.Stat stat)
 {
     stat.LevelUp();
 }
Ejemplo n.º 18
0
 public Regroup(Goblin goblin)
 {
     this.goblin = goblin;
 }
Ejemplo n.º 19
0
    public void SetupLevelScreen(Goblin character)
    {
        if (!character)
        {
            return;
        }

        Open();

        ConfirmButton.interactable = false;

        foreach (var generatedClassButton in generatedChoiceEntries)
        {
            Destroy(generatedClassButton.gameObject);
        }
        generatedChoiceEntries.Clear();

        this.character = character;

        ChoiceExplanantion.text = character.WaitingOnClassSelection ? "Select a Class": "Select level up";

        //TODO: use progression system instead
        Choices = character.WaitingOnClassSelection ? ClassChoices : LevelController.GetLevelUpChoices(character.ClassType, character.LevelUps);

        if (!Choices.Any())
        {
            Debug.LogError("no Choices for level: " + (character.LevelUps + 1));
            return;
        }

        if (generatedChoiceEntries == null || generatedChoiceEntries.Count == 0)
        {
            generatedChoiceEntries = new List <LevelUpChoiceEntry>();

            foreach (var choice in Choices)
            {
                var entry = Instantiate(levelUpChoiceEntry, levelUpChoiceEntry.transform.parent);

                entry.LevelUpChoice = choice;

                //TODO: merge attribute and class images
                switch (choice.Type)
                {
                case LevelController.ChoiceType.Attribute:
                    entry.Image.sprite = GameManager.GetAttributeImage(choice.Attribute);
                    break;

                case LevelController.ChoiceType.Class:
                    entry.Image.sprite = GameManager.GetClassImage(choice.Class);
                    break;

                case LevelController.ChoiceType.Skill:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                generatedChoiceEntries.Add(entry);

                entry.Button.onClick.AddListener(() => SelectChoice(entry));

                entry.gameObject.SetActive(true);
            }
        }
        levelUpChoiceEntry.gameObject.SetActive(false);


        //ViewHolder.SetActive(true);
    }
Ejemplo n.º 20
0
 private static void SummarizeAndWait(Goblin g1)
 {
     Console.WriteLine($"{g1.Name} has chosen {g1.Weapon}! Press any key to continue.");
     Console.ReadKey();
 }
Ejemplo n.º 21
0
 public void AddGoblinToList(Goblin script)
 {
     goblins.Add(script);
 }
Ejemplo n.º 22
0
 public void setSuperieur(Goblin superieur)
 {
     this.superieur = superieur;
 }
Ejemplo n.º 23
0
    public void SpawnCharacters()
    {
        for (int i = 0; i < 3; i++)
        {
            int choice = Random.Range(1, 7);

            if (choice == 1)
            {
                Character currentCharacter = new Warlock();
                Debug.Log("-- Personnage -- : " + currentCharacter.GetCharacterInfo.nom);
                Debug.Log("Vie: " + currentCharacter.GetCharacterInfo.vie);
                Debug.Log("Défense: " + currentCharacter.GetCharacterInfo.defense);
                Debug.Log("Attaque: " + currentCharacter.GetCharacterInfo.attack);
                InventorySlot AddCharac(Character Warlock);
                Inventory AddPerso(Character Warlock);
            }
            if (choice == 2)
            {
                Character currentCharacter = new Archer();
                Debug.Log("-- Personnage -- : " + currentCharacter.GetCharacterInfo.nom);
                Debug.Log("Vie: " + currentCharacter.GetCharacterInfo.vie);
                Debug.Log("Défense: " + currentCharacter.GetCharacterInfo.defense);
                Debug.Log("Attaque: " + currentCharacter.GetCharacterInfo.attack);
                InventorySlot AddCharac(Character Archer);
                Inventory AddPerso(Character Archer);
            }
            if (choice == 3)
            {
                Character currentCharacter = new Knight();
                Debug.Log("-- Personnage -- : " + currentCharacter.GetCharacterInfo.nom);
                Debug.Log("Vie: " + currentCharacter.GetCharacterInfo.vie);
                Debug.Log("Défense: " + currentCharacter.GetCharacterInfo.defense);
                Debug.Log("Attaque: " + currentCharacter.GetCharacterInfo.attack);
                InventorySlot AddCharac(Character Knight);
                Inventory AddPerso(Character Knight);
            }
            if (choice == 4)
            {
                Character currentCharacter = new Goblin();
                Debug.Log("-- Personnage -- : " + currentCharacter.GetCharacterInfo.nom);
                Debug.Log("Vie: " + currentCharacter.GetCharacterInfo.vie);
                Debug.Log("Défense: " + currentCharacter.GetCharacterInfo.defense);
                Debug.Log("Attaque: " + currentCharacter.GetCharacterInfo.attack);
                InventorySlot AddCharac(Character Goblin);
                Inventory AddPerso(Character Goblin);
            }
            if (choice == 5)
            {
                Character currentCharacter = new Orc();
                Debug.Log("-- Personnage -- : " + currentCharacter.GetCharacterInfo.nom);
                Debug.Log("Vie: " + currentCharacter.GetCharacterInfo.vie);
                Debug.Log("Défense: " + currentCharacter.GetCharacterInfo.defense);
                Debug.Log("Attaque: " + currentCharacter.GetCharacterInfo.attack);
                InventorySlot AddCharac(Character Orc);
                Inventory AddPerso(Character Orc);
            }
            if (choice == 6)
            {
                Character currentCharacter = new Troll();
                Debug.Log("-- Personnage -- : " + currentCharacter.GetCharacterInfo.nom);
                Debug.Log("Vie: " + currentCharacter.GetCharacterInfo.vie);
                Debug.Log("Défense: " + currentCharacter.GetCharacterInfo.defense);
                Debug.Log("Attaque: " + currentCharacter.GetCharacterInfo.attack);
                InventorySlot AddCharac(Character Troll);
                Inventory AddPerso(Character Troll);
            }
        }
    }
Ejemplo n.º 24
0
 public void Init()
 {
     Goblin.Reset();
 }
Ejemplo n.º 25
0
 public Obeying(Goblin goblin)
 {
     this.goblin = goblin;
 }
Ejemplo n.º 26
0
 public void Save(string savename, MainHero mainHero, Boss boss)
 {
     using (StreamWriter sw = new StreamWriter($"saves/savelog.txt", true))
     {
         sw.WriteLine($"{savename}.txt");
     }
     using (StreamWriter sw = new StreamWriter($"saves/{savename}.txt"))
     {
         sw.WriteLine($"Map Size - {Map.Size}");
         for (int i = 0; i < mainHero.Location; i++)
         {
             sw.WriteLine($"null: Location - {i}");
         }
         for (int i = mainHero.Location; i < Map.Size; i++)
         {
             if (Map[i] is Unit)
             {
                 if (Map[i] is MainHero)
                 {
                     MainHero temp = (MainHero)Map[i];
                     sw.WriteLine($"Unit/MainHero/: Name - {temp.Name}, HP - {temp.HP}, Mana - {temp.Mana}, Armor - {temp.Armor}, Damage - {temp.Damage}, Gold - {temp.Gold}, Location - {temp.Location}, ");
                 }
                 else if (Map[i] is Boss)
                 {
                     Boss temp = (Boss)Map[i];
                     sw.WriteLine($"Unit/Boss/: Name - {temp.Name}, HP - {temp.HP}, Mana - {temp.Mana}, Armor - {temp.Armor}, Damage - {temp.Damage}, Location - {temp.Location}, ");
                 }
                 else
                 {
                     //Все рядовые мобы
                     if (Map[i] is Goblin)
                     {
                         Goblin temp = (Goblin)Map[i];
                         sw.WriteLine($"Unit/Goblin/: Name - {temp.Name}, HP - {temp.HP}, Mana - {temp.Mana}, Armor - {temp.Armor}, Damage - {temp.Damage}, Gold - {temp.Gold}, Location - {temp.Location}, ");
                     }
                     else if (Map[i] is Spider)
                     {
                         Spider temp = (Spider)Map[i];
                         sw.WriteLine($"Unit/Spider/: Name - {temp.Name}, HP - {temp.HP}, Mana - {temp.Mana}, Armor - {temp.Armor}, Damage - {temp.Damage}, Location - {temp.Location}, ");
                     }
                 }
             }
             else if (Map[i] is Loot)
             {
                 if (Map[i] is Chest)
                 {
                     Chest temp = (Chest)Map[i];
                     sw.WriteLine($"Loot/Chest/: Gold - {temp.Gold}, Location - {temp.Location}, ");
                 }
                 else if (Map[i] is Aura)
                 {
                     if (Map[i] is AttackAura)
                     {
                         AttackAura temp = (AttackAura)Map[i];
                         sw.WriteLine($"Loot/Aura/AttackAura/: AttackBuff - {temp.AttackBuff}, Location - {temp.Location}, ");
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 27
0
        public ACreature CreateCreature(int height, int width)
        {
            //TODO Sikre at der ikke sker et uendeligt loop og at return null ikke laver ged i den

            var       rand = new Random();
            int       num  = rand.Next(3);
            ACreature c;

            if (num == 0)
            {
                int  row           = rand.Next(width);
                int  col           = rand.Next(height);
                Tile _tile         = new Tile(row, col);
                bool _tileOccupied = _usedTiles.Any(x => x.row == row && x.column == col);
                if (!_tileOccupied)
                {
                    c = new Goblin(_tile);
                    return(c);
                }
                else
                {
                    //bør kalde metoden igen i tilfælde af at der allerede er et Creature i den Tile
                    CreateCreature(height, width);
                    //metoden beklager sig hvis jeg ikke sætter return null ind. hvad sker der når return null kører igennem?
                    return(null);
                }
            }
            else if (num == 1)
            {
                int  row           = rand.Next(width);
                int  col           = rand.Next(height);
                Tile _tile         = new Tile(row, col);
                bool _tileOccupied = _usedTiles.Any(x => x.row == row && x.column == col);
                if (!_tileOccupied)
                {
                    c = new Orc(_tile);
                    return(c);
                }
                else
                {
                    //bør kalde metoden igen i tilfælde af at der allerede er et Creature i den Tile
                    CreateCreature(height, width);
                    return(null);
                }
            }
            else
            {
                int  row           = rand.Next(width);
                int  col           = rand.Next(height);
                Tile _tile         = new Tile(row, col);
                bool _tileOccupied = _usedTiles.Any(x => x.row == row && x.column == col);
                if (!_tileOccupied)
                {
                    c = new Human(_tile);
                    return(c);
                }
                else
                {
                    //bør kalde metoden igen i tilfælde af at der allerede er et Creature i den Tile
                    CreateCreature(height, width);
                    return(null);
                }
            }
        }
Ejemplo n.º 28
0
        public static IFighter GetFighter(FighterType type,
                                          int level,
                                          string name               = null,
                                          MagicType magicType       = MagicType.None,
                                          FighterClass fighterClass = FighterClass.None,
                                          IMenuFactory menuFactory  = null)
        {
            IFighter ret;

            switch (type)
            {
            case FighterType.Goblin:
                ret = new Goblin(level, ChanceService);
                break;

            case FighterType.Golem:     //high defense, low attack, low speed, low health
                ret = new Golem(level, ChanceService);
                break;

            case FighterType.Ogre:     //high attack, low speed, low defense
                ret = new Ogre(level, ChanceService);
                break;

            case FighterType.Fairy:     //high speed, high evade, low attack, low defense
                ret = new Fairy(level, ChanceService);
                break;

            case FighterType.HumanControlledPlayer:
                ret = new HumanFighter(name ?? "Player", level);
                GodRelationshipManager?.InitializeForFighter((HumanFighter)ret);
                break;

            case FighterType.HumanControlledEnemy:
                ret = new HumanControlledEnemyFighter(name ?? "Player", Input, Output, menuFactory ?? Globals.MenuFactory);
                break;

            case FighterType.MegaChicken:
                ret = new MegaChicken(level, ChanceService);
                break;

            case FighterType.Egg:
                if (magicType == MagicType.None)
                {
                    int magicIndex = ChanceService.WhichEventOccurs(Globals.EggMagicTypes.Length);
                    magicType = Globals.EggMagicTypes[magicIndex];
                }
                ret = new Egg(magicType);
                break;

            case FighterType.DancerBoss:
                ret = new DancerBoss(fighterClass, level, ChanceService);
                break;

            case FighterType.Zombie:
                ret = new Zombie(level, ChanceService);
                break;

            case FighterType.Warrior:
                ret = new Warrior(level, ChanceService);
                break;

            case FighterType.ShieldGuy:
                ret = new ShieldGuy(level, ChanceService);
                break;

            case FighterType.Barbarian:
                ret = new Barbarian(level, ChanceService);
                break;

            case FighterType.Shade:
                ret = GetShade(level, name);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type,
                                                      "The specified type is invalid for FighterFactory to initialize!");
            }

            return(ret);
        }
Ejemplo n.º 29
0
    private Tile Create(TileType type)
    {
        switch (type)
        {
        case (TileType.Hero):
        {
            int heroX = rando.Next(0, width);                       //get random width

            int heroY = rando.Next(0, height);                      //get random height

            while ((mapArray[heroX, heroY] is  EmptyTile) == false) //while the tile is already taken, create a random X and Y position
            {
                heroX = rando.Next(0, width);                       //get random width

                heroY = rando.Next(0, height);                      //get random height
            }

            Hero tempHero = new Hero(heroX, heroY, 20, 20);

            return(tempHero);
        }

        case (TileType.Enemy):
        {
            int gobX = rando.Next(0, width);                     //get random width

            int gobY = rando.Next(0, height);                    //get random height

            while ((mapArray[gobX, gobY] is EmptyTile) == false) //while the tile is already taken, create a random X and Y position
            {
                gobX = rando.Next(0, width);                     //get random width

                gobY = rando.Next(0, height);                    //get random height
            }

            Random randEnemy = new Random(Guid.NewGuid().GetHashCode());

            for (int i = 0; i < 2; ++i)
            {
                int getRandEnemy = randEnemy.Next(0, 2);

                if (getRandEnemy == 1)
                {
                    Goblin tempGob = new Goblin(gobX, gobY, 10, 1);

                    return(tempGob);
                }
                else
                {
                    Mage tempMage = new Mage(gobX, gobY, 5, 5);

                    return(tempMage);
                }
            }

            return(null);
        }

        case (TileType.Gold):
        {
            int goldX = rando.Next(0, width);                      //get random width

            int goldY = rando.Next(0, height);                     //get random height

            while ((mapArray[goldX, goldY] is EmptyTile) == false) //while the tile is already taken, create a random X and Y position
            {
                goldX = rando.Next(0, width);                      //get random width

                goldY = rando.Next(0, height);                     //get random height
            }

            Gold tempGold = new Gold(goldX, goldY);

            return(tempGold);
        }

        default:
            break;
        }
        return(null);
    }
Ejemplo n.º 30
0
 public Guarding(Goblin goblin)
 {
     this.goblin = goblin;
 }
Ejemplo n.º 31
0
    public void Action(MappableActions action)
    {
        if (Orders.Any(o => o.Order == action))
        {
            Team.LeaderShout(Orders.First(o => o.Order == action));
        }

        switch (action)
        {
        case MappableActions.Hide:
            //Shout from leader
            Team.Hide();
            break;

        case MappableActions.Attack:
            Team.Attack();
            break;

        case MappableActions.Flee:
            Team.Flee();
            break;

        case MappableActions.Menu:
            break;

        case MappableActions.FixCamOnLeader:
            FollowGoblin = Team.Leader;
            break;

        case MappableActions.Camp:
            Team.Camp();
            break;

        case MappableActions.InvincibleMode:
            GameManager.Instance.InvincibleMode = !GameManager.Instance.InvincibleMode;
            break;

        case MappableActions.AddXp:
            CharacterView.AddXp();
            break;

        case MappableActions.Move:
            MoveView();
            break;

        case MappableActions.ZoomIn:
            ZoomIn();
            break;

        case MappableActions.ZoomOut:
            ZoomOut();
            break;

        case MappableActions.Pause:
            if (GameManager.Instance.GamePaused)
            {
                GameManager.UnPause();
            }
            else
            {
                GameManager.Pause();
            }
            break;

        case MappableActions.Kill:
            CharacterView.Kill();
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }