Ejemplo n.º 1
0
        public override void performAction(GameTime gameTime, Main game)
        {
            Player player = game.player;

            Main.fastMessage playerHitFastMessage = new Main.fastMessage();

            playerHitFastMessage.Color = Color.GreenYellow;
            playerHitFastMessage.Position = player.Position;
            playerHitFastMessage.Duration = TimeSpan.FromSeconds(0.33);
            playerHitFastMessage.GameTime = gameTime.TotalGameTime;

            int healAmount = 15;

            if (player.Health == 100)
            {
                playerHitFastMessage.Message = "Full health!";
                game.fastMessages.Add(playerHitFastMessage);
                return;
            }
            else if(player.Health + healAmount > 100)
            {
                int healthIncrease = (100 - player.Health);
                player.Health = 100;
                playerHitFastMessage.Message = "+" + healthIncrease.ToString();
            }
            else
            {
                player.Health += healAmount;
                playerHitFastMessage.Message = "+" + healAmount.ToString();
            }

            game.fastMessages.Add(playerHitFastMessage);
            lastUse = gameTime.TotalGameTime;
            unlocked = false;
        }
Ejemplo n.º 2
0
        public override void Update(GameTime gameTime, Main game)
        {
            Player player = game.player;
            position = player.Position;

            Creature closestEnemy = game.enemyList[0];
            double lastDistance = 100000f;

            foreach (Creature enemy in game.enemyList)
            {
                double distance = Math.Pow((player.Position.X - enemy.position.X), 2) + Math.Pow((player.Position.Y - enemy.position.Y), 2);
                if (distance < lastDistance)// && Vector2.Dot((enemy.Position - player.Position), (new Vector2(1, (float)Math.Sin(rotation)) + player.Position)) > 0)
                {
                    closestEnemy = enemy;
                    lastDistance = distance;
                }
            }

            Vector2 projectileTarget = closestEnemy.position - player.Position;

            if ((gameTime.TotalGameTime - lastAction) > TimeSpan.FromSeconds(0.25f))
            {
                game.playerProjectileList.Add(new Projectile(this.position, closestEnemy.position, game.textureCache[2], true));
                lastAction = gameTime.TotalGameTime;
                totalShots++;
            }

            if (totalShots == 25) game.entityList.Remove(this);

            rotation = (float) Math.Atan2(projectileTarget.Y, projectileTarget.X);
        }
Ejemplo n.º 3
0
        public override void performAction(GameTime gameTime, Main game)
        {
            Player player = game.player;

            game.entityList.Add(new PlayerTurret(game.textureCache[7], player.Position));

            lastUse = gameTime.TotalGameTime;
            unlocked = false;
        }
Ejemplo n.º 4
0
 public virtual void Update(GameTime gameTime, Main game)
 {
 }
Ejemplo n.º 5
0
 public override void Update(GameTime gameTime, Main game)
 {
 }
Ejemplo n.º 6
0
 public virtual void performAction(GameTime gameTime, Main game)
 {
 }
Ejemplo n.º 7
0
 static void Main()
 {
     using (var game = new Main()) game.Run();
 }