Ejemplo n.º 1
0
        public Cursor(EntityState es, Town t, XmlParser xp)
            : base(es, "Cursor")
        {
            _town = t;

            //Current data path is GameState->Town->Cursor
            var path = es.Name + "->" + _town.Name + "->" + Name;

            Body = new Body(this, "Body");
            AddComponent(Body);

            Physics = new Physics(this, "Physics");
            AddComponent(Physics);

            ImageRender = new ImageRender(this, "ImageRender");
            AddComponent(ImageRender);

            _aimleftkey = new DoubleInput(this, "AimLeftKey", Keys.A, Buttons.DPadLeft, PlayerIndex.One);
            AddComponent(_aimleftkey);

            _aimrightkey = new DoubleInput(this, "AimRightKeys", Keys.D, Buttons.DPadRight, PlayerIndex.One);
            AddComponent(_aimrightkey);

            _quickaimkey = new DoubleInput(this, "QuickAimKey", Keys.LeftShift, Buttons.RightShoulder, PlayerIndex.One);
            AddComponent(_quickaimkey);

            ParseXml(xp, path);

            ImageRender.Origin = new Vector2(ImageRender.Texture.Width / 2f, ImageRender.Texture.Height / 2f);
            Body.Position = _town.Body.Position +
                            (_town.TileRender.Origin - Vector2.UnitY * 40 - ImageRender.Origin) *
                            ImageRender.Scale;
        }
Ejemplo n.º 2
0
        public override void Start()
        {
            if (!_alreadystarted)
            {
                base.Start();
                _alreadystarted = true;

                XmlParser xp = new XmlParser(@"States/Game/Game.xml");

                _bgimage = new Image(this, "BGImage");
                _bgimage.ParseXml(xp, Name + "->" + _bgimage.Name);
                AddEntity(_bgimage);

                _town = new Town(this, xp);
                AddEntity(_town);

                _scoretext = new Text(this, "ScoreText");
                _scoretext.ParseXml(xp, Name + "->" + _scoretext.Name);
                _scoretext.Body.Position = new Vector2(
                    GameRef.Viewport.Width / 2 - _scoretext.TextRender.DrawRect.Width / 2, 10);
                AddEntity(_scoretext);

                _healthtext = new Text(this, "HealthText");
                _healthtext.ParseXml(xp, Name + "->" + _healthtext.Name);
                _healthtext.Body.Position = new Vector2(
                    GameRef.Viewport.Width / 2 - _healthtext.TextRender.DrawRect.Width / 2, 50);
                AddEntity(_healthtext);

                _difficultytext = new Text(this, "DifficultyText");
                _difficultytext.ParseXml(xp, Name + "->" + _difficultytext.Name);
                _difficultytext.Body.Position = new Vector2(
                    GameRef.Viewport.Width / 2 - _difficultytext.TextRender.DrawRect.Width / 2, 90);
                AddEntity(_difficultytext);

                _es = new EnemySpawner(this, xp);
                EntityRemoved += _es.RemoveEnemy;
                _es.Targets.Add(_town);
                AddEntity(_es);

                _town.Targets.List = _es.Enemies;
            }
        }