예제 #1
0
        public void CreateFighterPlayers(int amount)
        {
            fighterPlayers = new List <FighterPlayer>();
            for (int i = 0; i < amount; i++)
            {
                Dictionary <string, Animation> fighterAnimations = new Dictionary <string, Animation>();
                Texture2D texture   = Content.Load <Texture2D>("Ape");
                Animation animation = new Animation(texture);
                fighterAnimations.Add("idle", animation);
                Body body = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(150),
                                                        ConvertUnits.ToSimUnits(250), 10.0f);
                body.BodyType            = BodyType.Dynamic;
                body.Position            = ConvertUnits.ToSimUnits(100, 100);
                body.CollisionCategories = Category.Cat4;
                body.CollidesWith        = Category.Cat1;
                body.Friction            = 0.6f;
                Body feetSensor = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(150),
                                                              ConvertUnits.ToSimUnits(251), 10.0f);
                feetSensor.BodyType            = BodyType.Dynamic;
                feetSensor.IsSensor            = true;
                feetSensor.CollisionCategories = Category.Cat3;
                feetSensor.CollidesWith        = Category.Cat2;

                FighterPlayer player = new FighterPlayer(fighterAnimations, body, feetSensor, (PlayerIndex)i);
                fighterPlayers.Add(player);
            }
        }
예제 #2
0
        public void CreateFighterPlayers(int amount, int health, int health2)
        {
            playersLeft = 0;

            fighterPlayers = new List <FighterPlayer>();
            for (int i = 0; i < amount; i++)
            {
                Texture2D healthBar = Content.Load <Texture2D>("healthbar");
                Texture2D redBar    = Content.Load <Texture2D>("redbar");
                Dictionary <string, Animation> attackAnimations = new Dictionary <string, Animation>();
                Texture2D texture   = Content.Load <Texture2D>("punchSwish");
                Animation animation = new Animation(texture);

                attackAnimations.Add("punch", animation);


                Dictionary <string, Animation> fighterAnimations = new Dictionary <string, Animation>();
                texture           = Content.Load <Texture2D>("jump");
                animation         = new Animation(texture, 5, 0.75f, new Vector2(0, 0));
                animation.runOnce = true;
                fighterAnimations.Add("jump", animation);
                texture   = Content.Load <Texture2D>("walk");
                animation = new Animation(texture, 8, 1f, new Vector2(0, 0));
                fighterAnimations.Add("walk", animation);
                texture   = Content.Load <Texture2D>("idle");
                animation = new Animation(texture, 5, 0.75f, new Vector2(0, 0));
                fighterAnimations.Add("idle", animation);


                texture   = Content.Load <Texture2D>("run");
                animation = new Animation(texture, 8, 1f, new Vector2(0, 0));
                fighterAnimations.Add("run", animation);

                texture           = Content.Load <Texture2D>("punch");
                animation         = new Animation(texture, 5, 0.5f, new Vector2(0, 0));
                animation.runOnce = true;
                fighterAnimations.Add("punch", animation);

                texture           = Content.Load <Texture2D>("death");
                animation         = new Animation(texture, 5, 0.75f, new Vector2(0, 0));
                animation.runOnce = true;
                fighterAnimations.Add("death", animation);
                Body body = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(120),
                                                        ConvertUnits.ToSimUnits(250), 10.0f);
                body.BodyType            = BodyType.Dynamic;
                body.Position            = ConvertUnits.ToSimUnits(100 * (i * 18), 100);
                body.CollisionCategories = Category.Cat4;
                body.CollidesWith        = Category.Cat1;
                body.Friction            = 0.6f;
                Body feetSensor = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(90),
                                                              ConvertUnits.ToSimUnits(260), 10.0f);
                feetSensor.BodyType            = BodyType.Dynamic;
                feetSensor.IsSensor            = true;
                feetSensor.CollisionCategories = Category.Cat3;
                feetSensor.CollidesWith        = Category.Cat2;

                FighterPlayer player = new FighterPlayer(fighterAnimations, attackAnimations, healthBar, redBar, body, feetSensor, (PlayerIndex)i);
                if (i == 0)
                {
                    player.hitPoints = health;
                }
                if (i == 1)
                {
                    player.hitPoints = health2;
                }
                fighterPlayers.Add(player);
            }
        }