Пример #1
0
    // Use this for initialization
    void Start()
    {
        //PlayerPrefs.DeleteAll();	//DEBUG
        Application.targetFrameRate = 60;        //ceiling the frame rate on 60 (debug only)

        RenderSettings.fog = true;               //turn on fog on launch

        if (GameObject.Find("MenuGroup"))        //check while type of menu is active (custom or ngui)
        {
            customMenuEnabled = true;
            hMenuScriptCS     = (MenuScriptCS)GameObject.Find("MenuGroup").GetComponent(typeof(MenuScriptCS));
        }
        else
        {
            hNGUIMenuScript = (NGUIMenuScript)GameObject.Find("UI Root (2D)").GetComponent(typeof(NGUIMenuScript));
        }

        hSoundManagerCS                = (SoundManagerCS)GameObject.Find("SoundManager").GetComponent(typeof(SoundManagerCS));
        hControllerScriptCS            = (ControllerScriptCS)this.GetComponent(typeof(ControllerScriptCS));
        hPowerupsMainControllerCS      = (PowerupsMainControllerCS)this.GetComponent(typeof(PowerupsMainControllerCS));
        hCameraControllerCS            = (CameraControllerCS)GameObject.Find("Main Camera").GetComponent(typeof(CameraControllerCS));
        hEnemyControllerCS             = (EnemyControllerCS)this.GetComponent(typeof(EnemyControllerCS));
        hMissionsControllerCS          = (MissionsControllerCS)this.GetComponent(typeof(MissionsControllerCS));
        hGlobalAchievementControllerCS = (GlobalAchievementControllerCS)this.GetComponent(typeof(GlobalAchievementControllerCS));

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

        bGameOver   = false;
        bGamePaused = true;
    }
Пример #2
0
    void Start()
    {
        HUDCamera       = (Camera)GameObject.Find("HUDMainGroup/HUDCamera").GetComponent(typeof(Camera));
        hMenuScriptCS   = (MenuScriptCS)GameObject.Find("MenuGroup").GetComponent(typeof(MenuScriptCS));
        hInGameScriptCS = (InGameScriptCS)GameObject.Find("Player").GetComponent(typeof(InGameScriptCS));
        hSoundManagerCS = (SoundManagerCS)GameObject.Find("SoundManager").GetComponent(typeof(SoundManagerCS));

        tShopMenuTransforms = new Transform[ShopMenus.GetValues(typeof(ShopMenus)).Length];
        tShopMenuTransforms[(int)ShopMenus.ShopHome] = (Transform)this.transform.Find("ShopHome").GetComponent(typeof(Transform));

        //shop primary menu
        tShopHomeButtons    = new Transform[iShopHomeButtonCount];
        tShopHomeButtons[0] = (Transform)tShopMenuTransforms[(int)ShopMenus.ShopHome].Find("Buttons/Button_Back").GetComponent(typeof(Transform));
        tShopHomeButtons[1] = (Transform)tShopMenuTransforms[(int)ShopMenus.ShopHome].Find("Buttons/Button_Costumes").GetComponent(typeof(Transform));
        tShopHomeButtons[2] = (Transform)tShopMenuTransforms[(int)ShopMenus.ShopHome].Find("Buttons/Button_Powerups").GetComponent(typeof(Transform));
        tShopHomeButtons[3] = (Transform)tShopMenuTransforms[(int)ShopMenus.ShopHome].Find("Buttons/Button_Utilities").GetComponent(typeof(Transform));
        tShopHomeButtons[4] = (Transform)tShopMenuTransforms[(int)ShopMenus.ShopHome].Find("Buttons/Button_MoreCoins").GetComponent(typeof(Transform));

        //shop costumes menu
        tShopMenuTransforms[(int)ShopMenus.Costumes] = (Transform)this.transform.Find("CostumesShop").GetComponent(typeof(Transform));
        tShopCostumesButtons    = new Transform[iShopCostumesButtonCount];
        tShopCostumesButtons[0] = (Transform)tShopMenuTransforms[(int)ShopMenus.Costumes].Find("Button_Back").GetComponent(typeof(Transform));

        //shop powerups menu
        tShopMenuTransforms[(int)ShopMenus.Powerups] = (Transform)this.transform.Find("PowerupsShop").GetComponent(typeof(Transform));
        tShopPowerupsButtons    = new Transform[iShopPowerupsButtonsCount];
        tShopPowerupsButtons[0] = (Transform)tShopMenuTransforms[(int)ShopMenus.Powerups].Find("Button_Back").GetComponent(typeof(Transform));

        //shop utilities menu
        tShopMenuTransforms[(int)ShopMenus.Utilities] = (Transform)this.transform.Find("UtilitiesShop").GetComponent(typeof(Transform));
        tShopUtilitiesButtons    = new Transform[iShopUtilitiesButtonCount];
        tShopUtilitiesButtons[0] = (Transform)tShopMenuTransforms[(int)ShopMenus.Utilities].Find("Button_Back").GetComponent(typeof(Transform));

        //shop IAP
        tShopMenuTransforms[(int)ShopMenus.IAPs] = (Transform)this.transform.Find("MoreCoinsShop").GetComponent(typeof(Transform));
        tShopIAPButtons    = new Transform[iShopIAPButtonsCount];
        tShopIAPButtons[0] = (Transform)tShopMenuTransforms[(int)ShopMenus.IAPs].Find("Button_Back").GetComponent(typeof(Transform));

        //vertical scroll initilization
        iScrollState = 0;

        setShopScriptEnabled(false);
    }
    private int[] achievementsProgress;             //store the current progress of achievements

    void Start()
    {
        achievementsProgress = new int[System.Enum.GetValues(typeof(GlobalAchievementTypes)).Length];

        hInGameScriptCS = (InGameScriptCS)this.GetComponent(typeof(InGameScriptCS));
        if (hInGameScriptCS.isCustomMenuEnabled())
        {
            hMenuScriptCS = (MenuScriptCS)GameObject.Find("MenuGroup").GetComponent(typeof(MenuScriptCS));
        }
        else
        {
            hNGUIMenuScript = (NGUIMenuScript)GameObject.Find("UI Root (2D)").GetComponent(typeof(NGUIMenuScript));
        }

        //get the GlobalAchievementsList file from the resources folder
        TextAsset taFile = (TextAsset)Resources.Load("GlobalAchievementsList");

        string[] lines = taFile.text.Split('\n');

        if (lines.Length == 0)    //if the file was empty
        {
            Debug.Log("No achievements found in file");
            this.enabled = false;
        }
        else        //read file and extract achievements detail
        {
            int lineIndex  = 0;
            int arrayIndex = 0;
            iTotalAchievementsCount = lines.Length / 3;                                     //get the total number of achievements in the file
            achievements            = new GlobalAchievementDetail[iTotalAchievementsCount]; //allocate memory according to the number of achievement

            /*for (var i=0; i<iTotalAchievementsCount; i++)
             *      achievements[i] = new GlobalAchievementDetail();*/

            while (lineIndex < lines.Length)            //store the file content in achievement array
            {
                achievements[arrayIndex].achievementDescription = lines[lineIndex++].ToString();
                achievements[arrayIndex].achievementCount       = int.Parse(lines[lineIndex++].ToString());
                achievements[arrayIndex].achievementType        = (GlobalAchievementTypes)System.Enum.Parse(typeof(GlobalAchievementTypes), lines[lineIndex++].ToString());
                achievements[arrayIndex].achievementComplete    = false;                //mark achievement incomplete by default

                if (PlayerPrefs.HasKey("GlobalAchievement_" + arrayIndex))              //check achievement progress
                {
                    achievementsProgress[(int)achievements[arrayIndex].achievementType] = PlayerPrefs.GetInt("GlobalAchievement_" + arrayIndex);

                    //check if the achievement has been completed
                    if (achievementsProgress[(int)achievements[arrayIndex].achievementType] >= achievements[arrayIndex].achievementCount)
                    {
                        achievements[arrayIndex].achievementComplete = true;
                    }
                }
                else                //if this is the first game launch
                {
                    PlayerPrefs.SetInt("GlobalAchievement_" + arrayIndex, 0);
                    achievementsProgress[(int)achievements[arrayIndex].achievementType] = 0;
                }

                arrayIndex++;
            }            //end of while

            updateMenuDescription();
        }        //end of else

        PlayerPrefs.Save();
    }
Пример #4
0
    void Start()
    {
        iActiveMissionCount = 3;        //three missions active at a time by deafult
        missionsProgress    = new int[System.Enum.GetValues(typeof(MissionTypes)).Length];

        //set the next mission index
        if (PlayerPrefs.HasKey("NextMissionIndex"))
        {
            iNextMission = PlayerPrefs.GetInt("NextMissionIndex");
        }
        else
        {
            iNextMission = 0;
            PlayerPrefs.SetInt("NextMissionIndex", iNextMission);
        }

        hInGameScriptCS = (InGameScriptCS)this.GetComponent(typeof(InGameScriptCS));

        if (hInGameScriptCS.isCustomMenuEnabled())
        {
            hMenuScriptCS    = (MenuScriptCS)GameObject.Find("MenuGroup").GetComponent(typeof(MenuScriptCS));
            hHUDControllerCS = (HUDControllerCS)GameObject.Find("HUDMainGroup").GetComponent(typeof(HUDControllerCS));
        }
        else
        {
            hNGUIMenuScript = (NGUIMenuScript)GameObject.Find("UI Root (2D)").GetComponent(typeof(NGUIMenuScript));
            hNGUIHUDScript  = hNGUIMenuScript.getNGUIHUDScriptReference();
        }

        //get the MissionList file from the resources folder
        TextAsset taFile = (TextAsset)Resources.Load("MissionsList");

        string[] lines = taFile.text.Split('\n');

        if (lines.Length == 0)        //if the file was empty
        {
            Debug.Log("No missions found in file");
            this.enabled = false;
        }
        else        //read file and extract mission detail
        {
            int lineIndex  = 0;
            int arrayIndex = 0;
            iTotalMissionCount = lines.Length / 3;
            missions           = new MissionDetail[iTotalMissionCount];  //allocate memory according to the number of missions
            for (int i = 0; i < iTotalMissionCount; i++)
            {
                missions[i] = new MissionDetail();
            }

            while (lineIndex < lines.Length)            //store the file content in mission array
            {
                missions[arrayIndex].missionDescription = lines[lineIndex++];
                missions[arrayIndex].missionCount       = int.Parse(lines[lineIndex++]);
                missions[arrayIndex].missionType        = (MissionTypes)System.Enum.Parse(typeof(MissionTypes), lines[lineIndex++]);

                arrayIndex++;
            }            //end of while

            iActiveMissions = new int[iActiveMissionCount];
            for (int i = 0; i < iActiveMissionCount; i++)        //set the currently active missions
            {
                if (PlayerPrefs.HasKey("ActiveMission_" + i.ToString()))
                {
                    iActiveMissions[i] = PlayerPrefs.GetInt("ActiveMission_" + i.ToString());
                }
                else
                {
                    iActiveMissions[i] = getNextMission();
                    PlayerPrefs.SetInt("ActiveMission_" + i.ToString(), iActiveMissions[i]);
                }
            }            //end of for

            updateMenuDescriptions();
        }        //end of else

        PlayerPrefs.Save();
    }
Пример #5
0
    void Start()
    {
        //script references
        hPatchesRandomizerCS           = (PatchesRandomizerCS)this.GetComponent(typeof(PatchesRandomizerCS));
        hMissionsControllerCS          = (MissionsControllerCS)this.GetComponent(typeof(MissionsControllerCS));
        hGlobalAchievementControllerCS = (GlobalAchievementControllerCS)this.GetComponent(typeof(GlobalAchievementControllerCS));
        hPlayerSidesColliderScriptCS   = (PlayerSidesColliderScriptCS)GameObject.Find("PlayerSidesCollider").GetComponent(typeof(PlayerSidesColliderScriptCS));
        hPlayerFrontColliderScriptCS   = (PlayerFrontColliderScriptCS)GameObject.Find("PlayerFrontCollider").GetComponent(typeof(PlayerFrontColliderScriptCS));
        hSoundManagerCS       = (SoundManagerCS)GameObject.Find("SoundManager").GetComponent(typeof(SoundManagerCS));
        hInGameScriptCS       = (InGameScriptCS)this.GetComponent(typeof(InGameScriptCS));
        hPitsMainControllerCS = (PitsMainControllerCS)this.GetComponent(typeof(PitsMainControllerCS));
        hCheckPointsMainCS    = (CheckPointsMainCS)this.GetComponent(typeof(CheckPointsMainCS));
        hPowerupScriptCS      = (PowerupsMainControllerCS)this.GetComponent(typeof(PowerupsMainControllerCS));
        hEnemyControllerCS    = (EnemyControllerCS)GameObject.Find("Enemy").GetComponent(typeof(EnemyControllerCS));
        hPowerupScriptCS      = (PowerupsMainControllerCS)this.GetComponent(typeof(PowerupsMainControllerCS));
        hCameraControllerCS   = (CameraControllerCS)GameObject.Find("Main Camera").GetComponent(typeof(CameraControllerCS));
        swipeLogic            = (SwipeControlsCS)transform.GetComponent(typeof(SwipeControlsCS));

        //check which type of menu (Custom or NGUI) to work with
        if (hInGameScriptCS.isCustomMenuEnabled())
        {
            hMenuScriptCS = (MenuScriptCS)GameObject.Find("MenuGroup").GetComponent(typeof(MenuScriptCS));
            HUDCamera     = GameObject.Find("HUDCamera").GetComponent <Camera>();

            tHUDGroup    = GameObject.Find("HUDMainGroup/HUDGroup").transform;
            tPauseButton = GameObject.Find("HUDMainGroup/HUDGroup/HUDPause").transform;
        }

        tPlayer         = transform;
        tPlayerRotation = transform.Find("PlayerRotation");

        //get the animation component of the player character
        if (this.transform.Find("PlayerRotation/PlayerMesh/Prisoner"))
        {
            mecanimEnabled = false;
            aPlayer        = (Animation)this.transform.Find("PlayerRotation/PlayerMesh/Prisoner").GetComponent(typeof(Animation));
            StartCoroutine("playIdleAnimations");                                    //start playing idle animations
        }
        else if (this.transform.Find("PlayerRotation/PlayerMesh/Prisoner(MecAnim)")) //check for mecanim animated character
        {
            mecanimEnabled = true;
            aPlayerMecAnim = (Animator)this.transform.Find("PlayerRotation/PlayerMesh/Prisoner(MecAnim)").GetComponent(typeof(Animator));

            v3DefaultPlayerAnimPosition = aPlayerMecAnim.transform.localPosition;            //get the default player position
            v3DefaultPlayerAnimRotation = aPlayerMecAnim.transform.localEulerAngles;         //get the default player rotation
        }

        tBlobShadowPlane = transform.Find("BlobShadowPlane");                    //get the shadow

        tPlayerSidesCollider = GameObject.Find("PlayerSidesCollider").transform; //get the sides collider to detect stumbles
        tFrontCollider       = GameObject.Find("PlayerFrontCollider").transform; //get the front collider to detect collisions

        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;
        fDeathAnimStartTime    = 0;
        bGroundhit             = false;
        bJumpFlag = false;
        bInJump   = false;
        fCurrentUpwardVelocity = 0;
        fCurrentHeight         = 0;

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

        //get the type of controls (swipe or gyro) set by user
        if (PlayerPrefs.HasKey("ControlsType"))
        {
            swipeControlsEnabled = PlayerPrefs.GetInt("ControlsType") == 1 ? true : false;
        }
        else
        {
            PlayerPrefs.SetInt("ControlsType", (swipeControlsEnabled == true ? 1 : 0));
        }

        //stop footsteps sound if playing
        hSoundManagerCS.stopSound(SoundManagerCS.CharacterSounds.Footsteps);
    }    //end of Start()