Ejemplo n.º 1
0
        void CharacterChangedLocation(CharacterChangeLocationEventArgs e)
        {
            APerson ch            = Characters.Find(c => c.id == e.characterId);
            var     destination   = Locations.Find(l => l.Position == e.DestinationTarget);
            var     startLocation = Locations.Find(l => l.Position == e.PreviousLocation);

            try
            {
                startLocation.CharacterLeft(ch);
            }
            catch
            {
                Stopwatch stp = new Stopwatch();
                stp.Start();

                while (stp.ElapsedMilliseconds < 1000)
                {
                }
                stp.Stop();
                CharacterChangedLocation(e);
            }

            destination.CharacterEnter(ch);

            ch.CurrentPosition = e.DestinationTarget;

            Console.WriteLine("{0} has left {1} and entered {2}", ch.Name, startLocation.Name, destination.Name);
        }
Ejemplo n.º 2
0
        public void MoveTo(int destinationPosition)
        {
            CharacterChangeLocationEventArgs e = new CharacterChangeLocationEventArgs();

            e.DestinationTarget = destinationPosition;
            e.PreviousLocation  = CurrentPosition;
            e.characterId       = id;
            OnChangeLocation(e);
        }
Ejemplo n.º 3
0
 protected virtual void OnChangeLocation(CharacterChangeLocationEventArgs e)
 {
     ChangeLocationEventHandler?.Invoke(e);
 }