Beispiel #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;
    }
Beispiel #2
0
    void Start()
    {
        hInGameScriptCS = (InGameScriptCS)GameObject.Find("Player").GetComponent(typeof(InGameScriptCS));
        hNGUIMenuScript = (NGUIMenuScript)GameObject.Find("UI Root (2D)").GetComponent(typeof(NGUIMenuScript));

        if (itemCost <= 0)
        {
            Debug.Log("EXCEPTION: No cost assigned to the Utility shop element. Check the user documentation.");
        }

        uilCost      = (UILabel)this.transform.Find("Text_Cost").GetComponent(typeof(UILabel));
        uilCost.text = itemCost.ToString();        //cost of the utility displayed in shop
    }
    void Start()
    {
        hNGUIMenuScript = (NGUIMenuScript)GameObject.Find("UI Root (2D)").GetComponent(typeof(NGUIMenuScript));
        hInGameScriptCS = (InGameScriptCS)GameObject.Find("Player").GetComponent(typeof(InGameScriptCS));

        if (itemCost <= 0)
        {
            Debug.Log("EXCEPTION: No cost assigned to the IAP shop element. Check the user documentation.");
        }
        else if (itemReward <= 0)
        {
            Debug.Log("EXCEPTION: No reward assigned to the IAP shop element. Check the user documentation.");
        }

        uilCost   = (UILabel)this.transform.Find("Text_Cost").GetComponent(typeof(UILabel));
        uilReward = (UILabel)this.transform.Find("Text_Reward").GetComponent(typeof(UILabel));

        uilCost.text   = "$ " + itemCost.ToString();   //display the cost of the item
        uilReward.text = itemReward.ToString();        //display the virtual currency reward
    }
    void Start()
    {
        uilLevelText = (UILabel)this.transform.Find("Text_ItemLevel").GetComponent(typeof(UILabel));

        hInGameScriptCS           = (InGameScriptCS)GameObject.Find("Player").GetComponent(typeof(InGameScriptCS));
        hNGUIMenuScript           = (NGUIMenuScript)GameObject.Find("UI Root (2D)").GetComponent(typeof(NGUIMenuScript));
        hPowerupsMainControllerCS = (PowerupsMainControllerCS)GameObject.Find("Player").GetComponent(typeof(PowerupsMainControllerCS));

        if (upgradeCost <= 0)
        {
            Debug.Log("EXCEPTION: No cost assigned to the Power-up shop element. Check the user documentation.");
        }
        else if (powerupUpgradeLevelMAX <= 0)
        {
            Debug.Log("EXCEPTION: Power-up upgrade level cannot be zero. Check the user documentation.");
        }

        uilUpgradeCost      = (UILabel)this.transform.Find("Text_Cost").GetComponent(typeof(UILabel));
        uilUpgradeCost.text = upgradeCost.ToString();        //set the cost of the item as specified by the user

        currentPowerupLevel = 1;
    }
    void Start()
    {
        hInGameScriptCS = (InGameScriptCS)GameObject.Find("Player").GetComponent(typeof(InGameScriptCS));
        hNGUIMenuScript = (NGUIMenuScript)GameObject.Find("UI Root (2D)").GetComponent(typeof(NGUIMenuScript));

        goBuyEquipButton   = (GameObject)this.transform.Find("Button_BuyEquip").gameObject;
        uilBuyEquipButton  = (UILabel)this.transform.Find("Button_BuyEquip/Label").GetComponent(typeof(UILabel));
        uilCostDescription = (UILabel)this.transform.Find("Text_Cost").GetComponent(typeof(UILabel));

        //check if a meterial, texture and cost has been assigned to exposed variables
        if (characterMaterial == null)
        {
            Debug.Log("EXCEPTION: Character material not assigned to costume shop element. Check the user documentation.");
        }
        else if (characterCostume == null)
        {
            Debug.Log("EXCEPTION: Character texture not assigned to costume shop element. Check the user documentation.");
        }
        else if (costumeCost <= 0)
        {
            Debug.Log("EXCEPTION: No cost assigned to the costume shop element. Check the user documentation.");
        }

        //is this the currently applied texture?
        if (characterMaterial.GetTexture("_MainTex") == characterCostume)
        {
            costumeOwned           = true;
            uilBuyEquipButton.text = "EQUIP";
        }
        else        //not the currently equiped texture
        {
            costumeOwned           = false;
            uilBuyEquipButton.text = "BUY";
        }

        //set the price on the label
        uilCostDescription.text = costumeCost.ToString();
    }    //end of Start
Beispiel #6
0
 void Start()
 {
     hNGUIMenuScript = (NGUIMenuScript)GameObject.Find("UI Root (2D)").GetComponent(typeof(NGUIMenuScript));
 }
Beispiel #7
0
 void Start()
 {
     hNGUIMenuScript = (NGUIMenuScript)GameObject.Find("UI Root (2D)").GetComponent(typeof(NGUIMenuScript));
     hInGameScriptCS = (InGameScriptCS)GameObject.Find("Player").GetComponent(typeof(InGameScriptCS));
 }
    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();
    }
Beispiel #9
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();
    }