public Player(BattleArena arena, ControlSet Controls, int ID, PlayerDef definition) { this.World = arena; PokemonName = definition.Pokemon.Name; 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(definition.Moves[i]); } InitPhysics(arena); }
public void Uninitialize() { Arena = null; Player1.Unload(); Player2.Unload(); Player1 = null; Player2 = null; Camera.Disable(); }
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.Density = 1; fix.Friction = 0.3f; fix.Restitution = 0.1f; fix.UserData = this; fix.Filter.GroupIndex = this.ID; fix.Filter.CategoryBits = 0x0002; if (Pokemon.Types.Contains(PokemonType.Ghost)) { fix.Filter.MaskBits = 0xFFFF - 0x0002; } else { fix.Filter.MaskBits = 0xFFFF; } // Now tell the dynamic body to compute it's mass properties base // on its shape. var mass = body.GetMassData(); mass.Mass = Pokemon.Weight; body.SetMass(mass); body.SetFixedRotation(true); }
public void Initialize() { if (LoadableBattleArena.Arenas.Count > 0) { Arena = LoadableBattleArena.Arenas[0]; Arena.Bind(); } else { Arena = new Forrest(); } Player1 = new Player(Arena, Controls.Player1, -1, PlayerOne); Player2 = new Player(Arena, Controls.Player2, -2, PlayerTwo); Player1.SetPosition(-5, 3); Player2.SetPosition(5, 3); Player1.Direction = 1; Camera = new FloatingCamera(Player1, Player2); DeadTimer = 0.0f; }
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.Density = 1; fix.Friction = 0.3f; fix.Restitution = 0.1f; fix.UserData = this; fix.Filter.GroupIndex = this.ID; fix.Filter.CategoryBits = 0x0002; if (Pokemon.Types.Contains(PokemonType.Ghost)){ fix.Filter.MaskBits = 0xFFFF - 0x0002; } else { fix.Filter.MaskBits = 0xFFFF; } // Now tell the dynamic body to compute it's mass properties base // on its shape. var mass = body.GetMassData(); mass.Mass = Pokemon.Weight; body.SetMass(mass); body.SetFixedRotation(true); }