public void Move(GameObject obj, ShipUpdateInfo info)
        {
            if (done)
            {
                return;
            }

            if (obj.position.X > (info.viewport.Left + 100) &&
                obj.position.X < (info.viewport.Right - 100))
            {
                done = true;
                obj.SetRotation(VecUtil.GetNormDown());
            }
        }
        public virtual void SetFaceDir(Vector2 v)
        {
            if (v.X == 0 && v.Y == 0)
            {
                v = VecUtil.GetNormDown();
            }
            else
            {
                v.Normalize();
            }

            faceDir = v;
            UpdateRotation();
        }
        public void Move(GameObject obj, ShipUpdateInfo info)
        {
            timer.Update(info.gameTime);

            switch (timer.Current)
            {
            case Timer2.TimerNum.First:
                obj.SetRotation(VecUtil.GetNormLeft());
                break;

            case Timer2.TimerNum.Second:
                obj.SetRotation(VecUtil.GetNormRight());
                break;
            }

            obj.SetFaceDir(VecUtil.GetNormDown());
        }
        private Vector2 dir;    //left, right, up, or down, in Vector2 form

        public MMCardinal(Cardinal direction)
        {
            switch (direction)
            {
            case Cardinal.Down:
                dir = VecUtil.GetNormDown();
                break;

            case Cardinal.Up:
                dir = VecUtil.GetNormUP();
                break;

            case Cardinal.Left:
                dir = VecUtil.GetNormLeft();
                break;

            case Cardinal.Right:
                dir = VecUtil.GetNormRight();
                break;
            }
        }
示例#5
0
        public override void Update(ShipUpdateInfo info)
        {
            if (!sleep)     //do nothing while sleeping
            {
                if (moving) //while moving, fix subShip positions manually
                {
                    //Override the boss move method
                    base.SetRotation(VecUtil.GetNormDown());
                    CenterInHoriz(info.viewport);

                    //move boss down at a fixed rate
                    float speed = 0.05f;
                    speed *= (float)info.gameTime.ElapsedGameTime.Milliseconds;
                    Vector2 v = new Vector2(0, speed);
                    base.Offset(v);

                    AdjustWeaponPos();

                    //base.Update(info, false);

                    //Override subship movement
                    FixSubShipPositions();
                }
                else  //once stopped moving allow sub ships to move themselves
                {
                    hp.MoveTopLeftTo(new Vector2(info.viewport.Left + 150f, info.viewport.Top + 30));
                    hp.SetHealth(this.health);

                    //Allow all the subShips to move
                    foreach (Ship s in subShips)
                    {
                        s.Update(info);
                    }

                    //Allow main boss ship to move according ot its move method
                    base.Update(info);
                }
            }
        }