Exemplo n.º 1
0
        public Critter(string name, int baseAttack, int baseDefense, int baseSpeed, int affinitieIndex, float hp)
        {
            affinityArray = new Affinity();
            Moveset       = new List <Skill>();
            string[] newAffinities;
            Name        = name;
            BaseAttack  = baseAttack;
            BaseDefense = baseDefense;
            BaseSpeed   = baseSpeed;

            CurrentDef = baseDefense;
            CurrentAtq = baseAttack;
            CurrentSpd = baseSpeed;
            //hacemos una validacion para no darle vida de zero a la criatura
            if (hp >= 0)
            {
                Hp = hp;
            }
            else
            {
                Hp = 200;
            }

            newAffinities = affinityArray.ReturnAffinities();

            if (affinitieIndex >= newAffinities.Length)
            {
                Affinity = newAffinities[newAffinities.Length - 1];
            }
            else if (affinitieIndex < 0)
            {
                Affinity = newAffinities[0];
            }
            else
            {
                Affinity = newAffinities[affinitieIndex];
            }
        }
Exemplo n.º 2
0
        static public void CombatSimulator()
        {
            Affinity affinity = new Affinity(); //definimos las afinidades para acceder a la tableta
            Player   player1  = new Player();
            Player   player2  = new Player();


            //Critter defCritter = new Critter("Alma", 75, 15, 50, 2, 500); //creamos una nueva criatura para combatir
            //Critter atqCritter = new Critter("Alma", 20, 60, 20, 1, 350); //creamos un criter atacante y uno defensor

            //player1.Critters.Add(defCritter); // le agregamos los criter a cada usuario
            //player2.Critters.Add(atqCritter);

            // AttackSkill attackSkillP1 = new AttackSkill("pancho Power", 10, 2); //creamos un ataque momentaneo para el primer critter
            //AttackSkill attackSkillP2 = new AttackSkill("pancho Power", 5, 1); // creamos un ataque momentaneo para el segundo



            Random range = new Random();


            //player1.Critters[0].DefineSkills(1, attackSkillP1); //le agregamos los ataques al move set
            //player2.Critters[0].DefineSkills(1, attackSkillP2);

            player1.EquipCritters(1);
            player2.EquipCritters(1);

            int coin = range.Next(0, 2);

            while (player2.Critters[0].Hp >= 0 || player1.Critters[0].Hp >= 0)
            {
                if (player2.Critters[0].BaseSpeed > player1.Critters[0].BaseSpeed)
                {
                    if (player2.Critters[0].Moveset[0] is AttackSkill askil)
                    {
                        askil = player2.Critters[0].Moveset[0] as AttackSkill;

                        float mult = affinity.AfinityTable(askil.MyAffinity, player1.Critters[0].Affinity);
                        player1.Critters[0].OnHit(player2.Critters[0].BaseAttack, askil.Power, mult);

                        if (player1.Critters[0].Hp <= 0)
                        {
                            break;
                        }
                    }
                    if (player1.Critters[0].Moveset[0] is AttackSkill askil1)
                    {
                        askil1 = player1.Critters[0].Moveset[0] as AttackSkill;

                        float mult = affinity.AfinityTable(askil1.MyAffinity, player2.Critters[0].Affinity);
                        player2.Critters[0].OnHit(player1.Critters[0].BaseAttack, askil1.Power, mult);

                        if (player2.Critters[0].Hp <= 0)
                        {
                            break;
                        }
                    }
                }
                else if (player1.Critters[0].BaseSpeed > player2.Critters[0].BaseSpeed)
                {
                    if (player1.Critters[0].Moveset[0] is AttackSkill askil)
                    {
                        askil = player1.Critters[0].Moveset[0] as AttackSkill;

                        float mult = affinity.AfinityTable(askil.MyAffinity, player2.Critters[0].Affinity);
                        player2.Critters[0].OnHit(player1.Critters[0].BaseAttack, askil.Power, mult);

                        if (player2.Critters[0].Hp <= 0)
                        {
                            break;
                        }
                    }
                    if (player2.Critters[0].Moveset[0] is AttackSkill askil1)
                    {
                        askil1 = player2.Critters[0].Moveset[0] as AttackSkill;

                        float mult = affinity.AfinityTable(askil1.MyAffinity, player1.Critters[0].Affinity);
                        player1.Critters[0].OnHit(player2.Critters[0].BaseAttack, askil1.Power, mult);

                        if (player1.Critters[0].Hp <= 0)
                        {
                            break;
                        }
                    }
                }
                else if (player2.Critters[0].BaseSpeed == player1.Critters[0].BaseSpeed && coin == 0)
                {
                    if (player2.Critters[0].Moveset[0] is AttackSkill askil)
                    {
                        askil = player2.Critters[0].Moveset[0] as AttackSkill;

                        float mult = affinity.AfinityTable(askil.MyAffinity, player1.Critters[0].Affinity);
                        player1.Critters[0].OnHit(player2.Critters[0].BaseAttack, askil.Power, mult);

                        if (player1.Critters[0].Hp <= 0)
                        {
                            break;
                        }
                    }
                    if (player1.Critters[0].Moveset[0] is AttackSkill askil1)
                    {
                        askil1 = player1.Critters[0].Moveset[0] as AttackSkill;

                        float mult = affinity.AfinityTable(askil1.MyAffinity, player2.Critters[0].Affinity);
                        player2.Critters[0].OnHit(player1.Critters[0].BaseAttack, askil1.Power, mult);

                        if (player2.Critters[0].Hp <= 0)
                        {
                            break;
                        }
                    }
                }
                else if (player1.Critters[0].BaseSpeed == player2.Critters[0].BaseSpeed && coin == 1)
                {
                    if (player1.Critters[0].Moveset[0] is AttackSkill askil)
                    {
                        askil = player1.Critters[0].Moveset[0] as AttackSkill;

                        float mult = affinity.AfinityTable(askil.MyAffinity, player2.Critters[0].Affinity);
                        player2.Critters[0].OnHit(player1.Critters[0].BaseAttack, askil.Power, mult);

                        if (player2.Critters[0].Hp <= 0)
                        {
                            break;
                        }
                    }
                    if (player2.Critters[0].Moveset[0] is AttackSkill askil1)
                    {
                        askil1 = player2.Critters[0].Moveset[0] as AttackSkill;

                        float mult = affinity.AfinityTable(askil1.MyAffinity, player1.Critters[0].Affinity);
                        player1.Critters[0].OnHit(player2.Critters[0].BaseAttack, askil1.Power, mult);

                        if (player1.Critters[0].Hp <= 0)
                        {
                            break;
                        }
                    }
                }
            }

            Console.WriteLine("-----------------------------------------------------------------");

            if (player2.Critters[0].Hp <= 0)
            {
                Console.WriteLine("Cantidad de Criaturas Player 1: " + player1.Critters.Count);
                Console.WriteLine("Cantidad de Criaturas Player 2: " + player2.Critters.Count);
                Console.WriteLine("-----------------------------------------------------------------");

                player1.Critters.Add(player2.Critters[0]);
                player2.Critters.Remove(player2.Critters[0]);


                Console.WriteLine("Cantidad de Criaturas Player 1: " + player1.Critters.Count);
                Console.WriteLine("Cantidad de Criaturas Player 2: " + player2.Critters.Count);
                Console.WriteLine("Ganador:  Player 1 ");
            }

            Console.WriteLine("-----------------------------------------------------------------");

            if (player1.Critters[0].Hp <= 0)
            {
                Console.WriteLine("Cantidad de Criaturas Player 1: " + player1.Critters.Count);
                Console.WriteLine("Cantidad de Criaturas Player 2: " + player2.Critters.Count);
                Console.WriteLine("-----------------------------------------------------------------");

                player2.Critters.Add(player1.Critters[0]);
                player1.Critters.Remove(player1.Critters[0]);

                Console.WriteLine("Cantidad de Criaturas Player 1: " + player1.Critters.Count);
                Console.WriteLine("Cantidad de Criaturas Player 2: " + player2.Critters.Count);

                Console.WriteLine("Ganador:  Player 2 ");
            }
        }