Exemplo n.º 1
0
 public void Initialize(out WorldView worldView)
 {
     this.world  = GameFactory.LoadGame(DEFAULT_DATA);
     worldView   = this.world.worldView;
     this.events = new EventManager(this);
     this.LoadArea();
 }
Exemplo n.º 2
0
        public void LoadArea()
        {
            this.IsGameOver = false;
            this.world      = GameFactory.LoadGame(DEFAULT_DATA);
            this.events     = new EventManager(this);
            this.events.QueueObject(this.world, 15);

            // by default always create the player object, which is indestructible
            if (!this.world.entities.ContainsKey(PLAYER_ID))
            {
                if (Random(100) < 50)
                {
                    this.CreateObject(PLAYER_ID, "bp_exekiel");
                }
                else
                {
                    this.CreateObject(PLAYER_ID, "bp_exekiel");
                }
            }
            var playerObject = GetObject(PLAYER_ID);

            playerObject.AI                      = new UserAI();
            playerObject.HasEnded                = true;
            playerObject.Visible                 = true;
            playerObject.OutObject.Color         = Color.White;
            this.world.worldView.ReferenceObject = GetObject(PLAYER_ID).OutObject;
            //this.AddLight (PLAYER_ID, 300, new Color(254, 250, 235));

            var wf = new WorldFactory();

            wf.Initialize(DEFAULT_LEVEL);
            wf.Generate(this.world);
            this.world.worldView.EnableGrid(false);

            if (world.StartCell.X != 0 && world.StartCell.Y != 0)
            {
                Move(PLAYER_ID, world.StartCell.X, world.StartCell.Y);
            }
            else
            {
                var done = false;
                do
                {
                    var x = Random(world.GridWidth - 1);
                    var y = Random(world.GridHeight - 1);
                    if (world.GetTile(x, y).Template.IsWalkable == true)
                    {
                        done = true;
                        this.Move(PLAYER_ID, x, y);
                    }
                } while(done != true);
            }
            this.world.CalculateFoV(playerObject.X, playerObject.Y, 6);
            this.events.DispatchAll();
            this.events.AcceptEvent = true;
            this.InitializeUserInterface();
            // XXX After the user interface is loaded!
            playerObject.ResetSkills();
            this.SelectedSkill = 1;
            Logger.Debug("Simulator", "LoadArea", "Starting fade at " + IoManager.Time.ToString());
            IoManager.FadeTo(Color.Transparent, 1500);
            IoManager.PlayMusic("intro");
            IoManager.SetNextMusicLoop("intro");
        }