示例#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()
    {
        iCurrentPNum           = 1;
        fPreviousTotalDistance = 0.0f;

        hInGameScript      = this.GetComponent <InGameScript>() as InGameScript;
        hCheckPointsMain   = GetComponent <CheckPointsMain>() as CheckPointsMain;
        hElementsGenerator = this.GetComponent <ElementsGenerator>() as ElementsGenerator;

        instantiateStartPatch();
        goPreviousPatch = goCurrentPatch;

        tPlayer = GameObject.Find("Player").transform;
        hCheckPointsMain.setChildGroups();

        hCheckPointsMain.SetCurrentPatchCPs();
        hCheckPointsMain.SetNextPatchCPs();
    }
    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
    }