コード例 #1
0
    public Vector3 applyForces(ref Vector3 shipPos, float shipMass, float timestep)
    {
        Vector3 r = shipPos - transform.position;

        Vector3 pushVelocity = new Vector3(0.0f, 0.0f, 0.0f);
        Vector3 pushForce    = new Vector3(0.0f, 0.0f, 0.0f);

        if (r.magnitude < innerRadius)
        {
            //destroy ship via explosion
            ObjectGeneratorScript obs        = GameObject.Find("ObjectGenerator").GetComponent <ObjectGeneratorScript>();
            GamePlayManagerScript gms        = GameObject.Find("GamePlayManager").GetComponent <GamePlayManagerScript>();
            ShipScript            shipscript = obs.playerShip.GetComponent <ShipScript>();

            shipscript.DieWithExplosion();
            gms.StartCoroutine("GameOverandReset");
        }
        else
        {
            pushVelocity.x = (outerRadius / r.x) * strength;
            pushVelocity.y = (outerRadius / r.y) * strength;
            pushVelocity.z = (outerRadius / r.z) * strength;
            pushForce      = pushVelocity * (shipMass / timestep);
        }

        return(pushForce);
    }
コード例 #2
0
    // Use this for initialization
    void Start()
    {
        ogs    = GameObject.Find("ObjectGenerator").GetComponent <ObjectGeneratorScript> ();
        gms    = GameObject.Find("GamePlayManager").GetComponent <GamePlayManagerScript>();
        camera = GameObject.Find("Main Camera");

        fuelBar = gms.fuelBar;

        //set camera so that it starts off behind and above the ship
        Vector3 camVec = transform.position;

        camVec.y += 40.0f;
        camVec   += 18 * -transform.forward;
        camera.transform.position = camVec;

        //set fuel levels
        currentFuel   = MaxFuel;
        fuelBar.value = MaxFuel;

        fixPositionalHeight = transform.position;

        //for win condition
        stageCleared = gms.stageCleared;
        stageCleared.SetActive(false);
    }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        gameOver.SetActive(false);

        timerScript = Timer.GetComponent<TimerScript>();
        generatorScript = objectGenerator.GetComponent<ObjectGeneratorScript>();
        InitializeObjectPositions();
    }
コード例 #4
0
 public void _wm_unlinkInteractProgram()
 {
     interactProgram = null;
 }
コード例 #5
0
    public Vector3 applyForces(ref Vector3 shipPos, ref Vector3 shipVel, float shipMass, float timestep)
    {
        Vector3 r = shipPos - transform.position;
        float   actualStrength = strength;

        Vector3 rdash = new Vector3(r.x - innerRadius, r.y - innerRadius, r.z - innerRadius);
        Vector3 temp  = new Vector3(outerRadius - rdash.x, outerRadius - rdash.y, outerRadius - rdash.z);

        Vector3 pullVelocity = new Vector3(0.0f, 0.0f, 0.0f);
        Vector3 pullForce    = new Vector3(0.0f, 0.0f, 0.0f);

        if (r.magnitude < innerRadius)
        {
            //destroyship byt sucking it in the blackhole
            ObjectGeneratorScript obs        = GameObject.Find("ObjectGenerator").GetComponent <ObjectGeneratorScript>();
            GamePlayManagerScript gms        = GameObject.Find("GamePlayManager").GetComponent <GamePlayManagerScript>();
            ShipScript            shipscript = obs.playerShip.GetComponent <ShipScript>();

            shipscript.Die();
            gms.StartCoroutine("GameOverandReset");
        }
        else if (r.magnitude < middle1Radius)
        {
            actualStrength *= 2.0f;

            pullVelocity.x = (-r.x / r.sqrMagnitude) * (temp.x / outerRadius) * (actualStrength * innerRadius);
            pullVelocity.y = (-r.y / r.sqrMagnitude) * (temp.y / outerRadius) * (actualStrength * innerRadius);
            pullVelocity.z = (-r.z / r.sqrMagnitude) * (temp.z / outerRadius) * (actualStrength * innerRadius);
            pullForce      = pullVelocity * (shipMass / timestep);
        }
        else if (r.magnitude < middle2Radius)
        {
            actualStrength *= 1.8f;

            pullVelocity.x = (-r.x / r.sqrMagnitude) * (temp.x / outerRadius) * (actualStrength * innerRadius);
            pullVelocity.y = (-r.y / r.sqrMagnitude) * (temp.y / outerRadius) * (actualStrength * innerRadius);
            pullVelocity.z = (-r.z / r.sqrMagnitude) * (temp.z / outerRadius) * (actualStrength * innerRadius);
            pullForce      = pullVelocity * (shipMass / timestep);
        }
        else if (r.magnitude < middle3Radius)
        {
            actualStrength *= 1.5f;

            //change velocity such that it locks to a stable orbit
            if ((orbitalSpeed < (shipVel.magnitude + epsilon)) || (orbitalSpeed > (shipVel.magnitude + epsilon)))
            {
                orbitalSpeed        = shipVel.magnitude;
                orbitalAcceleration = -r.normalized * (orbitalSpeed * orbitalSpeed / r.magnitude);
            }

            pullForce = orbitalAcceleration * shipMass;
        }
        else
        {
            pullVelocity.x = (-r.x / r.sqrMagnitude) * (temp.x / outerRadius) * (actualStrength * innerRadius);
            pullVelocity.y = (-r.y / r.sqrMagnitude) * (temp.y / outerRadius) * (actualStrength * innerRadius);
            pullVelocity.z = (-r.z / r.sqrMagnitude) * (temp.z / outerRadius) * (actualStrength * innerRadius);
            pullForce      = pullVelocity * (shipMass / timestep);
        }

        return(pullForce);
    }