Ejemplo n.º 1
0
        public void Update(GameTime gameTime, ref Player player)
        {
            if (InputManager.Instance.TouchPanelPressed() && BoundingBox.Contains(InputManager.Instance.TransformedTouchPosition))
                OnClick(this, null);

            Image.Update(gameTime);

            if ((State & Tile.TileState.Solid) == Tile.TileState.Solid)
            {
                //Rectangle playerRect = new Rectangle((int)player.Image.Position.X, (int)player.Image.Position.Y, player.Image.SourceRect.Width, player.Image.SourceRect.Height);
                Rectangle playerRect = new Rectangle ((int)player.Image.Position.X, (int)(player.Image.Position.Y + (player.Image.SourceRect.Height / 2)), player.Image.SourceRect.Width, (int)(player.Image.SourceRect.Height / 2));

                if (playerRect.Intersects(BoundingBox))
                {
                    Rectangle rectIntersection = Rectangle.Intersect (playerRect, BoundingBox);

                    if (rectIntersection.Height > rectIntersection.Width) {
                        if (player.Velocity.X < 0) {
                            player.UpdateImagePositionX (BoundingBox.Right);
                            player.Velocity = new Vector2 (0, player.Velocity.Y);
                        }

                        if (player.Velocity.X > 0) {
                            player.UpdateImagePositionX(BoundingBox.Left - player.Image.SourceRect.Width);
                            player.Velocity = new Vector2 (0, player.Velocity.Y);
                        }
                    }

                    if (rectIntersection.Width > rectIntersection.Height) {
                        if (player.Velocity.Y < 0) {
                            //player.Image.Position.Y = BoundingBox.Bottom;
                            player.UpdateImagePositionY (BoundingBox.Bottom - (player.Image.SourceRect.Height / 2));
                            player.Velocity = new Vector2 (player.Velocity.X, 0);
                        }

                        if (player.Velocity.Y > 0) {
                            player.UpdateImagePositionY (BoundingBox.Top - player.Image.SourceRect.Height);
                            player.Velocity = new Vector2 (player.Velocity.X, 0);
                        }
                    }

                    //if (player.Velocity.X < 0)
                        //player.Image.Position.X = BoundingBox.Right;
                    //else if (player.Velocity.X > 0)
                        //player.Image.Position.X = BoundingBox.Left - player.Image.SourceRect.Width;
                    //else if (player.Velocity.Y < 0)
                        //player.Image.Position.Y = BoundingBox.Bottom;
                    //else
                        //player.Image.Position.Y = BoundingBox.Top - player.Image.SourceRect.Height;

                    //player.Velocity = Vector2.Zero;
                }
            }
        }
Ejemplo n.º 2
0
        public void Update(GameTime gameTime, ref Player player)
        {
            if ((state & TileState.Solid) == TileState.Solid || (state & TileState.Entrance) == TileState.Entrance)
            {
                Rectangle tileRect = new Rectangle((int)position.X, (int)position.Y, sourceRect.Width, sourceRect.Height);
                //Rectangle playerRect = new Rectangle((int)player.Image.Position.X, (int)player.Image.Position.Y, player.Image.SourceRect.Width, player.Image.SourceRect.Height);
                Rectangle playerRect = new Rectangle ((int)player.Image.Position.X, (int)(player.Image.Position.Y + (player.Image.SourceRect.Height / 2)), player.Image.SourceRect.Width, (int)(player.Image.SourceRect.Height / 2));

                if (playerRect.Intersects(tileRect))
                {
                    if ((state & TileState.Entrance) == TileState.Entrance) {

                    }

                    Rectangle rectIntersection = Rectangle.Intersect (playerRect, tileRect);

                    if (rectIntersection.Height == rectIntersection.Width) {
                        if (player.Velocity.X < 0) {
                            player.UpdateImagePositionX (tileRect.Right);
                            player.Velocity = new Vector2 (0, player.Velocity.Y);
                        }

                        if (player.Velocity.X > 0) {
                            player.UpdateImagePositionX (tileRect.Left - player.Image.SourceRect.Width);
                            player.Velocity = new Vector2 (0, player.Velocity.Y);
                        }

                        if (player.Velocity.Y < 0) {
                            //player.Image.Position.Y = tileRect.Bottom;
                            player.UpdateImagePositionY (tileRect.Bottom - (player.Image.SourceRect.Height / 2));
                            player.Velocity = new Vector2 (player.Velocity.X, 0);
                        }

                        if (player.Velocity.Y > 0) {
                            player.UpdateImagePositionY (tileRect.Top - player.Image.SourceRect.Height);
                            player.Velocity = new Vector2 (player.Velocity.X, 0);
                        }
                    }

                    if (rectIntersection.Height > rectIntersection.Width) {
                        if (player.Velocity.X < 0) {
                            player.UpdateImagePositionX (tileRect.Right);
                            player.Velocity = new Vector2 (0, player.Velocity.Y);
                        }

                        if (player.Velocity.X > 0) {
                            player.UpdateImagePositionX (tileRect.Left - player.Image.SourceRect.Width);
                            player.Velocity = new Vector2 (0, player.Velocity.Y);
                        }
                    }

                    if (rectIntersection.Width > rectIntersection.Height) {
                        if (player.Velocity.Y < 0) {
                            //player.Image.Position.Y = tileRect.Bottom;
                            player.UpdateImagePositionY(tileRect.Bottom - (player.Image.SourceRect.Height / 2));
                            player.Velocity = new Vector2 (player.Velocity.X, 0);
                        }

                        if (player.Velocity.Y > 0) {
                            player.UpdateImagePositionY (tileRect.Top - player.Image.SourceRect.Height);
                            player.Velocity = new Vector2 (player.Velocity.X, 0);
                        }
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void Update(GameTime gameTime, ref Player player)
        {
            if (InteractionType == Globals.MapEntranceInteractionType.Click) {
                if (InputManager.Instance.TouchPanelPressed () && BoundingBox.Contains (InputManager.Instance.TransformedTouchPosition)) {
                    if (Locked) {
                        if (!HasPrerequisiteSongism || (HasPrerequisiteSongism && Inventory.Instance.PrerequisiteSongismHasBeenDiscovered (PrerequisiteSongism))) {
                            Locked = false;
                        }
                    }

                    if (!Locked) {
                        OnClick (this, null);
                    }
                }
            }

            if (HasImage) {
                Image.Update(gameTime);
            }

            if ((State & Tile.TileState.Solid) == Tile.TileState.Solid)
            {
                //Rectangle playerRect = new Rectangle((int)player.Image.Position.X, (int)player.Image.Position.Y, player.Image.SourceRect.Width, player.Image.SourceRect.Height);
                Rectangle playerRect = new Rectangle ((int)player.Image.Position.X, (int)(player.Image.Position.Y + (player.Image.SourceRect.Height / 2)), player.Image.SourceRect.Width, (int)(player.Image.SourceRect.Height / 2));

                if (playerRect.Intersects(BoundingBox))
                {
                    if (InteractionType == Globals.MapEntranceInteractionType.PlayerEnter) {
                        OnPlayerEnter (this, null);
                    }

                    Rectangle rectIntersection = Rectangle.Intersect (playerRect, BoundingBox);

                    if (rectIntersection.Height > rectIntersection.Width) {
                        if (player.Velocity.X < 0) {
                            player.UpdateImagePositionX (BoundingBox.Right);
                            player.Velocity = new Vector2 (0, player.Velocity.Y);
                        }

                        if (player.Velocity.X > 0) {
                            player.UpdateImagePositionX (BoundingBox.Left - player.Image.SourceRect.Width);
                            player.Velocity = new Vector2 (0, player.Velocity.Y);
                        }
                    }

                    if (rectIntersection.Width > rectIntersection.Height) {
                        if (player.Velocity.Y < 0) {
                            //player.Image.Position.Y = BoundingBox.Bottom;
                            player.UpdateImagePositionY (BoundingBox.Bottom - (player.Image.SourceRect.Height / 2));
                            player.Velocity = new Vector2 (player.Velocity.X, 0);
                        }

                        if (player.Velocity.Y > 0) {
                            player.UpdateImagePositionY (BoundingBox.Top - player.Image.SourceRect.Height);
                            player.Velocity = new Vector2 (player.Velocity.X, 0);
                        }
                    }

                    //if (player.Velocity.X < 0)
                        //player.Image.Position.X = BoundingBox.Right;
                    //else if (player.Velocity.X > 0)
                        //player.Image.Position.X = BoundingBox.Left - player.Image.SourceRect.Width;
                    //else if (player.Velocity.Y < 0)
                        //player.Image.Position.Y = BoundingBox.Bottom;
                    //else
                        //player.Image.Position.Y = BoundingBox.Top - player.Image.SourceRect.Height;

                    //player.Velocity = Vector2.Zero;
                }
            }
        }
Ejemplo n.º 4
0
        public void Update(GameTime gameTime, ref Player player)
        {
            if (InputManager.Instance.TouchPanelPressed () && BoundingBox.Contains (InputManager.Instance.TransformedTouchPosition)) {
                if (Inventory.Instance.PrerequisiteSongismHasBeenDiscovered (this.MissionSongismName)) {
                    MissionCompleted = true;

                } else {
                    InteractionBoundingBoxPosition.X = (int)(Camera2D.Instance.Position.X - (ScreenManager.Instance.GraphicsDevice.Viewport.Width / 2)) + 256;

                    InteractionImage.UpdatePositionX ((int)InteractionBoundingBoxPosition.X);

                    MissionCompleteInteractionImage.UpdatePositionX ((int)InteractionBoundingBoxPosition.X);
                    InteractionBoundingBox.X = (int)InteractionBoundingBoxPosition.X;
                }

                OnClick (this, null);
            }
            else if (InputManager.Instance.TouchPanelPressed () && InteractionBoundingBox.Contains (InputManager.Instance.TransformedTouchPosition) && CurrentlyInteracting) {
                OnClick (this, null);

                if (MissionCompleted) {
                    if (MissionReward != null) {
                        Inventory.Instance.Items.Add (MissionReward);
                    }

                    SetNpcToInactive ();
                }
            }

            if (CurrentlyInteracting) {
                if (MissionCompleted) {
                    MissionCompleteInteractionImage.Update (gameTime);
                } else {
                    InteractionImage.Update (gameTime);
                }
            } else {
                Image.Update (gameTime);

                if ((State & Tile.TileState.Solid) == Tile.TileState.Solid) {
                    Rectangle playerRect = new Rectangle ((int)player.Image.Position.X, (int)(player.Image.Position.Y + (player.Image.SourceRect.Height / 2)), player.Image.SourceRect.Width, (int)(player.Image.SourceRect.Height / 2));

                    if (playerRect.Intersects(BoundingBox))
                    {
                        Rectangle rectIntersection = Rectangle.Intersect (playerRect, BoundingBox);

                        if (rectIntersection.Height > rectIntersection.Width) {
                            if (player.Velocity.X < 0) {
                                player.UpdateImagePositionX (BoundingBox.Right);
                                player.Velocity = new Vector2 (0, player.Velocity.Y);
                            }

                            if (player.Velocity.X > 0) {
                                player.UpdateImagePositionX (BoundingBox.Left - player.Image.SourceRect.Width);
                                player.Velocity = new Vector2 (0, player.Velocity.Y);
                            }
                        }

                        if (rectIntersection.Width > rectIntersection.Height) {
                            if (player.Velocity.Y < 0) {
                                //player.Image.Position.Y = BoundingBox.Bottom;
                                player.UpdateImagePositionY (BoundingBox.Bottom - (player.Image.SourceRect.Height / 2));
                                player.Velocity = new Vector2 (player.Velocity.X, 0);
                            }

                            if (player.Velocity.Y > 0) {
                                player.UpdateImagePositionY (BoundingBox.Top - player.Image.SourceRect.Height);
                                player.Velocity = new Vector2 (player.Velocity.X, 0);
                            }
                        }

                        //if (player.Velocity.X < 0)
                        //player.Image.Position.X = BoundingBox.Right;
                        //else if (player.Velocity.X > 0)
                        //player.Image.Position.X = BoundingBox.Left - player.Image.SourceRect.Width;
                        //else if (player.Velocity.Y < 0)
                        //player.Image.Position.Y = BoundingBox.Bottom;
                        //else
                        //player.Image.Position.Y = BoundingBox.Top - player.Image.SourceRect.Height;

                        //player.Velocity = Vector2.Zero;
                    }
                }
            }
        }
        public void Update(GameTime gameTime, ref Player player)
        {
            foreach (Tile tile in underlayTiles)
                tile.Update(gameTime, ref player);

            foreach (Tile tile in overlayTiles)
                tile.Update(gameTime, ref player);
        }
Ejemplo n.º 6
0
        public void Update(GameTime gameTime, ref Player player)
        {
            if (ScreenManager.Instance.GameplayScreenActive)
            {
                /* If the Gameplay screen is active and we're set as guessing the songism, this means we just got back from guessing */
                if (ScreenManager.Instance.IsGuessingSongism)
                {
                    //Camera2D.Instance.Position = player.Position;

                    ScreenManager.Instance.IsGuessingSongism = false;
                    XmlManager<Songism> songismLoader = new XmlManager<Songism>();
                    Songism currentSongism = songismLoader.Load(System.IO.Path.Combine(Globals.LoadGameplaySongismsDirectory, "CurrentSongism.xml"));

                    if (currentSongism.Discovered)
                    {
                        foreach (Songism songism in Songisms)
                        {
                            if (songism.Name.Equals(currentSongism.Name))
                            {
                                songism.Discovered = currentSongism.Discovered;

                                if (songism.Name == "Frolic Room" && songism.Image.Path == "Gameplay/Songisms/frolic_room_dark") {
                                    songism.Image.UnloadContent ();

                                    songism.Image.Path = "Gameplay/Songisms/frolic_room_light";

                                    songism.Image.LoadContent ();

                                    songism.Image.Alpha= 1;

                                    songism.Image.Position = new Vector2 (448, 64);
                                    songism.Image.SourceRect = new Rectangle (448, 64, 256, 128);
                                    songism.Image.SourceRect = new Rectangle (0, 0, songism.Image.SourceRect.Width, songism.Image.SourceRect.Height);
                                    songism.Image.IsActive = true;

                                    songism.Image.FadeEffect.IsActive = false;
                                    songism.Image.SpriteSheetEffect.IsActive = false;
                                }
                                break;
                            }
                        }

                        XmlManager<List<Songism>> songismSaver = new XmlManager<List<Songism>>();
                        songismSaver.Save (System.IO.Path.Combine (Globals.LoadGameplaySongismsDirectory, MapName + ".xml"), Songisms);
                    }
                }

                foreach (Layer l in Layers)
                    l.Update(gameTime, ref player);

                foreach (MapEntrance mapEntrance in MapEntrances)
                    mapEntrance.Update (gameTime, ref player);

                foreach (Songism songism in Songisms)
                    songism.Update(gameTime, ref player);

                bool fInteracting = false;
                foreach (NPC npc in NPCs) {
                    if (npc.IsActive) {
                        npc.Update (gameTime, ref player);
                        if (npc.CurrentlyInteracting)
                            fInteracting = true;
                    }
                }

                ScreenManager.Instance.IsInteractingWithNpc = fInteracting;
            }

            //if (dialog != null)
            //{
            //    dialog.Update(gameTime);

            //    if (dialog.DialogResult == DialogResult.AddToSongBook)
            //    {
            //        /*
            //            The player correctly guessed the name of the songism
            //            Let's set the discovered property to 'true' and add it to the SongBook
            //        */
            //        currentSongism.Discovered = true;
            //        Inventory.Instance.SongBook.Add(currentSongism);

            //        dialog.UnloadContent();
            //        dialog = null;
            //        currentSongism = null;
            //    }
            //    else if (dialog.DialogResult == DialogResult.Cancel)
            //    {
            //        dialog.UnloadContent();
            //        dialog = null;
            //        currentSongism = null;
            //    }
            //}
        }