Example #1
0
 public void UpdatePortal(Game1 game)
 {
     if (side1.active)
     {
         door1.UpdateDoor(game.worldMap[game.currentRoom]);
         CollisionState result = CollisionDetector.PerPixelSprite(door1, game.player, game.graphics);
         if (result == CollisionState.Hurtbox)
         {
             if (!side1.GetWasJustActivated())
             {
                 game.RemoveObjectToDraw(door1);
                 game.ActivateMap(side2, door2);
             }
         }
         else
         {
             if (door1.onScreen)
             {
                 game.AddObjectToDraw(door1);
             }
             else
             {
                 game.RemoveObjectToDraw(door1);
             }
         }
     }
     else if (side2.active)
     {
         door2.UpdateDoor(game.worldMap[game.currentRoom]);
         CollisionState result = CollisionDetector.PerPixelSprite(door2, game.player, game.graphics);
         if (result == CollisionState.Hurtbox)
         {
             if (!side2.GetWasJustActivated())
             {
                 game.RemoveObjectToDraw(door2);
                 game.ActivateMap(side1, door1);
             }
         }
         else
         {
             if (door2.onScreen)
             {
                 game.AddObjectToDraw(door2);
             }
             else
             {
                 game.RemoveObjectToDraw(door2);
             }
         }
     }
 }
        public void UpdateProjectile(Projectile projectile, Game1 game)
        {
            projectile.life++;
            if (projectile.life == GetLifeSpan())
            {
                DestroyProjectile(projectile);
            }
            projectile.worldX += projectile.GetData().GetXVel(projectile);
            projectile.worldY += projectile.GetData().GetYVel(projectile);
            projectile.UpdateSprite(game.worldMap[game.currentRoom]);
            CollisionState result = CollisionDetector.PerPixelSprite(projectile, game.player, game.graphics);

            if ((result == CollisionState.Hurtbox || result == CollisionState.Standard) && game.worldMap[game.currentRoom].enemyProjectiles.Contains(projectile))
            {
                game.player.TakeDamage(projectile);
                DestroyProjectile(projectile);
            }
            if (CollisionDetector.CheckMapCollision(0, 0, projectile, game.worldMap[game.currentRoom]) == false)
            {
                if (projectile.onScreen && projectile.nearScreen)
                {
                    game.AddObjectToDraw(projectile);
                }
                else
                {
                    projectile.Delete();
                }
            }
            else
            {
                DestroyProjectile(projectile);
            }
        }
Example #3
0
        void IMapItem.UpdateSprite(Game1 game)
        {
            CollisionState result = CollisionDetector.PerPixelSprite(this, game.player, game.graphics);

            if (result == CollisionState.Hurtbox || result == CollisionState.Standard)
            {
                this.timer++;
                if (this.timer >= 3 * this.FRAME_OFFSET)
                {
                    if (this.frameNum == numFrames - 1)
                    {
                        if (!this.recentlyActivated)
                        {
                            game.OpenSaveStationMenu();
                            this.recentlyActivated = true;
                            dialUp.Play("dialUp");
                        }
                    }
                    else
                    {
                        this.frameNum++;
                    }
                    this.timer = 1;
                }
            }
            else
            {
                this.recentlyActivated = false;
                this.timer--;
                if (this.timer <= 0)
                {
                    this.timer = 3 * this.FRAME_OFFSET;
                    if (this.frameNum <= 0)
                    {
                        this.frameNum = 0;
                    }
                    else
                    {
                        this.frameNum--;
                    }
                }
            }
            this.UpdateSprite(game.worldMap[game.currentRoom]);
            if (this.onScreen)
            {
                game.AddObjectToDraw(this);
            }
            else
            {
                game.RemoveObjectToDraw(this);
            }
        }