public Player(World world, PlayerInformation playerInfo) : base(world, GetTexture(world, playerInfo), Vector2.Zero, GetTankSize(world, playerInfo), 0) { this.playerInfo = playerInfo; World.ServerLink.MessageReceivedEvent += HandleReceivedMessage; }
public Player(World world, PlayerInformation playerInfo) : base(world, GetTexture(world, playerInfo), Vector2.Zero, GetTankSize(world, playerInfo), 0) { this.playerInfo = playerInfo; this.Score = new Score(); //Gives scoreHUD a valid reference to start with World.ServerLink.MessageReceivedEvent += HandleReceivedMessage; }
public RemotePlayer(World world, PlayerInformation playerInfo) : base(world, playerInfo) { this.lastMsgUpdate = new TimeSpan(); // set our update frequency this.msgUpdateFrequency = new TimeSpan(0, 0, 0, 0, (int)(1000 / (UInt16)World.VarDB["updatesPerSecond"].Value)); }
public LocalPlayer(World world, PlayerInformation playerInfo) : base(world, playerInfo) { // set our update frequency this.msgUpdateFrequency = new TimeSpan(0, 0, 0, 0, (int)(1000 / (UInt16)World.VarDB["updatesPerSecond"].Value)); // TODO support if these variables change this.maxVelocity = (Single)World.VarDB["tankSpeed"].Value; this.maxAngularVelocity = (Single)World.VarDB["tankAngVel"].Value; }
public Sprite(World world, Texture2D texture, Vector2 position, Vector2 size, Single rotation, Color color) { this.World = world; this.Texture = texture; this.Position = position; this.Size = size; this.Rotation = rotation; this.Color = color; this.Bounds = new RotatedRectangle(new RectangleF(this.Position - this.Size / 2, this.Size), this.Rotation); }
public LocalPlayer(World world, PlayerInformation playerInfo) : base(world, playerInfo) { // set our update frequency this.msgUpdateFrequency = new TimeSpan(0, 0, 0, 0, (int)(1000 / (UInt16)World.VarDB["updatesPerSecond"].Value)); // TODO support if these variables change this.maxVelocity = (Single)World.VarDB["tankSpeed"].Value; this.maxAngularVelocity = (Single)World.VarDB["tankAngVel"].Value; inputService = (IInputService)World.IService.GetService(typeof(IInputService)); inputService.GetKeyboard().KeyPressed += KeyPressed; }
public AnimatedSprite(World world, Texture2D texture, Vector2 position, Vector2 size, Single rotation, Color color, Point maxFrames, Point frameSize, SpriteSheetDirection direction, bool loop) : base(world, texture, position, size, rotation, color) { this.maxFrames = maxFrames; this.frameSize = frameSize; this.direction = direction; this.Loop = loop; if (Direction == SpriteSheetDirection.LeftToRight) this.currentFrame = Point.Zero; else if (Direction == SpriteSheetDirection.RightToLeft) this.currentFrame = new Point(maxFrames.X, 0); else throw new ArgumentOutOfRangeException("direction", "Only left-to-right and right-to-left are supported at this time"); }
public Player(World world, PlayerInformation playerInfo) : base(world, GetTexture(world, playerInfo), Vector2.Zero, GetTankSize(world, playerInfo), 0) { this.playerInfo = playerInfo; this.Score = new Score(); //Gives scoreHUD a valid reference to start with explosion = new AnimatedSprite(World, World.Content.Load<Texture2D>("textures/bz/explode1"), Position, GetTankSize(World, PlayerInfo) * 4, Rotation, new Point(8, 8), new Point(64, 64), SpriteSheetDirection.RightToLeft, false); explosion.Running = false; World.ServerLink.MessageReceivedEvent += HandleReceivedMessage; }
public AngryTanks() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; // increase update rate to 120 Hz IsFixedTimeStep = true; TargetElapsedTime = new TimeSpan(0, 0, 0, 0, (int)(1000 / 120)); // instantiate server link serverLink = new ServerLink(); // get GameStateManager up and running gameStateManager = new GameStateManager(Services); Components.Add(gameStateManager); gameStateManager.UpdateOrder = 200; gameStateManager.DrawOrder = 200; // down with xna's input! input = new InputManager(Services, Window.Handle); Components.Add(input); input.UpdateOrder = 100; input.GetKeyboard().KeyPressed += HandleKeyPress; // instantiate world world = new World(Services, serverLink); world.UpdateOrder = 500; world.DrawOrder = 500; Components.Add(world); // instantiate game console gameConsole = new GameConsole(this, new Vector2(0, 400), new Vector2(800, 200), new Vector2(10, 10), new Vector2(10, 10), new Color(255, 255, 255, 100)); Components.Add(gameConsole); gameConsole.UpdateOrder = 1000; gameConsole.DrawOrder = 1000; gameConsole.PromptReceivedInput += HandlePromptInput; // instantiate AudioManager audioManager = new AudioManager(this); }
private void Connect(String host, UInt16? port, String callsign, String tag, TeamType team) { Disconnect("player disconnected"); if (world != null) { world.Dispose(); world = null; } world = new World(this, serverLink); Components.Add(world); world.UpdateOrder = 100; world.DrawOrder = 100; Console.WriteLine("Connecting to server."); serverLink.Connect(host, port, callsign, tag, team); }
protected static Texture2D GetTexture(World world, Player player) { try { return world.Content.Load<Texture2D>(String.Format("textures/bz/{0}_bolt", ProtocolHelpers.TeamTypeToName(player.Team))); } catch (ContentLoadException e) { Log.Error(e.Message); Log.Error(e.StackTrace); return world.Content.Load<Texture2D>("textures/bz/rabbit_bolt"); } }
public Shot(World world, Player player, Byte slot, bool local, Vector2 initialPosition, Single rotation, Vector2 initialVelocity) : base(world, GetTexture(world, player), initialPosition, new Vector2(2, 2), rotation) { Single shotSpeed = (Single)World.VarDB["shotSpeed"].Value; // get the unit vector in the forward direction Velocity = new Vector2((Single)Math.Cos(Rotation - Math.PI / 2), (Single)Math.Sin(Rotation - Math.PI / 2)); // get our shot velocity by multiplying by the magnitude Velocity *= shotSpeed; // add the velocity from the tank to the shot //Velocity += initialVelocity; // store info... this.slot = slot; this.local = local; this.player = player; this.initialPosition = initialPosition; this.maxShotRange = (Single)World.VarDB["shotRange"].Value; this.maxTTL = new TimeSpan(0, 0, 0, 0, (int)((Single)World.VarDB["reloadTime"].Value * 1000)); // start the shot state = ShotState.Starting; }
public Box(World world, Texture2D texture, Vector2 position, Vector2 size, Single rotation, Color color) : base(world, texture, position, size, rotation, color) { }
public AnimatedSprite(World world, Texture2D texture, Vector2 position, Vector2 size, Single rotation, Color color, Point maxFrames, Point frameSize, SpriteSheetDirection direction, bool loop) : base(world, texture, position, size, rotation, color) { this.maxFrames = maxFrames; this.frameSize = frameSize; this.direction = direction; this.Loop = loop; this.currentFrame = FirstFrame; }
public PlayerManager(World world) { this.world = world; this.world.ServerLink.MessageReceivedEvent += HandleReceivedMessage; }
protected static Texture2D GetTexture(World world, PlayerInformation playerInfo) { // TODO get the correct texture depending on team return world.Content.Load<Texture2D>("textures/tank_white"); }
public AnimatedSprite(World world, Texture2D texture, Vector2 position, Vector2 size, Single rotation, Point maxFrames, Point frameSize, SpriteSheetDirection direction, bool loop) : this(world, texture, position, size, rotation, Color.White, maxFrames, frameSize, direction, loop) { }
protected static Vector2 GetTankSize(World world, PlayerInformation playerInfo) { return new Vector2((Single)world.VarDB["tankWidth"].Value, (Single)world.VarDB["tankLength"].Value); }
protected static Texture2D GetTexture(World world, PlayerInformation playerInfo) { try { return world.Content.Load<Texture2D>(String.Format("textures/tank_{0}", ProtocolHelpers.TeamTypeToName(playerInfo.Team))); } catch (ContentLoadException e) { Log.Error(e.Message); Log.Error(e.StackTrace); return world.Content.Load<Texture2D>("textures/tank_white"); } }
public StaticSprite(World world, Texture2D texture, Vector2 position, Vector2 size, Single rotation) : base(world, texture, position, size, rotation) { }
public Pyramid(World world, Texture2D texture, Vector2 position, Vector2 size, Single rotation) : base(world, texture, position, size, rotation) { }
private void Disconnect(String reason) { if (world != null) { world.Dispose(); world = null; } world = new World(this, serverLink); Components.Add(world); world.UpdateOrder = 100; world.DrawOrder = 100; Console.WriteLine("Disconnecting from server."); serverLink.Disconnect(reason); world.LoadMap(new StreamReader("Content/maps/ducati_style_random.bzw")); }
protected static Vector2 GetTankSize(World world, PlayerInformation playerInfo) { // TODO get size from variable database return new Vector2(4.86f, 6); }
public Shot(World world, Texture2D texture, Vector2 position, Vector2 size, Single rotation, Vector2 velocity) : base(world, texture, position, size, rotation) { // TODO: Construct any child components here }