예제 #1
0
    // helper function that resets the player to initial drifting state
    private void ResetPlayerStates()
    {
        isDead                    = false;
        isLanded                  = false;
        canJump                   = false;
        currentChargeTime         = 0f;
        canAction                 = false;
        takingAction              = false;
        currentActionChargeTime   = 0f;
        actionChargesUsable       = 0;
        transform.parent          = null;
        currentPlanet             = null;
        lastPlanet                = null;
        currentAntiStuckForceTime = 0f;
        leavingSpeed              = 0f;

        chargeBar.SetActive(false);
        jetpackFlame.SetActive(false);
        activatedPowerup = PowerupScript.PowerupType.none;
        powerupCountdown = 0;
        powerupEffect.DeactivateAllEffects();
        transform.position    = initialPosition;      // TODO: need better method for respawn
        transform.eulerAngles = initialRotation;
        nearbyPlanets.Clear();
    }
예제 #2
0
    // helper function that resets the player to initial drifting state
    private void ResetPlayerStates()
    {
        isDead           = false;
        isLanded         = false;
        canJump          = false;
        transform.parent = null;
        currentPlanet    = null;
        activatedPowerup = PowerupScript.PowerupType.none;
        powerupCountdown = 0;
        powerupEffect.DeactivateAllEffects();
        coinCombo             = 0;
        transform.position    = initialPosition;
        transform.eulerAngles = initialRotation;
        //powerLevel = powerLevelInitial;
        nearbyPlanets.Clear();

        // give a starting velocity to nearest planet. if no planets exist, then just assign random velocity
        float      startingSpeed   = 5f;
        GameObject nearestPlanet   = null;
        float      nearestDistance = 9999f;

        foreach (GameObject planet in GameObject.FindGameObjectsWithTag("Planet"))
        {
            float newDistance = Vector3.Distance(planet.transform.position, transform.position);
            if (newDistance < nearestDistance)
            {
                nearestDistance = newDistance;
                nearestPlanet   = planet;
            }
        }
        if (nearestPlanet != null)
        {
            Vector2 startingDirection = (nearestPlanet.transform.position - transform.position).normalized;
            GetComponent <Rigidbody2D>().velocity = startingDirection * startingSpeed;
        }
        else
        {
            float angle = Random.Range(0, 360) * Mathf.Deg2Rad;
            GetComponent <Rigidbody2D>().velocity = new Vector2(Mathf.Cos(angle) * startingSpeed,
                                                                Mathf.Sin(angle) * startingSpeed);
        }
    }
예제 #3
0
 // function that the powerup object calls when it's been picked up by the player
 // TODO: how to get enum from another file?
 // TODO: investigate pssing anonymous functions
 public void AcquiredPowerup(PowerupScript.PowerupType type, int duration, AudioClip sound)
 {
     powerupCountdown = duration;
     activatedPowerup = type;
     //TODOGetComponent<AudioSource>().PlayOneShot(sound);
     powerupEffect.DeactivateAllEffects();
     powerupEffect.ActivateEffect(type);
     if (type == PowerupScript.PowerupType.barrier)
     {
         // barrier: extra life
     }
     else if (type == PowerupScript.PowerupType.charge)
     {
         // charge: max powerlevel
     }
     else if (type == PowerupScript.PowerupType.lighting)
     {
         // lightingbolt: max speed and mass
     }
     else if (type == PowerupScript.PowerupType.magnet)
     {
         // coin magnet
     }
 }
 // call by parent player to show the flashing animation for a waning power up
 public void ActivateEffectFlash(PowerupScript.PowerupType type)
 {
 }