/// <summary>
        /// Determines belt orientation. Belt movements handled by MngrLvl.
        /// </summary>
        public override void Update()
        {
            //Updates the belt sprite by direction.
            //Depends on the texture frames.
            if (BlockDir == Dir.Right)
            {
                BlockSprite.angle = 0;
            }
            else if (BlockDir == Dir.Down)
            {
                BlockSprite.angle = (float)(Math.PI / 2);
            }
            else if (BlockDir == Dir.Left)
            {
                BlockSprite.angle = (float)(Math.PI);
            }
            else
            {
                BlockSprite.angle = (float)(-Math.PI / 2);
            }

            spriteAtlas.Update(true);
            base.Update();

            //Determines the belt's image speed.
            if (IsEnabled)
            {
                spriteAtlas.frameSpeed = 0.25f;
            }
            else
            {
                spriteAtlas.frameSpeed = 0;
            }
        }
예제 #2
0
        /// <summary>
        /// Updates the sprite.
        /// </summary>
        public override void Update()
        {
            if (!IsEnabled)
            {
                spriteAtlas.frame = 0;
            }
            else if (receivedBullet)
            {
                spriteAtlas.frame = isActivating ? 3 : 4;
            }
            else
            {
                spriteAtlas.frame = isActivating ? 2 : 1;
            }

            if (!receivedBullet)
            {
                framesWithoutBullets++;

                if (ActionType == 7 && isActivating && (framesWithoutBullets > CustInt2 || CustInt2 == 0))
                {
                    framesWithoutBullets = 0;
                    bulletsReceived      = 0;
                    ActivateLinkedItems((item) => false);
                    isActivating = false;
                }
            }

            spriteAtlas.Update(true);
            base.Update();
        }
예제 #3
0
        /// <summary>
        /// If actors are synced, disables them on touch and deletes itself.
        /// </summary>
        public override void Update()
        {
            //Slowly rotates the sprite.
            BlockSprite.angle += 0.05f;

            //If actors are synchronized.
            if (game.mngrLvl.opSyncActors)
            {
                //Gets a list of all actors on the freeze object.
                List <GameObj> items = game.mngrLvl.items.Where(o =>
                                                                o.X == X && o.Y == Y && o.Layer == Layer &&
                                                                o.BlockType == Type.Actor).ToList();

                //Disables all actors touching the freeze ice.
                foreach (GameObj item in items)
                {
                    item.IsEnabled = false;
                    game.mngrLvl.RemoveItem(this);
                    game.playlist.Play(sndFreeze, X, Y);
                }
            }

            spriteAtlas.Update(true);
            base.Update();
        }
        /// <summary>
        /// Updates the atlas. Behavior handled by MngrLvl.cs.
        /// </summary>
        public override void Update()
        {
            #region Determines sprite by dir and isEnabled.
            if (Utils.DirCardinal(BlockDir))
            {
                if (IsEnabled)
                {
                    spriteAtlas.frame = 0;
                }
                else
                {
                    spriteAtlas.frame = 1;
                }
            }
            else
            {
                if (IsEnabled)
                {
                    spriteAtlas.frame = 2;
                }
                else
                {
                    spriteAtlas.frame = 3;
                }
            }
            #endregion

            spriteAtlas.Update(true);
            base.Update();
        }
예제 #5
0
        /// <summary>
        /// If actors are synced, disables them on touch and deletes itself.
        /// </summary>
        public override void Update()
        {
            //If actors are synchronized.
            if (game.mngrLvl.opSyncActors)
            {
                //Gets a list of all actors on the thaw object.
                List <GameObj> items = game.mngrLvl.items.Where(o =>
                                                                o.X == X && o.Y == Y && o.Layer == Layer &&
                                                                o.BlockType == Type.Actor).ToList();

                //Enables all actors on contact.
                if (items.Count != 0)
                {
                    items = game.mngrLvl.items.Where(o =>
                                                     o.BlockType == Type.Actor).ToList();

                    foreach (GameObj item in items)
                    {
                        item.IsEnabled = true;
                    }

                    game.mngrLvl.RemoveItem(this);
                    game.playlist.Play(sndThaw, X, Y);
                }
            }

            spriteAtlas.Update(true);
            base.Update();
        }
예제 #6
0
        /// <summary>
        /// Saves if touched by an actor, deleting itself if custInt1 == 1.
        /// </summary>
        public override void Update()
        {
            //Gets a list of all actors in the same position.
            List <GameObj> items = game.mngrLvl.items.Where(o =>
                                                            o.X == X && o.Y == Y && o.Layer == Layer &&
                                                            o.BlockType == Type.Actor).ToList();

            if (items.Count > 0) //Attempts to save.
            {
                if (!hasActivated)
                {
                    game.mngrLvl.doCheckpoint = true;

                    if (CustInt1 == 1)
                    {
                        game.mngrLvl.RemoveItem(this);
                    }
                }

                hasActivated = true;
            }
            else //Doesn't attempt to save.
            {
                hasActivated = false;
            }

            spriteAtlas.Update(true);
            base.Update();
        }
        /// <summary>
        /// Controls sprite frames used and toggles isSolid.
        /// </summary>
        public override void Update()
        {
            #region Adjusts sprite.
            if (!IsEnabled || !IsActivated)
            {
                spriteAtlas.frame = 1;
            }
            else if (ActionType == 5)
            {
                spriteAtlas.frame = 0;
            }
            #endregion

            spriteAtlas.Update(true);
            base.Update();
        }
예제 #8
0
        /// <summary>
        /// Adds to number of goals on contact.
        /// </summary>
        public override void Update()
        {
            //Gets a list of all actors on the goal object.
            List <GameObj> items = game.mngrLvl.items.Where(o =>
                                                            o.X == X && o.Y == Y && o.Layer == Layer &&
                                                            o.BlockType == Type.Actor).ToList();

            //If there is at least one actor touching the goal.
            if (items.Count != 0)
            {
                game.mngrLvl.ActorGoals++;
                game.mngrLvl.RemoveItem(this);
                game.playlist.Play(sndCollectGoal, X, Y);
            }

            spriteAtlas.Update(true);
            base.Update();
        }
예제 #9
0
        /// <summary>
        /// Handled by MazeActor.cs
        /// </summary>
        public override void Update()
        {
            //Determines solidity by custInt1.
            if (CustInt2 == 1)
            {
                IsSolid = true;
            }
            else
            {
                IsSolid = false;
            }

            //Determines animation by enabledness.
            if (IsEnabled)
            {
                spriteAtlas.frameSpeed = 0.35f;
            }
            else
            {
                spriteAtlas.frame      = 0;
                spriteAtlas.frameSpeed = 0;
            }

            //Handles activation behavior.
            if (IsEnabled && (IsActivated || CustInt1 == 0))
            {
                //Plays the activation sound.
                game.playlist.Play(sndActivated, X, Y);

                //Removes this block from the level.
                game.mngrLvl.RemoveItem(this);

                //Creates different blocks based on action type.
                if (ActionType > 4)
                {
                    game.mngrLvl.AddItem(Utils.BlockFromType
                                             (game, (Type)(ActionType - 5), X, Y, Layer));
                }
            }

            spriteAtlas.Update(true);
            base.Update();
        }
예제 #10
0
        /// <summary>
        /// Updates the atlas and damages actor on contact.
        /// </summary>
        public override void Update()
        {
            //Slowly rotates the sprite.
            BlockSprite.angle += 0.02f;

            //Gets a list of all actor blocks on the spike.
            List <GameObj> items = game.mngrLvl.items.Where(o =>
                                                            o.X == X && o.Y == Y && o.Layer == Layer &&
                                                            o.BlockType == Type.Actor).ToList();

            //Destroys all actors touching the spike.
            foreach (GameObj item in items)
            {
                (item as MazeActor).hp = 0;
                game.playlist.Play(MngrLvl.sndHit, X, Y); //Depends: MngrLvl.
            }

            spriteAtlas.Update(true);
            base.Update();
        }
예제 #11
0
        /// <summary>
        /// Determines orientation. Multiway interaction handled by
        /// MngrLvl and MazeActor.
        /// </summary>
        public override void Update()
        {
            //Updates the sprite by direction.
            if (BlockDir == Dir.Right)
            {
                BlockSprite.angle = 0;
            }
            else if (BlockDir == Dir.Down)
            {
                BlockSprite.angle = (float)(Math.PI / 2);
            }
            else if (BlockDir == Dir.Left)
            {
                BlockSprite.angle = (float)(Math.PI);
            }
            else
            {
                BlockSprite.angle = (float)(-Math.PI / 2);
            }

            //Determines the frame used.
            //Dependent on frame order.
            if (CustInt1 == 0)
            {
                spriteAtlas.frame = 0;
            }
            else
            {
                spriteAtlas.frame = 2;
            }
            if (!IsEnabled)
            {
                spriteAtlas.frame += 1;
            }

            spriteAtlas.Update(true);
            base.Update();
        }
        /// <summary>
        /// Deletes crates on the hole (moved to hole by MngrLvl). Controls
        /// sprite frame used.
        /// </summary>
        public override void Update()
        {
            //If a crate is on the hole, fills it and deletes the crate.
            if (IsSolid)
            {
                //Gets a list of all crates on the hole.
                List <GameObj> items = game.mngrLvl.items.Where(o =>
                                                                o.X == X && o.Y == Y && o.Layer == Layer &&
                                                                o.BlockType == Type.Crate).ToList();

                //Removes the first crate and fills the hole.
                if (items.Count != 0)
                {
                    game.mngrLvl.RemoveItem(items[0]);
                    game.playlist.Play(sndCrateHole, X, Y);

                    spriteAtlas.frame = 1;
                    IsSolid           = false;
                }
            }

            spriteAtlas.Update(true);
            base.Update();
        }
        /// <summary>
        /// Updates the atlas. Behavior handled by MngrLvl.cs.
        /// </summary>
        public override void Update()
        {
            #region Determines sprite by dir and isEnabled.
            if (BlockDir == Dir.Right)
            {
                spriteAtlas.frame = 0;
            }
            else if (BlockDir == Dir.Down)
            {
                spriteAtlas.frame = 1;
            }
            else if (BlockDir == Dir.Left)
            {
                spriteAtlas.frame = 2;
            }
            else if (BlockDir == Dir.Up)
            {
                spriteAtlas.frame = 3;
            }
            #endregion

            spriteAtlas.Update(true);
            base.Update();
        }
        /// <summary>
        /// Adds to the actor's health and deletes itself on contact.
        /// </summary>
        public override void Update()
        {
            //Gets a list of all actors on the health object.
            List <GameObj> items = game.mngrLvl.items.Where(o =>
                                                            o.X == X && o.Y == Y && o.Layer == Layer &&
                                                            o.BlockType == Type.Actor).ToList();

            //If there is at least one actor touching the health, the
            //first in the list gains 25 hp (no more than 100).
            if (items.Count != 0)
            {
                (items[0] as MazeActor).hp += 25;
                if ((items[0] as MazeActor).hp > 100)
                {
                    (items[0] as MazeActor).hp = 100;
                }

                game.mngrLvl.RemoveItem(this);
                game.playlist.Play(sndCollectHealth, X, Y);
            }

            spriteAtlas.Update(true);
            base.Update();
        }
예제 #15
0
        /// <summary>
        /// Controls sprite frames used and toggles isSolid.
        /// </summary>
        public override void Update()
        {
            if (!updateCalled)
            {
                //Starts as solid if chosen.
                if (CustInt2 == 1)
                {
                    IsSolid = true;
                }

                updateCalled = true;
            }

            //Determines the old solidity.
            bool wasSolid = IsSolid;

            //Handles activation.
            if (IsEnabled)
            {
                if (IsActivated)
                {
                    //If the gate should toggle solidity.
                    if (ActionType == 5)
                    {
                        IsSolid = !IsSolid;

                        IsActivated = false;
                        game.playlist.Play(sndActivated, X, Y);
                    }
                    //If the gate should be solid while active.
                    else if (ActionType == 6)
                    {
                        IsSolid = true;
                    }
                    //If the gate should be non-solid while active.
                    else if (ActionType == 7)
                    {
                        IsSolid = false;
                    }
                }
                else
                {
                    if (ActionType == 6)
                    {
                        IsSolid = false;
                    }
                    else if (ActionType == 7)
                    {
                        IsSolid = true;
                    }
                }

                //If the solidity changed.
                if (wasSolid != IsSolid)
                {
                    //All solids at the gate position, except itself.
                    List <GameObj> trappedActors = new List <GameObj>();
                    List <GameObj> items         = game.mngrLvl.items.Where(o =>
                                                                            o.X == X && o.Y == Y && o.Layer == Layer && o.IsSolid)
                                                   .ToList();
                    items.Remove(this);

                    //Solids prevent gate closure, so if it can close on actors,
                    //the actors must be removed from the list.
                    if (CustInt1 == 1)
                    {
                        trappedActors = items.Where(o =>
                                                    o.BlockType == Type.Actor).ToList();
                    }
                    //The gate becomes open if it can't close on solids.
                    if (items.Count - trappedActors.Count != 0)
                    {
                        IsSolid = false;
                    }

                    //Actors lose if trapped by a gate.
                    if (trappedActors.Count != 0)
                    {
                        foreach (GameObj item in trappedActors)
                        {
                            (item as MazeActor).hp = 0;
                        }
                    }
                }

                //Determines the sprite via solidity.
                spriteAtlas.frame = (IsSolid) ? 1 : 0;
            }

            spriteAtlas.Update(true);
            base.Update();
        }
예제 #16
0
        /// <summary>
        /// Adds to the actor's list of keys on contact.
        /// </summary>
        public override void Update()
        {
            //Determines the key color.
            switch (CustInt1)
            {
            case (0):
                BlockSprite.color = Color.Blue;
                break;

            case (1):
                BlockSprite.color = Color.Red;
                break;

            case (2):
                BlockSprite.color = Color.Goldenrod;
                break;

            case (3):
                BlockSprite.color = Color.Purple;
                break;

            case (4):
                BlockSprite.color = Color.Orange;
                break;

            case (5):
                BlockSprite.color = Color.Black;
                break;

            case (6):
                BlockSprite.color = Color.DarkBlue;
                break;

            case (7):
                BlockSprite.color = Color.DarkRed;
                break;

            case (8):
                BlockSprite.color = Color.DarkGoldenrod;
                break;

            case (9):
                BlockSprite.color = Color.DarkOrange;
                break;
            }

            //Gets a list of all actors on the key object.
            List <GameObj> items = game.mngrLvl.items.Where(o =>
                                                            o.X == X && o.Y == Y && o.Layer == Layer &&
                                                            o.BlockType == Type.Actor).ToList();

            //Adds the key to the index of the first actor to touch it.
            if (items.Count != 0)
            {
                (items[0] as MazeActor).keys.Add(BlockSprite.color);
                game.mngrLvl.RemoveItem(this);
                game.playlist.Play(sndCollectKey, X, Y);
            }

            spriteAtlas.Update(true);
            base.Update();
        }
        /// <summary>
        /// Clicks to activate.
        /// </summary>
        public override void Update()
        {
            #region Adjusts sprite and handles growing/shrinking animation.
            if (IsEnabled)
            {
                spriteAtlas.frame = 0;
                if (isShrinking)
                {
                    BlockSprite.scaleX -= 0.01f;
                    BlockSprite.scaleY -= 0.01f;
                    if (BlockSprite.scaleX <= 0.5f)
                    {
                        isShrinking = false;
                    }
                }
                else
                {
                    spriteAtlas.frame   = 0;
                    BlockSprite.scaleX += 0.01f;
                    BlockSprite.scaleY += 0.01f;
                    if (BlockSprite.scaleX >= 1)
                    {
                        isShrinking = true;
                    }
                }
            }
            else
            {
                spriteAtlas.frame = 1;
            }
            #endregion

            if (IsEnabled)
            {
                //The block activates itself when clicked.
                if (Sprite.IsIntersecting(BlockSprite, new SmoothRect
                                              (game.mngrLvl.GetCoordsMouse(), 1, 1)) &&
                    Layer == game.mngrLvl.actor.Layer)
                {
                    if (game.MsState.LeftButton == ButtonState.Pressed &&
                        game.MsStateOld.LeftButton == ButtonState.Released)
                    {
                        IsActivated = true;
                    }
                }

                //Handles activation behavior.
                if (IsActivated && ActionType > 4)
                {
                    //Deletes itself if applicable.
                    if (CustInt1 == 1)
                    {
                        game.mngrLvl.RemoveItem(this);
                    }

                    //Gets all items matching the index to affect.
                    List <GameObj> items = game.mngrLvl.items.Where(o =>
                                                                    o.ActionIndex == ActionIndex2).ToList();

                    //Filters out blocks on different layers.
                    if (CustInt2 == 1)
                    {
                        items = items.Where(o => o.Layer == Layer).ToList();
                    }

                    //Deactivates the item and plays sound.
                    IsActivated = false;
                    game.playlist.Play(sndActivated, X, Y);

                    if (ActionType == 5)
                    {
                        foreach (GameObj item in items)
                        {
                            item.IsActivated = true;
                        }
                    }
                    else if (ActionType == 6)
                    {
                        foreach (GameObj item in items)
                        {
                            item.IsActivated = false;
                        }
                    }
                    else if (ActionType == 7)
                    {
                        foreach (GameObj item in items)
                        {
                            item.IsActivated = !item.IsActivated;
                        }
                    }
                }
            }

            spriteAtlas.Update(true);
            base.Update();
        }
예제 #18
0
        /// <summary>
        /// Pushes solids out of the way.
        /// </summary>
        public override void Update()
        {
            //Causes a delay in sprite drawing.
            if (spriteAtlas.frame == 1 && pressTimer > 0)
            {
                pressTimer--;
                if (pressTimer == 0)
                {
                    spriteAtlas.frame = 0;
                    pressTimer        = pressTimerMax;
                    if (!IsEnabled)
                    {
                        spriteAtlas.frame = 2;
                    }
                }
            }

            #region Adjusts sprite.
            if (BlockDir == Dir.Right)
            {
                BlockSprite.angle = 0;
            }
            else if (BlockDir == Dir.Down)
            {
                BlockSprite.angle = (float)(Math.PI / 2);
            }
            else if (BlockDir == Dir.Left)
            {
                BlockSprite.angle = (float)(Math.PI);
            }
            else
            {
                BlockSprite.angle = (float)(-Math.PI / 2);
            }

            if (IsActivated && ActionType > 4)
            {
                spriteAtlas.frame = 1;
            }
            if (IsEnabled)
            {
                if (!IsActivated && pressTimer == 0)
                {
                    spriteAtlas.frame = 0;
                }
            }
            else
            {
                spriteAtlas.frame = 2;
            }
            #endregion

            if (IsActivated)
            {
                if (ActionType == 5)
                {
                    IsActivated = false;

                    if (IsEnabled)
                    {
                        //Gets a list of all solid blocks to be pushed and all
                        //solid blocks that may prevent movement.
                        List <GameObj> items = game.mngrLvl.items.Where(o =>
                                                                        o.X == X + (int)Utils.DirVector(BlockDir).X&&
                                                                        o.Y == Y + (int)Utils.DirVector(BlockDir).Y&&
                                                                        o.Layer == Layer && o.IsSolid).ToList();
                        List <GameObj> items2 = game.mngrLvl.items.Where(o =>
                                                                         o.X == X + (int)Utils.DirVector(BlockDir).X * 2 &&
                                                                         o.Y == Y + (int)Utils.DirVector(BlockDir).Y * 2 &&
                                                                         o.Layer == Layer && o.IsSolid).ToList();

                        //Solid blocks in the destination prevent pushing.
                        if (items2.Count != 0)
                        {
                            spriteAtlas.frame = 0;
                        }
                        else
                        {
                            game.playlist.Play(sndActivatePush, X, Y);

                            foreach (GameObj item in items)
                            {
                                item.X += (int)Utils.DirVector(BlockDir).X;
                                item.Y += (int)Utils.DirVector(BlockDir).Y;
                            }
                        }
                    }
                }
            }

            spriteAtlas.Update(true);
            base.Update();
        }
        /// <summary>
        /// Transfers between senders and receivers on contact if possible.
        /// </summary>
        public override void Update()
        {
            #region Adjusts sprite.
            //Adjusts the sprite frame.
            if (CustInt1 == 0)
            {
                spriteAtlas.frame = 0; //Sender.
            }
            else
            {
                spriteAtlas.frame = 2; //Receiver.
            }
            //Depends on frame positions and texture.
            if (!IsEnabled)
            {
                spriteAtlas.frame++;
            }
            #endregion

            //Sender logic.
            if (IsEnabled && CustInt1 == 0)
            {
                //Blocks on this block, blocks on receivers, and receivers.
                List <GameObj> itemsTop     = new List <GameObj>();
                List <GameObj> itemsDestTop = new List <GameObj>();
                List <GameObj> itemsNodes   = new List <GameObj>();

                //Gets a list of all blocks on the sender.
                itemsTop = game.mngrLvl.items.Where(o =>
                                                    o.X == X && o.Y == Y && o.Layer == Layer &&
                                                    (o.BlockSprite.depth < BlockSprite.depth)).ToList();

                #region Interaction: MazeTurretBullet
                itemsTop.AddRange(game.mngrLvl.items.Where(o =>
                                                           o.BlockType == Type.TurretBullet &&
                                                           Math.Abs(X * 32 + 16 - o.X) < 16 &&
                                                           Math.Abs(Y * 32 + 16 - o.Y) < 16 &&
                                                           o.Layer == Layer));
                #endregion

                //Gets a list of all enabled receivers.
                itemsNodes = game.mngrLvl.items.Where(o =>
                                                      o.BlockType == Type.Teleporter &&
                                                      o.IsEnabled &&
                                                      o.CustInt1 != 0 &&
                                                      o.CustInt2 == CustInt2).ToList();

                //Teleports blocks if receivers are available.
                foreach (GameObj item in itemsTop)
                {
                    //Filters out all incapable receivers.
                    for (int i = itemsNodes.Count - 1; i >= 0; i--)
                    {
                        //Gets a list of all solid blocks on the receiver.
                        itemsDestTop = game.mngrLvl.items.Where(o =>
                                                                o.X == itemsNodes[i].X &&
                                                                o.Y == itemsNodes[i].Y && o.Layer ==
                                                                itemsNodes[i].Layer && o.IsSolid).ToList();

                        //Iterates through each block on the receiver.
                        for (int j = itemsDestTop.Count - 1; j >= 0; j--)
                        {
                            #region Interaction: MazeCrate
                            if (itemsDestTop[j].BlockType == Type.Crate)
                            {
                                //Gets a list of all solid blocks in front.
                                List <GameObj> itemsDestFront =
                                    game.mngrLvl.items.Where(o => o.IsSolid &&
                                                             o.X == itemsNodes[i].X +
                                                             (int)Utils.DirVector(item.BlockDir).X&&
                                                             o.Y == itemsNodes[i].Y +
                                                             (int)Utils.DirVector(item.BlockDir).Y&&
                                                             o.Layer == itemsNodes[i].Layer).ToList();

                                //Removes valid multiways from the list.
                                #region Interaction: MazeMultiWay.cs
                                itemsDestFront = itemsDestFront.Where(o =>
                                                                      !(o.IsEnabled &&
                                                                        o.BlockType == Type.MultiWay &&
                                                                        ((o.CustInt1 == 0 && o.BlockDir == item.BlockDir) ||
                                                                         (o.CustInt1 != 0 && (o.BlockDir == item.BlockDir ||
                                                                                              o.BlockDir == Utils.DirOpp(BlockDir)))))).ToList();
                                #endregion

                                /*Allows a block to enter the teleporter if
                                 * the crate blocking the receiver can be
                                 * pushed out of the way in the direction the
                                 * block is traveling.*/
                                if (itemsDestFront.Count == 0)
                                {
                                    //Moves the crate; removes it from list.
                                    itemsDestTop[j].X +=
                                        (int)Utils.DirVector(item.BlockDir).X;
                                    itemsDestTop[j].Y +=
                                        (int)Utils.DirVector(item.BlockDir).Y;
                                    itemsDestTop[j].BlockDir = item.BlockDir;
                                    itemsDestTop.RemoveAt(j);
                                }
                            }
                            #endregion
                        }

                        //Removes the receiver for being incapable.
                        if (itemsDestTop.Count != 0)
                        {
                            itemsNodes.RemoveAt(i);
                        }
                    }

                    if (itemsNodes.Count != 0)
                    {
                        //Selects a receiver at random.
                        GameObj receiver =
                            itemsNodes[Utils.Rng.Next(itemsNodes.Count)];

                        game.playlist.Play(sndTeleport, X, Y);

                        #region Interaction: MazeTurretBullet
                        if (item.BlockType == Type.TurretBullet)
                        {
                            item.X  = (int)Math.IEEERemainder(item.X, 32);
                            item.Y  = (int)Math.IEEERemainder(item.Y, 32);
                            item.X += receiver.X * 32;
                            item.Y += receiver.Y * 32;
                        }
                        else
                        {
                            item.X = receiver.X;
                            item.Y = receiver.Y;
                        }
                        #endregion

                        item.Layer = receiver.Layer;
                    }
                }
            }

            spriteAtlas.Update(true);
            base.Update();
        }
예제 #20
0
        /// <summary>
        /// Adjusts the sprite to match the type, dir, etc. This is called
        /// whenever the sprite is updated.
        /// </summary>
        public void AdjustSprite()
        {
            BlockSprite = new Sprite();

            switch (BlockType)
            {
            case Type.Actor:
                BlockSprite              = new Sprite(true, MazeActor.TexActor);
                BlockSprite.depth        = 0.1f;
                BlockSprite.drawBehavior = SpriteDraw.all;
                BlockSpriteAtlas         = new SpriteAtlas(BlockSprite, 32, 32, 6, 2, 3);
                #region Chooses sprite by direction.
                if (BlockDir == Dir.Right)
                {
                    BlockSpriteAtlas.frame    = 0;
                    BlockSprite.spriteEffects = SpriteEffects.None;
                }
                else if (BlockDir == Dir.Down)
                {
                    BlockSpriteAtlas.frame    = 1;
                    BlockSprite.spriteEffects = SpriteEffects.None;
                }
                else if (BlockDir == Dir.Left)
                {
                    BlockSpriteAtlas.frame    = 0;
                    BlockSprite.spriteEffects = SpriteEffects.FlipHorizontally;
                }
                else
                {
                    BlockSpriteAtlas.frame    = 2;
                    BlockSprite.spriteEffects = SpriteEffects.None;
                }
                #endregion
                break;

            case Type.Belt:
                BlockSprite              = new Sprite(true, MazeBelt.TexBelt);
                BlockSprite.depth        = 0.401f;
                BlockSprite.doDrawOffset = true;
                BlockSprite.drawBehavior = SpriteDraw.all;
                BlockSpriteAtlas         = new SpriteAtlas(BlockSprite, 32, 32, 9, 1, 9);
                BlockSpriteAtlas.CenterOrigin();
                #region Chooses sprite by direction and isEnabled.
                if (BlockDir == Dir.Right)
                {
                    BlockSprite.angle = 0;
                }
                else if (BlockDir == Dir.Down)
                {
                    BlockSprite.angle = (float)(Math.PI / 2);
                }
                else if (BlockDir == Dir.Left)
                {
                    BlockSprite.angle = (float)(Math.PI);
                }
                else
                {
                    BlockSprite.angle = (float)(-Math.PI / 2);
                }

                //Determines the belt's image speed.
                if (IsEnabled)
                {
                    BlockSpriteAtlas.frameSpeed = 0.25f;
                }
                else
                {
                    BlockSpriteAtlas.frameSpeed = 0;
                }
                #endregion
                break;

            case Type.Checkpoint:
                //Sets sprite information.
                BlockSprite                 = new Sprite(true, MazeCheckpoint.TexCheckpoint);
                BlockSprite.depth           = 0.208f;
                BlockSpriteAtlas            = new SpriteAtlas(BlockSprite, 32, 32, 19, 2, 10);
                BlockSpriteAtlas.frameSpeed = 0.35f;
                break;

            case Type.Click:
                //Sets sprite information.
                BlockSprite              = new Sprite(true, MazeClick.TexClick);
                BlockSprite.depth        = 0.201f;
                BlockSprite.drawBehavior = SpriteDraw.all;
                BlockSpriteAtlas         = new SpriteAtlas(BlockSprite, 32, 32, 2, 1, 2);
                #region Adjusts sprite and handles growing/shrinking animation.
                if (IsEnabled)
                {
                    BlockSpriteAtlas.frame = 0;
                }
                else
                {
                    BlockSpriteAtlas.frame = 1;
                }
                #endregion
                break;

            case Type.Coin:
                BlockSprite                 = new Sprite(true, MazeCoin.TexCoin);
                BlockSprite.depth           = 0.205f;
                BlockSpriteAtlas            = new SpriteAtlas(BlockSprite, 32, 32, 19, 2, 10);
                BlockSpriteAtlas.frameSpeed = 0.2f;
                break;

            case Type.CoinLock:
                BlockSprite       = new Sprite(true, MazeCoinLock.TexCoinLock);
                BlockSprite.depth = 0.410f;
                break;

            case Type.Crate:
                BlockSprite                 = new Sprite(true, MazeCrate.TexCrate);
                BlockSprite.depth           = 0.3f;
                BlockSprite.rectSrc         = new SmoothRect(0, 0, 32, 32);
                BlockSprite.rectDest.Width  = 32;
                BlockSprite.rectDest.Height = 32;
                BlockSprite.drawBehavior    = SpriteDraw.basicAnimated;
                break;

            case Type.CrateHole:
                BlockSprite       = new Sprite(true, MazeCrateHole.TexCrateHole);
                BlockSprite.depth = 0.403f;
                BlockSpriteAtlas  = new SpriteAtlas(BlockSprite, 32, 32, 2, 1, 2);
                break;

            case Type.EAuto:
                //Sets sprite information.
                BlockSprite       = new Sprite(true, MazeEAuto.TexEAuto);
                BlockSprite.depth = 0.417f;
                BlockSpriteAtlas  = new SpriteAtlas(BlockSprite, 32, 32, 3, 2, 3);
                #region Adjusts sprite.
                if (IsEnabled)
                {
                    BlockSpriteAtlas.frameSpeed = 0.2f;
                }
                else
                {
                    BlockSpriteAtlas.frameSpeed = 0;
                }
                #endregion
                break;

            case Type.ELight:
                BlockSprite            = new Sprite(true, MazeELight.TexELight);
                BlockSprite.depth      = 0.416f;
                BlockSpriteAtlas       = new SpriteAtlas(BlockSprite, 32, 32, 2, 1, 2);
                BlockSpriteAtlas.frame = 1;
                break;

            case Type.Enemy:
                BlockSprite              = new Sprite(true, MazeEnemy.TexEnemy);
                BlockSprite.depth        = 0.4f;
                BlockSprite.drawBehavior = SpriteDraw.all;
                BlockSpriteAtlas         = new SpriteAtlas(BlockSprite, 32, 32, 4, 1, 4);
                #region Chooses sprite by direction and isEnabled.
                if (Utils.DirCardinal(BlockDir))
                {
                    if (IsEnabled)
                    {
                        BlockSpriteAtlas.frame = 0;
                    }
                    else
                    {
                        BlockSpriteAtlas.frame = 1;
                    }
                }
                else
                {
                    if (IsEnabled)
                    {
                        BlockSpriteAtlas.frame = 2;
                    }
                    else
                    {
                        BlockSpriteAtlas.frame = 3;
                    }
                }
                #endregion
                break;

            case Type.EPusher:
                BlockSprite              = new Sprite(true, MazeEPusher.TexEPusher);
                BlockSprite.depth        = 0.415f;
                BlockSprite.drawBehavior = SpriteDraw.all;
                BlockSpriteAtlas         = new SpriteAtlas(BlockSprite, 64, 32, 3, 1, 3);
                BlockSprite.doDrawOffset = true;
                BlockSprite.origin.X     = 16;
                BlockSprite.origin.Y     = 16;
                #region Adjusts sprite.
                if (BlockDir == Dir.Right)
                {
                    BlockSprite.angle = 0;
                }
                else if (BlockDir == Dir.Down)
                {
                    BlockSprite.angle = (float)(Math.PI / 2);
                }
                else if (BlockDir == Dir.Left)
                {
                    BlockSprite.angle = (float)(Math.PI);
                }
                else
                {
                    BlockSprite.angle = (float)(-Math.PI / 2);
                }
                if (IsEnabled)
                {
                    BlockSpriteAtlas.frame = 0;
                }
                else
                {
                    BlockSpriteAtlas.frame = 2;
                }
                #endregion
                break;

            case Type.Filter:
                BlockSprite              = new Sprite(true, MazeFilter.TexFilter);
                BlockSprite.depth        = 0.405f;
                BlockSprite.doDrawOffset = true;
                BlockSprite.drawBehavior = SpriteDraw.all;
                BlockSpriteAtlas         = new SpriteAtlas(BlockSprite, 32, 32, 19, 2, 10);
                BlockSpriteAtlas.CenterOrigin();
                #region Chooses frame speed by isEnabled.
                if (IsEnabled)
                {
                    BlockSpriteAtlas.frameSpeed = 0.35f;
                }
                else
                {
                    BlockSpriteAtlas.frame      = 0;
                    BlockSpriteAtlas.frameSpeed = 0;
                }
                #endregion
                break;

            case Type.Finish:
                BlockSprite       = new Sprite(true, MazeFinish.TexFinish);
                BlockSprite.depth = 0.417f;
                break;

            case Type.Floor:
                BlockSprite       = new Sprite(true, MazeFloor.TexFloor);
                BlockSprite.depth = 0.6f;
                break;

            case Type.Freeze:
                BlockSprite                 = new Sprite(true, MazeFreeze.TexFreeze);
                BlockSprite.depth           = 0.203f;
                BlockSprite.doDrawOffset    = true;
                BlockSprite.drawBehavior    = SpriteDraw.all;
                BlockSpriteAtlas            = new SpriteAtlas(BlockSprite, 32, 32, 10, 1, 10);
                BlockSpriteAtlas.frameSpeed = 0.4f;
                BlockSpriteAtlas.CenterOrigin();
                break;

            case Type.Gate:
                BlockSprite       = new Sprite(true, MazeGate.TexGate);
                BlockSprite.depth = 0.102f;
                BlockSpriteAtlas  = new SpriteAtlas(BlockSprite, 32, 32, 2, 1, 2);
                if (CustInt2 == 1)
                {
                    BlockSpriteAtlas.frame = 1;
                }
                break;

            case Type.Goal:
                BlockSprite                 = new Sprite(true, MazeGoal.TexGoal);
                BlockSprite.depth           = 0.202f;
                BlockSprite.doDrawOffset    = true;
                BlockSprite.drawBehavior    = SpriteDraw.all;
                BlockSpriteAtlas            = new SpriteAtlas(BlockSprite, 32, 32, 9, 1, 9);
                BlockSpriteAtlas.frameSpeed = 0.2f;
                BlockSpriteAtlas.CenterOrigin();
                break;

            case Type.Health:
                BlockSprite                 = new Sprite(true, MazeHealth.TexHealth);
                BlockSprite.depth           = 0.206f;
                BlockSpriteAtlas            = new SpriteAtlas(BlockSprite, 32, 32, 19, 2, 10);
                BlockSpriteAtlas.frameSpeed = 0.2f;
                break;

            case Type.Ice:
                BlockSprite       = new Sprite(true, MazeIce.TexIce);
                BlockSprite.depth = 0.5f;
                break;

            case Type.Key:
                BlockSprite                 = new Sprite(true, MazeKey.TexKey);
                BlockSprite.depth           = 0.207f;
                BlockSprite.drawBehavior    = SpriteDraw.all;
                BlockSpriteAtlas            = new SpriteAtlas(BlockSprite, 32, 32, 19, 2, 10);
                BlockSpriteAtlas.frameSpeed = 0.2f;
                #region Chooses key color by custInt1.
                switch (CustInt1)
                {
                case (0):
                    BlockSprite.color = Color.Blue;
                    break;

                case (1):
                    BlockSprite.color = Color.Red;
                    break;

                case (2):
                    BlockSprite.color = Color.Goldenrod;
                    break;

                case (3):
                    BlockSprite.color = Color.Purple;
                    break;

                case (4):
                    BlockSprite.color = Color.Orange;
                    break;

                case (5):
                    BlockSprite.color = Color.Black;
                    break;

                case (6):
                    BlockSprite.color = Color.DarkBlue;
                    break;

                case (7):
                    BlockSprite.color = Color.DarkRed;
                    break;

                case (8):
                    BlockSprite.color = Color.DarkGoldenrod;
                    break;

                case (9):
                    BlockSprite.color = Color.DarkOrange;
                    break;
                }
                #endregion
                break;

            case Type.LaserActuator:
                BlockSprite       = new Sprite(true, MazeLaserActuator.TexLaserActuator);
                BlockSprite.depth = 0.421f;
                BlockSpriteAtlas  = new SpriteAtlas(BlockSprite, 32, 32, 5, 1, 5);
                #region Adjusts sprite.
                if (IsEnabled)
                {
                    BlockSpriteAtlas.frame = 1;
                }
                #endregion
                break;

            case Type.Lock:
                BlockSprite              = new Sprite(true, MazeLock.TexLock);
                BlockSprite.depth        = 0.407f;
                BlockSprite.drawBehavior = SpriteDraw.all;
                #region Chooses lock color by custInt1.
                switch (CustInt1)
                {
                case (0):
                    BlockSprite.color = Color.Blue;
                    break;

                case (1):
                    BlockSprite.color = Color.Red;
                    break;

                case (2):
                    BlockSprite.color = Color.Goldenrod;
                    break;

                case (3):
                    BlockSprite.color = Color.Purple;
                    break;

                case (4):
                    BlockSprite.color = Color.Orange;
                    break;

                case (5):
                    BlockSprite.color = Color.Black;
                    break;

                case (6):
                    BlockSprite.color = Color.DarkBlue;
                    break;

                case (7):
                    BlockSprite.color = Color.DarkRed;
                    break;

                case (8):
                    BlockSprite.color = Color.DarkGoldenrod;
                    break;

                case (9):
                    BlockSprite.color = Color.DarkOrange;
                    break;
                }
                #endregion
                break;

            case Type.Message:
                BlockSprite       = new Sprite(true, MazeMessage.TexMessage);
                BlockSprite.depth = 0.209f;
                break;

            case Type.Mirror:
                BlockSprite = new Sprite(true, MazeMirror.TexMirror);
                BlockSprite.drawBehavior = SpriteDraw.all;
                BlockSprite.depth        = 0.420f;
                BlockSpriteAtlas         = new SpriteAtlas(BlockSprite, 32, 32, 4, 1, 4);
                if (BlockDir == Dir.Right)
                {
                    BlockSpriteAtlas.frame = 0;
                }
                else if (BlockDir == Dir.Down)
                {
                    BlockSpriteAtlas.frame = 1;
                }
                else if (BlockDir == Dir.Left)
                {
                    BlockSpriteAtlas.frame = 2;
                }
                else
                {
                    BlockSpriteAtlas.frame = 3;
                }
                break;

            case Type.MultiWay:
                BlockSprite              = new Sprite(true, MazeMultiWay.TexMultiWay);
                BlockSprite.depth        = 0.408f;
                BlockSprite.doDrawOffset = true;
                BlockSprite.drawBehavior = SpriteDraw.all;
                BlockSpriteAtlas         = new SpriteAtlas(BlockSprite, 32, 32, 4, 1, 4);
                BlockSpriteAtlas.CenterOrigin();
                #region Chooses sprite by direction and frame.
                //Updates the sprite by direction.
                if (BlockDir == Dir.Right)
                {
                    BlockSprite.angle = 0;
                }
                else if (BlockDir == Dir.Down)
                {
                    BlockSprite.angle = (float)(Math.PI / 2);
                }
                else if (BlockDir == Dir.Left)
                {
                    BlockSprite.angle = (float)(Math.PI);
                }
                else
                {
                    BlockSprite.angle = (float)(-Math.PI / 2);
                }

                //Determines the frame used.
                //Dependent on frame order.
                if (CustInt1 == 0)
                {
                    BlockSpriteAtlas.frame = 0;
                }
                else
                {
                    BlockSpriteAtlas.frame = 2;
                }
                if (!IsEnabled)
                {
                    BlockSpriteAtlas.frame += 1;
                }
                #endregion
                break;

            case Type.Panel:
                BlockSprite       = new Sprite(true, MazePanel.TexPanel);
                BlockSprite.depth = 0.414f;
                BlockSpriteAtlas  = new SpriteAtlas(BlockSprite, 32, 32, 4, 1, 4);
                break;

            case Type.Rotate:
                BlockSprite              = new Sprite(true, MazeRotate.TexRotate);
                BlockSprite.depth        = 0.418f;
                BlockSprite.doDrawOffset = true;
                BlockSprite.drawBehavior = SpriteDraw.all;
                BlockSpriteAtlas         = new SpriteAtlas(BlockSprite, 32, 32, 2, 1, 2);
                BlockSpriteAtlas.CenterOrigin();
                #region Adjusts sprite.
                if (IsEnabled)
                {
                    BlockSpriteAtlas.frame = 0;
                }
                else
                {
                    BlockSpriteAtlas.frame = 1;
                }
                #endregion
                break;

            case Type.Spawner:
                BlockSprite              = new Sprite(true, MazeSpawner.TexSpawner);
                BlockSprite.depth        = 0.402f;
                BlockSprite.drawBehavior = SpriteDraw.all;
                BlockSpriteAtlas         = new SpriteAtlas(BlockSprite, 32, 32, 8, 2, 4);
                #region Chooses sprite by direction and isEnabled.
                if (BlockDir == Dir.Right)
                {
                    BlockSpriteAtlas.frame = 0;
                }
                else if (BlockDir == Dir.Down)
                {
                    BlockSpriteAtlas.frame = 1;
                }
                else if (BlockDir == Dir.Left)
                {
                    BlockSpriteAtlas.frame = 2;
                }
                else
                {
                    BlockSpriteAtlas.frame = 3;
                }
                if (!IsEnabled)
                {
                    BlockSpriteAtlas.frame += 4;
                }
                #endregion
                break;

            case Type.Spike:
                BlockSprite                 = new Sprite(true, MazeSpike.TexSpike);
                BlockSprite.depth           = 0.409f;
                BlockSprite.drawBehavior    = SpriteDraw.all;
                BlockSprite.doDrawOffset    = true;
                BlockSpriteAtlas            = new SpriteAtlas(BlockSprite, 32, 32, 19, 2, 10);
                BlockSpriteAtlas.frameSpeed = 0.2f;
                BlockSpriteAtlas.CenterOrigin();
                break;

            case Type.Stairs:
                BlockSprite       = new Sprite(true, MazeStairs.TexStairs);
                BlockSprite.depth = 0.406f;
                BlockSpriteAtlas  = new SpriteAtlas(BlockSprite, 32, 32, 2, 1, 2);
                #region Chooses frame by custInt1.
                //Adjusts the sprite frame.
                if (CustInt1 == 0)
                {
                    BlockSpriteAtlas.frame = 0;     //up.
                }
                else
                {
                    BlockSpriteAtlas.frame = 1;     //down.
                }
                #endregion
                break;

            case Type.Teleporter:
                BlockSprite       = new Sprite(true, MazeTeleporter.TexTeleporter);
                BlockSprite.depth = 0.412f;
                BlockSpriteAtlas  = new SpriteAtlas(BlockSprite, 32, 32, 4, 1, 4);
                #region Chooses sprite by frame and isEnabled.
                //Adjusts the sprite frame.
                if (CustInt1 == 0)
                {
                    BlockSpriteAtlas.frame = 0;     //Sender.
                }
                else
                {
                    BlockSpriteAtlas.frame = 2;     //Receiver.
                }
                //Depends on frame positions and texture.
                if (!IsEnabled)
                {
                    BlockSpriteAtlas.frame++;
                }
                #endregion
                break;

            case Type.Thaw:
                BlockSprite                 = new Sprite(true, MazeThaw.TexThaw);
                BlockSprite.depth           = 0.204f;
                BlockSpriteAtlas            = new SpriteAtlas(BlockSprite, 32, 32, 13, 1, 13);
                BlockSpriteAtlas.frameSpeed = 0.25f;
                break;

            case Type.Turret:
                BlockSprite              = new Sprite(true, MazeTurret.TexTurret);
                BlockSprite.depth        = 0.419f;
                BlockSprite.drawBehavior = SpriteDraw.all;
                BlockSpriteAtlas         = new SpriteAtlas(BlockSprite, 32, 32, 8, 2, 4);
                #region Chooses sprite by direction and isEnabled.
                if (BlockDir == Dir.Right)
                {
                    BlockSpriteAtlas.frame = 0;
                }
                else if (BlockDir == Dir.Down)
                {
                    BlockSpriteAtlas.frame = 1;
                }
                else if (BlockDir == Dir.Left)
                {
                    BlockSpriteAtlas.frame = 2;
                }
                else
                {
                    BlockSpriteAtlas.frame = 3;
                }
                if (!IsEnabled)
                {
                    BlockSpriteAtlas.frame += 4;
                }
                #endregion
                break;

            case Type.Wall:
                BlockSprite       = new Sprite(true, MazeWall.TexWall);
                BlockSprite.depth = 0.413f;
                break;
            }

            //Synchronizes sprite position to location.
            BlockSprite.rectDest.X = X * 32 - 16; //-16 for camera offset.
            BlockSprite.rectDest.Y = Y * 32 - 16; //-16 for camera offset.
            if (BlockSpriteAtlas != null)
            {
                BlockSpriteAtlas.Update(true);
            }
        }
        /// <summary>
        /// Updates the atlas. Behavior handled by MngrLvl.cs.
        /// </summary>
        public override void Update()
        {
            #region Determines sprite by dir and isEnabled.
            if (BlockDir == Dir.Right)
            {
                spriteAtlas.frame = 0;
            }
            else if (BlockDir == Dir.Down)
            {
                spriteAtlas.frame = 1;
            }
            else if (BlockDir == Dir.Left)
            {
                spriteAtlas.frame = 2;
            }
            else if (BlockDir == Dir.Up)
            {
                spriteAtlas.frame = 3;
            }
            if (!IsEnabled)
            {
                spriteAtlas.frame += 4;
            }
            #endregion

            //Manages turret bullet spawning.
            if (IsEnabled)
            {
                msDelay -= 1;
                if (msDelay <= 0)
                {
                    msDelay = CustInt1;

                    MazeTurretBullet bullet = new MazeTurretBullet(game,
                                                                   X * 32 + 16, Y * 32 + 16, Layer);

                    //Updates the bullet position after adjusting it.
                    bullet.X += (int)((Utils.DirVector(BlockDir)).X * 16 - 4);
                    bullet.Y += (int)((Utils.DirVector(BlockDir)).Y * 16 - 4);

                    bullet.BlockSprite.rectDest.X = bullet.X;
                    bullet.BlockSprite.rectDest.Y = bullet.Y;

                    bullet.BlockDir = BlockDir;
                    bullet.CustInt2 = CustInt2; //Provides the bullet speed.
                    game.mngrLvl.AddItem(bullet);
                }

                //Fires a bullet when activated.
                if (IsActivated && ActionType == 5)
                {
                    IsActivated = false;

                    MazeTurretBullet bullet = new MazeTurretBullet(game,
                                                                   X * 32 + 16, Y * 32 + 16, Layer);

                    //Updates the bullet position after adjusting it.
                    bullet.X += (int)((Utils.DirVector(BlockDir)).X * 16 - 4);
                    bullet.Y += (int)((Utils.DirVector(BlockDir)).Y * 16 - 4);

                    bullet.BlockSprite.rectDest.X = bullet.X;
                    bullet.BlockSprite.rectDest.Y = bullet.Y;

                    bullet.BlockDir = BlockDir;
                    game.mngrLvl.AddItem(bullet);
                }
            }

            spriteAtlas.Update(true);
            base.Update();
        }
예제 #22
0
        /// <summary>
        /// Transfers actors up/down a layer on contact if possible.
        /// </summary>
        public override void Update()
        {
            //Adjusts the sprite frame.
            if (CustInt1 == 0)
            {
                spriteAtlas.frame = 0; //up.
            }
            else
            {
                spriteAtlas.frame = 1; //down.
            }

            //Gets a list of all actors on the stairs object.
            List <GameObj> items = game.mngrLvl.items.Where(o =>
                                                            o.X == X && o.Y == Y && o.Layer == Layer &&
                                                            (o.BlockType == Type.Actor || o.BlockType == Type.Enemy ||
                                                             o.BlockType == Type.Crate)).ToList();

            //If there is at least one actor/enemy/crate touching the stairs.
            foreach (GameObj item in items)
            {
                //Gets a list of all solids in the destination.
                List <GameObj> itemsDest;
                if (CustInt1 == 0)
                {
                    itemsDest = game.mngrLvl.items.Where(o => o.IsSolid &&
                                                         o.X == X && o.Y == Y && o.Layer == Layer + 1).ToList();
                }
                else
                {
                    itemsDest = game.mngrLvl.items.Where(o => o.IsSolid &&
                                                         o.X == X && o.Y == Y && o.Layer == Layer - 1).ToList();
                }

                #region Interaction: MazeMultiWay.cs
                itemsDest = itemsDest.Where(o => !(o.BlockType == Type.MultiWay &&
                                                   o.IsEnabled && ((o.CustInt1 == 0 && o.BlockDir == item.BlockDir) ||
                                                                   (o.CustInt1 != 0 && (o.BlockDir == item.BlockDir ||
                                                                                        o.BlockDir == Utils.DirOpp(item.BlockDir)))))).ToList();
                #endregion

                //Removes crates from the list if they can be pushed out of
                //the way by objects ascending/descending the stairs.
                List <GameObj> itemsFront;
                for (int i = itemsDest.Count - 1; i >= 0; i--)
                {
                    #region Interaction: MazeCrate.cs
                    if (itemsDest[i].BlockType == Type.Crate)
                    {
                        if (CustInt1 == 0)
                        {
                            itemsFront = game.mngrLvl.items.Where(o => o.IsSolid &&
                                                                  o.X == X + (int)Utils.DirVector(item.BlockDir).X&&
                                                                  o.Y == Y + (int)Utils.DirVector(item.BlockDir).Y&&
                                                                  o.Layer == Layer + 1).ToList();
                        }
                        else
                        {
                            itemsFront = game.mngrLvl.items.Where(o => o.IsSolid &&
                                                                  o.X == X + (int)Utils.DirVector(item.BlockDir).X&&
                                                                  o.Y == Y + (int)Utils.DirVector(item.BlockDir).Y&&
                                                                  o.Layer == Layer - 1).ToList();
                        }

                        #region Interaction: MazeMultiWay.cs
                        itemsFront = itemsFront.Where(o => !(o.IsEnabled &&
                                                             o.BlockType == Type.MultiWay && ((o.CustInt1 == 0 &&
                                                                                               o.BlockDir == item.BlockDir) || (o.CustInt1 != 0 &&
                                                                                                                                (o.BlockDir == item.BlockDir ||
                                                                                                                                 o.BlockDir == Utils.DirOpp(BlockDir)))))).ToList();
                        #endregion

                        if (itemsFront.Count == 0)
                        {
                            //Moves the crate and removes it from itemsTop.
                            itemsDest[i].X       += (int)Utils.DirVector(item.BlockDir).X;
                            itemsDest[i].Y       += (int)Utils.DirVector(item.BlockDir).Y;
                            itemsDest[i].BlockDir = item.BlockDir;
                            itemsDest.RemoveAt(i);
                        }
                    }
                    #endregion
                }

                //Transports the block if nothing covers the destination.
                if (itemsDest.Count == 0)
                {
                    if (CustInt1 == 0)
                    {
                        item.Layer++;
                        game.playlist.Play(sndStairsUp, X, Y);
                    }
                    else
                    {
                        item.Layer--;
                        game.playlist.Play(sndStairsDown, X, Y);
                    }
                }
            }

            spriteAtlas.Update(true);
            base.Update();
        }
        /// <summary>
        // Counts down to zero and activates linked items at zero.
        /// </summary>
        public override void Update()
        {
            #region Adjusts sprite.
            if (IsEnabled)
            {
                spriteAtlas.frameSpeed = 0.2f;
            }
            else
            {
                spriteAtlas.frameSpeed = 0;
            }
            #endregion

            //Counts down the timer and activates at zero.
            if (IsEnabled)
            {
                timer--;
                if (timer <= 0 && CustInt1 > 0)
                {
                    timer       = CustInt1;
                    IsActivated = true;
                }

                //Handles automated activation.
                if (IsActivated && ActionType > 4)
                {
                    //Deactivates the item and plays a sound.
                    IsActivated  = false;
                    hasActivated = true;
                    game.playlist.Play(sndActivateAuto, X, Y);

                    //Gets all items matching the index to affect.
                    List <GameObj> items = game.mngrLvl.items.Where(o =>
                                                                    o.ActionIndex == ActionIndex2).ToList();

                    //Filters out blocks on different layers.
                    if (CustInt2 == 1)
                    {
                        items = items.Where(o => o.Layer == Layer).ToList();
                    }

                    if (ActionType == 5)
                    {
                        foreach (GameObj item in items)
                        {
                            item.IsActivated = true;
                        }
                    }
                    else if (ActionType == 6)
                    {
                        foreach (GameObj item in items)
                        {
                            item.IsActivated = false;
                        }
                    }
                    else if (ActionType == 7)
                    {
                        foreach (GameObj item in items)
                        {
                            item.IsActivated = !item.IsActivated;
                        }
                    }
                }
                else if (hasActivated)
                {
                    hasActivated       = false;
                    spriteAtlas.frames = 3;
                    spriteAtlas.frame -= 3;
                }
            }

            spriteAtlas.Update(true);
            base.Update();
        }
        /// <summary>
        /// Transfers between senders and receivers on contact if possible.
        /// </summary>
        public override void Update()
        {
            //Gets a list of all solid blocks in the same location.
            List <GameObj> items = game.mngrLvl.items.Where(o =>
                                                            o.X == X && o.Y == Y && o.Layer == Layer &&
                                                            o.IsSolid).ToList();

            if (IsEnabled)
            {
                //Sets whether the panel is pressed down or not.
                isHeld = items.Count > 0;

                //If activated or held down.
                if (IsActivated || isHeld)
                {
                    IsActivated = false;

                    //All connected items are activated.
                    if (!hasActivated && ActionType > 4)
                    {
                        //Gets all items matching the index to affect.
                        items = game.mngrLvl.items.Where(o =>
                                                         o.ActionIndex == ActionIndex2).ToList();

                        //Filters out blocks on different layers.
                        if (CustInt1 == 1)
                        {
                            items = items.Where(o => o.Layer == Layer)
                                    .ToList();
                        }

                        //If there are linked items to activate, plays sound.
                        if (items.Count != 0)
                        {
                            game.playlist.Play(sndActivated, X, Y);
                        }

                        foreach (GameObj item in items)
                        {
                            item.IsActivated = true;
                        }
                    }

                    //The panel is now activated.
                    hasActivated = true;
                }
                else
                {
                    if (hasActivated)
                    {
                        //Gets all items matching the index to affect.
                        items = game.mngrLvl.items.Where(o =>
                                                         o.ActionIndex == ActionIndex2).ToList();

                        //Filters out blocks on different layers.
                        if (CustInt1 == 1)
                        {
                            items = items.Where(o =>
                                                o.Layer == Layer).ToList();
                        }

                        if (ActionType == 5)
                        {
                            foreach (GameObj item in items)
                            {
                                item.IsActivated = false;
                            }
                        }
                        else if (ActionType == 7)
                        {
                            IsEnabled = false;
                        }
                    }

                    //The panel is now deactivated.
                    hasActivated = false;
                }
            }

            #region Adjusts sprite.
            //Adjusts the sprite frame.
            if (!isHeld)
            {
                spriteAtlas.frame = 0; //Not pressed.
            }
            else
            {
                spriteAtlas.frame = 1; //Pressed.
            }
            //Depends on frame positions and texture.
            if (!IsEnabled)
            {
                spriteAtlas.frame += 2;
            }
            #endregion

            spriteAtlas.Update(true);
            base.Update();
        }
        /// <summary>
        /// Handled by MazeActor.cs
        /// </summary>
        public override void Update()
        {
            #region Adjusts sprite.
            if (IsEnabled)
            {
                spriteAtlas.frame = 0;
            }
            else
            {
                spriteAtlas.frame = 1;
            }
            #endregion

            if (IsActivated && ActionType > 4)
            {
                //Deactivates the object and plays a sound.
                IsActivated = false;
                game.playlist.Play(sndActivated, X, Y);

                //Saves the new positions of each block so the
                //transposition doesn't affect them twice.
                List <GameObj> queueItems  = new List <GameObj>();
                List <int>     queueItemsX = new List <int>();
                List <int>     queueItemsY = new List <int>();

                //Iterates through each affected space.
                for (int xx = 0; xx < CustInt1; xx++)
                {
                    for (int yy = 0; yy < CustInt1; yy++)
                    {
                        //Gets a list of all blocks in the space.
                        List <GameObj> blocks = game.mngrLvl.items
                                                .Where(o => o.Layer == Layer &&
                                                       o.X == xStart + xx && o.Y == yStart + yy)
                                                .ToList();

                        foreach (GameObj block in blocks)
                        {
                            queueItems.Add(block);
                            if (ActionType == 5 || ActionType == 7)
                            {
                                queueItemsX.Add(xStart + (CustInt1 - yy - 1));
                            }
                            else
                            {
                                queueItemsX.Add(xStart + yy);
                            }
                            if (ActionType == 6 || ActionType == 7)
                            {
                                queueItemsY.Add(yStart + (CustInt1 - xx - 1));
                            }
                            else
                            {
                                queueItemsY.Add(yStart + xx);
                            }
                        }
                    }
                }

                //Moves each block synchronously.
                for (int i = 0; i < queueItems.Count; i++)
                {
                    queueItems[i].X = queueItemsX[i];
                    queueItems[i].Y = queueItemsY[i];
                }
            }

            spriteAtlas.Update(true);
            base.Update();
        }
        /// <summary>
        /// Updates the atlas. Behavior handled by MngrLvl.cs.
        /// </summary>
        public override void Update()
        {
            //Performs activation behaviors.
            if (IsEnabled && IsActivated)
            {
                if (ActionType > 4)
                {
                    //Deactivates the item and plays a sound.
                    IsActivated = false;

                    //Gets a list of solid objects in the way.
                    List <GameObj> items = game.mngrLvl.items.Where(o =>
                                                                    o.X == X + (int)Utils.DirVector(BlockDir).X&&
                                                                    o.Y == Y + (int)Utils.DirVector(BlockDir).Y&&
                                                                    o.Layer == Layer && o.IsSolid).ToList();

                    #region Interaction: MazeMultiWay.cs
                    items = items.Where(o =>
                                        !(o.IsEnabled && o.BlockType == Type.MultiWay &&
                                          ((o.CustInt1 == 0 && o.BlockDir == BlockDir) ||
                                           (o.CustInt1 != 0 && (o.BlockDir == BlockDir ||
                                                                o.BlockDir == Utils.DirOpp(BlockDir)))))).ToList();
                    #endregion

                    //Creates an item if there are no solid objects.
                    if (items.Count == 0)
                    {
                        //Plays a sound when an object is spawned.
                        game.playlist.Play(sndActivated, X, Y);

                        //Creates different blocks based on action type.
                        game.mngrLvl.AddItem(Utils.BlockFromType(game,
                                                                 (Type)(ActionType - 5),
                                                                 X + (int)Utils.DirVector(BlockDir).X,
                                                                 Y + (int)Utils.DirVector(BlockDir).Y, Layer));
                    }
                }
            }

            #region Updates the sprite.
            //Updates the actor sprite by direction.
            //Depends on the texture frames and orientation.
            if (BlockDir == Dir.Right)
            {
                spriteAtlas.frame = 0;
            }
            else if (BlockDir == Dir.Down)
            {
                spriteAtlas.frame = 1;
            }
            else if (BlockDir == Dir.Left)
            {
                spriteAtlas.frame = 2;
            }
            else
            {
                spriteAtlas.frame = 3;
            }
            if (!IsEnabled)
            {
                spriteAtlas.frame += 4;
            }
            #endregion

            spriteAtlas.Update(true);
            base.Update();
        }
        /// <summary>
        /// Responds to movement requests.
        /// </summary>
        public override void Update()
        {
            #region Updates the sprite.
            //Updates the actor sprite by direction.
            //Depends on the texture frames and orientation.
            if (BlockDir == Dir.Right)
            {
                spriteAtlas.frame         = 0;
                BlockSprite.spriteEffects = SpriteEffects.None;
            }
            else if (BlockDir == Dir.Down)
            {
                spriteAtlas.frame         = 1;
                BlockSprite.spriteEffects = SpriteEffects.None;
            }
            else if (BlockDir == Dir.Left)
            {
                spriteAtlas.frame         = 0;
                BlockSprite.spriteEffects = SpriteEffects.FlipHorizontally;
            }
            else
            {
                spriteAtlas.frame         = 2;
                BlockSprite.spriteEffects = SpriteEffects.None;
            }
            if (this == game.mngrLvl.actor)
            {
                spriteAtlas.frame += 3;
            }
            #endregion

            #region Updates timer.
            _countdown--;
            if (_countdown == 0)
            {
                _countdown  = _countdownStart;
                IsTimerZero = true;
            }
            else
            {
                IsTimerZero = false;
            }
            #endregion

            #region Checks for actor death.
            if (hp <= 0)
            {
                if (game.mngrLvl.opSyncDeath)
                {
                    game.mngrLvl.doRevert = true;
                }
                else
                {
                    game.mngrLvl.RemoveItem(this);
                }
            }
            #endregion

            #region Player movement
            //Captures keyboard commands to move.
            if (IsEnabled && (this == game.mngrLvl.actor ||
                              game.mngrLvl.opSyncActors))
            {
                //Represents intent and ability to move.
                bool doMove = false, canMove = true;

                //Contains previous direction.
                Dir dirPrev = BlockDir;

                //If dir should be reverted. Almost never set to false.
                bool doRevertDir = true;

                //If the character hasn't met the step limit.
                //Prevents keystroke processing when app is inactive.
                if ((game.mngrLvl.OpMaxSteps == 0 ||
                     game.mngrLvl.LvlSteps < game.mngrLvl.OpMaxSteps) &&
                    game.IsActive)
                {
                    if ((game.KbState.IsKeyDown(Keys.D) &&
                         game.KbStateOld.IsKeyUp(Keys.D)) ||
                        (game.KbState.IsKeyDown(Keys.Right) &&
                         game.KbStateOld.IsKeyUp(Keys.Right)))
                    {
                        _countdown  = _countdownStart;
                        IsTimerZero = true;
                    }
                    else if ((game.KbState.IsKeyDown(Keys.S) &&
                              game.KbStateOld.IsKeyUp(Keys.S)) ||
                             (game.KbState.IsKeyDown(Keys.Down) &&
                              game.KbStateOld.IsKeyUp(Keys.Down)))
                    {
                        _countdown  = _countdownStart;
                        IsTimerZero = true;
                    }
                    else if ((game.KbState.IsKeyDown(Keys.A) &&
                              game.KbStateOld.IsKeyUp(Keys.A)) ||
                             (game.KbState.IsKeyDown(Keys.Left) &&
                              game.KbStateOld.IsKeyUp(Keys.Left)))
                    {
                        _countdown  = _countdownStart;
                        IsTimerZero = true;
                    }
                    else if ((game.KbState.IsKeyDown(Keys.W) &&
                              game.KbStateOld.IsKeyUp(Keys.W)) ||
                             (game.KbState.IsKeyDown(Keys.Up) &&
                              game.KbStateOld.IsKeyUp(Keys.Up)))
                    {
                        _countdown  = _countdownStart;
                        IsTimerZero = true;
                    }

                    //Updates the player direction based on movement.
                    //Prevents keystroke processing when app is inactive.
                    if (game.IsActive && IsTimerZero)
                    {
                        if (game.KbState.IsKeyDown(Keys.D) ||
                            game.KbState.IsKeyDown(Keys.Right))
                        {
                            BlockDir = Dir.Right;
                            doMove   = true;
                        }
                        else if (game.KbState.IsKeyDown(Keys.S) ||
                                 game.KbState.IsKeyDown(Keys.Down))
                        {
                            BlockDir = Dir.Down;
                            doMove   = true;
                        }
                        else if (game.KbState.IsKeyDown(Keys.A) ||
                                 game.KbState.IsKeyDown(Keys.Left))
                        {
                            BlockDir = Dir.Left;
                            doMove   = true;
                        }
                        else if (game.KbState.IsKeyDown(Keys.W) ||
                                 game.KbState.IsKeyDown(Keys.Up))
                        {
                            BlockDir = Dir.Up;
                            doMove   = true;
                        }
                    }

                    if (doMove)
                    {
                        //Considers all scenarios where the player can't move.
                        //Gets a list of all blocks at the location to move.
                        List <GameObj> items = game.mngrLvl.items.Where(o =>
                                                                        o.X == X + Utils.DirVector(BlockDir).X&&
                                                                        o.Y == Y + Utils.DirVector(BlockDir).Y&&
                                                                        o.Layer == Layer).ToList();

                        foreach (GameObj item in items)
                        {
                            #region Interaction: MazeBelt.cs
                            //Can't move into opposing belts.
                            if (item.BlockType == Type.Belt &&
                                item.IsEnabled &&
                                item.BlockDir == Utils.DirOpp(BlockDir))
                            {
                                canMove = false;
                            }
                            #endregion

                            //Can't move if space is occupied.
                            if (item.IsSolid)
                            {
                                #region Interaction: MazeLock.cs
                                if (item.BlockType == Type.Lock)
                                {
                                    if (keys.Count == 0)
                                    {
                                        canMove = false;
                                    }

                                    bool isFound = false;
                                    for (int i = keys.Count - 1; i >= 0; i--)
                                    {
                                        if (keys[i] == item.BlockSprite.color)
                                        {
                                            isFound = true;
                                            game.mngrLvl.RemoveItem(item);
                                            keys.RemoveAt(i);
                                            game.playlist.Play(sndLockOpen, X, Y);
                                            break;
                                        }
                                    }

                                    //Prevents walking through locks.
                                    if (!isFound)
                                    {
                                        canMove = false;
                                    }
                                }
                                #endregion

                                #region Interaction: MazeCoinLock.cs
                                if (item.BlockType == Type.CoinLock)
                                {
                                    bool isOpened = false;

                                    //Opens if player has enough coins.
                                    if (game.mngrLvl.ActorCoins >= item.CustInt1)
                                    {
                                        //Subtracts the coins.
                                        if (item.CustInt2 == 1)
                                        {
                                            game.mngrLvl.ActorCoins -= item.CustInt1;
                                        }

                                        isOpened = true;
                                        game.mngrLvl.RemoveItem(item);
                                        game.playlist.Play(sndLockOpen, X, Y);
                                        break;
                                    }

                                    //Prevents walking through locks.
                                    if (!isOpened)
                                    {
                                        canMove = false;
                                    }
                                }
                                #endregion

                                #region Interaction: MazeCrate.cs
                                else if (item.BlockType == Type.Crate)
                                {
                                    #region Interaction: MazeIce.cs
                                    //If the actor is on ice.
                                    if (game.mngrLvl.items.Any(o =>
                                                               o.BlockType == Type.Ice &&
                                                               o.X == X && o.Y == Y &&
                                                               o.Layer == Layer))
                                    {
                                        //If on ice without solid objects in
                                        //front, moving crates is not allowed.
                                        //This prevents moving crates to the
                                        //side of the actor while they slide.
                                        if (!game.mngrLvl.items.Any(o =>
                                                                    o.X == X + Utils.DirVector(dirPrev).X&&
                                                                    o.Y == Y + Utils.DirVector(dirPrev).Y&&
                                                                    o.Layer == Layer && o.IsSolid))
                                        {
                                            canMove = false;
                                            continue;
                                        }
                                    }
                                    #endregion

                                    //Gets a list of all solids ahead of the
                                    //crate in the player's direction.
                                    List <GameObj> itemsFront =
                                        game.mngrLvl.items.Where(o => o.X ==
                                                                 item.X + Utils.DirVector(BlockDir).X&&
                                                                 o.Y == item.Y + Utils.DirVector(BlockDir).Y &&
                                                                 o.Layer == Layer && o.BlockType !=
                                                                 Type.CrateHole).ToList();

                                    //Gets a list of all items the crate is on.
                                    List <GameObj> itemsTop =
                                        game.mngrLvl.items.Where(o => o.X ==
                                                                 item.X && o.Y == item.Y && o.Layer ==
                                                                 Layer && o.IsEnabled).ToList();

                                    //Removes crate from affecting itself.
                                    itemsTop.Remove(item);

                                    #region Interaction: MazeBelt.cs
                                    //Can't move crates into opposing belts.
                                    itemsFront = itemsFront.Where(o =>
                                                                  o.IsSolid || (o.BlockType == Type.Belt &&
                                                                                o.BlockDir == Utils.DirOpp(BlockDir) &&
                                                                                o.IsEnabled)).ToList();

                                    //Can't move crates from belts.
                                    itemsTop = itemsTop.Where(o =>
                                                              o.IsSolid || (o.BlockType == Type.Belt &&
                                                                            o.IsEnabled && o.BlockDir != BlockDir)).ToList();
                                    #endregion

                                    #region Interaction: MazeMultiWay.cs
                                    itemsFront = itemsFront.Where(o =>
                                                                  !(o.IsEnabled &&
                                                                    o.BlockType == Type.MultiWay &&
                                                                    ((o.CustInt1 == 0 && o.BlockDir == BlockDir) ||
                                                                     (o.CustInt1 != 0 && (o.BlockDir == BlockDir ||
                                                                                          o.BlockDir == Utils.DirOpp(BlockDir))))))
                                                 .ToList();

                                    itemsTop = itemsTop.Where(o =>
                                                              !(o.IsEnabled &&
                                                                o.BlockType == Type.MultiWay &&
                                                                ((o.CustInt1 == 0 && o.BlockDir == BlockDir) ||
                                                                 (o.CustInt1 != 0 && (o.BlockDir == BlockDir ||
                                                                                      o.BlockDir == Utils.DirOpp(BlockDir))))))
                                               .ToList();
                                    #endregion

                                    //If nothing is in way, moves the crate.
                                    if (itemsFront.Count == 0 &&
                                        itemsTop.Count == 0)
                                    {
                                        #region Interaction: MazeTurretBullet.cs
                                        //Finds all bullets skipped over by moving 32px at a time.
                                        //The +32 at the end accounts for sprite width and height.
                                        float          xMin    = Math.Min(item.X * 32, (item.X + Utils.DirVector(item.BlockDir).X) * 32);
                                        float          xMax    = Math.Max(item.X * 32, (item.X + Utils.DirVector(item.BlockDir).X) * 32) + 32;
                                        float          yMin    = Math.Min(item.Y * 32, (item.Y + Utils.DirVector(item.BlockDir).Y) * 32);
                                        float          yMax    = Math.Max(item.Y * 32, (item.Y + Utils.DirVector(item.BlockDir).Y) * 32) + 32;
                                        List <GameObj> bullets = game.mngrLvl.items.Where(o =>
                                                                                          o.BlockType == Type.TurretBullet &&
                                                                                          o.Layer == item.Layer &&
                                                                                          o.X >= xMin && o.X <= xMax &&
                                                                                          o.Y >= yMin && o.Y <= yMax)
                                                                 .ToList();

                                        for (int i = 0; i < bullets.Count; i++)
                                        {
                                            game.mngrLvl.RemoveItem(bullets[i]);
                                        }
                                        #endregion

                                        //Plays the crate-moving sound.
                                        game.playlist.Play
                                            (sndMoveCrate, X, Y);

                                        item.BlockDir = BlockDir; //used for ice.
                                        item.X       += (int)Utils.DirVector(BlockDir).X;
                                        item.Y       += (int)Utils.DirVector(BlockDir).Y;

                                        //Recalculates sprite (no flicker).
                                        item.Update();
                                    }
                                    else
                                    {
                                        canMove = false;
                                    }
                                }
                                #endregion

                                #region Interaction: MazeMultiWay.cs
                                else if (item.BlockType == Type.MultiWay)
                                {
                                    if ((item.CustInt1 == 0 &&
                                         item.BlockDir != BlockDir) ||
                                        (item.CustInt1 != 0 &&
                                         item.BlockDir != BlockDir &&
                                         item.BlockDir != Utils.DirOpp(BlockDir)) ||
                                        (item.IsEnabled == false))
                                    {
                                        canMove = false;
                                    }
                                }
                                else
                                {
                                    canMove = false;
                                }
                                #endregion
                            }
                        }

                        //Considers all scenarios where the player can't move.
                        //Gets a list of all blocks at the current location.
                        items = game.mngrLvl.items.Where(o => o.X == X &&
                                                         o.Y == Y && o.Layer == Layer && o.IsEnabled)
                                .ToList();

                        foreach (GameObj item in items)
                        {
                            #region Interaction: MazeBelt.cs
                            //Cannot move while on a belt.
                            if (item.BlockType == Type.Belt && item.IsEnabled)
                            {
                                canMove     = false;
                                doRevertDir = true;
                            }
                            #endregion

                            #region Interaction: MazeIce.cs
                            else if (item.BlockType == Type.Ice)
                            {
                                //Gets a list of blocks in front.
                                List <GameObj> itemsTemp;
                                itemsTemp = game.mngrLvl.items.Where(o =>
                                                                     o.X == X + Utils.DirVector(dirPrev).X&&
                                                                     o.Y == Y + Utils.DirVector(dirPrev).Y&&
                                                                     o.Layer == Layer).ToList();

                                #region Interaction: MazeMultiWay.cs
                                itemsTemp = itemsTemp.Where(o =>
                                                            !(o.IsEnabled && o.BlockType == Type.MultiWay &&
                                                              ((o.CustInt1 == 0 && o.BlockDir == dirPrev) ||
                                                               (o.CustInt1 != 0 && (o.BlockDir == dirPrev ||
                                                                                    o.BlockDir == Utils.DirOpp(dirPrev)
                                                                                    ))))).ToList();
                                #endregion
                                #region Interaction: MazeBelt.cs
                                //Blocked by solids and enabled belts.
                                itemsTemp = itemsTemp.Where(o =>
                                                            o.IsSolid || (o.BlockType == Type.Belt &&
                                                                          o.BlockDir != Utils.DirOpp(BlockDir))).ToList();
                                #endregion

                                //Can't move unless blocked.
                                if (itemsTemp.Count == 0)
                                {
                                    canMove = false;
                                }
                            }
                            #endregion

                            #region Interaction: MazeMultiWay.cs
                            else if (item.BlockType == Type.MultiWay)
                            {
                                if ((item.CustInt1 == 0 && item.BlockDir != BlockDir) ||
                                    (item.CustInt1 != 0 && item.BlockDir != BlockDir &&
                                     item.BlockDir != Utils.DirOpp(BlockDir)))
                                {
                                    canMove = false;
                                }
                            }
                            #endregion
                        }
                    }

                    //Moves the player if capable.
                    if (doMove && canMove)
                    {
                        #region Interaction: MazeFilter.cs
                        //Gets a list of all filters the actor is standing on.
                        List <GameObj> items = game.mngrLvl.items.Where(o =>
                                                                        o.X == X && o.Y == Y && o.Layer == Layer &&
                                                                        o.BlockType == Type.Filter).ToList();

                        //Decrements each filter's countdown.
                        foreach (GameObj item in items)
                        {
                            if (item.IsEnabled && item.CustInt1 > 0)
                            {
                                item.CustInt1--;
                            }
                        }
                        #endregion

                        #region Interaction: MazeTurretBullet.cs
                        //Finds all bullets skipped over by moving 32px at a time.
                        //The +32 at the end accounts for sprite width and height.
                        float          xMin    = Math.Min(X * 32, (X + Utils.DirVector(BlockDir).X) * 32);
                        float          xMax    = Math.Max(X * 32, (X + Utils.DirVector(BlockDir).X) * 32) + 32;
                        float          yMin    = Math.Min(Y * 32, (Y + Utils.DirVector(BlockDir).Y) * 32);
                        float          yMax    = Math.Max(Y * 32, (Y + Utils.DirVector(BlockDir).Y) * 32) + 32;
                        List <GameObj> bullets = game.mngrLvl.items.Where(o =>
                                                                          o.BlockType == Type.TurretBullet &&
                                                                          o.Layer == Layer &&
                                                                          o.X >= xMin && o.X <= xMax &&
                                                                          o.Y >= yMin && o.Y <= yMax)
                                                 .ToList();

                        List <GameObj> thisActor = new List <GameObj>();
                        thisActor.Add(this);

                        hp -= 25 * bullets.Count;
                        game.playlist.Play(MngrLvl.sndHit, X, Y);

                        for (int i = 0; i < bullets.Count; i++)
                        {
                            game.mngrLvl.RemoveItem(bullets[i]);
                        }
                        #endregion

                        X += (int)Utils.DirVector(BlockDir).X;
                        Y += (int)Utils.DirVector(BlockDir).Y;

                        //Increments the step counter if applicable.
                        if (this == game.mngrLvl.actor)
                        {
                            game.mngrLvl.LvlSteps++;
                        }
                    }
                    else if (doRevertDir)
                    {
                        BlockDir = dirPrev;
                    }
                }
            }
            #endregion

            #region player clicks to select actor
            if (!game.mngrLvl.opSyncActors && game.IsActive)
            {
                //If the player is clicked.
                if (game.MsState.LeftButton == ButtonState.Pressed &&
                    game.MsStateOld.LeftButton == ButtonState.Released &&
                    Sprite.IsIntersecting(BlockSprite, new SmoothRect
                                              (game.mngrLvl.GetCoordsMouse(), 1, 1)) &&
                    Layer == game.mngrLvl.actor.Layer)
                {
                    if (this != game.mngrLvl.actor)
                    {
                        game.mngrLvl.actor = this;

                        //Interaction: TitleItemMain.cs
                        SfxPlaylist.Play(TitleItemMain.sndBttnClick);
                    }
                }
            }
            #endregion

            spriteAtlas.Update(true);
            base.Update();
        }