Esempio n. 1
0
        public void CannotLeave()
        {
            var room  = YouInARoom(out IWorld world).CurrentLocation;
            var guard = new Npc("Guard", room);

            guard.BaseBehaviours.Add(new ForbidBehaviour <LeaveAction>(new ConditionCode("return true"), guard));

            var leave = new LeaveAction(world.Player);

            var stack = new ActionStack();

            stack.RunStack(world, GetUI(Direction.South), leave, world.Player, guard.GetFinalBehaviours());

            Assert.AreSame(room, world.Player.CurrentLocation, "Expected to be in the same room as started in");
        }
Esempio n. 2
0
        public void PageLeave()
        {
            DoubleAnimation OpacityAnimation = new DoubleAnimation()
            {
                From           = 1,
                To             = 0,
                Duration       = TimeSpan.FromSeconds(1),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseIn
                }
            };

            OpacityAnimation.Completed += delegate { LeaveAction?.Invoke(); };
            this.BeginAnimation(OpacityProperty, OpacityAnimation);
        }
Esempio n. 3
0
        public void WalkInCircle()
        {
            YouInARoom(out IWorld world);
            world.RoomFactory = new RoomFactory();
            world.RoomFactory.Blueprints.Add(new RoomBlueprint()
            {
                Name          = "NorthRoom", Tile = '-',
                FixedLocation = new Point3(0, 1, 0)
            });
            world.RoomFactory.Blueprints.Add(new RoomBlueprint()
            {
                Name          = "NorthEastRoom", Tile = '-',
                FixedLocation = new Point3(1, 1, 0)
            });
            world.RoomFactory.Blueprints.Add(new RoomBlueprint()
            {
                Name          = "EastRoom", Tile = '-',
                FixedLocation = new Point3(1, 0, 0)
            });

            var leave = new LeaveAction(world.Player);

            var room1 = world.Player.CurrentLocation;

            Assert.IsNotNull(room1);

            var stack = new ActionStack();

            //north
            stack.RunStack(world, GetUI(Direction.North), leave, world.Player, new IBehaviour[0]);
            Assert.AreNotSame(room1, world.Player.CurrentLocation, "After going north we should not be in the same room");
            Assert.AreEqual("NorthRoom", world.Player.CurrentLocation.Name);

            //east,south,west
            stack.RunStack(world, GetUI(Direction.East), leave, world.Player, new IBehaviour[0]);
            Assert.AreEqual("NorthEastRoom", world.Player.CurrentLocation.Name);

            stack.RunStack(world, GetUI(Direction.South), leave, world.Player, new IBehaviour[0]);
            Assert.AreEqual("EastRoom", world.Player.CurrentLocation.Name);

            stack.RunStack(world, GetUI(Direction.West), leave, world.Player, new IBehaviour[0]);
            Assert.AreEqual("TestRoom", world.Player.CurrentLocation.Name);

            Assert.AreSame(room1, world.Player.CurrentLocation, "Should be back in the first room again");
        }
Esempio n. 4
0
        public void WalkUpThenDownAgain()
        {
            var you = YouInARoom(out IWorld world);

            world.RoomFactory = new RoomFactory();

            world.RoomFactory.Blueprints.Add(new RoomBlueprint()
            {
                Name          = "Start", Tile = '-',
                FixedLocation = new Point3(0, 0, 0),

                //let the player go up from here (normally only horizontal movement is allowed)
                LeaveDirections = new [] { Direction.Up }
            });
            world.RoomFactory.Blueprints.Add(new RoomBlueprint()
            {
                Name          = "UpperRoom", Tile = '-',
                FixedLocation = new Point3(0, 0, 1)
            });

            var leave = new LeaveAction(you);

            var stack = new ActionStack();

            world.Map[new Point3(0, 0, 0)] = world.GetNewRoom(new Point3(0, 0, 0));
            world.Player.CurrentLocation   = world.Map[new Point3(0, 0, 0)];
            var room1 = world.Player.CurrentLocation;

            Assert.IsNotNull(room1);

            //should start in the starting room
            Assert.AreEqual("Start", world.Player.CurrentLocation.Name);

            //up
            stack.RunStack(world, GetUI(Direction.Up), leave, world.Player, new IBehaviour[0]);
            Assert.AreEqual("UpperRoom", world.Player.CurrentLocation.Name);

            //down
            stack.RunStack(world, GetUI(Direction.Down), leave, world.Player, new IBehaviour[0]);
            Assert.AreEqual("Start", world.Player.CurrentLocation.Name);


            Assert.AreSame(room1, world.Player.CurrentLocation, "Should be back in the first room again");
        }
Esempio n. 5
0
        public void LeaveAndComeBack()
        {
            var you = YouInARoom(out IWorld world);

            world.RoomFactory = new RoomFactory();
            world.RoomFactory.Blueprints.Add(new RoomBlueprint()
            {
                Name          = "North Room",
                Tile          = '-',
                FixedLocation = new Point3(0, 1, 0)
            });

            Assert.AreEqual(new Point3(0, 0, 0), world.Map.GetPoint(world.Player.CurrentLocation));

            var leave = new LeaveAction(you);

            var room1 = world.Player.CurrentLocation;

            Assert.IsNotNull(room1);
            Assert.AreEqual("TestRoom", room1.Name);

            var stack = new ActionStack();

            stack.RunStack(world, GetUI(Direction.North), leave, world.Player, new IBehaviour[0]);

            var room2 = world.Player.CurrentLocation;

            Assert.IsNotNull(room1);
            Assert.IsNotNull(room2);
            Assert.AreNotSame(room1, room2, "Expected room to change after leaving it");
            Assert.AreEqual("North Room", world.Player.CurrentLocation.Name);

            stack.RunStack(world, GetUI(Direction.South), leave, world.Player, new IBehaviour[0]);

            Assert.AreSame(room1, world.Player.CurrentLocation, "Should be back in the first room again");
            Assert.AreEqual("TestRoom", world.Player.CurrentLocation.Name);
        }
Esempio n. 6
0
        public void PageLeave()
        {
            if (ContentViewer.Visibility == Visibility.Visible)
            {
                ContentViewer.BeginAnimation(OpacityProperty, new DoubleAnimation()
                {
                    From           = 1,
                    To             = 0,
                    Duration       = TimeSpan.FromSeconds(0.3),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    }
                });
            }

            var SkillListMarginAnimation = new ThicknessAnimation()
            {
                From           = SkillListGrid.Margin,
                To             = new Thickness(-300, 100, 0, 0),
                Duration       = TimeSpan.FromSeconds(0.3),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseIn
                }
            };

            SkillListMarginAnimation.Completed += delegate
            {
                DispatcherTimer Timer = new DispatcherTimer()
                {
                    Interval = TimeSpan.FromSeconds(0.75)
                };
                Timer.Tick += delegate
                {
                    LeaveAction?.Invoke();
                    Timer.Stop();
                };
                TitleGrid.BeginAnimation(OpacityProperty, new DoubleAnimation()
                {
                    From           = 1,
                    To             = 0,
                    Duration       = TimeSpan.FromSeconds(0.75),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    }
                });
                TitleGrid.BeginAnimation(MarginProperty, new ThicknessAnimation()
                {
                    From = TitleGrid.Margin,
                    To   = new Thickness(
                        TitleGrid.Margin.Left + 50,
                        TitleGrid.Margin.Top,
                        TitleGrid.Margin.Right - 50,
                        TitleGrid.Margin.Bottom),
                    Duration       = TimeSpan.FromSeconds(0.75),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    }
                });
                Timer.Start();
            };
            SkillListGrid.BeginAnimation(MarginProperty, SkillListMarginAnimation);
        }
Esempio n. 7
0
        public void PageLeave()
        {
            DoubleAnimation OpacityAnimation = new DoubleAnimation()
            {
                From           = 1,
                To             = 0,
                Duration       = TimeSpan.FromSeconds(0.75),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseIn
                }
            };
            ThicknessAnimation MarginAnimation = new ThicknessAnimation()
            {
                From = ContentGrid.Margin,
                To   = new Thickness(
                    ContentGrid.Margin.Left + 50,
                    ContentGrid.Margin.Top,
                    ContentGrid.Margin.Right - 50,
                    ContentGrid.Margin.Bottom),
                Duration       = TimeSpan.FromSeconds(0.75),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseIn
                }
            };

            MarginAnimation.Completed += delegate
            {
                DispatcherTimer Timer = new DispatcherTimer()
                {
                    Interval = TimeSpan.FromSeconds(0.5)
                };
                Timer.Tick += delegate
                {
                    DoubleAnimation FadeAnimation = new DoubleAnimation()
                    {
                        From           = 1,
                        To             = 0,
                        Duration       = TimeSpan.FromSeconds(1),
                        EasingFunction = new ExponentialEase()
                        {
                            EasingMode = EasingMode.EaseIn
                        }
                    };
                    FadeAnimation.Completed += delegate
                    {
                        LeaveAction?.Invoke();
                    };
                    this.BeginAnimation(OpacityProperty, FadeAnimation);
                    Timer.Stop();
                };
                TitleGrid.BeginAnimation(OpacityProperty, new DoubleAnimation()
                {
                    From           = 1,
                    To             = 0,
                    Duration       = TimeSpan.FromSeconds(0.75),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    }
                });
                TitleGrid.BeginAnimation(MarginProperty, new ThicknessAnimation()
                {
                    From = TitleGrid.Margin,
                    To   = new Thickness(
                        TitleGrid.Margin.Left + 50,
                        TitleGrid.Margin.Top,
                        TitleGrid.Margin.Right - 50,
                        TitleGrid.Margin.Bottom),
                    Duration       = TimeSpan.FromSeconds(0.75),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    }
                });
                Timer.Start();
            };
            ContentGrid.BeginAnimation(OpacityProperty, OpacityAnimation);
            ContentGrid.BeginAnimation(MarginProperty, MarginAnimation);
        }
Esempio n. 8
0
 public void SendAction(LeaveAction action)
 {
     this._connection.WriteLine(action.ToString());
 }
Esempio n. 9
0
        public void PageLeave()
        {
            DispatcherTimer MenuTimer = new DispatcherTimer()
            {
                Interval = TimeSpan.FromSeconds(0.25)
            };
            int Count = 0;

            MenuTimer.Tick += delegate
            {
                MenuList[Count].BeginAnimation(OpacityProperty, new DoubleAnimation()
                {
                    From           = 1,
                    To             = 0,
                    Duration       = TimeSpan.FromSeconds(0.5),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    }
                });
                var MarginAnimation = new ThicknessAnimation()
                {
                    From = MenuList[Count].Margin,
                    To   = new Thickness(
                        MenuList[Count].Margin.Left + 50,
                        MenuList[Count].Margin.Top,
                        MenuList[Count].Margin.Right,
                        MenuList[Count].Margin.Bottom),
                    Duration       = TimeSpan.FromSeconds(0.5),
                    EasingFunction = new ExponentialEase()
                    {
                        EasingMode = EasingMode.EaseIn
                    }
                };
                if (Count == MenuList.Count - 1)
                {
                    MarginAnimation.Completed += delegate
                    {
                        DispatcherTimer FinalTimer = new DispatcherTimer()
                        {
                            Interval = TimeSpan.FromSeconds(0.75)
                        };
                        FinalTimer.Tick += delegate
                        {
                            LeaveAction?.Invoke();
                            FinalTimer.Stop();
                        };
                        TitleGrid.BeginAnimation(OpacityProperty, new DoubleAnimation()
                        {
                            From           = 1,
                            To             = 0,
                            Duration       = TimeSpan.FromSeconds(0.75),
                            EasingFunction = new ExponentialEase()
                            {
                                EasingMode = EasingMode.EaseIn
                            }
                        });
                        TitleGrid.BeginAnimation(MarginProperty, new ThicknessAnimation()
                        {
                            From = TitleGrid.Margin,
                            To   = new Thickness(
                                TitleGrid.Margin.Left + 50,
                                TitleGrid.Margin.Top,
                                TitleGrid.Margin.Right - 50,
                                TitleGrid.Margin.Bottom),
                            Duration       = TimeSpan.FromSeconds(0.75),
                            EasingFunction = new ExponentialEase()
                            {
                                EasingMode = EasingMode.EaseIn
                            }
                        });
                        FinalTimer.Start();
                    }
                }
                ;
                MenuList[Count].BeginAnimation(MarginProperty, MarginAnimation);
                Count++;
                if (Count >= MenuList.Count)
                {
                    MenuTimer.Stop();
                }
            };
            MenuTimer.Start();
        }
Esempio n. 10
0
        public void PageLeave()
        {
            DispatcherTimer Timer = new DispatcherTimer();

            Timer.Interval = TimeSpan.FromSeconds(0.5);
            Timer.Tick    += delegate
            {
                LeaveAction?.Invoke();
                Timer.Stop();
            };

            AvatorEllipse.BeginAnimation(OpacityProperty, new DoubleAnimation()
            {
                From           = AvatorEllipse.Opacity,
                To             = 0,
                Duration       = TimeSpan.FromSeconds(0.5),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseIn
                },
            });
            MaskEllipse.BeginAnimation(OpacityProperty, new DoubleAnimation()
            {
                From           = MaskEllipse.Opacity,
                To             = 0,
                Duration       = TimeSpan.FromSeconds(0.5),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseIn
                },
            });
            NameLabel.BeginAnimation(OpacityProperty, new DoubleAnimation()
            {
                From           = NameLabel.Opacity,
                To             = 0,
                Duration       = TimeSpan.FromSeconds(0.5),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseIn
                },
            });
            NameBox.BeginAnimation(OpacityProperty, new DoubleAnimation()
            {
                From           = NameBox.Opacity,
                To             = 0,
                Duration       = TimeSpan.FromSeconds(0.5),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseIn
                },
            });
            DescriptionLabel.BeginAnimation(OpacityProperty, new DoubleAnimation()
            {
                From           = DescriptionLabel.Opacity,
                To             = 0,
                Duration       = TimeSpan.FromSeconds(0.5),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseIn
                },
            });
            DescriptionBox.BeginAnimation(OpacityProperty, new DoubleAnimation()
            {
                From           = DescriptionBox.Opacity,
                To             = 0,
                Duration       = TimeSpan.FromSeconds(0.5),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseIn
                },
            });
            BackButton.BeginAnimation(OpacityProperty, new DoubleAnimation()
            {
                From           = BackButton.Opacity,
                To             = 0,
                Duration       = TimeSpan.FromSeconds(0.5),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseIn
                },
            });
            SignupButton.BeginAnimation(OpacityProperty, new DoubleAnimation()
            {
                From           = SignupButton.Opacity,
                To             = 0,
                Duration       = TimeSpan.FromSeconds(0.5),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseIn
                },
            });
            StatusBar.BeginAnimation(OpacityProperty, new DoubleAnimation()
            {
                From           = StatusBar.Opacity,
                To             = 0,
                Duration       = TimeSpan.FromSeconds(0.5),
                EasingFunction = new ExponentialEase()
                {
                    EasingMode = EasingMode.EaseIn
                },
            });
            Timer.Start();
        }