Exemplo n.º 1
0
      private void pegarDados()
      {
          nome = cbnSuperHeroi.Text;
          if (nome == "Batman")
          {
              Batman bat = new Batman();
              bat.ObterDados();
              nomeFic    = bat.NomeFicticio;
              identidade = bat.Identidade;
              cidade     = bat.Cidade;

              MessageBox.Show("Conhecido como: " + nomeFic + "\n Sua identidade verdadeira é:" + identidade + "\n Ele defende a cidade de:" + cidade);
          }
          else if (nome == "Super-Man")
          {
              SuperMan super = new SuperMan();
              super.ObterDados();
              nomeFic    = super.NomeFicticio;
              identidade = super.Identidade;
              cidade     = super.Cidade;
              MessageBox.Show("Conhecido como: " + nomeFic + "\n Sua identidade verdadeira é:" + identidade + "\n Ele defende a cidade de:" + cidade + "\npoderes:" + super.Poderes[0] + ", " + super.Poderes[1] + ", " + super.Poderes[2]);
          }
          else
          {
              MessageBox.Show("Selecione um Super-Herói!!!");
          }
      }
Exemplo n.º 2
0
    protected void enemyAttack()
    {
        List <Piece> pieces = new List <Piece>(board.Pieces);
        Batman       batman = board.getBatman();

        foreach (Piece p in pieces)
        {
            if (p != batman && p is ActivePiece)
            {
                ActivePiece e = (ActivePiece)p;
                if (e.State == ActivePiece.ActivePieceState.ALERT)
                {
                    if (batman != null && e.canMoveTo(board, batman.Pos))
                    {
                        board.movePieceTo(e, batman.Pos);
                        board.removePiece(batman);
                        if (onBatmanDead != null)
                        {
                            onBatmanDead();
                        }

                        Debug.Log("The Batman is Dead.");
                    }
                }
            }
        }
    }
Exemplo n.º 3
0
    static void Main(string[] args)
    {
        string[] inputs;
        inputs = Console.ReadLine().Split(' ');
        int W = int.Parse(inputs[0]);          // width of the building.
        int H = int.Parse(inputs[1]);          // height of the building.
        int N = int.Parse(Console.ReadLine()); // maximum number of turns before game over.

        inputs = Console.ReadLine().Split(' ');
        int X0 = int.Parse(inputs[0]);
        int Y0 = int.Parse(inputs[1]);

        House  house  = new House(W, H);
        Batman batman = new Batman(X0, Y0, house);
        // game loop
        Direction curDir = Direction.U;

        while (true)
        {
            string bombDir = Console.ReadLine();             // the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)

            // Write an action using Console.WriteLine()
            // To debug: Console.Error.WriteLine("Debug messages...");
            Enum.TryParse(bombDir, out curDir);
            string nextMove = batman.BatmanMove(curDir);
            // the location of the next window Batman should jump to.
            Console.WriteLine(nextMove);
        }
    }
Exemplo n.º 4
0
    protected void enemyAttack()
    {
        List <Piece> pieces = new List <Piece>(board.Pieces);
        Batman       batman = board.getBatman();

        foreach (Piece p in pieces)
        {
            if (p != batman && p is ActivePiece)
            {
                ActivePiece e = (ActivePiece)p;
                if (e.State == ActivePiece.ActivePieceState.ALERT)
                {
                    if (batman != null && e.canMoveTo(board, batman.Pos))                      //If you can attack the batman, do so
                    {
                        board.movePieceTo(e, batman.Pos);
                        //board.removePiece(batman);
                        //batman.State= Piece.ActivePieceState.Dead;
                        if (onBatmanDead != null)
                        {
                            onBatmanDead();
                        }

                        Debug.Log("The Batman is Dead.");
                    }
                    else                       //Attack where the Batman was
                    {
                        if (e.canMoveTo(board, e.TargetPos))
                        {
                            board.movePieceTo(e, e.TargetPos);
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 5
0
    protected void testAlert()
    {
        Batman batman = board.getBatman();

        foreach (Piece p in board.Pieces)
        {
            if (p != batman && p is ActivePiece)
            {
                ActivePiece e = (ActivePiece)p;
                if (e.State == ActivePiece.ActivePieceState.IDLE)
                {
                    if (batman != null && e.canMoveTo(board, batman.Pos))                        //Its the Bat, get 'im!!
                    {
                        e.State     = ActivePiece.ActivePieceState.ALERT;
                        e.TargetPos = batman.Pos;
                    }
                }
                else if (e.State == ActivePiece.ActivePieceState.ALERT)                    //Cannot see the Batman, go idle
                {
                    e.State = ActivePiece.ActivePieceState.IDLE;
                }
                //else if( e.State == ActivePiece.ActivePieceState.DEAD) { //stay dead
                //	;
                //}
            }
        }
    }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            string[] inputs;
            inputs = Console.ReadLine().Split(' ');
            int width          = int.Parse(inputs[0]);          // width of the building.
            int height         = int.Parse(inputs[1]);          // height of the building.
            int jumpsRemaining = int.Parse(Console.ReadLine()); // maximum number of turns before game over.

            inputs = Console.ReadLine().Split(' ');
            int batmanX = int.Parse(inputs[0]);
            int batmanY = int.Parse(inputs[1]);

            var batman   = new Batman(batmanX, batmanY);
            var building = new Building(width, height, batman);

            // game loop
            while (true)
            {
                string bombDir = Console.ReadLine(); // the direction of the bombs from batman's current location (U, UR, R, DR, D, DL, L or UL)

                building.ReducePlayArea(bombDir);
                building.MoveBatman();


                // Write an action using Console.WriteLine()
                // To debug: Console.Error.WriteLine("Debug messages...");


                // the location of the next window Batman should jump to.
                Console.WriteLine($"{building.Batman.X} {building.Batman.Y}");
            }
        }
Exemplo n.º 7
0
        public void SpecialCaseWithDestructuringObject()
        {
            Hero hero = new Batman();

            var message = hero switch
            {
                { lastName : "Wayne" } => "Sure, you are batman",
Exemplo n.º 8
0
    // Use this for initialization
    void Start()
    {
        input    = new Vector3();
        velocity = new Vector3();

        blocs = Manager.Instance.Blocs;

        playerCollider = GetComponent <BoxCollider>();
        playerSprite   = GetComponent <SpriteRenderer>();
        attackSprite   = transform.Find("Attack").GetComponent <SpriteRenderer>();
        attackCollider = attackSprite.GetComponent <BoxCollider>();

        opponent = Manager.Instance.GetOpponent(player1);

        if (!player1)
        {
            inputHorizontalName = "Horizontal2";
            inputVerticalName   = "Vertical2";
            inputAttack         = KeyCode.K;
            inputAttackBullet   = KeyCode.L;
        }

        if (!spriteStand || !spriteDuck || !spriteAttack || !spriteDead)
        {
            Debug.Log("*Woops* public links broken");
        }

        playerStartPosition = transform.position;
        playerEndPosition   = transform.position;
        playerEndPosition.x = Manager.ScreenRight;

        batman = Manager.Instance.Batman;
    }
Exemplo n.º 9
0
        public GothamCity()
        {
            var batgirl = new Batgirl(null);
            var robin   = new Robin(batgirl);
            var batman  = new Batman(robin);

            _protector = batman;
        }
Exemplo n.º 10
0
        public void BatmanAndVampireBatCanReturnDifferentStringsForHowIFlyMethod_ProvingMethodOverride()
        {
            Batman     bruceWayne = new Batman();
            VampireBat vampBat    = new VampireBat();


            Assert.NotEqual(bruceWayne.HowIFly(), vampBat.HowIFly());
        }
Exemplo n.º 11
0
        public void ObjectAvoidDestructuringAProperty()
        {
            // Use _ when you don't need to extract a property
            var batman = new Batman("Bruce", "Wayne");

            var(_, lastName) = batman;  // use Deconstruct(out string fistName, out string lastName)

            Assert.Equal(FILL_ME_IN, lastName);
        }
Exemplo n.º 12
0
        public void ObjectCanBeDestructured()
        {
            var batman = new Batman("Bruce", "Wayne");

            var(firstName, lastName) = batman;  // use Deconstruct(out string fistName, out string lastName)

            Assert.Equal(FILL_ME_IN, firstName);
            Assert.Equal(FILL_ME_IN, lastName);
        }
Exemplo n.º 13
0
        public Building(int width, int height, Batman batman)
        {
            Batman = batman;

            height0 = 0;
            height1 = height;
            width0  = 0;
            width1  = width;
            SetupPlayArea();
        }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            Hero hero = new Batman();

            hero.SetHeroStaff(new Fly());
            hero.DoheroStaff();

            hero.SetHeroStaff(new Attack());

            hero.DoheroStaff();
        }
Exemplo n.º 15
0
        public void ObjectDestrucuringCanBeConfigure()
        {
            // Use _ whn you don't need to extract a property
            var batman = new Batman("Bruce", "Wayne");

            var(firstName, _, heroName) = batman;  // use Deconstruct(out string firstName, out string lastName, out string heroName)

            Assert.Equal(FILL_ME_IN, heroName);

            // Do you think it is a good practice ?
        }
 // Start is called before the first frame update
 void Start()
 {
     ySpeed        = 85;
     xSpeed        = 85;
     platforms     = new Platforms[3];
     theBats       = GameObject.FindWithTag("Batman").GetComponent <Batman>();
     thePlatforms  = GameObject.FindWithTag("PlatformFloor").GetComponent <Platforms>();
     thePlatforms1 = GameObject.FindWithTag("PlatformFloor1").GetComponent <Platforms>();
     platforms[0]  = GameObject.FindWithTag("PlatformFloor2").GetComponent <Platforms>();
     platforms[1]  = GameObject.FindWithTag("PlatformFloor3").GetComponent <Platforms>();
     platforms[2]  = GameObject.FindWithTag("PlatformFloor4").GetComponent <Platforms>();
 }
Exemplo n.º 17
0
        static void Heroes()
        {
            var robin       = new Robin();
            var batman      = new Batman(robin);
            var joker       = new Joker();
            var harleyQuinn = new HarleyQuinn();

            batman.Goto("Bludhaven");
            batman.Fight(harleyQuinn);
            batman.Fight(joker);
            batman.Goto("Hall of Justice");
        }
Exemplo n.º 18
0
        public void PatternMatchingCastObject()
        {
            Hero hero = new Batman();

            var gadgets = GetGadgetsWithIf(hero);

            Assert.Equal("Batarang,Batgyro,Batsuit,Batmobile,Belt", string.Join(",", gadgets));

            var gadgets2 = GetGadgetsWithCase(hero);

            Assert.Equal("Batarang,Batgyro,Batsuit,Batmobile,Belt", string.Join(",", gadgets2));
        }
        public void PatternMatchingCastObject()
        {
            Hero hero = new Batman();

            var gadgets = GetGadgetsWithIf(hero);

            Assert.Equal(FILL_ME_IN, string.Join(",", gadgets));

            var gadgets2 = GetGadgetsWithCase(hero);

            Assert.Equal(FILL_ME_IN, string.Join(",", gadgets2));
        }
Exemplo n.º 20
0
        static void Heroes()
        {
            var mediator = new TowerOfJustice();
            var batman   = new Batman(mediator);
            var superman = new Superman(mediator);
            var robin    = new Robin(mediator);

            superman.send(new HeroMessage("Help needed in Metropolis!", batman, robin));
            batman.send(new HeroMessage("On the way to Metropolis!", superman));

            batman.send(new HeroMessage("Help needed in Gotham City!", superman, robin));
            superman.send(new HeroMessage("On the way to Gotham City!", batman));
            robin.send(new HeroMessage("On the way!", batman));
        }
Exemplo n.º 21
0
        static void Main(string[] args)
        {
            Batman    batman    = new Batman("Batman", "Dark Stuff");
            Wolverine wolverine = new Wolverine("wolverine", "regenerative power");
            Superman  superman  = new Superman("superman", "fly");
            Spiderman spiderman = new Spiderman("Spiderman", "throw spider web");


            //Encapsulation .....
            Console.WriteLine(wolverine.ToString());
            Console.WriteLine(superman);
            Console.WriteLine(spiderman);
            Console.WriteLine(batman);
        }
Exemplo n.º 22
0
        public void SpecialCaseWithWhenClause()
        {
            Hero hero = new Batman();

            hero.ReplaceBy("Jean-Paul", "Valley");

            var message = hero switch
            {
                Batman batman when batman.lastName == "Wayne" => "Sure, you are batman", // Special case
                Batman batman => "You look like batman, but I don't think you are",
                _ => "I don't know you"                                                  // default case
            };

            Assert.Equal("You look like batman, but I don't think you are", message);
        }
Exemplo n.º 23
0
        public void PatternMatchingCaseSugarSyntax()
        {
            /// In the two previous examples, each switch case always returns a value.
            /// There is a sugar syntax for that
            /// Let's refactor the second one.
            Hero hero = new Batman();

            var gadgets = hero switch
            {
                Batman batman => batman.gadget,
                _ => new string[0] // default case
            };

            Assert.Equal("Batarang,Batgyro,Batsuit,Batmobile,Belt", string.Join(",", gadgets));
        }
Exemplo n.º 24
0
        public HeroesController()
        {
            context = new ApplicationDbContext();

            Hulk          hulk          = new Hulk();
            Batman        batman        = new Batman();
            Goliath       goliath       = new Goliath();
            OptimusPrime  optimusPrime  = new OptimusPrime();
            List <Heroes> initialHeroes = new List <Heroes>();

            initialHeroes.Add(hulk);
            initialHeroes.Add(batman);
            initialHeroes.Add(goliath);
            initialHeroes.Add(optimusPrime);
            CheckInitialHeroes(initialHeroes);
        }
Exemplo n.º 25
0
        public bool CheckIfHeroIsDefault(int id)
        {
            Hulk         hulk         = new Hulk();
            Batman       batman       = new Batman();
            Goliath      goliath      = new Goliath();
            OptimusPrime optimusPrime = new OptimusPrime();
            var          listedHeroes = (from r in context.Heroes
                                         where r.heroId == id
                                         select r.heroName).FirstOrDefault();

            if (listedHeroes.ToString() == hulk.heroName || listedHeroes.ToString() == batman.heroName || listedHeroes.ToString() == goliath.heroName || listedHeroes.ToString() == optimusPrime.heroName)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 26
0
        private void InitializeMonsters() //initializes monsters and adds them to a list
        {
            NiceOldLady niceOldLady = new NiceOldLady();
            Greta       greta       = new Greta();
            Ghandi      ghandi      = new Ghandi();
            MLK         mLK         = new MLK();
            ObiWan      obiWan      = new ObiWan();
            Superman    superman    = new Superman();
            Frodo       frodo       = new Frodo();
            Batman      batman      = new Batman();
            McFly       mcFly       = new McFly();
            HarryPotter harryPotter = new HarryPotter();
            TrashMob    trashMob    = new TrashMob();

            listOfSpecialMonsters.AddRange(new Monster[]
            {
                greta, niceOldLady, ghandi, mLK, obiWan, superman, frodo, batman, mcFly, harryPotter
            });

            List <Monster> listToShuffle = new List <Monster>()
            {
                greta, niceOldLady, ghandi, mLK, obiWan, superman, frodo, batman, mcFly, harryPotter
            };

            //randomizes monsters to a new list so that the player doesnt always meet them in the same order
            int i = listToShuffle.Count;

            while (i > 0)
            {
                if (random.Next(10) <= 7)
                {
                    listOfMonsters.Add(trashMob);
                }
                else
                {
                    i--;
                    int listIndex = random.Next(i + 1);
                    listOfMonsters.Add(listToShuffle[listIndex]);
                    listToShuffle.RemoveAt(listIndex);
                }
            }
        }
Exemplo n.º 27
0
    protected void testAlert()
    {
        Batman batman = board.getBatman();

        foreach (Piece p in board.Pieces)
        {
            if (p != batman && p is ActivePiece)
            {
                ActivePiece e = (ActivePiece)p;
                if (batman != null && e.canMoveTo(board, batman.Pos))
                {
                    e.State = ActivePiece.ActivePieceState.ALERT;
                }
                else
                {
                    e.State = ActivePiece.ActivePieceState.IDLE;
                }
            }
        }
    }
        public void Setup()
        {
            //1
            h1           = new Herramienta("bati_navaja", 6, 2);
            h2           = new Herramienta("bati_lazo", 10, 7);
            batiCinturon = new List <Herramienta>()
            {
                h1, h2
            };
            batman = new Batman(batiCinturon);

            psico  = new Psicopata(10);
            marron = new Guante_Marron();
            blanco = new Guante_Blanco();
            robin  = new Robin_Hood();
            et     = new Extraterrestre(2);

            c1  = new Ciudadano(10000000);
            c7  = new Ciudadano(6000000);
            c4  = new Ciudadano(2000000);
            c2  = new Ciudadano(1000000);
            c9  = new Ciudadano(522000);
            c8  = new Ciudadano(500000);
            c10 = new Ciudadano(52000);
            c11 = new Ciudadano(51000);
            c3  = new Ciudadano(5000);
            c5  = new Ciudadano(5000);
            c6  = new Ciudadano(5000);

            pandilla = new List <Villano>()
            {
                blanco, marron, psico
            };

            ciudadanos = new List <Ciudadano>()
            {
                c1, c2, c3, c4, c5, c6
            };

            int cant = ciudadanos.Count();
        }
Exemplo n.º 29
0
        public void Setup()
        {
            batiriñonera = new List <Tecnologias>();
            Tecnologias batibumerangs = new Tecnologias("Batibumerangs", 100, 1);

            batiriñonera.Add(batibumerangs);
            batman = new Batman(batiriñonera);

            villanos = new List <Villano>();
            Psicopatas psicopata = new Psicopatas(5, 100);

            villanos.Add(psicopata);

            Habitante habitante   = new Habitante(2000000);
            Habitante habitante1  = new Habitante(7000000);
            Habitante habitante2  = new Habitante(8000000);
            Habitante habitante3  = new Habitante(9000000);
            Habitante habitante4  = new Habitante(10000000);
            Habitante habitante5  = new Habitante(11000000);
            Habitante habitante6  = new Habitante(12000000);
            Habitante habitante7  = new Habitante(13000000);
            Habitante habitante8  = new Habitante(14000000);
            Habitante habitante9  = new Habitante(15000000);
            Habitante habitante10 = new Habitante(16000000);
            Habitante habitante11 = new Habitante(500000);

            habitantes = new List <Habitante>();
            habitantes.Add(habitante);
            habitantes.Add(habitante1);
            habitantes.Add(habitante2);
            habitantes.Add(habitante3);
            habitantes.Add(habitante4);
            habitantes.Add(habitante5);
            habitantes.Add(habitante6);
            habitantes.Add(habitante7);
            habitantes.Add(habitante8);
            habitantes.Add(habitante9);
            habitantes.Add(habitante10);
            habitantes.Add(habitante11);
            ciudadGotica = new CiudadGotica(habitantes);
        }
Exemplo n.º 30
0
        public void Setup()
        {
            soplete    = new BatiRiñonera("Bati-Soplete", 30, 5);
            cinturon   = new BatiRiñonera("Bati-Cinturon", 20, 15);
            puños      = new BatiRiñonera("Bati-Puños", 55, 30);
            tecnologia = new List <BatiRiñonera>()
            {
                soplete, cinturon, puños
            };
            batman = new Batman(tecnologia);

            extra      = new Extraterrestres(6, 3);
            blanco     = new GuanteBlanco();
            marron     = new GuanteMarron();
            psicopatas = new Psicopatas(10);
            robin      = new RobinHood();

            villanos = new List <Villanos>()
            {
                extra, blanco, marron
            };

            h1  = new Habitantes(2000000);
            h2  = new Habitantes(50000);
            h3  = new Habitantes(6000000);
            h4  = new Habitantes(7000000);
            h5  = new Habitantes(7500000);
            h6  = new Habitantes(40000);
            h7  = new Habitantes(8000000);
            h8  = new Habitantes(10000000);
            h9  = new Habitantes(150000);
            h10 = new Habitantes(650000);

            personas = new List <Habitantes>()
            {
                h1, h2, h3, h4, h5, h6, h7, h8, h9, h10
            };

            gotica = new Gotica();
        }