Esempio n. 1
0
        public SceneGame(Game game) : base(game)
        {
            string saveName = $"save{DateTime.Now.ToString("ddMMyyyyHHmm")}";

            SaveFile = new SaveFile(new DirectoryInfo(Path.Combine(SaveFile.SaveDirectory.FullName, saveName)))
            {
                Name       = "Test",
                CreateTime = DateTime.Now,
            };

            ActionQueue = new ActionQueue(this);
            Menu        = new PlayerUI(this);

            CreateHome();

            PushObjects();

            var startTile = MapHome.EnumerateTiles().Where(tile => !tile.Solid).Shuffle(Random).First();

            Player = new Hero(this);
            Player.MoveTo(startTile, 1);
            Player.AddControlTurn();

            CameraMap   = MapHome;
            CameraFocus = new CameraFocus(Player);

            Player.Pickup(new Ingot(this, Material.Bone, 80));
            Player.Pickup(new Ingot(this, Material.Dilithium, 80));
            Player.Pickup(new Ingot(this, Material.Tiberium, 80));
            Player.Pickup(new Ingot(this, Material.Basalt, 80));
            Player.Pickup(new Ingot(this, Material.Meteorite, 80));
            Player.Pickup(new Ingot(this, Material.Obsidiorite, 80));
            Player.Pickup(new Ingot(this, Material.Jauxum, 80));
            Player.Pickup(new Ingot(this, Material.Karmesine, 80));
            Player.Pickup(new Ingot(this, Material.Ovium, 80));
            Player.Pickup(new Ingot(this, Material.Ardite, 80));
            Player.Pickup(new Ingot(this, Material.Cobalt, 80));
            Player.Pickup(new Ingot(this, Material.Manyullyn, 80));
            Player.Pickup(new Ingot(this, Material.Terrax, 80));
            Player.Pickup(new Ingot(this, Material.Triberium, 80));
            Player.Pickup(new Ingot(this, Material.Aurorium, 80));
            Player.Pickup(new Ingot(this, Material.Violium, 80));
            Player.Pickup(new Ingot(this, Material.Astrium, 80));
            Player.Pickup(new Ingot(this, Material.Ignitz, 80));
            Player.Pickup(new Ingot(this, Material.Tritonite, 80));
            Player.Pickup(new ItemFeather(this, 80));
            Player.Pickup(new ItemHandle(this, 80));

            Quest getOre    = new TutorialGetOre(this);
            Quest getFuel   = new TutorialGetFuel(this, getOre);
            Quest smeltOre  = new TutorialSmeltOre(this, getOre, getFuel);
            Quest buildAdze = new TutorialBuildAdze(this, smeltOre);

            Quests.Add(getOre);
            Quests.Add(getFuel);
            Quests.Add(smeltOre);
            Quests.Add(buildAdze);

            Spawner = new EnemySpawner(this, 5);
        }
Esempio n. 2
0
        private IEnumerable <Wait> RoutineBossWarning(Enemy boss)
        {
            yield return(new WaitTime(40));

            SeenBosses.Add(boss);
            boss.OnManifest();
            CameraFocus      = CameraFocus.MoveNext(boss, 30);
            Menu.BossWarning = new BossWarning(boss.BossDescription);
            yield return(new WaitMenu(Menu.BossWarning));

            CameraFocus.SetDead();
        }
Esempio n. 3
0
        public SceneGame(Game game, SaveFile saveFile) : base(game)
        {
            SaveFile = saveFile;

            ActionQueue = new ActionQueue(this);
            Menu        = new PlayerUI(this);

            Load();

            Player = Entities.First(x => x is Hero);

            CameraMap   = Player.Map;
            CameraFocus = new CameraFocus(Player);

            Spawner = new EnemySpawner(this, 5);
        }
Esempio n. 4
0
        public override void Update(GameTime gameTime)
        {
            SeenBosses.RemoveWhere(x => x.Destroyed);

            CameraFocus.Update();
            if (CameraFocus.Dead)
            {
                CameraFocus = CameraFocus.MoveNext(Player, 30);
            }
            InputTwinState state = Game.InputState;

            PushObjects();
            Menu.Update(this);

            if (Player.Dead)
            {
                Menu.HandleInput(this);
            }

            PopupHelper.Global.Update(this);
            //PopupManager.Update(this);
            Wait.Update();

            bool cancel = false;

            while (!cancel && Wait.Done && !Player.Dead && CameraFocus.Done)
            {
                var         corpses            = Entities.Where(x => x.Dead && !x.Control.HasImmediateTurns());
                List <Wait> waitForDestruction = new List <Wait>();
                foreach (var corpse in corpses)
                {
                    waitForDestruction.Add(Scheduler.Instance.RunAndWait(corpse.RoutineDestroy()));
                }
                if (waitForDestruction.Any())
                {
                    Wait.Add(new WaitAll(waitForDestruction));
                }

                Enemy foundBoss = Spawner.Bosses.Find(x => !x.Dead && IsBossVisible(x) && !SeenBosses.Contains(x));
                if (foundBoss != null)
                {
                    Wait.Add(Scheduler.Instance.RunAndWait(RoutineBossWarning(foundBoss)));
                    break;
                }

                ActionQueue.Step();

                Turn = ActionQueue.CurrentTurn;
                if (Turn == null)
                {
                    break;
                }

                switch (Turn.Phase)
                {
                case TurnPhase.Start:
                    Wait.Add(Turn.StartTurn());
                    break;

                case TurnPhase.Tick:
                    if (Turn.TurnTaker.Controllable(Player))
                    {
                        Menu.HandleInput(this);
                        cancel = true;
                    }
                    else if (Turn.TakeTurn())
                    {
                        Wait.Add(Turn.Wait);
                    }
                    break;

                case TurnPhase.End:
                    Wait.Add(Turn.EndTurn());
                    break;
                }

                Wait.Update();
            }

            foreach (var obj in GameObjects.GetAndClean(x => x.Destroyed))
            {
                obj.Update();
            }

            foreach (var quest in Quests)
            {
                if (!quest.Completed && quest.PrerequisitesCompleted)
                {
                    quest.Completed = quest.CheckCompletion();
                }
            }

            Vector2 worldPos = Vector2.Transform(new Vector2(InputState.MouseX, InputState.MouseY), Matrix.Invert(WorldTransform));
            int     tileX    = Util.FloorDiv((int)worldPos.X, 16);
            int     tileY    = Util.FloorDiv((int)worldPos.Y, 16);

            TileCursor = new Point(tileX, tileY);
            if (Menu.IsMouseOver(InputState.MouseX, InputState.MouseY))
            {
                TileCursor = null;
            }

            Tooltip = string.Empty;
            if (TileCursor.HasValue && CameraMap != null)
            {
                Tile tile = CameraMap.GetTile(TileCursor.Value.X, TileCursor.Value.Y);
                if (tile != null && tile.IsVisible())
                {
                    tile.AddTooltip(ref Tooltip);
                }
            }
            Tooltip = Tooltip.Trim();
        }