コード例 #1
0
ファイル: Player.cs プロジェクト: aotis/AngryTanks
        public Player(World world, PlayerInformation playerInfo)
            : base(world, GetTexture(world, playerInfo), Vector2.Zero, GetTankSize(world, playerInfo), 0)
        {
            this.playerInfo = playerInfo;

            World.ServerLink.MessageReceivedEvent += HandleReceivedMessage;
        }
コード例 #2
0
ファイル: Player.cs プロジェクト: pr0gramm3r1/AngryTanks
        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;
        }
コード例 #3
0
ファイル: RemotePlayer.cs プロジェクト: aotis/AngryTanks
        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));
        }
コード例 #4
0
ファイル: LocalPlayer.cs プロジェクト: aotis/AngryTanks
        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;
        }
コード例 #5
0
ファイル: Sprite.cs プロジェクト: aotis/AngryTanks
        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);
        }
コード例 #6
0
ファイル: LocalPlayer.cs プロジェクト: pr0gramm3r1/AngryTanks
        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;
        }
コード例 #7
0
        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");
        }
コード例 #8
0
ファイル: Player.cs プロジェクト: dvicory/AngryTanks
        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;
        }
コード例 #9
0
ファイル: AngryTanks.cs プロジェクト: pr0gramm3r1/AngryTanks
        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);

        }
コード例 #10
0
ファイル: AngryTanks.cs プロジェクト: aotis/AngryTanks
        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);
        }
コード例 #11
0
ファイル: Shot.cs プロジェクト: pr0gramm3r1/AngryTanks
 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");
     }
 }
コード例 #12
0
ファイル: Shot.cs プロジェクト: pr0gramm3r1/AngryTanks
        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;
        }
コード例 #13
0
ファイル: Box.cs プロジェクト: pr0gramm3r1/AngryTanks
 public Box(World world, Texture2D texture, Vector2 position, Vector2 size, Single rotation, Color color)
     : base(world, texture, position, size, rotation, color)
 {
 }
コード例 #14
0
ファイル: AnimatedSprite.cs プロジェクト: dvicory/AngryTanks
        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;
        }
コード例 #15
0
        public PlayerManager(World world)
        {
            this.world = world;

            this.world.ServerLink.MessageReceivedEvent += HandleReceivedMessage;
        }
コード例 #16
0
ファイル: Player.cs プロジェクト: aotis/AngryTanks
 protected static Texture2D GetTexture(World world, PlayerInformation playerInfo)
 {
     // TODO get the correct texture depending on team
     return world.Content.Load<Texture2D>("textures/tank_white");
 }
コード例 #17
0
ファイル: AnimatedSprite.cs プロジェクト: dvicory/AngryTanks
 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)
 { }
コード例 #18
0
ファイル: Player.cs プロジェクト: pr0gramm3r1/AngryTanks
 protected static Vector2 GetTankSize(World world, PlayerInformation playerInfo)
 {
     return new Vector2((Single)world.VarDB["tankWidth"].Value,
                        (Single)world.VarDB["tankLength"].Value);
 }
コード例 #19
0
ファイル: Player.cs プロジェクト: pr0gramm3r1/AngryTanks
 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");
     }
 }
コード例 #20
0
 public StaticSprite(World world, Texture2D texture, Vector2 position, Vector2 size, Single rotation)
     : base(world, texture, position, size, rotation)
 {
 }
コード例 #21
0
ファイル: Pyramid.cs プロジェクト: pr0gramm3r1/AngryTanks
 public Pyramid(World world, Texture2D texture, Vector2 position, Vector2 size, Single rotation)
     : base(world, texture, position, size, rotation)
 {
 }
コード例 #22
0
ファイル: AngryTanks.cs プロジェクト: aotis/AngryTanks
        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"));
        }
コード例 #23
0
ファイル: Player.cs プロジェクト: aotis/AngryTanks
 protected static Vector2 GetTankSize(World world, PlayerInformation playerInfo)
 {
     // TODO get size from variable database
     return new Vector2(4.86f, 6);
 }
コード例 #24
0
ファイル: Shot.cs プロジェクト: aotis/AngryTanks
 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
 }