예제 #1
0
        public Player(BattleArena arena, ControlSet Controls, int ID, string pokemon)
        {
            this.World  = arena;
            PokemonName = pokemon;
            anim        = new Animation(Pokemon.Animation);
            anim.state.SetAnimation("idle", true);
            foreach (MixItem item in Pokemon.MixQueue)
            {
                anim.stateData.SetMix(item.From, item.To, item.Time);
            }
            this.Controls       = Controls;
            this.HP             = Pokemon.HP;
            this.Attack         = Pokemon.Attack;
            this.Defense        = Pokemon.Defense;
            this.SpecialAttack  = Pokemon.SpecialAttack;
            this.SpecialDefense = Pokemon.SpecialDefense;
            this.Speed          = Pokemon.Speed;
            this.ID             = (short)ID;

            for (int i = 0; i < 4; i++)
            {
                Move[i] = new MoveInstance(Pokemon.Move[i]);
            }

            InitPhysics(arena);
        }
예제 #2
0
        private static void Initialize()
        {
            ResourceManager.Initialize();

            Arena   = new Forrest();
            Player1 = new Player(Arena, Controls.Player1, -1, "squirtle");             //needs to be negative, thanks to box2d
            Player2 = new Player(Arena, Controls.Player2, -2, "bulbasaur");

            Player1.SetPosition(-5, 3);
            Player2.SetPosition(5, 3);
            Player1.Direction = 1;

            Camera = new FloatingCamera(Player1, Player2);

            DrawTime.Start();
            UpdateTime.Start();
        }
예제 #3
0
        private void InitPhysics(BattleArena arena)
        {
            // Define the dynamic body. We set its position and call the body factory.
            BodyDef bodyDef = new BodyDef();

            bodyDef.Position.Set(0.0f, 4.0f);
            body = arena._world.CreateBody(bodyDef);

            // Define another box shape for our dynamic body.
            PolygonDef shapeDef = new PolygonDef();

            shapeDef.SetAsBox(Pokemon.Width / 2, Pokemon.Height / 2);

            // Set the box density to be non-zero, so it will be dynamic.
            shapeDef.Density = 1.0f;

            // Override the default friction.
            //shapeDef.Friction = 2f;

            // Add the shape to the body.
            Fixture fix = body.CreateFixture(shapeDef);

            fix.UserData            = this;
            fix.Filter.GroupIndex   = this.ID;
            fix.Filter.CategoryBits = 0x0002;
            fix.Filter.MaskBits     = 0xFFFF;

            // Now tell the dynamic body to compute it's mass properties base
            // on its shape.
            body.SetMassFromShapes();
            var mass = body.GetMassData();

            mass.Mass = Pokemon.Weight / 10;
            body.SetMass(mass);

            body.SetFixedRotation(true);
        }