コード例 #1
0
        private Vector3 AddVelocityNoise(Vector3 velocity)
        {
            float       scaleMin = 1f - VelocityNoiseScale;
            const float ScaleMax = 1f;
            //float scaleMax = 1f + VelocityNoiseScale;

            Vector2 normalVelocity = RandomUtil.Bool()
                ? new Vector2(-velocity.y, velocity.x)
                : new Vector2(velocity.y, -velocity.x);

            //Debug.DrawRay(Player.Position, velocity, Color.red, 1.0f);
            //Debug.DrawRay(Player.Position, normalVelocity, Color.cyan, 1.0f);

            float normalScale = RandomUtil.Float(0f, VelocityScaleMax);

            velocity.x += (normalScale * normalVelocity.x);
            velocity.y += (normalScale * normalVelocity.y);

            velocity *= RandomUtil.Float(scaleMin, ScaleMax);

            return(velocity);

            //float averageOfValues = (velocity.x + velocity.y) * 0.5f;

            //velocity.x += RandomUtil.Float(-VelocityNoiseOffset, VelocityNoiseOffset);
            //velocity.x *= RandomUtil.Float(scaleMin, ScaleMax);

            //velocity.y += RandomUtil.Float(-VelocityNoiseOffset, VelocityNoiseOffset);
            //velocity.y *= RandomUtil.Float(scaleMin, ScaleMax);

            //return velocity;
        }
コード例 #2
0
    protected override void OnStart()
    {
        bool shouldKeep = RandomUtil.Bool(percentKeepChance / 100.0f);

        if (!shouldKeep)
        {
            Remove();
        }
    }
コード例 #3
0
ファイル: MapGenerator.cs プロジェクト: J0eCool/RuneShooter
    private void generateRooms()
    {
        // Generate room layout via random walk
        width  = Random.Range(6, 8);
        height = Random.Range(4, 6);
        rooms  = new Room[width, height];

        int  x         = Random.Range(0, width);
        int  y         = Random.Range(0, height);
        Room startRoom = new Room();

        rooms[x, y]           = startRoom;
        startRoom.isStartRoom = true;
        startOffset           = transform.position - offsetForRoom(x, y);

        int count    = Random.Range(1, width) + Random.Range(1, height) + width * height / 4;
        int numRooms = 1;

        while (numRooms < count)
        {
            // Set up next move
            bool horizontal = RandomUtil.Bool();
            int  sign       = RandomUtil.Sign();
            int  dx         = horizontal ? sign : 0;
            int  dy         = horizontal ? 0 : sign;
            int  newX       = x + dx;
            int  newY       = y + dy;
            if (newX < 0 || newX >= width || newY < 0 || newY >= height)
            {
                continue;
            }

            // Create new room if unvisited
            bool shouldConnect = RandomUtil.Bool();
            if (rooms[newX, newY] == null)
            {
                rooms[newX, newY] = new Room();
                numRooms++;
                shouldConnect = true;
            }

            // Connect to previous room
            if (shouldConnect)
            {
                int  prevX = Mathf.Min(x, x + dx);
                int  prevY = Mathf.Min(y, y + dy);
                Room prev  = rooms[prevX, prevY];
                if (horizontal)
                {
                    prev.doorToEast = true;
                }
                else
                {
                    prev.doorToNorth = true;
                }
                int  curX = Mathf.Max(x, x + dx);
                int  curY = Mathf.Max(y, y + dy);
                Room cur  = rooms[curX, curY];
                prev.AddNeighbor(cur);
            }

            // Perform move
            x = newX;
            y = newY;
        }
    }
コード例 #4
0
ファイル: RotateAround.cs プロジェクト: WSHSHIWBB/DLL
 private void RotateGoOnHandler()
 {
     isCapturePaused = false;
     StartCoroutine(WorldRotate(true, RandomUtil.Bool(), Random.Range(30f, 90f), _rotateSpeed));
     HandleScreenMoveAnimation(true, _rotateSpeed);
 }