Пример #1
0
        public void Move(MobMovement moveType)
        {
            Random rand = RandomProvider.Get();

            switch (moveType)
            {
            case MobMovement.Patrol:
                // TODO: Grab move radius from metadata
                int   moveDistance = rand.Next(0, MoveRange);
                short moveAngle    = (short)rand.Next(-1800, 1800);

                Velocity = CoordF.From(moveDistance, moveAngle);

                // Keep near spawn
                if ((SpawnDistance - Velocity).Length() >= Block.BLOCK_SIZE * 2)
                {
                    moveAngle = (short)SpawnDistance.XYAngle();
                    Velocity  = CoordF.From(Block.BLOCK_SIZE, moveAngle);
                }

                ZRotation = moveAngle;      // looking direction of the monster
                break;

            case MobMovement.Follow:        // move towards target
            case MobMovement.Strafe:        // move around target
            case MobMovement.Run:           // move away from target
            case MobMovement.LookAt:
            case MobMovement.Hold:
            default:
                Velocity = CoordF.From(0, 0, 0);
                break;
            }

            SpawnDistance -= Velocity;
        }