Esempio n. 1
0
        private void HellCanvas_KeyDown(object sender, KeyEventArgs e)
        {
            GenObstacle.CollisionCheck();
            GenObstacle obs = GenObstacle.ClosestElement();

            if (GoodStory.OccuredOnce != true)
            {
                GoodStory.PrintLevelIntro(StoryBox);
            }

            if (e.Key == Key.Escape)
            {
                PauseScreen pause = new PauseScreen(this);
                pause.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                pause.ShowDialog();
            }
            else if (obs.CollisionStatus)
            {
                if (obs.collideable)
                {
                    if (Canvas.GetRight(MainCharacter) == Canvas.GetLeft(GenObstacle.ClosestObstacle))//going right
                    {
                        press.RestrictRight(e);
                    }

                    else if (Canvas.GetBottom(MainCharacter) == Canvas.GetTop(GenObstacle.ClosestObstacle))//going down
                    {
                        press.RestrictDown(e);
                    }

                    else if (Canvas.GetTop(MainCharacter) == Canvas.GetBottom(GenObstacle.ClosestObstacle))//going up
                    {
                        press.RestrictUp(e);
                    }

                    else if (Canvas.GetLeft(MainCharacter) == Canvas.GetRight(GenObstacle.ClosestObstacle))//going left
                    {
                        press.RestrictLeft(e);
                    }

                    else
                    {
                        press.MoveFreely(e);
                    }
                }
                else if (obs is Item)
                {
                    HellCanvas.Children.Remove(GenObstacle.ClosestObstacle);
                    CollectItm.Collect(GenObstacle.ClosestObstacle);
                    obs.Remove(obs);
                    LevelFinished = true;

                    GoodStory.PrintConversation(StoryBox);
                    GoodStory.ShouldContinue = true;
                }
                else if (obs is Door)
                {
                    if (LevelFinished)
                    {
                        obs.Clear();
                        this.Close();
                    }
                    else if (Canvas.GetLeft(MainCharacter) == Canvas.GetRight(GenObstacle.ClosestObstacle))
                    {
                        press.RestrictLeft(e);
                    }

                    else if (Canvas.GetBottom(MainCharacter) == Canvas.GetTop(GenObstacle.ClosestObstacle))
                    {
                        press.RestrictDown(e);
                    }
                    else
                    {
                        press.MoveFreely(e);
                    }
                }
            }
            else
            {
                press.MoveFreely(e);
            }
            Canvas.SetRight(MainCharacter, Canvas.GetLeft(MainCharacter) + MainCharacter.Width);//setting right and bottom of character
            Canvas.SetBottom(MainCharacter, Canvas.GetTop(MainCharacter) + MainCharacter.Height);
        }
Esempio n. 2
0
        private void TraverseCanvas_KeyDown(object sender, KeyEventArgs e)
        {
            /*<Summary> Controls player movement, collision checking and the story within the level. />*/

            GenObstacle.CollisionCheck();
            GenObstacle obs = GenObstacle.ClosestElement();

            if (GoodStory.OccuredOnce != true)
            {
                GoodStory.PrintLevelIntro(StoryBox);
            }

            if (e.Key == Key.Escape)
            {
                PauseScreen pause = new PauseScreen(this);
                pause.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                pause.ShowDialog();
            }
            else if (obs.CollisionStatus)
            {
                if (obs.collideable)
                {
                    if (Canvas.GetRight(character) == Canvas.GetLeft(GenObstacle.ClosestObstacle))//going right
                    {
                        move.RestrictRight(e);
                    }

                    else if (Canvas.GetBottom(character) == Canvas.GetTop(GenObstacle.ClosestObstacle))//going down
                    {
                        move.RestrictDown(e);
                    }

                    else if (Canvas.GetTop(character) == Canvas.GetBottom(GenObstacle.ClosestObstacle))//going up
                    {
                        move.RestrictUp(e);
                    }

                    else if (Canvas.GetLeft(character) == Canvas.GetRight(GenObstacle.ClosestObstacle))//going left
                    {
                        move.RestrictLeft(e);
                    }

                    else
                    {
                        move.MoveFreely(e);
                    }
                }
                else if (obs is NPC)
                {
                    if (GoodStory.ShouldContinue == false && observe.Count == 0)
                    {
                        /*<Summary> The player chooses the good path. />*/

                        GoodStory.PrintConversation(StoryBox);
                        make.MakeItem(character, canvas, @"../../Object Model/Band.png", bandage1);
                        make.MakeItem(character, canvas, @"../../Object Model/Band.png", bandage2);
                        make.MakeItem(character, canvas, @"../../Object Model/Band.png", bandage3);
                        GoodStory.ShouldContinue = true;

                        canvas.Children.Remove(money);
                    }

                    else if (GoodStory.ShouldContinue == true && observe.Count == 3 && GoodStory.IsComplete == false)
                    {
                        BitmapImage bit = new BitmapImage();

                        bit.BeginInit();
                        bit.UriSource = new Uri("../../Object Model/Amb.png", UriKind.Relative);
                        bit.EndInit();

                        ambulance.Source = bit;

                        GoodStory.PrintConversation(StoryBox);
                        canvas.Children.Remove(NPC1);
                        observe.Clear();
                        GameBeaten = true;
                    }

                    move.MoveFreely(e);
                }

                else if (obs is Item)
                {
                    if (GoodStory.ShouldContinue == false && BadStory.IsComplete == false)
                    {
                        BadStory.PrintConversation(StoryBox);
                    }

                    canvas.Children.Remove(GenObstacle.ClosestObstacle);

                    ItmCollect.Collect(GenObstacle.ClosestObstacle);
                    obs.Remove(obs);
                }

                else if (obs is Door)
                {
                    if (BadStory.IsComplete)
                    {
                        obs.Clear();
                        LevelFinished = true;
                        this.Close();
                    }
                    else if (GoodStory.IsComplete)
                    {
                        obs.Clear();
                        GameBeaten = true;
                        this.Close();
                    }
                    move.RestrictUp(e);
                }
            }

            else
            {
                move.MoveFreely(e);
            }

            Canvas.SetRight(character, Canvas.GetLeft(character) + character.Width);
            Canvas.SetBottom(character, Canvas.GetTop(character) + character.Height);
        }
        private void HellCanvas_KeyDown(object sender, KeyEventArgs e)
        {
            GenObstacle.CollisionCheck();
            GenObstacle obs = GenObstacle.ClosestElement();

            if (GoodStory.OccuredOnce != true)
            {
                GoodStory.PrintLevelIntro(StoryText);
            }

            if (e.Key == Key.Escape)
            {
                PauseScreen pause = new PauseScreen(this);
                pause.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                pause.ShowDialog();
            }
            else if (obs.CollisionStatus)
            {
                if (obs.collideable)
                {
                    if (Canvas.GetRight(MainCharacter) == Canvas.GetLeft(GenObstacle.ClosestObstacle))//going right
                    {
                        press.RestrictRight(e);
                    }

                    else if (Canvas.GetBottom(MainCharacter) == Canvas.GetTop(GenObstacle.ClosestObstacle))//going down
                    {
                        press.RestrictDown(e);
                    }

                    else if (Canvas.GetTop(MainCharacter) == Canvas.GetBottom(GenObstacle.ClosestObstacle))//going up
                    {
                        press.RestrictUp(e);
                    }

                    else if (Canvas.GetLeft(MainCharacter) == Canvas.GetRight(GenObstacle.ClosestObstacle))//going left
                    {
                        press.RestrictLeft(e);
                    }

                    else
                    {
                        press.MoveFreely(e);
                    }
                }
                else if (obs is NPC)
                {
                    if (inv.Count == 1)
                    {
                        if (GoodStory.ShouldContinue)
                        {
                            if (GoodStory.IsComplete != true)
                            {
                                GoodStory.PrintConversation(StoryText);
                                LevelFinished = true;
                                GameBeaten    = true;
                            }
                        }
                    }
                    press.MoveFreely(e);
                }
                else if (obs is Item)
                {
                    HellCanvas.Children.Remove(GenObstacle.ClosestObstacle);
                    CollectItm.Collect(GenObstacle.ClosestObstacle);
                    obs.Remove(obs);

                    if (inv.Count == 3)
                    {
                        inv.Clear();

                        Image       img = new Image();
                        BitmapImage bit = new BitmapImage();

                        bit.BeginInit();
                        bit.UriSource = new Uri("../../Object Model/Trident.png", UriKind.Relative);
                        bit.EndInit();

                        img.Source = bit;
                        CollectItm.Collect(img);
                        GoodStory.ShouldContinue = true;
                    }
                }
                else if (obs is Door)
                {
                    if (GoodStory.IsComplete)
                    {
                        this.Close();
                    }

                    else if (Canvas.GetTop(MainCharacter) == Canvas.GetBottom(GenObstacle.ClosestObstacle))//going up
                    {
                        press.RestrictUp(e);
                    }

                    else if (Canvas.GetLeft(MainCharacter) == Canvas.GetRight(GenObstacle.ClosestObstacle))//going left
                    {
                        press.RestrictLeft(e);
                    }

                    else
                    {
                        press.MoveFreely(e);
                    }
                }
            }
            else
            {
                press.MoveFreely(e);
            }
            Canvas.SetRight(MainCharacter, Canvas.GetLeft(MainCharacter) + MainCharacter.Width);//setting right and bottom of character
            Canvas.SetBottom(MainCharacter, Canvas.GetTop(MainCharacter) + MainCharacter.Height);
        }
Esempio n. 4
0
        private void HellCanvas_keyDown(object sender, KeyEventArgs e)
        {
            GenObstacle.CollisionCheck();
            GenObstacle obs = GenObstacle.ClosestElement();

            if (GoodStory.OccuredOnce != true)
            {
                GoodStory.PrintLevelIntro(StoryBox);
            }

            if (e.Key == Key.Escape)
            {
                PauseScreen pause = new PauseScreen(this);
                pause.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                pause.ShowDialog();
            }
            else if (obs.CollisionStatus)
            {
                if (obs is NPC)
                {
                    if (GoodStory.ShouldContinue == false)
                    {
                        GoodStory.PrintConversation(StoryBox);
                        GoodStory.ShouldContinue = true;
                        LevelFinished            = true;
                        GoodEnding = true;
                        make.MakeItem(MainCharacter, HellCanvas, "../../Object Model/Fan.png", Fan);
                    }
                    move.MoveFreely(e);
                }

                else if (obs is Item)
                {
                    HellCanvas.Children.Remove(GenObstacle.ClosestObstacle);

                    CollectItm.Collect(GenObstacle.ClosestObstacle);
                    obs.Remove(obs);

                    BadStory.ShouldContinue = true;
                    GoodEnding = false;
                }

                else if (obs is Door)
                {
                    if (BadStory.ShouldContinue == true || GoodStory.ShouldContinue == true)
                    {
                        obs.Clear();
                        this.Close();
                    }

                    else if (Canvas.GetRight(MainCharacter) == Canvas.GetLeft(GenObstacle.ClosestObstacle))//going right
                    {
                        move.RestrictRight(e);
                    }

                    else if (Canvas.GetBottom(MainCharacter) == Canvas.GetTop(GenObstacle.ClosestObstacle))//going down
                    {
                        move.RestrictDown(e);
                    }

                    else if (Canvas.GetTop(MainCharacter) == Canvas.GetBottom(GenObstacle.ClosestObstacle))//going up
                    {
                        move.RestrictUp(e);
                    }

                    else if (Canvas.GetLeft(MainCharacter) == Canvas.GetRight(GenObstacle.ClosestObstacle))//going left
                    {
                        move.RestrictLeft(e);
                    }

                    else
                    {
                        move.MoveFreely(e);
                    }
                }
            }

            else
            {
                move.MoveFreely(e);
            }

            Canvas.SetRight(MainCharacter, Canvas.GetLeft(MainCharacter) + MainCharacter.Width);
            Canvas.SetBottom(MainCharacter, Canvas.GetTop(MainCharacter) + MainCharacter.Height);
        }