Esempio n. 1
0
        protected void Active()
        {
            if (reData)
            {
                oldX       = npc.position.X;
                upperPoint = npc.position.Y - 50f;
                idle       = npc.position;
                upper      = new Vector2(oldX, upperPoint);
                type       = -1;
                points     = new Vector2[5];
                reData     = false;
            }
            switch (type)
            {
            case -1:
                BeginInRange();
                if (BeginActive())
                {
                    type  = 0;
                    index = 0;
                    goto case 0;
                }
                break;

            case 0:
                Vector2 ground = ArchaeaNPC.FindEmptyRegion(target(), targetRange);
                if (index < points.Length)
                {
                    if (ground != Vector2.Zero)
                    {
                        points[index] = ground;
                        index++;
                    }
                }
                else
                {
                    index = 0;
                    goto case 1;
                }
                break;

            case 1:
                type = 1;
                if (index++ > moveRate)
                {
                    rand  = Main.rand.Next(points.Length);
                    index = 0;
                    moveCount++;
                    count++;
                }
                newMove = points[rand];
                ArchaeaNPC.PositionToVel(npc, newMove, 0.6f, 0.4f, true, -5f, 5f);
                if (npc.Distance(target().position) > range * 2f || moveCount > 2)
                {
                    moveCount = 0;
                    type      = 0;
                    goto case 0;
                }
                break;
            }
        }