Пример #1
0
 public GameObject(string name, Maps.Map map)
 {
     this.Name       = name;
     this.components = new Dictionary <Type, Components.ComponentBase>();
     this.Location   = new Components.Location(this, map);
     this.RegisterComponent(this.Location);
     this.IsBlocking = true;
     this.MessageLog = new List <string>();
 }
Пример #2
0
        public void Initialize()
        {
            // Any custom loading and prep. We will use a sample console for now
            Console startingConsole = new Console(Width, Height);

            // Set our new console as the thing to render and process
            SadConsole.Global.CurrentScreen = startingConsole;

            var generator = new Maps.MapGenerator(this, 50, 50, 10, 10, 6);

            this.activeMap = generator.CreateMap();

            //Add an display a character
            this.Player = new GameObjects.Character("Kek", 1, this.activeMap);
            this.Player.Location.Point = this.activeMap.Rooms.First().Box.Center;
            this.Player.RegisterComponent(new Components.Vision(this.Player, 10));

            this.activeMap.AddGameObject(Player);
            this.gameArea   = new UI.GameArea(this.Player, this, Width - 21, Height);
            this.messageLog = new UI.MessageLog(this.Player, this, Width - 21, Height);

            //Add Npcs
            //for(var i = 0; i < 10; i++)
            //{
            //    var npc = new GameObjects.Character("Npc", 1, this.activeMap);
            //    npc.Display.SadEntity.Animation.SetForeground(0, 0, Color.Red);
            //    npc.Location.Point = new Point(i * 2, i);
            //    this.activeMap.AddGameObject(npc);
            //}

            var hud = new HiveRL.UI.Hud(this.Player, 20, Height);

            hud.Position = new Point(Width - 21, 0);
            startingConsole.Children.Add(hud);
            startingConsole.Children.Add(gameArea);
            startingConsole.Children.Add(messageLog);
            this.PlayerMoved = true;
            this.gameArea.Draw(TimeSpan.Zero);
            this.Player.Message("Welcome!");
        }