コード例 #1
0
ファイル: GameTracker.cs プロジェクト: bburhans/vtank
        /// <summary>
        /// Start moving forward.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="pos"></param>
        private void StartMovingForward(MetaPlayer player, VTankObject.Point pos)
        {
            player.Player.MovementDirection = VTankObject.Direction.FORWARD;
            player.Player.Position          = pos;

            bot.GameServer.Move(pos.x, pos.y, VTankObject.Direction.FORWARD);
        }
コード例 #2
0
 public FlagDroppedEvent(GamePlayState _game, int droppedId, VTankObject.Point where, GameSession.Alliance flagColor)
     : base(_game)
 {
     this.droppedId = droppedId;
     this.where = where;
     this.flagColor = flagColor;
 }
コード例 #3
0
ファイル: GameTracker.cs プロジェクト: bburhans/vtank
        /// <summary>
        /// Adjust a player's position according to his movement/rotation.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="deltaTimeSeconds"></param>
        private void MovePlayer(MetaPlayer player, double deltaTimeSeconds)
        {
            Player info = player.Player;

            if (info.MovementDirection != VTankObject.Direction.NONE)
            {
                double speed = (VELOCITY * info.SpeedFactor) * deltaTimeSeconds;
                if (info.MovementDirection == VTankObject.Direction.REVERSE)
                {
                    speed = -speed;
                }

                VTankObject.Point newPosition = new VTankObject.Point(
                    info.Position.x + Math.Cos(info.Angle) * speed,
                    info.Position.y + Math.Sin(info.Angle) * speed
                    );

                if (!CheckCollision(newPosition))
                {
                    info.SetPosition(newPosition);
                }
                else
                {
                    info.MovementDirection = VTankObject.Direction.NONE;
                    if (info == LocalPlayer)
                    {
                        bot.GameServer.Move(info.Position.x, info.Position.y, VTankObject.Direction.NONE);
                        bot.InvokeOnHitWall();
                    }
                }
            }
        }
コード例 #4
0
 public PlayerMoveEvent(GamePlayState _game, int id, VTankObject.Point point,
                        VTankObject.Direction direction) : base(_game)
 {
     this.id        = id;
     this.direction = direction;
     this.point     = point;
 }
コード例 #5
0
 public SpawnUtilityEvent(VTankBot bot, int utilityId, VTankObject.Utility utility, VTankObject.Point pos)
     : base(bot)
 {
     ID           = utilityId;
     this.utility = utility;
     position     = pos;
 }
コード例 #6
0
        public override void OnHitWall()
        {
            Game.StopMoving();
            stateMachine.MicroState = MicroBotState.STILL;

            if (targetNode != null)
            {
                Game.StartMoving(VTankObject.Direction.REVERSE);
                stateMachine.MicroState = MicroBotState.MOVE_REVERSE;
                VTankObject.Point targetPosition = new VTankObject.Point(
                    Game.LocalPlayer.Position.x - Math.Cos(Game.LocalPlayer.Angle) * 100.0f,
                    Game.LocalPlayer.Position.y - Math.Sin(Game.LocalPlayer.Angle) * 100.0f);

                timeToNextPoint = Math.Sqrt(
                    Math.Pow(Game.LocalPlayer.Position.y - targetPosition.y, 2) +
                    Math.Pow(Game.LocalPlayer.Position.x - targetPosition.x, 2)) /
                                  (VELOCITY * Game.LocalPlayer.SpeedFactor);

                DebugPrint("OnHitWall(), will take {0:0.00} seconds to reverse.", timeToNextPoint);
            }
            else
            {
                stateMachine.MicroState = MicroBotState.ROTATE;
                Random random   = new Random();
                float  rotation = random.Next(0, 1) == 0 ? 1.5f : -1.5f;
                Game.RotateTo(Player, (Player.Angle + rotation) % (Math.PI * 2));
            }
        }
コード例 #7
0
 public FlagDroppedEvent(GamePlayState _game, int droppedId, VTankObject.Point where, GameSession.Alliance flagColor)
     : base(_game)
 {
     this.droppedId = droppedId;
     this.where     = where;
     this.flagColor = flagColor;
 }
コード例 #8
0
ファイル: GameTracker.cs プロジェクト: bburhans/vtank
        /// <summary>
        /// Perform a movement on the player if that player wants to move.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="deltaTimeSeconds"></param>
        private bool CheckCollision(VTankObject.Point position)
        {
            return(false);

            /*const float TANK_RADIUS = 25f;
             *
             * int tileX = (int)Math.Round(position.x / Tile.TILE_SIZE_IN_PIXELS);
             * int tileY = (int)Math.Round((-position.y) / Tile.TILE_SIZE_IN_PIXELS);
             *
             * Circle circle = new Circle(position.x, position.y, TANK_RADIUS);
             *
             * for (int y = tileY - 2; y < tileY + 2 && y < CurrentMap.Height; ++y)
             * {
             *  if (y < 0) continue;
             *  for (int x = tileX - 2; x < tileX + 2 && x < CurrentMap.Width; ++x)
             *  {
             *      if (x < 0) continue;
             *
             *      Tile currentTile = CurrentMap.GetTile(x, y);
             *      Rectangle tileRect = new Rectangle(x * Tile.TILE_SIZE_IN_PIXELS,
             *          -(y * Tile.TILE_SIZE_IN_PIXELS + 64),
             *          Tile.TILE_SIZE_IN_PIXELS, Tile.TILE_SIZE_IN_PIXELS);
             *      if (!currentTile.IsPassable && circle.CollidesWith(tileRect))
             *      {
             *          return true;
             *      }
             *  }
             * }
             *
             * return false;*/
        }
コード例 #9
0
 public SpawnUtilityEvent(VTankBot bot, int utilityId, VTankObject.Utility utility, VTankObject.Point pos)
     : base(bot)
 {
     ID = utilityId;
     this.utility = utility;
     position = pos;
 }
コード例 #10
0
 public AddUtilityEvent(VTankBot _game, 
     int _utilityID, VTankObject.Utility _utility, VTankObject.Point _position)
     : base(_game)
 {
     utilityID = _utilityID;
     utility = _utility;
     position = _position;
 }
コード例 #11
0
 public AddUtilityEvent(VTankBot _game,
                        int _utilityID, VTankObject.Utility _utility, VTankObject.Point _position)
     : base(_game)
 {
     utilityID = _utilityID;
     utility   = _utility;
     position  = _position;
 }
コード例 #12
0
 public PlayerMoveEvent(VTankBot _game, int id, VTankObject.Point point,
     VTankObject.Direction direction)
     : base(_game)
 {
     this.id = id;
     this.direction = direction;
     this.point = point;
 }
コード例 #13
0
 public SpawnEnvironmentEffectEvent(GamePlayState _game, int id, int typeId, VTankObject.Point location, int ownerId)
     : base(_game)
 {
     this.id       = id;
     this.typeId   = typeId;
     this.location = location;
     this.ownerId  = ownerId;
 }
コード例 #14
0
        /// <summary>
        /// Get the local player's position as a node.
        /// </summary>
        /// <returns></returns>
        private Node GetPositionAsNode()
        {
            VTankObject.Point pos = Game.LocalPlayer.Position;
            int tileX             = (int)Math.Round(pos.x / Tile.TILE_SIZE_IN_PIXELS);
            int tileY             = (int)Math.Round(-pos.y / Tile.TILE_SIZE_IN_PIXELS);

            return(new Node(tileX, tileY));
        }
コード例 #15
0
 public SpawnEnvironmentEffectEvent(GamePlayState _game, int id, int typeId, VTankObject.Point location, int ownerId)
     : base(_game)
 {
     this.id = id;
     this.typeId = typeId;
     this.location = location;
     this.ownerId = ownerId;
 }
コード例 #16
0
ファイル: GameCallback.cs プロジェクト: bburhans/vtank
        public override void PlayerRespawned(int id, VTankObject.Point where, Ice.Current current__)
        {
            if (!ReceivingMessages())
            {
                return;
            }

            buffer.Enqueue(new PlayerRespawnedEvent(Game, id, where));
        }
コード例 #17
0
 public SpawnEnvironmentEffectEvent(VTankBot _game, int id, int typeId, VTankObject.Point location, int ownerId)
     : base(_game)
 {
     this.id = id;
     this.typeId = typeId;
     this.location = location;
     this.ownerId = ownerId;
     envEffect = WeaponLoader.GetEnvironmentProperty(typeId);
 }
コード例 #18
0
ファイル: GameTracker.cs プロジェクト: bburhans/vtank
        public MetaProjectile(Projectile projectile)
            : this()
        {
            Projectile = projectile;

            MillisecondsUntilExpiration = (projectile.Data.Range / Projectile.Data.TerminalVelocity) * 1000;
            MillisecondsSoFar           = 0;
            Position = projectile.StartingPosition;
        }
コード例 #19
0
ファイル: Projectile.cs プロジェクト: bburhans/vtank
 public Projectile(int ID, int projectileTypeId,
                   VTankObject.Point position, double angle)
 {
     this.ID          = ID;
     ProjectileTypeID = projectileTypeId;
     this.Data        = WeaponLoader.GetProjectile(ProjectileTypeID);
     StartingPosition = position;
     Angle            = angle;
 }
コード例 #20
0
 public SpawnEnvironmentEffectEvent(VTankBot _game, int id, int typeId, VTankObject.Point location, int ownerId)
     : base(_game)
 {
     this.id       = id;
     this.typeId   = typeId;
     this.location = location;
     this.ownerId  = ownerId;
     envEffect     = WeaponLoader.GetEnvironmentProperty(typeId);
 }
コード例 #21
0
 public CreateProjectileEvent(VTankBot _game, int projectileTypeId, 
                              VTankObject.Point point, int ownerId,
                              int projectileId)
     : base(_game)
 {
     this.type = WeaponLoader.GetProjectile(projectileTypeId);
     this.point = point;
     this.ownerId = ownerId;
     this.projectileId = projectileId;
 }
コード例 #22
0
        public void InvokeOnPlayerMove(int playerID, VTankObject.Point position,
                                       VTankObject.Direction direction)
        {
            Player player = Game.GetPlayerByID(playerID);

            if (player != null)
            {
                Game.SetPlayerMovement(player, position, direction);
            }
        }
コード例 #23
0
 public CreateProjectileEvent(GamePlayState _game, int projectileTypeId,
                              VTankObject.Point point, int ownerId,
                              int projectileId)
     : base(_game)
 {
     this.projectileTypeId = projectileTypeId;
     this.point            = point;
     this.ownerId          = ownerId;
     this.projectileId     = projectileId;
 }
コード例 #24
0
 public CreateProjectileEvent(VTankBot _game, int projectileTypeId,
                              VTankObject.Point point, int ownerId,
                              int projectileId)
     : base(_game)
 {
     this.type         = WeaponLoader.GetProjectile(projectileTypeId);
     this.point        = point;
     this.ownerId      = ownerId;
     this.projectileId = projectileId;
 }
コード例 #25
0
 public CreateProjectileEvent(GamePlayState _game, int projectileTypeId, 
                              VTankObject.Point point, int ownerId,
                              int projectileId)
     : base(_game)
 {
     this.projectileTypeId = projectileTypeId;
     this.point = point;
     this.ownerId = ownerId;
     this.projectileId = projectileId;
 }
コード例 #26
0
ファイル: GameCallback.cs プロジェクト: bburhans/vtank
        public override void CreateProjectile(int ownerId, int projectileId,
                                              int projectileTypeId, VTankObject.Point point, Ice.Current current__)
        {
            if (!ReceivingMessages())
            {
                return;
            }

            buffer.Enqueue(new CreateProjectileEvent(Game, projectileTypeId, point, ownerId, projectileId));
        }
コード例 #27
0
ファイル: GameCallback.cs プロジェクト: bburhans/vtank
        public override void PlayerMove(int id, VTankObject.Point point,
                                        VTankObject.Direction direction, Ice.Current current__)
        {
            if (!ReceivingMessages())
            {
                return;
            }

            buffer.Enqueue(new PlayerMoveEvent(Game, id, point, direction));
        }
コード例 #28
0
ファイル: GameTracker.cs プロジェクト: bburhans/vtank
        /// <summary>
        /// Stop moving forward.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="pos"></param>
        private void StopMovingForward(MetaPlayer player, VTankObject.Point pos)
        {
            player.Player.Position = pos;

            //if (player.Player.MovementDirection != VTankObject.Direction.NONE)
            //{
            player.Player.MovementDirection = VTankObject.Direction.NONE;

            bot.GameServer.Move(pos.x, pos.y, VTankObject.Direction.NONE);
            //}
        }
コード例 #29
0
ファイル: GameTracker.cs プロジェクト: bburhans/vtank
        /// <summary>
        /// Get the next position.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="currentNode"></param>
        /// <returns></returns>
        private VTankObject.Point SetPosition(MetaPlayer player, Node currentNode)
        {
            double halfTile = Tile.TILE_SIZE_IN_PIXELS / 2;

            VTankObject.Point newPosition = new VTankObject.Point(
                (currentNode.X * Tile.TILE_SIZE_IN_PIXELS) + halfTile,
                -((currentNode.Y * Tile.TILE_SIZE_IN_PIXELS + halfTile)));
            player.Player.Position = newPosition;

            return(newPosition);
        }
コード例 #30
0
        public void InvokePlayerHasRespawned(int playerID, VTankObject.Point position)
        {
            Player player = Game.GetPlayerByID(playerID);

            if (player != null)
            {
                player.Respawn(position);

                PlayerRespawnEventArgs args = new PlayerRespawnEventArgs(player);
                PlayerHasRespawned(args);
                args.Dispose();
            }
        }
コード例 #31
0
        public void InvokeOnProjectileFired(int projectileID, int ownerID,
                                            int projectileTypeId, VTankObject.Point projectilePosition)
        {
            Player owner = Game.GetPlayerByID(ownerID);

            if (owner != null)
            {
                double angle = Math.Atan2(owner.Position.y - projectilePosition.y,
                                          owner.Position.x - projectilePosition.x);

                Projectile projectile = new Projectile(
                    projectileID, owner.Weapon.ProjectileID, projectilePosition, angle);
                ProjectileFiredEventArgs args = new ProjectileFiredEventArgs(
                    owner, projectile);

                Game.AddProjectile(projectile);

                OnProjectileFired(args);

                args.Dispose();
            }
        }
コード例 #32
0
 public PlayerRespawnedEvent(GamePlayState _game, int id, VTankObject.Point where)
     : base(_game)
 {
     this.id = id;
     this.where = where;
 }
コード例 #33
0
ファイル: Projectile.cs プロジェクト: bburhans/vtank
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="_model">Projectile model</param>
        /// <param name="_position">Position of the missile</param>
        /// <param name="_angle">Angle at which the missile will be fired</param>
        /// <param name="_velocity">Velocity of the missile</param>
        /// <param name="_alive">Alive</param>
        /// <param name="_firedBy">Who fired the missile</param>
        public Projectile(Vector3 _position, VTankObject.Point target, double _angle, double _velocity,
                          float _alive, PlayerTank _firedBy, ProjectileData projectileData)
        {
            this.data     = projectileData;
            this.position = _position;

            position                   = _position + Vector3.UnitZ;;
            base.ZRotation             = (float)_angle;
            velocity                   = (float)_velocity;
            timeAlive                  = _alive;
            elapsed                    = 0;
            this.boundingSphere.Radius = projectileData.CollisionRadius;
            SetBoundingSpherePosition();
            owner    = _firedBy;
            RenderID = -1;
            ID       = projectileData.ID;
            origin   = position;

            if (_firedBy.Weapon.HasFiringArc)
            {
                this.usingLaunchAngle = true;

                float swivelAngle = ZRotation;
                float tiltAngle   = _firedBy.Weapon.LaunchAngle;

                float projection = DEFAULT_CANNON_LENGTH * (float)Math.Cos(tiltAngle);
                float tipX       = -projection * (float)Math.Cos(swivelAngle);
                float tipY       = -projection * (float)Math.Sin(swivelAngle);
                float tipZ       = Math.Abs(DEFAULT_CANNON_LENGTH * (float)Math.Sin(swivelAngle));
                tip = new float[] { tipX, tipY, tipZ };

                Vector3 newPosition = position + new Vector3(tipX, tipY, tipZ);
                // Calculate initial velocity based on the distance we travel.
                float distance = (float)Math.Sqrt(
                    Math.Pow(target.x - newPosition.X, 2) +
                    Math.Pow(target.y - newPosition.Y, 2));
                float maxDistance = (int)projectileData.Range;
                if (distance > maxDistance)
                {
                    distance = maxDistance;
                }

                // TODO: This is a temporary work-around until we figure out what velocity component
                // is missing from the formula.
                float offset = 1.1f;
                if (tiltAngle > MathHelper.ToRadians(45.0f))
                {
                    offset = 1.6f;
                }

                float V  = (float)Math.Sqrt(-gravity * distance * offset);
                float Vx = -V * (float)(Math.Cos(tiltAngle) * Math.Cos(swivelAngle));
                float Vy = -V * (float)(Math.Cos(tiltAngle) * Math.Sin(swivelAngle));
                float Vz = V * (float)Math.Sin(tiltAngle);

                componentVelocity = new float[] { Vx, Vy, Vz };
                elapsedDelta      = 0f;

                /*this.verticalVelocity = this.FindVerticalVelocity(_firedBy.Weapon.LaunchAngle, velocity);
                 * float flightTime = this.FindFlightTime(verticalVelocity, gravity);
                 * float horizontalVelocity = this.FindHorizontalVelocity(
                 *  distance,
                 *  flightTime);
                 * velocity = horizontalVelocity;*/
            }

            Object3 turret = owner.Turret;

            ModelBoneCollection.Enumerator collection = turret.Model.Bones.GetEnumerator();
            List <ModelBone> emitters = new List <ModelBone>();

            while (collection.MoveNext())
            {
                if (collection.Current.Name.StartsWith("Emitter"))
                {
                    emitters.Add(collection.Current);
                }
            }

            if (emitters.Count == 0)
            {
                ServiceManager.Game.Console.DebugPrint(
                    "Warning: Can't attach to owner tank, no emitter exists.");
            }
            else
            {
                int emitter = _firedBy.Weapon.GetNextEmitterIndex();
                this.Attach(turret, emitters[emitter].Name);

                this.MimicRotation(turret);
                this.Unattach();
                Vector3 forward = emitters[emitter].Transform.Forward;
                forward.Z = Math.Abs(forward.Z);
                //position *= forward;
            }

            if (!String.IsNullOrEmpty(projectileData.Model))
            {
                model = new Object3(ServiceManager.Resources.GetModel("projectiles\\" + projectileData.Model), position);
                model.MimicPosition(this, Vector3.Zero);
                model.MimicRotation(this);
                modelRenderID = ServiceManager.Scene.Add(model, 3);
            }
            else
            {
                model = null;
            }

            if (!String.IsNullOrEmpty(projectileData.ParticleEffect) && projectileData.Model == null)
            {
                ParticleEmitter.MimicPosition(this, Vector3.Zero);
                ParticleEmitter.MimicRotation(this);
                particleEmitterRenderID = ServiceManager.Scene.Add(ParticleEmitter, 3);
            }
            else if (!String.IsNullOrEmpty(projectileData.ParticleEffect))
            {
                ParticleEmitter = new ParticleEmitter(projectileData.ParticleEffect, this.Position);
                this.particleEmitterRenderID = ServiceManager.Scene.Add(ParticleEmitter, 3);
                ParticleEmitter.Follow(this);
            }
        }
コード例 #34
0
ファイル: GameCallback.cs プロジェクト: bburhans/vtank
 public override void FlagSpawned(VTankObject.Point where, GameSession.Alliance flagColor, Ice.Current current__)
 {
     buffer.Enqueue(new FlagSpawnedEvent(Game, where, flagColor));
 }
コード例 #35
0
 public FlagSpawnedEvent(GamePlayState _game, VTankObject.Point where, GameSession.Alliance flagColor)
     : base(_game)
 {
     this.where     = where;
     this.flagColor = flagColor;
 }
コード例 #36
0
        /// <summary>
        /// Get the next position.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="currentNode"></param>
        /// <returns></returns>
        private VTankObject.Point SetPosition(MetaPlayer player, Node currentNode)
        {
            double halfTile = Tile.TILE_SIZE_IN_PIXELS / 2;
            VTankObject.Point newPosition = new VTankObject.Point(
                (currentNode.X * Tile.TILE_SIZE_IN_PIXELS) + halfTile,
                -((currentNode.Y * Tile.TILE_SIZE_IN_PIXELS + halfTile)));
            player.Player.Position = newPosition;

            return newPosition;
        }
コード例 #37
0
        /// <summary>
        /// Adjust a player's position according to his movement/rotation.
        /// </summary>
        /// <param name="player"></param>
        /// <param name="deltaTimeSeconds"></param>
        private void MovePlayer(MetaPlayer player, double deltaTimeSeconds)
        {
            Player info = player.Player;
            if (info.MovementDirection != VTankObject.Direction.NONE)
            {
                double speed = (VELOCITY * info.SpeedFactor) * deltaTimeSeconds;
                if (info.MovementDirection == VTankObject.Direction.REVERSE)
                {
                    speed = -speed;
                }

                VTankObject.Point newPosition = new VTankObject.Point(
                    info.Position.x + Math.Cos(info.Angle) * speed,
                    info.Position.y + Math.Sin(info.Angle) * speed
                );

                if (!CheckCollision(newPosition))
                {
                    info.SetPosition(newPosition);
                }
                else
                {
                    info.MovementDirection = VTankObject.Direction.NONE;
                    if (info == LocalPlayer)
                    {
                        bot.GameServer.Move(info.Position.x, info.Position.y, VTankObject.Direction.NONE);
                        bot.InvokeOnHitWall();
                    }
                }
            }
        }
コード例 #38
0
 public FlagSpawnedEvent(VTankBot _game, VTankObject.Point where, GameSession.Alliance flagColor)
     : base(_game)
 {
     this.where = where;
     this.flagColor = flagColor;
 }
コード例 #39
0
        public override void DoAction()
        {
            string killerName = "<Unknown>";
            Vector3 killerPos = Vector3.Zero;
            int killerProjectileID = 0;
            bool weaponIsInstant = false;
            PlayerTank killer;
            if (Game.Players.ContainsKey(ownerId))
            {
                killer = Game.Players[ownerId];
                killerName = killer.Name;
                killerPos = killer.Position;
                killerProjectileID = killer.Weapon.Projectile.ID;
                weaponIsInstant = killer.Weapon.Projectile.IsInstantaneous;
            }

            try
            {
                if (!Game.Players.ContainsKey(victimId))
                {
                    // The player doesn't exist in our local copy: the tank list may have been de-synchronized.
                    Game.Players.RefreshPlayerList();
                }
                else
                {
                    PlayerTank victim = Game.Players[victimId];
                    string shooterName = killerName;
                    bool isChargeableWeapon = victim.Weapon.CanCharge;
                    if (weaponIsInstant)
                    {
                        VTankObject.Point position = new VTankObject.Point(victim.Position.X, victim.Position.Y);
                        float angle = (float)Math.Atan2((killerPos.Y - victim.Position.Y),
                            (killerPos.X - victim.Position.X));

                        new CreateProjectileEvent(Game, killerProjectileID, position,
                            ownerId, projectileId).DoAction();
                    }

                    if (victim.Name == PlayerManager.LocalPlayerName)
                        Game.PlayerHit();

                    victim.InflictDamage(damageTaken, killingBlow);
                    if (killingBlow)
                    {
                        // The player died as a result.
                        string chatMessage;
                        Color messageColor;
                        if (shooterName == PlayerManager.LocalPlayerName)
                        {
                            // The shooter was this user.
                            chatMessage = "You destroyed " + victim.Name + "!";
                            messageColor = Color.LightGreen;
                        }
                        else if (victim.Name == PlayerManager.LocalPlayerName)
                        {
                            // The victim was this user.
                            chatMessage = "You were destroyed by " + shooterName + "!";
                            messageColor = Color.DarkOrange;
                            Game.buffbar.RemoveAllBuffs();
                            Game.Players.GetLocalPlayer().RemoveAllUtilities();
                            Game.StartRespawnTimer();
                        }
                        else
                        {
                            // The shooter and victim are unrelated.
                            chatMessage = victim.Name + " was destroyed by " + shooterName + ".";
                            messageColor = Color.Yellow;
                        }

                        ServiceManager.Game.Console.DebugPrint(
                             String.Format("[CHAT] {0}", chatMessage));

                        Game.Chat.AddMessage(chatMessage, messageColor);

                        Game.Scores.AddKill(shooterName);
                        Game.Scores.AddDeath(victim.Name);

                        victim.RemoveAssister(ownerId);
                        List<int> assisters = victim.GetAssisters();
                        for (int i = 0; i < assisters.Count; ++i)
                        {
                            PlayerTank helper = Game.Players[assisters[i]];
                            if (helper != null)
                            {
                                Game.Scores.AddAssist(helper.Name);
                            }
                        }

                        victim.ClearAssists();
                    }
                    else
                    {
                        victim.AddAssist(ownerId);
                    }
                }

                if (!weaponIsInstant && Game.Projectiles.ContainsKey(projectileId))
                {
                    Game.Projectiles.Remove(projectileId);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
コード例 #40
0
ファイル: GameCallback.cs プロジェクト: bburhans/vtank
 public override void SpawnEnvironmentEffect(int id, int typeId, int ownerId,
                                             VTankObject.Point position, Ice.Current current__)
 {
     buffer.Enqueue(new SpawnEnvironmentEffectEvent(Game, id, typeId, position, ownerId));
 }
コード例 #41
0
ファイル: GameCallback.cs プロジェクト: bburhans/vtank
        public override void SpawnUtility(int utilityId, VTankObject.Utility utility, VTankObject.Point pos, Ice.Current current__)
        {
            Vector3 position3d = new Vector3((float)pos.x, (float)pos.y, 0.0f);

            buffer.Enqueue(new AddUtilityEvent(Game, utilityId, utility, position3d));
        }
コード例 #42
0
 public ResetPositionEvent(GamePlayState _game, VTankObject.Point position)
     : base(_game)
 {
     this.position = position;
 }
コード例 #43
0
ファイル: GameCallback.cs プロジェクト: bburhans/vtank
 public override void FlagDropped(int droppedId, VTankObject.Point where, GameSession.Alliance flagColor, Ice.Current current__)
 {
     buffer.Enqueue(new FlagDroppedEvent(game, droppedId, where, flagColor));
 }
コード例 #44
0
        /// <summary>
        /// Create a missile object from the projectile data received from the server.
        /// </summary>
        /// <param name="data">Data to convert.</param>
        /// <returns>New missile object.</returns>
        public static Projectile CreateProjectileObject(
            ProjectileData data, VTankObject.Point point, float angle, PlayerTank owner)
        {
            Vector3 soundPos = new Vector3((float)owner.Position.X, (float)owner.Position.Y, 0);
            Vector3 velocity = new Vector3((float)((data.InitialVelocity + 50) * Math.Cos(angle)),
                                           (float)(data.InitialVelocity * Math.Sin(angle)), 0);

            if (soundEffectBank.ContainsKey(data.ID))
            {
                try
                {
                    GamePlayState state = (GamePlayState)ServiceManager.StateManager.CurrentState;
                    if (!String.IsNullOrEmpty(owner.Weapon.FiringSound))
                    {
                        ServiceManager.AudioManager.Play3DSound(owner.Weapon.FiringSound,
                                                                state.Players.GetLocalPlayer().Position, soundPos, velocity, false);
                    }
                }
                catch (Exception e)
                {
                    ServiceManager.Game.Console.DebugPrint(
                        "Warning: Current state isn't a game: {0}", e);
                }
            }
            else
            {
                if (data != null)
                {
                    ServiceManager.Game.Console.DebugPrint(
                        "Warning: Couldn't find sound effect for projectile #{0}.",
                        data.ID);
                }
                else
                {
                    ServiceManager.Game.Console.DebugPrint("Warning:  ProjectileManager received a null projectile");
                }
            }

            const float inflation  = -0.01f;
            float       alive      = (float)(data.Range) / (float)(data.TerminalVelocity);
            Projectile  projectile = new Projectile(owner.Position, point,
                                                    angle, data.InitialVelocity, alive + inflation, owner, data);

            if (!String.IsNullOrEmpty(owner.Weapon.MuzzleEffectName))
            {
                ParticleEmitter p = new ParticleEmitter(owner.Weapon.MuzzleEffectName, projectile.Position);
                p.Attach(owner.Turret, "Emitter0");
                p.MimicRotation(owner.Turret);
                ServiceManager.Scene.Add(p, 3);
            }

            /*
             * if(projectile.Data.IsInstantaneous)
             * {
             *  if (!String.IsNullOrEmpty(projectile.Data.ParticleEffect))
             *  {
             *      ParticleEmitter p = new ParticleEmitter(projectile.Data.ParticleEffect, projectile.Position);
             *      projectile.ParticleEmitter = p;
             *      p.MimicPosition(projectile, Vector3.Zero);
             *      ServiceManager.Scene.Add(p, 3);
             *  }
             * }*/

            // TODO: Z-index should be transformed to be attached to the turret end.
            return(projectile);
        }
コード例 #45
0
 public ResetPositionEvent(VTankBot _game, VTankObject.Point position)
     : base(_game)
 {
     this.position = position;
 }