Exemplo n.º 1
0
 public EnemyTypeII(object sprite, Vector2 speed, Vector2 locate, float ringSize, float enemySize, float enemySize2, AIBase.FaceSide face, AIBase.ID id)
     : base(sprite, speed, locate, ringSize, enemySize, enemySize2, face, id)
 {
     this.BeCatch = false;
     this.DefaultSpeed = Speed;
     this.CurrentFlee = 0;
     this.AttackTime = 0;
     Find = false;
     IsLead = false;
     Sharp = new List<PicList>();
     this.CombineList = new List<EnemyTypeII>();
 }
Exemplo n.º 2
0
 public Vector2 MoveTest(Vector2 locate, Speed speed, float time, int size)
 {
     return MoveTest(locate, speed.Radian, speed.Length, time, size);
 }
Exemplo n.º 3
0
        //初始化方法
        public Unit(object sprite, Vector2 speed, Vector2 locate, float ringSize, float enemySize,float enemySize2, AIBase.FaceSide face, AIBase.ID id)
            : base(sprite)
        {
            //四个输入参数
            Speed = speed;
            m_locate = locate;
            Face = face;
            Id = id;
            RingSize = ringSize;
            EnemySize = enemySize;
            CoolDownTime = 0;
            CurrentFly = 0;
            EnemySize2 = enemySize;
            CurrentDialog = AIBase.StatusDialog.Blank;

            StatusColor = Color.AliceBlue;
            StatusPostion = new Vector2(0);

            //放在开始位置
            StartPoint = locate;
            //默认在Normal状态
            Status = AIBase.Status.Normal;
            LastStatus = AIBase.Status.Blank;
            //默认不旋转
            Rotate = 0f;
            this.CurrentRing = 0;
            //表初始化
            ListLeft = new List<PicList>();
            ListRight = new List<PicList>();
            ListTurnLeft = new List<PicList>();
            ListTurnRight = new List<PicList>();
            List = new List<PicList>();
            ListRing = new List<PicList>();
            //中心位置
            Center = new Vector2(enemySize / 2, enemySize / 2);
        }
Exemplo n.º 4
0
        //    public bool CollsionDetection()
        //     {
        //        foreach (var ptr in AIBase.ScenceList)
        //        {
        //             if (AIBase.Player.Postion.X > ptr.Area.X && AIBase.Player.Postion.X < ptr.Area.X + ptr.Area.Width
        //               && AIBase.Player.Postion.Y > ptr.Area.Y && AIBase.Player.Postion.Y < ptr.Area.Y + ptr.Area.Height
        //                && ptr.Status)
        //             {
        //                  return true;
        //             }
        //         }
        //         return false;
        //       }
        public override void Update(GameTime gameTime)
        {
            Speed inputSpeed = Input.Speed;
            if (this.Scale.Y <= 1)
                this.Scale.Y += 0.01f;
            else
                this.Scale.Y = 1;

            if (this.Scale.X <= 1)
                this.Scale.X += 0.01f;
            else
                this.Scale.X = 1;

            if (Input.IsTransformKeyDown() || this.Status == AIBase.Status.Freeze)
            {
                inputSpeed = new Speed(0, 0);
            }

            switch (Status)
            {
                case AIBase.Status.Turning:
                case AIBase.Status.Blank:
                case AIBase.Status.Normal:
                    {
                        if (inputSpeed.Radian == inputSpeed.Radian && inputSpeed.Length > 0.2)
                        {
                            this.Speed.Radian = inputSpeed.Radian;
                            this.Speed.Length = inputSpeed.Length * this.MaxSpeed;
                        }
                        else
                        {
                            Speed.Length = 0;
                        }
                        break;
                    }
                case AIBase.Status.Attck:
                    {
                        //Speed.
                        break;
                    }
                case AIBase.Status.Strike:

                    if ((!Input.IsSpeedupKeyDown()) || RingSize <= 105)
                    {
                        Status = AIBase.Status.Normal;
                    }
                    else if (inputSpeed.Radian == inputSpeed.Radian && inputSpeed.Length > 0.2)
                    {
                        if (Math.Abs(inputSpeed.Radian - this.Speed.Radian) > 0.7 * MathHelper.Pi)
                        {
                            Status = AIBase.Status.Normal;
                            Speed.Radian = Input.Speed.Radian;
                        }
                        else
                        {
                            Speed.Radian = Speed.Radian - (float)gameTime.ElapsedGameTime.TotalSeconds * (Speed.Radian - Input.Speed.Radian) * 10;
                            if (Speed.Length < 180)
                                Status = AIBase.Status.Normal;
                            else
                                this.RingSize -= (float)gameTime.ElapsedGameTime.TotalSeconds * 60.0f;
                        }
                    }
                    else
                    {
                        Speed.Length = 0;
                        Status = AIBase.Status.Normal;
                    }
                    //Speed.Length -= 80f * (float) gameTime.ElapsedGameTime.TotalSeconds;
                    break;
                    ;
            }
            this.Postion = AIBase.SenceManager.MoveTest(this.Locate, Speed.Radian, Speed.Length,
                                   (float)gameTime.ElapsedGameTime.TotalSeconds);
            RadianGenerate(gameTime);
            //        if(!this.CollsionDetection())
            LocateConfirm();
            //Console.WriteLine(RingSize);

            //Speed = Utilities.Utilities.GetVector(this.CommonSpeed,Input.Radian);

            if (Input.IsTransformKeyDown())
            {
                this.Transforming = true;

                if (Input.IsUpKeyDown() && this.HideObtain[0])
                {
                    this.FakeID = AIBase.ID.II; //刺头
                }
                else if (Input.IsLeftKeyDown() && this.HideObtain[1])
                {
                    this.FakeID = AIBase.ID.I; //合体怪
                }
                else if (Input.IsRightKeyDown() && this.HideObtain[2])
                {
                    this.FakeID = AIBase.ID.V; //幽灵
                }
                else if (Input.IsDownKeyDown())
                {
                    this.FakeID = AIBase.ID.Zero;
                }
            }
            else
            {
                this.Transforming = false;
            }

            if (Input.IsSpeedupKeyDown() && !Input.IsTransformKeyDown())
            {
                switch (Status)
                {
                    case AIBase.Status.Normal:
                    case AIBase.Status.Blank:
                    case AIBase.Status.Abandon:
                        if (RingSize > 150)
                        {
                            //RingSize -= 10;
                            Status = AIBase.Status.Strike;
                            this.Speed.Length = 400f;
                        }
                        break;
                }
            }

            if (Input.IsLeftKeyDown() && !Input.IsTransformKeyDown())
            {
                if (this.Face == AIBase.FaceSide.Right && Status == AIBase.Status.Normal)
                {
                    this.LastStatus = this.Status;
                    this.Status = AIBase.Status.Turning;
                    //Speed.X = -Speed.X;
                }
            }

            if (Input.IsRightKeyDown() && !Input.IsTransformKeyDown())
            {
                if (this.Face == AIBase.FaceSide.Left && Status == AIBase.Status.Normal)
                {
                    this.LastStatus = this.Status;
                    this.Status = AIBase.Status.Turning;
                    //Speed.X = -Speed.X;
                }
            }

            if (Input.IsAttackKeyDown() && !Input.IsTransformKeyDown())
            {
                //只有在RingSize大于100的时候才能够冲刺
                if (this.RingSize > 100 && (this.Status == AIBase.Status.Normal || this.Status == AIBase.Status.Blank))
                {
                    this.LastStatus = this.Status;
                    this.Status = AIBase.Status.Attck;
                    Speed.Length = 0;
                }
            }

            //运动中环逐渐减小 每秒减小6
            if (RingSize > 200)
            {
                this.RingSize -= (float)gameTime.ElapsedGameTime.TotalSeconds *6;
            }
            if (RingSize < 200)
            {
                this.RingSize += (float)gameTime.ElapsedGameTime.TotalSeconds * 6;
            }
            if (this.Status == AIBase.Status.Strike)
            {
                this.CurrentDialog = AIBase.StatusDialog.Strike;
            }
            else if (this.Status == AIBase.Status.Attck)
            {
                this.CurrentDialog = AIBase.StatusDialog.Kakaka;
            }
            else if (this.Status == AIBase.Status.Freeze)
            {
                this.CurrentDialog = AIBase.StatusDialog.Ahhh;
            }
            else
            {
                this.CurrentDialog = AIBase.StatusDialog.Blank;
            }

            this.EyeColor.A = (byte)(255f * (0.5f * (float)Math.Sin(gameTime.TotalGameTime.TotalSeconds) + 0.5f));

            //Console.WriteLine(Speed);
            if (this.HP == 3)
                this.HP_3[0].Update(gameTime);
            if (this.HP == 2)
                this.HP_2[0].Update(gameTime);
            if (this.HP == 1)
                this.HP_1[0].Update(gameTime);

            base.Update(gameTime);
        }
Exemplo n.º 5
0
 private static void SetSpeedXY(float x,float y, ref Speed i)
 {
     i.m_length = (float)Math.Sqrt(x * x + y * y);
     float d = (float)Math.Acos(-y / i.m_length);
     if (!(d<MathHelper.TwoPi && d>-MathHelper.Pi))
     {
         i.m_radian = 0;
         return;
     }
     //Console.WriteLine(d);
     if (x > 0)
     {
         i.m_radian = d;
     }
     else i.m_radian = -d;
 }
Exemplo n.º 6
0
        public static Speed FormXY(float x,float y)
        {
            Speed i = new Speed();
            SetSpeedXY(x, y, ref i);
            if (float.IsNaN(i.m_radian) || float.IsNaN(i.m_length))
            {

            }
            return i;
        }
Exemplo n.º 7
0
        public static Speed FormVector2(Vector2 input)
        {
            Speed a = new Speed(input.Length(), input.Radian());
            if(float.IsNaN(a.m_radian) || float.IsNaN(a.m_length))
            {

            }
            return a;
        }
Exemplo n.º 8
0
            public void Update(GameTime gameTime, Vector2 postion, List<BodyNode> list, BigSnake snake)
            {
                if (RightGlass.CurrentStatus == GlassStatus.Bad
                    && LeftGlass.CurrentStatus == GlassStatus.Bad
                    && this.NodeStatus == NodeStatus.Good)
                {
                    this.NodeStatus = NodeStatus.Judge;
                }

                this.RightGlass.Update(gameTime);
                this.LeftGlass.Update(gameTime);
                switch (this.NodeStatus)
                {
                    case NodeStatus.Good:

                        if (list.IndexOf(this) == 0)
                        {
                            this.Speed = postion - this.Postion;
                        }
                        else
                        {
                            this.Speed = list[list.IndexOf(this) - 1].Postion - this.Postion;
                        }

                        this.Speed.Length = this.Speed.Length / 3 + 320;

                        if (list.IndexOf(this) == 0)
                        {
                            if ((this.Postion - postion).Length() > 120)
                            {
                                this.Postion = AIBase.SenceManager.MoveTest(this.Postion, this.Speed,
                                                                            (float)gameTime.ElapsedGameTime.TotalSeconds);
                            }
                            this.Rotation = Speed.Radian + MathHelper.PiOver2;

                        }
                        else
                        {
                            if ((this.Postion - list[list.IndexOf(this) - 1].Postion).Length() >120)
                            {
                                this.Postion = AIBase.SenceManager.MoveTest(this.Postion, this.Speed,
                                                                            (float)gameTime.ElapsedGameTime.TotalSeconds);
                            }
                            this.Rotation = Speed.Radian + MathHelper.PiOver2;
                        }
                        break;

                    case NodeStatus.Judge:
                        if (!this.Next)
                        {
                            this.NodeStatus = NodeStatus.Bad;
                            if (list.IndexOf(this) != 0)
                            {
                                list[list.IndexOf(this) - 1].Next = false;
                            }
                            else
                            {
                                snake.CurrentSnakeStatus = SnakeStatus.Notail;
                            }
                        }
                        else
                        {
                            this.NodeStatus = NodeStatus.Freeze;
                        }
                        break;

                    case NodeStatus.Bad:
                        if (this.Color.A != 0)
                        {
                            this.Color.A -= 15;
                        }
                        else
                        {
                            this.Color.A = 0;

                        }
                        break;

                    case NodeStatus.Freeze:
                        this.Color = Color.Gray;

                        if (list.IndexOf(this) == 0)
                        {
                            this.Speed = postion - this.Postion;
                        }
                        else
                        {
                            this.Speed = list[list.IndexOf(this) - 1].Postion - this.Postion;
                        }
                        this.Speed.Length = this.Speed.Length/2 + 320;

                        if (list.IndexOf(this) == 0)
                        {
                            if ((this.Postion - postion).Length() > 120)
                            {
                                this.Postion = AIBase.SenceManager.MoveTest(this.Postion, this.Speed,
                                                                            (float)gameTime.ElapsedGameTime.TotalSeconds);
                            }
                            this.Rotation = Speed.Radian + MathHelper.PiOver2;

                        }
                        else
                        {
                            if ((this.Postion - list[list.IndexOf(this) - 1].Postion).Length() > 120)
                            {
                                this.Postion = AIBase.SenceManager.MoveTest(this.Postion, this.Speed,
                                                                            (float)gameTime.ElapsedGameTime.TotalSeconds);
                            }
                            this.Rotation = Speed.Radian + MathHelper.PiOver2;
                        }

                        this.Rotation = Speed.Radian + MathHelper.PiOver2;

                        if (!this.Next)
                        {
                            this.NodeStatus = NodeStatus.Bad;
                            if (list.IndexOf(this) != 0)
                            {
                                list[list.IndexOf(this) - 1].Next = false;
                            }
                            else
                            {
                                snake.CurrentSnakeStatus = SnakeStatus.Notail;
                            }
                        }
                        break;
                }
            }
Exemplo n.º 9
0
 public BodyNode(Vector2 postion)
 {
     this.Postion = postion;
     RightGlass = new RightGlass(postion);
     LeftGlass = new LeftGlass(postion);
     this.NodeStatus = NodeStatus.Good;
     Next = true;
     this.Color = Color.AliceBlue;
     this.Rotation = MathHelper.PiOver2;
     this.Speed = new Vector2(0);
 }