Exemple #1
0
    void Start()
    {
        iObstacleCount = obstaclePrefabs.Length;
        iPowerupCount  = powerupPrefabs.Length;
        iTotalCount    = iObstacleCount + iPowerupCount + 1;     //obstacles + powerups + currency

        bGenerateElements = true;
        bPowerupPlaced    = true;     //do not place powerup on first patch
        System.DateTime dt = System.DateTime.Now;
        Random.seed = dt.Hour * dt.Minute * dt.Second;

        setPrefabHandlers();

        hPowerupsMainController = this.GetComponent <PowerupsMainController>() as PowerupsMainController;
        hCheckPointsMain        = GameObject.Find("Player").GetComponent <CheckPointsMain>() as CheckPointsMain;

        //generate elements on first patch
        float i = 0.20f;

        while (i < 0.99f)
        {
            float incrementValue = generateElements(getRandomElement(), i, true); //get any type of element
            i += incrementValue;
        }                                                                         //end of while
    }
    void Start()
    {
        tPlayer = GameObject.Find("Player").transform;

        hInGameScript           = GameObject.Find("Player").GetComponent <InGameScript>() as InGameScript;
        hPowerupsMainController = GameObject.Find("Player").GetComponent <PowerupsMainController>() as PowerupsMainController;
    }
Exemple #3
0
    void Start()
    {
        RenderSettings.fog = true;                 //turn on fog on launch

        hSoundManager           = GameObject.Find("SoundManager").GetComponent <SoundManager>() as SoundManager;
        hMenuScript             = GameObject.Find("MenuGroup").GetComponent <MenuScript>() as MenuScript;
        hControllerScript       = this.GetComponent <ControllerScript>() as ControllerScript;
        hPowerupsMainController = this.GetComponent <PowerupsMainController>() as PowerupsMainController;
        hCameraController       = Camera.main.GetComponent <CameraController>() as CameraController;
        hEnemyController        = this.GetComponent <EnemyController>() as EnemyController;

        CurrentEnergy = 100;
        iPauseStatus  = 0;
        iMenuStatus   = 1;

        quitButtonTime = PersistentManagerScript.Instance.secondsBeforeQuitButton;
        quitGameTime   = PersistentManagerScript.Instance.secondsBeforeGameEnd;

        bGameOver   = false;
        bGamePaused = true;
    }
    void Start()
    {
        tPlayer                 = GameObject.Find("Player").transform;
        hInGameScript           = GameObject.Find("Player").GetComponent <InGameScript>() as InGameScript;
        hControllerScript       = GameObject.Find("Player").GetComponent <ControllerScript>() as ControllerScript;
        hPowerupsMainController = GameObject.Find("Player").GetComponent <PowerupsMainController>() as PowerupsMainController;

        tmHUDCurrencyText = GameObject.Find("HUDMainGroup/HUDGroup/HUDCurrencyGroup/HUD_Currency_Text").GetComponent <TextMesh>() as TextMesh;
        tmHUDScoreText    = GameObject.Find("HUDMainGroup/HUDGroup/HUDScoreGroup/HUD_Score_Text").GetComponent <TextMesh>() as TextMesh;
        tmHUDTimerText    = GameObject.Find("HUDMainGroup/HUDGroup/HUDTimer/HUD_Timer_Text").GetComponent <TextMesh>() as TextMesh;

        tHUDScoreContainerMid    = GameObject.Find("HUDMainGroup/HUDGroup/HUDScoreGroup/HUD_Score_BG").GetComponent <Transform>() as Transform;         //	HUD Score Container
        tHUDCurrencyContainerMid = GameObject.Find("HUDMainGroup/HUDGroup/HUDCurrencyGroup/HUD_Currency_BG").GetComponent <Transform>() as Transform;   //	HUD Currency Container

        tHUDTimer = GameObject.Find("HUDMainGroup/HUDGroup/HUDTimer/HUD_Timer_Text").GetComponent <MeshRenderer>();

        HUDTimerBg = GameObject.Find("HUDMainGroup/HUDGroup/HUDTimer/HUD_Timer_BG/HUD_Score_BG_Mid").GetComponent <MeshRenderer>();

        if (!PersistentManagerScript.Instance.showTimer)
        {
            tHUDTimer.enabled = false;
            tmHUDTimerText.GetComponent <MeshRenderer>().enabled = false;
            HUDTimerBg.enabled = false;
        }

        //get time difference to calculate score

        fCurrentTime  = Time.time;
        fPreviousTime = Time.time;

        fPreviousDistance = 0;
        fCurrentDistance  = 0;
        fCurrentTime      = 0;
        fPreviousTime     = 0;

        iDivisorScore      = 10;
        iDivisorCurrency   = 10;
        iDivisorMultiplier = 10;
    }
    void Start()
    {
        hMenuScript                = GameObject.Find("MenuGroup").GetComponent <MenuScript>() as MenuScript;
        hPatchesRandomizer         = this.GetComponent <PatchesRandomizer>() as PatchesRandomizer;
        hPlayerSidesColliderScript = GameObject.Find("PlayerSidesCollider").GetComponent <PlayerSidesColliderScript>() as PlayerSidesColliderScript;
        hPlayerFrontColliderScript = GameObject.Find("PlayerFrontCollider").GetComponent <PlayerFrontColliderScript>() as PlayerFrontColliderScript;
        hSoundManager              = GameObject.Find("SoundManager").GetComponent <SoundManager>() as SoundManager;
        hInGameScript              = this.GetComponent <InGameScript>() as InGameScript;
        hPitsMainController        = this.GetComponent <PitsMainController>() as PitsMainController;
        hCheckPointsMain           = this.GetComponent <CheckPointsMain>() as CheckPointsMain;
        hPowerupScript             = this.GetComponent <PowerupsMainController>() as PowerupsMainController;
        hEnemyController           = GameObject.Find("Enemy").GetComponent <EnemyController>() as EnemyController;
        hPowerupScript             = this.GetComponent <PowerupsMainController>() as PowerupsMainController;
        hCameraController          = Camera.main.gameObject.GetComponent <CameraController>() as CameraController;
        swipeLogic = transform.GetComponent <SwipeControls>() as SwipeControls;

        tPlayer         = transform;
        tPlayerRotation = transform.Find("PlayerRotation");
        playerRenderer  = GameObject.Find("rend").GetComponent <SkinnedMeshRenderer>();

        //get the animation component of the player character
        aPlayer          = this.transform.Find("PlayerRotation/PlayerMesh/Prisoner").GetComponent <Animation>() as Animation;
        tBlobShadowPlane = transform.Find("BlobShadowPlane");

        tPlayerSidesCollider = GameObject.Find("PlayerSidesCollider").transform;
        tFrontCollider       = GameObject.Find("PlayerFrontCollider").transform;
        if (!PersistentManagerScript.Instance.obstacles)
        {
            tFrontCollider.GetComponent <BoxCollider>().enabled       = false;
            tPlayerSidesCollider.GetComponent <BoxCollider>().enabled = false;
        }

        tHUDGroup    = GameObject.Find("HUDMainGroup/HUDGroup").transform;
        tPauseButton = GameObject.Find("HUDMainGroup/HUDGroup/HUDPause").transform;
        tQuitButton  = GameObject.Find("HUDMainGroup/HUDGroup/HUDQuit").transform;
        tQuitButton.gameObject.active = false;

        HUDCamera = GameObject.Find("HUDCamera").GetComponent <Camera>();

        v3BNCDefaultScale = tFrontCollider.localScale;
        v3BFCDefaultScale = tPlayerSidesCollider.localScale;

        bInAir = false;
        fCurrentDistanceOnPath = 50.0f;         //inital distance with respect to spline
        fCurrentDistance       = 0.0f;
        fCurrentMileage        = 0.0f;
        tCurrentAngle          = 0.0f;
        fPitFallLerpValue      = 0.0f;
        fPitFallForwardSpeed   = 0.0f;
        fPitPositionX          = 0.0f;
        iDeathAnimStartTime    = 0;
        bGroundhit             = false;
        bJumpFlag = false;
        bInJump   = false;
        fCurrentUpwardVelocity = 0;
        fCurrentHeight         = 0;

        bDirectionQueueFlag = false;
        directionQueue      = SwipeControls.SwipeDirection.Null;
        iLanePosition       = 0;        //set current lane to mid
        fCurrentWalkSpeed   = fStartingWalkSpeed;


        if (PlayerPrefs.HasKey("ControlsType"))
        {
            swipeControlsEnabled = PlayerPrefs.GetInt("ControlsType") == 1 ? true : false;
        }
        else
        {
            PlayerPrefs.SetInt("ControlsType", (swipeControlsEnabled == true ? 1 : 0));
        }

        hSoundManager.stopSound(SoundManager.CharacterSounds.Footsteps);
        StartCoroutine("playIdleAnimations");        //start playing idle animations
    }