Пример #1
0
        public static LaunchEvent FromJson(string jsonString)
        {
            DeserializedLaunchEvent parsed = JsonConvert.DeserializeObject <DeserializedLaunchEvent>(jsonString);

            GameTick currentTick = Game.TimeMachine.GetCurrentTick();
            GameTick eventTick   = GameTick.FromTickNumber(parsed.GameTick);

            // Go to the time the event occurred.
            Game.TimeMachine.GoTo(eventTick);
            GameState state = Game.TimeMachine.GetState();

            ILaunchable source = state.GetOutpostById(parsed.Source);

            if (source == null)
            {
                source = state.GetSubById(parsed.Source);
            }

            ICombatable destination = state.GetOutpostById(parsed.Destination);

            if (destination == null)
            {
                destination = state.GetSubById(parsed.Destination);
            }

            Game.TimeMachine.GoTo(currentTick);

            return(new LaunchEvent(eventTick, source, parsed.Drillers, destination));
        }
Пример #2
0
 // Update is called once per frame
 void Update()
 {
     tickNumber       = (int)Math.Floor(currentPosition / -6);
     CurrentTick.text = tickNumber.ToString();
     if (tickNumber >= 0)
     {
         Game.TimeMachine.GoTo(GameTick.FromTickNumber(tickNumber));
     }
 }
Пример #3
0
        public void CanGoToAGameTick()
        {
            GameTick initialTick = Game.TimeMachine.GetCurrentTick();

            Game.TimeMachine.GoTo(GameTick.FromTickNumber(5));

            Assert.IsTrue(initialTick < Game.TimeMachine.GetCurrentTick());
            Assert.AreEqual(initialTick.Advance(5).GetTick(), Game.TimeMachine.GetCurrentTick().GetTick());
        }
Пример #4
0
        public void FromTick()
        {
            int      numberOfTicks = 4;
            int      minutes       = GameTick.MinutesPerTick * numberOfTicks;
            DateTime newDate       = _time.AddMinutes(minutes);
            GameTick newTick       = GameTick.FromTickNumber(numberOfTicks);

            Assert.AreEqual(_tick.GetTick() + numberOfTicks, newTick.GetTick());
            Assert.AreEqual(newDate, newTick.GetDate());
        }
Пример #5
0
        public void CanRemoveEvents()
        {
            Player  player1 = new Player(1);
            Rft     map     = new Rft(3000, 3000);
            Outpost outpost = new Outpost(new RftVector(map, 0, 0), player1, OutpostType.Generator);

            outpost.AddDrillers(10);
            Sub         sub         = new Sub(outpost, outpost, new GameTick(), 10, player1);
            CombatEvent arriveEvent = new CombatEvent(sub, outpost, GameTick.FromTickNumber(5), outpost.GetTargetPosition(sub.GetCurrentPosition(), sub.GetSpeed()));

            Game.TimeMachine.AddEvent(arriveEvent);
            Assert.AreEqual(1, Game.TimeMachine.GetQueuedEvents().Count);
            Assert.AreEqual(arriveEvent, Game.TimeMachine.GetQueuedEvents()[0]);

            Game.TimeMachine.RemoveEvent(arriveEvent);
            Assert.AreEqual(0, Game.TimeMachine.GetQueuedEvents().Count);
        }