Inheritance: DynamicSprite, IDisposable
Beispiel #1
0
 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");
     }
 }
Beispiel #2
0
        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;
        }
Beispiel #3
0
        public override void Die(Player killer)
        {
            // send out the death packet right away
            NetOutgoingMessage deathMessage = World.ServerLink.CreateMessage();

            MsgDeathPacket deathPacket = new MsgDeathPacket(killer.Slot);

            deathMessage.Write((Byte)deathPacket.MsgType);
            deathPacket.Write(deathMessage);

            World.ServerLink.SendMessage(deathMessage, NetDeliveryMethod.ReliableOrdered, 0);

            // write to console that you were killed
            ConsoleMessageLine consoleMessage;

            if (killer != this)
            {
                consoleMessage =
                    new ConsoleMessageLine(
                        "You were killed by ", Color.White,
                        killer.Callsign, ProtocolHelpers.TeamTypeToColor(killer.Team));
            }
            else
            {
                consoleMessage = new ConsoleMessageLine("You blew yourself up!", Color.White);
            }

            World.Console.WriteLine(consoleMessage);

            base.Die(killer);
        }
Beispiel #4
0
 public virtual void Die(Player killer)
 {
     // move into the exploding state
     state = PlayerState.Exploding;
 }
Beispiel #5
0
        public virtual void Die(Player killer)
        {
            // move explosion animation to running state
            explosion.Running = true;

            // move into the exploding state
            state = PlayerState.Exploding;
        }