예제 #1
0
        override public void update(float dt)
        {
            if (pursueCountDown >= 0)
            {
                pursueCountDown -= dt;

                attackVector = new Vector2(owner.hitBox.Center.X - target.hitBox.Center.X, owner.hitBox.Center.Y - target.hitBox.Center.Y);
                attackVector.Normalize();
                attackVector   *= owner.reach;
                attackVector.X += target.hitBox.Center.X;
                attackVector.Y += target.hitBox.Center.Y;
                double distance = Math.Sqrt(Math.Pow(attackVector.X - owner.hitBox.Center.X, 2) + Math.Pow(attackVector.Y - owner.hitBox.Center.Y, 2));
                if (distance > owner.reach)
                {
                    attackPos = new Point((int)attackVector.X, (int)attackVector.Y);
                    movement  = new Vector2((float)(attackPos.X - owner.hitBox.Center.X), (float)(attackPos.Y - owner.hitBox.Center.Y));
                    movement.Normalize();
                    movement        *= owner.maxSpeed;
                    owner.velocity.X = movement.X;
                    owner.velocity.Y = movement.Y;
                    owner.isWalking  = true;
                    owner.setGaze(attackPos);
                }
                else
                {
                    if (attackCoolDown <= 0)
                    {
                        owner.setGaze(target.hitBox.Center);
                        owner.Light_Attack();
                        attackCoolDown = (float)(.5f);
                    }
                    else
                    {
                        attackCoolDown -= dt;
                    }
                }
            }
            else
            {
                elapsed   = 0;
                traceInfo = owner.world.traceWorld(owner.hitBox.Center, target.hitBox.Center);
                if (traceInfo.hitWorld)
                {
                    Pursue pursue = new Pursue(ownerList, owner, target);
                    ownerList.pushFront(pursue);
                    //onEnd();
                }
                else
                {
                    pursueCountDown = 2.5f;
                }
            }
        }
예제 #2
0
        override public void update(float dt)
        {
            if (pursueCountDown >= 0)
            {
                pursueCountDown -= dt;

                attackVector = new Vector2(owner.hitBox.Center.X - target.hitBox.Center.X, owner.hitBox.Center.Y - target.hitBox.Center.Y);
                attackVector.Normalize();
                attackVector *= owner.reach;
                attackVector.X += target.hitBox.Center.X;
                attackVector.Y += target.hitBox.Center.Y;
                double distance = Math.Sqrt(Math.Pow(attackVector.X - owner.hitBox.Center.X, 2) + Math.Pow(attackVector.Y - owner.hitBox.Center.Y, 2));
                if (distance > owner.reach)
                {
                    attackPos = new Point((int)attackVector.X, (int)attackVector.Y);
                    movement = new Vector2((float)(attackPos.X - owner.hitBox.Center.X), (float)(attackPos.Y - owner.hitBox.Center.Y));
                    movement.Normalize();
                    movement *= owner.maxSpeed;
                    owner.velocity.X = movement.X;
                    owner.velocity.Y = movement.Y;
                    owner.isWalking = true;
                    owner.setGaze(attackPos);
                }
                else
                {
                    if (attackCoolDown <= 0)
                    {
                        owner.setGaze(target.hitBox.Center);
                        owner.Light_Attack();
                        attackCoolDown = (float)(.5f);
                    }
                    else
                    {
                        attackCoolDown -= dt;
                    }
                }
                
            }
            else
            {
                elapsed = 0;
                traceInfo = owner.world.traceWorld(owner.hitBox.Center, target.hitBox.Center);
                if (traceInfo.hitWorld)
                {
                    Pursue pursue = new Pursue(ownerList, owner, target);
                    ownerList.pushFront(pursue);
                    //onEnd();
                }
                else
                    pursueCountDown = 2.5f;
            }
        }