示例#1
0
        //public virtual Vector2 Bounds { get; set; }
        public override void ParseXml(XmlParser xp, string path)
        {
            base.ParseXml(xp, path);

            string rootnode = path + "->" + Name;
            Color = xp.GetColor(rootnode + "->Color", Color);
            Alpha = xp.GetFloat(rootnode + "->Alpha", Alpha);
            Scale = xp.GetVector2(rootnode + "->Scale", Scale);
            Layer = xp.GetFloat(rootnode + "->Layer", Layer);

            if(xp.CheckElement(rootnode + "->Flip"))
            {
                string s = xp.GetString(rootnode + "->Flip", "None");
                switch (s)
                {
                    case "None":
                        Flip = SpriteEffects.None;
                        break;
                    case "FlipH":
                        Flip = SpriteEffects.FlipHorizontally;
                        break;
                    case "FlipV":
                        Flip = SpriteEffects.FlipVertically;
                        break;
                }
            }
        }
示例#2
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;
        }
示例#3
0
 public override void ParseXml(XmlParser xp, string path)
 {
     base.ParseXml(xp, path);
     string rootnode = path + "->" + Name;
     Texture = Entity.StateRef.GameRef.Game.Content.Load<Texture2D>(
         xp.GetString(rootnode + "->Texture", "TextureNotSet"));
     TileSize = xp.GetVector2(rootnode + "->TileSize", Vector2.Zero);
 }
示例#4
0
        public override void ParseXml(XmlParser xp, string path)
        {
            base.ParseXml(xp, path);
            string rootnode = path + "->" + Name + "->";

            LoadFont(xp.GetString(rootnode + "Font", "FontNotSet"));
            Text = xp.GetString(rootnode + "Text", "");
        }
示例#5
0
 public override void ParseXml(XmlParser xp, string path)
 {
     _xp = xp;
     base.ParseXml(xp, path);
     string rootnode = path + "->" + Name;
     Thrust = xp.GetFloat(rootnode + "->Thrust", 8.5f);
     _correctionangle = xp.GetFloat(rootnode + "->CorrectionAngle", .17f);
 }
        public override void ParseXml(XmlParser xp, string path)
        {
            base.ParseXml(xp, path);
            string rootnode = path + "->" + Name;

            if(xp.CheckElement(rootnode + "->Texture"))
            {
                LoadTexture(xp.GetString(rootnode + "->Texture", "TEXTURENOTSET"));
            }
        }
示例#7
0
        public override void ParseXml(XmlParser xp, string path)
        {
            base.ParseXml(xp, path);
            string rootnode = path + "->" + Name + "->";

            Milliseconds = xp.GetInt(rootnode + "Milliseconds", 0);
            if (xp.GetBool(rootnode + "StartAfterCreation", false))
            {
                Start();
            }
        }
        public Soldier(EntityState es, string name, XmlParser xp)
            : base(es, name)
        {
            Name = name + ID;

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

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

            Animation = new Animation(this, "Animation");
            Animation.Start();
            AddComponent(Animation);

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

            Health = new Health(this, "Health");
            Health.DiedEvent += OnDeath;
            AddComponent(Health);

            _attacktimer = new Timer(this, "AttackTimer");
            _attacktimer.LastEvent += OnAttackTimer;
            AddComponent(_attacktimer);

            _attacksound = new Sound(this, "AttackSound");
            AddComponent(_attacksound);

            _hitsound = new Sound(this, "HitSound");
            AddComponent(_hitsound);

            _ge = new GibEmitter(this, "GibEmitter");
            AddComponent(_ge);

            string path = es.Name + "->" + "Soldier";
            ParseXml(xp, path);

            Animation.Flip = (_rand.RandomBool()) ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
            Physics.Velocity.X = (Animation.Flip == SpriteEffects.None) ? -_speed : _speed;
            Body.Position.X = (Animation.Flip == SpriteEffects.None) ? es.GameRef.Viewport.Right + 10 : -10;
            Body.Position.Y = 520 - _rand.Next(-10, 10);

            //TODO: Set origin
            //TODO: Set Health.DiedEvent to emit blood particles and Destroy
        }
        public override void Start()
        {
            base.Start();
            var menuparser = new XmlParser(@"States/Menu/menu.xml");

            _bgimage = new Image(this, "BGImage");
            _bgimage.ParseXml(menuparser, "Menu->BGImage");
            AddEntity(_bgimage);

            _starttext = new Text(this, "StartText");
            _starttext.ParseXml(menuparser, "Menu->StartText");
            float x = GameRef.Viewport.Width / 2 - _starttext.TextRender.DrawRect.Width / 2;
            _starttext.Body.Position = new Vector2(x, 500);
            AddEntity(_starttext);

            _startkey = new DoubleInput(null, "StartKey", Keys.Enter, Buttons.Start, PlayerIndex.One);
        }
        public EnemySpawner(EntityState es, XmlParser xp)
            : base(es, "EnemySpawner")
        {
            Enemies = new List<Entity>();
            Targets = new List<Entity>();
            _xp = xp;

            SoldierTimer = new Timer(this, "SoldierTimer");
            SoldierTimer.LastEvent += AddSoldier;
            AddComponent(SoldierTimer);

            HelicopterTimer = new Timer(this, "HelicopterTimer");
            HelicopterTimer.LastEvent += AddHelicopter;
            AddComponent(HelicopterTimer);

            ParseXml(xp, "GameState->" + Name);
        }
示例#11
0
        public Town(EntityState es, XmlParser xp)
            : base(es, "Town")
        {
            Body = new Body(this, "Body");
            AddComponent(Body);

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

            DeadCityAnim = new Animation(this, "DeadCityAnim");
            AddComponent(DeadCityAnim);

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

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

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

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

            _firebombsound = new Sound(this, "FireBombSound");
            AddComponent(_firebombsound);

            _firekey = new DoubleInput(this, "FireKey", Keys.Enter, Buttons.A, PlayerIndex.One);
            AddComponent(_firekey);

            _debugkey = new DoubleInput(this, "DebugKey", Keys.Tab, Buttons.B, PlayerIndex.One);
            AddComponent(_debugkey);

            ParseXml(xp, "GameState->" + Name);

            //Add our custom data here.
            Body.Position.X = StateRef.GameRef.Viewport.Width / 2 - TileRender.DrawRect.Width / 2;

            //Set our rotation origins
            TileRender.Origin = new Vector2(TileRender.TileSize.X / 2f, TileRender.TileSize.Y / 2f);
            DeadCityAnim.Origin = TileRender.Origin;

            //TODO: Health.Hurtevent changes color
            Cursor = new Cursor(es, this, xp);
            es.AddEntity(Cursor);
        }
        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;
            }
        }
        public override void ParseXml(XmlParser xp, string path)
        {
            base.ParseXml(xp, path);

            string rootnode = path + "->" + Name;
            if (xp.CheckElement(rootnode + "->Texture"))
            {
                Texture =
                    Entity.StateRef.GameRef.Game.Content.Load<Texture2D>(xp.GetString(rootnode + "->Texture",
                                                                                      "TEXTURENOTSET"));
            }

            if (xp.CheckElement(rootnode + "->Colors"))
            {
                string[] test = xp.GetAllDesendents(rootnode + "->Colors");
                foreach (string s in test)
                {
                    Colors.Add(xp.GetColor(rootnode + "->Colors->" + s));
                }
            }
        }
        public Helicopter(EntityState es, string name, XmlParser xp)
            : base(es, name)
        {
            Name = name + ID;
            _xp = xp;

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

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

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

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

            Health = new Health(this, "Health");
            Health.DiedEvent += OnDeath;
            AddComponent(Health);

            _ge = new GibEmitter(this, "GibEmitter");
            AddComponent(_ge);

            _explodeanim = new Animation(this, "ExplodeAnim");
            _explodeanim.LastFrameEvent += Destroy;
            AddComponent(_explodeanim);

            _hitsound = new Sound(this, "HitSound");
            AddComponent(_hitsound);

            string path = es.Name + "->Helicopter";
            ParseXml(xp, path);

            Animation.Flip = (_rand.RandomBool()) ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
            Physics.Velocity.X = (Animation.Flip == SpriteEffects.None) ? -.4f : .4f;
            Body.Position.Y = 300 - _rand.Next(-10, 10);
            Body.Position.X = (Animation.Flip == SpriteEffects.None) ? es.GameRef.Viewport.Right + 10 : -10;
        }
示例#15
0
        public Bomb(EntityState es, string name, XmlParser xp)
            : base(es, name)
        {
            string path = es.Name + "->" + "Bomb";

            Name = Name + ID;

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

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

            Collision = new Collision(this, "Collision");
            Collision.CollideEvent += CollisionHandler;
            AddComponent(Collision);

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

            _explodeanim = new Animation(this, "ExplodeAnim");
            _explodeanim.LastFrameEvent += Destroy;
            AddComponent(_explodeanim);

            _explodesound = new Sound(this, "ExplodeSound");
            AddComponent(_explodesound);

            _explosionemitter = new ExplosionEmitter(this);
            AddComponent(_explosionemitter);

            _smokeemitter = new SmokeEmitter(this);
            AddComponent(_smokeemitter);

            ParseXml(xp, path);

            //TODO: Hook up Collision.CollideEvent to a handler
            _explodeanim.Origin = new Vector2(_explodeanim.TileSize.X / 2.0f, _explodeanim.TileSize.Y / 2.0f);
            ImageRender.Origin = new Vector2(ImageRender.Texture.Width / 2f, ImageRender.Texture.Height / 2f);
        }
示例#16
0
 public override void ParseXml(XmlParser xp, string path)
 {
     base.ParseXml(xp, path);
     Points = xp.GetInt(path + "->Points", 0);
 }
示例#17
0
 public override void ParseXml(XmlParser xp, string path)
 {
     base.ParseXml(xp, path);
     string rootnode = path + "->" + Name + "->";
     TileSize = xp.GetVector2(rootnode + "TileSize", Vector2.Zero);
     Index = xp.GetInt(rootnode + "Index", 0);
 }
示例#18
0
 public override void ParseXml(XmlParser xp, string path)
 {
     base.ParseXml(xp, path);
     string rootnode = path + "->" + Name + "->";
     FrameTimer.ParseXml(xp, path + "->" + Name);
     TileSize = xp.GetVector2(rootnode + "TileSize", Vector2.Zero);
     FramesPerSecond = xp.GetInt(rootnode + "FramesPerSecond", 0);
     CurrentFrame = xp.GetInt(rootnode + "CurrentFrame", 0);
     if (xp.GetBool(rootnode + "StartAfterCreation", false))
         Start();
 }
示例#19
0
 public override void ParseXml(XmlParser xp, string path)
 {
     base.ParseXml(xp, path);
     _normalcolor = xp.GetColor(path + "->NormalColor");
     _inactivecolor = xp.GetColor(path + "->InactiveColor");
     _safetyangle = xp.GetFloat(path + "->SafetyAngle");
     _angleconstraint = xp.GetFloat(path + "->AngleConstraint");
     _rotationspeed = xp.GetFloat(path + "->RotationSpeed");
     _quickaimmultiplier = xp.GetFloat(path + "->QuickAimMultiplier");
 }
示例#20
0
 public override void ParseXml(XmlParser xp, string path)
 {
     base.ParseXml(xp, path);
     _speed = xp.GetFloat(path + "->Speed", 1);
 }
示例#21
0
 public override void ParseXml(XmlParser xp, string path)
 {
     base.ParseXml(xp, path);
     string rootnode = path + "->" + Name + "->";
     Debug = xp.GetBool(rootnode + "Debug", false);
     DebugColor = xp.GetColor(rootnode + "DebugColor", Color.PowderBlue);
     Bounds = xp.GetRectangle(rootnode + "Bounds", new Rectangle());
 }
 public override void ParseXml(XmlParser xp, string path)
 {
     base.ParseXml(xp, path);
     string rootnode = path + "->" + Name;
     _minttl = xp.GetInt(rootnode + "->MinTTL");
     _maxttl = xp.GetInt(rootnode + "->MaxTTL");
 }
示例#23
0
 public virtual void ParseXml(XmlParser xp, string path)
 {
     string rootnode = path + "->" + Name;
     Active = xp.GetBool(rootnode + "->Active", Active);
     Default = xp.GetBool(rootnode + "->Default", Default);
 }
示例#24
0
        public override void ParseXml(XmlParser xp, string path)
        {
            base.ParseXml(xp, path);
            string rootnode = path + "->" + Name + "->";

            SoundEffect = LoadSound(xp.GetString(rootnode + "SoundEffect", "SoundNotSet")).CreateInstance();
            Volume = xp.GetFloat(rootnode + "Volume", 1);
            Pan = xp.GetFloat(rootnode + "Pan", 0);
            Pitch = xp.GetFloat(rootnode + "Pitch", 0);
            Loop = xp.GetBool(rootnode + "Loop", false);
        }
示例#25
0
 public override void ParseXml(XmlParser xp, string path)
 {
     base.ParseXml(xp, path);
     string rootnode = path + "->" + Name + "->";
     HitPoints = xp.GetInt(rootnode + "HitPoints", 1);
 }
示例#26
0
            public override void ParseXml(XmlParser xp, string path)
            {
                base.ParseXml(xp, path);
                string rootnode = path + "->" + Name;
                _minttl = xp.GetInt(rootnode + "->MinTTL");
                _maxttl = xp.GetInt(rootnode + "->MaxTTL");

                colors = new List<Color>()
                    {
                        xp.GetColor(rootnode + "->Colors->Color1"),
                        xp.GetColor(rootnode + "->Colors->Color2"),
                        xp.GetColor(rootnode + "->Colors->Color3"),
                        xp.GetColor(rootnode + "->Colors->Color4")
                    };
            }
示例#27
0
 public virtual void ParseXml(XmlParser xp)
 {
     string path = Entity.Name;
     ParseXml(xp, path);
 }
        public override void ParseXml(XmlParser xp, string path)
        {
            base.ParseXml(xp, path);
            _soldiermaxtime = xp.GetInt(path + "->SoldierMaxTime");
            _helicoptermaxtime = xp.GetInt(path + "->HelicopterMaxTime");
            _soldiermintime = xp.GetInt(path + "->SoldierMinTime");
            _helicoptermintime = xp.GetInt(path + "->HelicopterMinTime");

            _difficultyrise = xp.GetFloat(path + "->DifficultyRise");
            _difficultystep = xp.GetInt(path + "->DifficultyStep");
        }
示例#29
0
 public override void ParseXml(XmlParser xp, string path)
 {
     base.ParseXml(xp, path);
 }
示例#30
0
 public override void ParseXml(XmlParser xp, string path)
 {
     base.ParseXml(xp, path);
     _gravity = xp.GetFloat(path + "->Gravity", .1f);
     Damage = xp.GetFloat(path + "->Damage", 1);
 }