Ejemplo n.º 1
0
        void ToolStripButton5Click(object sender, EventArgs e)
        {
            Past pastForm = new Past();

            pastForm.MdiParent = this;
            pastForm.Show();
        }
Ejemplo n.º 2
0
        // Discard redo stack if item is added to move history
        public void AddItem(HistoryItem newItem)
        {
            Future = new Stack <HistoryItem>();

            Past.Push(newItem);
            CurrItem = Past.Peek();
        }
Ejemplo n.º 3
0
        public void Undo()
        {
            int currTurn   = CurrItem.Turn;
            int targetTurn = currTurn - 2;

            while (Past.Count > 0 && currTurn != targetTurn)
            {
                Future.Push(Past.Pop());

                if (Past.Count <= 0)
                {
                    currTurn = 1;
                }
                else
                {
                    CurrItem = Past.Peek();
                    currTurn = CurrItem.Turn;
                }
            }

            // check if can revert
            //if (Past.Count > 2)
            //{
            //    Future.Push(Past.Pop());
            //    Future.Push(Past.Pop());

            //    CurrItem = Past.Peek();
            //}
        }
Ejemplo n.º 4
0
        void PastToolStripMenuItemClick(object sender, EventArgs e)
        {
            Past pastForm = new Past();

            pastForm.MdiParent = this;
            pastForm.Show();
        }
Ejemplo n.º 5
0
 public void Clear()
 {
     Past.Clear();
     Future.Clear();
     _history.Clear();
     _future.Clear();
     CanUndo = false;
     CanRedo = false;
 }
Ejemplo n.º 6
0
 //constructor
 public Mission(int Howmanydays, DateTime BeginningDateEatrh, List<Astronaut> L_astronaut)
 {
     howmanydays = Howmanydays;
     begniningDateEarth = BeginningDateEatrh;
     l_astronaut = L_astronaut;
     l_day = new List<Day>();
     for (int i=0 ; i <= howmanydays; i++) {Past Day = new Past(i);}
     //generate l_activity from XML
 }
 public void SaveTime()
 {
     pasts[saveIndex] = new Past
     {
         position        = transform.position,
         rotation        = transform.rotation,
         velocity        = rb.velocity,
         angularVelocity = rb.angularVelocity
     };
 }
Ejemplo n.º 8
0
        public void AddHandler(HistoryHandler handler)
        {
            handler.ActionPush += (sender, action) => {
                if (!_acceptNew)
                {
                    return;
                }

                _history.Push(action);
                Past.Add(action);
                _future.Clear();
                Future.Clear();
                CanRedo = false;
                CanUndo = true;
            };
        }
Ejemplo n.º 9
0
        public static int PastToScore(Past p)
        {
            switch (p)
            {
            default:
            case Past.T:
                return(5);

            case Past.R:
                return(3);

            case Past.P:
                return(1);

            case Past.S:
                return(0);
            }
        }
Ejemplo n.º 10
0
        public static int PastToIndex(Past p)
        {
            switch (p)
            {
            default:
            case Past.T:
                return(0);

            case Past.R:
                return(1);

            case Past.P:
                return(2);

            case Past.S:
                return(3);
            }
        }
Ejemplo n.º 11
0
        public void Undo()
        {
            if (_history.Count == 0)
            {
                throw new NothingToUndoException();
            }

            IHistoryAction action = _history.Pop();

            _future.Push(action);
            Past.RemoveAt(Past.Count - 1);
            Future.Insert(0, action);
            _acceptNew = false;
            action.Undo();
            _acceptNew = true;

            CanUndo = _history.Count > 0;
            CanRedo = true;
        }
Ejemplo n.º 12
0
        public void Redo()
        {
            if (_future.Count == 0)
            {
                throw new NothingToRedoException();
            }

            IHistoryAction action = _future.Pop();

            _history.Push(action);
            Future.RemoveAt(0);
            Past.Add(action);
            _acceptNew = false;
            action.Redo();
            _acceptNew = true;

            CanUndo = true;
            CanRedo = _future.Count > 0;
        }
Ejemplo n.º 13
0
        protected bool NotBroken()
        {
            //TODO: алгоритм работы станка с учетом поломки
            //if (IsBroken && CanThrow())
            //{
            //    IsBroken = false;
            //    return true;
            //}
            var chance = CrashChance * 100;

            if (random1to100.Next(1, 101) <= chance)
            {
                Past.AddSeconds(InactiveTime);
                IsBroken = true;
                return(false);
            }
            IsBroken = false;
            return(true);
        }
Ejemplo n.º 14
0
        public void Redo()
        {
            int currTurn   = CurrItem.Turn;
            int targetTurn = currTurn + 2;

            while (Future.Count > 0 && currTurn != targetTurn)
            {
                Past.Push(Future.Pop());

                CurrItem = Past.Peek();
                currTurn = CurrItem.Turn;
            }

            // check if can redo
            //if (Future.Count > 1)
            //{
            //    Past.Push(Future.Pop());
            //    Past.Push(Future.Pop());

            //    CurrItem = Past.Peek();
            //}
        }
Ejemplo n.º 15
0
 public PlayerGhost SetPast(Past past)
 {
     this.past = past;
     return(this);
 }