コード例 #1
0
        public override void Init()
        {
            _inputManager    = _engineSystems.GetSystem <InputManager>();
            _worldManager    = _engineSystems.GetSystem <WorldManager>();
            _entityManager   = _engineSystems.GetSystem <EntityManager>();
            _resourceManager = _engineSystems.GetSystem <ResourceManager>();
            _uiManager       = _engineSystems.GetSystem <UIManager>();

            var world = _worldManager.NewWorld();

            _worldManager.SetActiveWorld(world);

            entity = _entityManager.NewEntity();
            entity.AddComponent(new RenderableComponent(_resourceManager.LoadModel("Models/2b.obj")));
            world.AddChild(entity);

            entity.Transform.Scale = new Vector3(0.1f, 0.1f, 0.1f);

            var camera = world.AddCamera(new Camera(new Vector3(0.0f, 0.0f, -1.0f)));

            world.SetActiveCamera(camera);

            light = world.AddPointLight(new PointLight(new Color4(1.0f, 1.0f, 1.0f, 1.0f), new Color4(1.0f, 1.0f, 1.0f, 1.0f), Color4.White));
            light.Transform.Position = new Vector3(5.0f, 5.0f, 5.0f);

            _uiManager.AddScreen("test", new TestScreen());
            _uiManager.SetActiveScreen("test");
        }
コード例 #2
0
        public override void Run(EntityManager.Entity entity)
        {
            if (!entity.HasComponent <WanderingMonster>())
            {
                return;
            }
            if (!entity.HasComponent <Location>())
            {
                return;
            }

            var actual  = entity.GetComponent <Location>();
            var desired = entity.GetComponent <Destination>();

            var point = new Point(actual.X, actual.Y);

            if (_engine.GetPlayerViewable().Contains(point))
            {
                desired = new Destination()
                {
                    X = _engine.GetPlayerLocation().X, Y = _engine.GetPlayerLocation().Y
                };
                entity.AddOrUpdateComponent((IComponent)desired);
            }
            else if (desired == null || desired == actual)
            {
                entity.RemoveComponent <Destination>();
                var randCell = walkable[rand.Next(0, walkable.Count)];
                desired   = entity.AddComponent <Destination>();
                desired.X = randCell.X;
                desired.Y = randCell.Y;
            }
        }
コード例 #3
0
        public override void Run(EntityManager.Entity entity)
        {
            var life = entity.GetComponent <Life>();

            if (life == null)
            {
                return;
            }

            if (life.Health < life.MaxHealth)
            {
                var regenRole = rand.Next(1000);
                if (regenRole < life.MaxHealth)
                {
                    life.Health++;
                }
            }

            if (life.Health <= 0)
            {
                var    nameComponent = entity.GetComponent <Name>();
                string name          = "";
                if (nameComponent != null)
                {
                    name = nameComponent.NameString;
                }

                _logger.Log($"{name}({entity.Id.ToString()}) has run out of hitpoints and died.");

                entity.RemoveComponent <Actor>();
                entity.RemoveComponent <Life>();
                entity.AddComponent <Dead>();

                var glyph = entity.GetComponent <Glyph>();
                glyph.glyph = CORPSE;
            }
        }