Пример #1
0
        protected override void AI(MainChar a_mainChar)
        {
            if (_state == State.ATTACKING || _state == State.DYING || _state == State.HURTING)
            {
                return;
            }

            float mcDist = Globals.GetDistance(Position, a_mainChar.Position);

            if (mcDist < 70)
            {
                CurrentAnimation = 0;
                _state           = State.ATTACKING;
                return;
            }
            else if (mcDist < 400)
            {
                MoveTowards(a_mainChar.Position.X);
            }
            else
            {
                if (Math.Abs(Position.X - _originalXPos) < 1)
                {
                    _state = State.STANDING;
                }
                else
                {
                    MoveTowards(_originalXPos);
                }
            }
        }
Пример #2
0
        public override void Update(Vector2 a_offset, MainChar a_mainChar, SquareGrid a_grid)
        {
            a_grid.GetSlotFromPixel(Position, Vector2.Zero).Filled = false;

            _shooterTimer.UpdateTimer();
            if (_shooterTimer.Test())
            {
                if (Globals.GetDistance(Position, a_mainChar.Position) < 500)
                {
                    //GameGlobals.PassProjectile(new CurlyLine(new Vector2(Position.X, Position.Y - (Dimension.Y / 2)), this, new Vector2(a_mainChar.Position.X, a_mainChar.Position.Y)));
                }
                _shooterTimer.Reset();
            }


            _moveTimer.UpdateTimer();
            if (_moveTimer.Test())
            {
                MovSpeed = -MovSpeed;
                _moveTimer.Reset();
            }

            //HSpeed += MovSpeed;

            base.Update(a_offset, a_mainChar, a_grid);

            if (Globals.GetDistance(Position, a_mainChar.Position) < 45)
            {
                a_mainChar.GetHit(1);
            }

            a_grid.GetSlotFromPixel(Position, Vector2.Zero).Filled = true;
        }
Пример #3
0
        protected virtual void AI(MainChar a_mainChar)
        {
            Position += Globals.RadialMovement(Position, a_mainChar.Position, MovSpeed);
            Rotation  = Globals.RotateTowards(Position, a_mainChar.Position);

            if (Globals.GetDistance(Position, a_mainChar.Position) < 50)
            {
                a_mainChar.GetHit(1);
                Dead = true;
            }
        }
Пример #4
0
        public override void Update(Vector2 a_offset, MainChar a_mainChar, SquareGrid a_grid)
        {
            a_grid.GetSlotFromPixel(Position, Vector2.Zero).Filled = false;

            AI(a_mainChar);

            StartAnimation();

            base.Update(a_offset, a_mainChar, a_grid);

            a_grid.GetSlotFromPixel(Position, Vector2.Zero).Filled = true;
        }
Пример #5
0
        public virtual void LoadData(int a_level)
        {
            float     scale = 2f;
            XDocument xml   = XDocument.Load("XML\\Levels\\Level" + a_level + ".xml");

            // Load MainChar
            String   mcAsset     = "Assets\\MainChar\\full_animation";
            Vector2  mcPosition  = new Vector2(Engine.Globals.ScreenWidth / 2, Engine.Globals.ScreenHeight / 2);
            XElement mainCharXML = xml.Element("Root").Element("Unit").Element("MainChar");

            if (mainCharXML != null)
            {
                if (mainCharXML.Element("asset") != null)
                {
                    mcAsset = mainCharXML.Element("asset").Value;
                }
                if (mainCharXML.Element("position") != null)
                {
                    mcPosition = new Vector2(Convert.ToInt32(mainCharXML.Element("position").Value), 400);
                }
            }
            MainCharacter = new MainChar(mcAsset, /* position */ mcPosition, /* dimension */ new Vector2(76 * scale, 64 * scale), /* frames */ new Vector2(6, 18));

            // Load map
            XElement map = XDocument.Load("XML\\Maps\\swamp.xml").Element("map");

            XElement enemies = map.Elements("objectgroup").Where(elem => (string)elem.Attribute("name") == "EnemyLayer").First();

            foreach (XElement enemy in enemies.Elements("object"))
            {
                float posX        = (float)Convert.ToDouble(enemy.Attribute("x").Value);
                float posY        = (float)Convert.ToDouble(enemy.Attribute("y").Value);
                float enemyWidth  = (float)Convert.ToDouble(enemy.Attribute("width").Value);
                float enemyHeight = (float)Convert.ToDouble(enemy.Attribute("height").Value);
                Type  enemyType   = Type.GetType("FirstMG.Source.GamePlay." + enemy.Attribute("type").Value);

                if (enemyType != null)
                {
                    AddNpc((Npc)(Activator.CreateInstance(enemyType, new Vector2(posX * scale, posY * scale), new Vector2(enemyWidth * scale, enemyHeight * scale))));
                }
            }

            Vector2 mapSize  = new Vector2(Convert.ToInt32(map.Attribute("width").Value), Convert.ToInt32(map.Attribute("height").Value));
            Vector2 tileDims = new Vector2(Convert.ToInt32(map.Attribute("tilewidth").Value) * scale, Convert.ToInt32(map.Attribute("tileheight").Value) * scale);

            _grid = new SquareGrid(tileDims, new Vector2(0, 0), mapSize, map, 0.99f);
        }
Пример #6
0
        public override void Update(Vector2 a_offset, MainChar a_mainChar, SquareGrid a_grid)
        {
            if (!_locationImpassible)
            {
                GridLocation location = a_grid.GetSlotFromPixel(Position - new Vector2(0, a_grid.SlotDimensions.Y), Vector2.Zero);
                location.SetToFilled(true);
                Position            = location.Position + Dimension / 2;
                _locationImpassible = true;
            }
            if (FrameAnimationList[CurrentAnimation].CurrentFrame == 4)
            {
                a_grid.GetSlotFromPixel(Position, Vector2.Zero).Impassible = false;
                a_grid.GetSlotFromPixel(Position, Vector2.Zero).Filled     = false;
            }
            if (Globals.GetDistance(a_mainChar.Position, Position) < 100)
            {
                SetAnimationByName("Crumble");
            }

            base.Update(a_offset);
        }
Пример #7
0
        public virtual void Update(Vector2 a_offset, MainChar a_mainChar, SquareGrid a_grid)
        {
            //AI(a_mainChar);

            base.Update(a_offset, a_grid);
        }
Пример #8
0
 public override void Update(Vector2 a_offset, MainChar a_mainChar, SquareGrid a_grid)
 {
     base.Update(a_offset);
 }