RXRandom.Double C# (CSharp) Méthode

Double() public static méthode

public static Double ( ) : double
Résultat double
    public static double Double()
    {
        return _randomSource.NextDouble();
    }

Usage Example

Exemple #1
0
    public override void Update()
    {
        if (isControllable)
        {
            xMove = 0;
            yMove = 0;
            if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
            {
                yMove = controlSpeed * UnityEngine.Time.deltaTime;
            }
            if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
            {
                yMove = -(controlSpeed * UnityEngine.Time.deltaTime);
            }
            if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
            {
                xMove = -(controlSpeed * UnityEngine.Time.deltaTime);
            }
            if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
            {
                xMove = controlSpeed * UnityEngine.Time.deltaTime;
            }
            if (Input.GetMouseButton(0))
            {
                state = State.SHOOTING;
            }
            else
            {
                state = State.IDLE;
            }

            rotation = 0;
            rotation = this.GetLocalMousePosition().GetAngle() + 90;
        }
        else
        {
            if (RXRandom.Double() < .03)
            {
                xMove = (RXRandom.Float() * speed * 2 - speed) * UnityEngine.Time.deltaTime;
                yMove = (RXRandom.Float() * speed * 2 - speed) * UnityEngine.Time.deltaTime;

                rotation = new Vector2(xMove, yMove).GetAngle() + 90;
            }
            else if (RXRandom.Double() < .01)
            {
                xMove = 0;
                yMove = 0;
            }
        }

        tryMove();

        if (this.powerupClock.percentage <= 0 && this.powerUpType != Powerup.PowerupType.NONE)
        {
            collectPowerUp(Powerup.PowerupType.NONE);
        }

        if (lastShoot < minShoot)
        {
            lastShoot += UnityEngine.Time.deltaTime;
        }
        switch (state)
        {
        case State.IDLE:
            break;

        case State.SHOOTING:

            if (lastShoot >= minShoot || (powerUpType == Powerup.PowerupType.MACHINEGUN && lastShoot >= minShoot * .05f))
            {
                lastShoot = 0;

                foreach (Bullet b in shootBullet())
                {
                    world.addBullet(b);
                }
            }

            break;
        }
        if (isControllable)
        {
            switch (this.powerUpType)
            {
            case Powerup.PowerupType.NONE:
                play("pistol");
                break;

            case Powerup.PowerupType.SHOTGUN:
                play("shotgun");
                break;

            case Powerup.PowerupType.MACHINEGUN:
                play("machinegun");
                break;
            }
        }

        shadow.rotation = this.rotation;
        shadow.SetPosition(this.GetPosition());
        shadow.y -= 3;
        hair.SetPosition(this.GetPosition());
        hair.rotation = this.rotation;

        playerBlip.SetPosition(GetPosition() * Minimap.BLIP_POS_MULT);
        playerBlip.rotation = this.rotation;
        playerBlip.scale    = this.scale * .5f;

        base.Update();
    }