Exemplo n.º 1
0
    public static void SetTutorial(int type, ObscuredBool isDone)
    {
        switch (type)
        {
        case 1:
            mStartTut = isDone;
            Saved.SetBool(SaveKey.StartTutorial, mStartTut);
            break;

        case 2:
            mGameTut = isDone;
            Saved.SetBool(SaveKey.GameTutorial, mGameTut);
            break;

        case 3:
            mFeverTut = isDone;
            Saved.SetBool(SaveKey.FeverTutorial, mFeverTut);
            break;

        case 4:
            mMissionTut = isDone;
            Saved.SetBool(SaveKey.MissionTutorial, mMissionTut);
            break;
        }
    }
Exemplo n.º 2
0
 void Start()
 {
     jump = GameObject.Find("Player").GetComponent <Jump>();
     //Debug.Log("Ground Layer: " + LayerMask.NameToLayer("ground"));
     onGround    = GameObject.Find("Player").GetComponent <Jump>().grounded;
     groundCheck = GetComponent <Transform>();
 }
Exemplo n.º 3
0
        public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
        {
            var hiddenValue = prop.FindPropertyRelative("hiddenValue");

            SetBoldIfValueOverridePrefab(prop, hiddenValue);

            var cryptoKey = prop.FindPropertyRelative("currentCryptoKey");
            var inited    = prop.FindPropertyRelative("inited");

            var currentCryptoKey = cryptoKey.intValue;
            var val = false;

            if (!inited.boolValue)
            {
                if (currentCryptoKey == 0)
                {
                    currentCryptoKey = cryptoKey.intValue = ObscuredBool.cryptoKeyEditor;
                }
                inited.boolValue     = true;
                hiddenValue.intValue = ObscuredBool.Encrypt(false, (byte)currentCryptoKey);
            }
            else
            {
                val = ObscuredBool.Decrypt(hiddenValue.intValue, (byte)currentCryptoKey);
            }

            EditorGUI.BeginChangeCheck();
            val = EditorGUI.Toggle(position, label, val);
            if (EditorGUI.EndChangeCheck())
            {
                hiddenValue.intValue = ObscuredBool.Encrypt(val, (byte)currentCryptoKey);
            }

            ResetBoldFont();
        }
Exemplo n.º 4
0
        public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
        {
            SerializedProperty hiddenValue      = prop.FindPropertyRelative("hiddenValue");
            SerializedProperty cryptoKey        = prop.FindPropertyRelative("currentCryptoKey");
            SerializedProperty fakeValue        = prop.FindPropertyRelative("fakeValue");
            SerializedProperty fakeValueChanged = prop.FindPropertyRelative("fakeValueChanged");
            SerializedProperty inited           = prop.FindPropertyRelative("inited");

            int  currentCryptoKey = cryptoKey.intValue;
            bool val = false;

            if (!inited.boolValue)
            {
                if (currentCryptoKey == 0)
                {
                    currentCryptoKey = cryptoKey.intValue = 215;
                }
                inited.boolValue     = true;
                hiddenValue.intValue = ObscuredBool.Encrypt(val, (byte)currentCryptoKey);
            }
            else
            {
                val = ObscuredBool.Decrypt(hiddenValue.intValue, (byte)currentCryptoKey);
            }

            EditorGUI.BeginChangeCheck();
            val = EditorGUI.Toggle(position, label, val);
            if (EditorGUI.EndChangeCheck())
            {
                hiddenValue.intValue = ObscuredBool.Encrypt(val, (byte)currentCryptoKey);
            }

            fakeValue.boolValue        = val;
            fakeValueChanged.boolValue = true;
        }
        public ObscuredValueConverter()
        {
            list.Add(typeof(ObscuredInt), new Conv(
                         typeof(int),
                         o => { return((int)(ObscuredInt)o); },
                         o => { ObscuredInt value = Convert.ToInt32(o); return(value); }
                         ));
            list.Add(typeof(ObscuredFloat), new Conv(
                         typeof(float),
                         o => { return((float)(ObscuredFloat)o); },
                         o => { ObscuredFloat value = Convert.ToSingle(o); return(value); }
                         ));
            list.Add(typeof(ObscuredDouble), new Conv(
                         typeof(double),
                         o => { return((double)(ObscuredDouble)o); },
                         o => { ObscuredDouble value = Convert.ToSingle(o); return(value); }
                         ));

            list.Add(typeof(ObscuredBool), new Conv(
                         typeof(bool),
                         o => { return((bool)(ObscuredBool)o); },
                         o => { ObscuredBool value = Convert.ToBoolean(o); return(value); }
                         ));

            list.Add(typeof(ObscuredString), new Conv(
                         typeof(string),
                         o => { return((string)(ObscuredString)o); },
                         o => { ObscuredString value = o + ""; return(value); }
                         ));
        }
Exemplo n.º 6
0
    private void Die()
    {
        isInvulnerable = true;
        this.GetComponent <PlayerMovement>().Death();
        //this.GetComponent<SpriteRenderer>().color = Color.green;
        GameObject.Find("MissleCounter").GetComponent <MissleCounter>().Reset();
        isInvulnerable = false;

        //Debug.Log(transform.name + " dies.");
    }
Exemplo n.º 7
0
 public void ReadData()
 {
     _gem                    = ObscuredPrefs.GetInt("Gem", 0);
     _star                   = ObscuredPrefs.GetInt("Star", 0);
     _energy                 = ObscuredPrefs.GetInt("Energy", 0);
     _timesPlay              = ObscuredPrefs.GetInt("TimesPlay", 0);
     _timesLevelComplete     = ObscuredPrefs.GetInt("TimesLevelComplete", 0);
     _maxEnergy              = 15;
     isBoughtChangeGameSpeed = ObscuredPrefs.GetInt("BuyChangeGameSpeed", 0) == 0 ? false : true;
     isRemovedAd             = ObscuredPrefs.GetInt("RemoveAd", 0) == 0 ? false : true;
     isClickedRating         = ObscuredPrefs.GetInt("isClickedRating", 0) == 0 ? false : true;
 }
Exemplo n.º 8
0
 protected void Restart()
 {
     detonatorTime = 0f;
     detonating    = false;
     throwing      = false;
     if (curAmmo > 0)
     {
         ShowGrenade(body: true, clip: true);
     }
     else
     {
         ShowGrenade(body: false, clip: false);
     }
 }
Exemplo n.º 9
0
    /// <summary> 교역을 시작 </summary>
    public void TradeStart()
    {
        remainingTime = tradeTime;
        if (Storage.GetItemStoredAmount(sellMaterialID) < sellAmount)
        {
            Debug.Log("재고부족");
            isTrade = false;
            return;
        }

        Storage.OutItem(sellMaterialID, sellAmount);

        startTime = tradeTime + Time.unscaledTime;
        isTrade   = true;
        Debug.Log("거래 시작 : " + isTrade);
    }
Exemplo n.º 10
0
    private void RewardToUesr(object sender, EventArgs arg)
    {
        rewarded = true;

        string[] sceneName = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name.Split(' ');
        int      level     = int.Parse(sceneName[1]);

        if (SaveAndLoad.instance.LoadIntData("CurLevel") < level)
        {
            SaveAndLoad.instance.SaveIntData("CurLevel", level);
        }

        rewardedAD.OnAdLoaded   -= RewardedADLoad;
        rewardedAD.OnAdClosed   -= RewardedADClose;
        rewardedAD.OnAdRewarded -= RewardToUesr;
    }
    private void TestBool()
    {
        Debug.Log("  Testing ObscuredBool vs bool preformance:\n  " + boolIterations + " iterations for read and same for write");

        Stopwatch sw = Stopwatch.StartNew();

        ObscuredBool obscured    = true;
        bool         notObscured = obscured;
        bool         dummy       = false;

        for (int i = 0; i < boolIterations; i++)
        {
            dummy = obscured;
        }

        for (int i = 0; i < boolIterations; i++)
        {
            obscured = dummy;
        }

        Debug.Log("    ObscuredBool:\n    " + sw.ElapsedMilliseconds + " ms ");
        sw.Reset();

        sw.Start();
        for (int i = 0; i < boolIterations; i++)
        {
            dummy = notObscured;
        }

        for (int i = 0; i < boolIterations; i++)
        {
            notObscured = dummy;
        }

        sw.Stop();
        Debug.Log("    bool:\n    " + sw.ElapsedMilliseconds + "  ms ");

        if (dummy)
        {
        }
        if (obscured)
        {
        }
        if (notObscured)
        {
        }
    }
Exemplo n.º 12
0
    void FixedUpdate()
    {
        GameObject.Find("Player").GetComponent <Jump>().grounded = Physics2D.OverlapBox(groundCheck.position, size, angle, whatIsGround);

        if (GameObject.Find("Player").GetComponent <Jump>().grounded == false && (onGround != GameObject.Find("Player").GetComponent <Jump>().grounded))
        {
            //Debug.Log(GameObject.Find("Player").GetComponent<jump>().grounded);
            onGround = GameObject.Find("Player").GetComponent <Jump>().grounded;
        }

        if (GameObject.Find("Player").GetComponent <Jump>().grounded&& (onGround != GameObject.Find("Player").GetComponent <Jump>().grounded))
        {
            //Debug.Log(GameObject.Find("Player").GetComponent<jump>().grounded);
            onGround = GameObject.Find("Player").GetComponent <Jump>().grounded;
            jump.JumpReset();
        }
    }
Exemplo n.º 13
0
        private void TestBool()
        {
            logBuilder.AppendLine("ObscuredBool vs bool, " + boolIterations + " iterations for read and write");

            ObscuredBool obscured    = true;
            bool         notObscured = obscured;
            var          dummy       = false;

            var sw = Stopwatch.StartNew();

            for (var i = 0; i < boolIterations; i++)
            {
                dummy = obscured;
            }

            for (var i = 0; i < boolIterations; i++)
            {
                obscured = dummy;
            }
            sw.Stop();
            logBuilder.AppendLine("ObscuredBool:").AppendLine(sw.ElapsedMilliseconds + " ms");

            sw.Reset();
            sw.Start();
            for (var i = 0; i < boolIterations; i++)
            {
                dummy = notObscured;
            }

            for (var i = 0; i < boolIterations; i++)
            {
                notObscured = dummy;
            }
            sw.Stop();
            logBuilder.AppendLine("bool:").AppendLine(sw.ElapsedMilliseconds + " ms");

            if (dummy)
            {
            }
            if (obscured)
            {
            }
            if (notObscured)
            {
            }
        }
Exemplo n.º 14
0
 protected void RemoveSafetyClip()
 {
     if (GetComponent <Weapon>().CatridgeOrClip != null)
     {
         GameObject gameObject = Object.Instantiate((Object)GetComponent <Weapon>().CatridgeOrClip, base.transform.position, base.transform.rotation) as GameObject;
         if (null != gameObject)
         {
             Rigidbody component = gameObject.GetComponent <Rigidbody>();
             if (null != component)
             {
                 component.AddForce(Vector3.left * 0.2f, ForceMode.Impulse);
                 component.AddTorque(Vector3.up * 0.2f, ForceMode.Impulse);
             }
         }
     }
     detonatorTime = 0f;
     detonating    = true;
     ShowGrenade(body: true, clip: false);
 }
Exemplo n.º 15
0
    private void Update()
    {
        if (visitedHeroList.Count > 0)
        {
            for (int i = 0; i < visitedHeroList.Count; i++)
            {
                if (visitedHeroList[i].remainingTime <= 0)
                {
                    // 삭제
                    visitedHeroList.Remove(visitedHeroList[i]);
                    if (onRemoveVisitedHero != null)
                    {
                        onRemoveVisitedHero();
                    }
                }
                else
                {
                    visitedHeroList[i].remainingTime = visitedHeroList[i].startTime - Time.unscaledTime;
                }
            }
        }

        if (isInitialized == false)
        {
            return;
        }


        if (remainingVisitTime < 0f)
        {
            //startTime = Time.unscaledTime + 1200f;
            //remainingVisitTime = startTime - Time.unscaledTime;

            isVisitTime = true;
        }
        else
        {
            isVisitTime        = false;
            remainingVisitTime = startTime - Time.unscaledTime;
        }
    }
Exemplo n.º 16
0
        private void TestBool()
        {
            this.logBuilder.AppendLine("ObscuredBool vs bool, " + this.boolIterations + " iterations for read and write");
            ObscuredBool value     = true;
            bool         flag      = value;
            bool         flag2     = false;
            Stopwatch    stopwatch = Stopwatch.StartNew();

            for (int i = 0; i < this.boolIterations; i++)
            {
                flag2 = value;
            }
            for (int j = 0; j < this.boolIterations; j++)
            {
                value = flag2;
            }
            stopwatch.Stop();
            this.logBuilder.AppendLine("ObscuredBool:").AppendLine(stopwatch.ElapsedMilliseconds + " ms");
            stopwatch.Reset();
            stopwatch.Start();
            for (int k = 0; k < this.boolIterations; k++)
            {
                flag2 = flag;
            }
            for (int l = 0; l < this.boolIterations; l++)
            {
                flag = flag2;
            }
            stopwatch.Stop();
            this.logBuilder.AppendLine("bool:").AppendLine(stopwatch.ElapsedMilliseconds + " ms");
            if (flag2)
            {
            }
            if (value)
            {
            }
            if (flag)
            {
            }
        }
    private void TestBool()
    {
        UnityEngine.Debug.Log("  Testing ObscuredBool vs bool preformance:\n  " + boolIterations + " iterations for read and same for write");
        Stopwatch    stopwatch = Stopwatch.StartNew();
        ObscuredBool value     = true;
        bool         flag      = value;
        bool         flag2     = false;

        for (int i = 0; i < boolIterations; i++)
        {
            flag2 = value;
        }
        for (int j = 0; j < boolIterations; j++)
        {
            value = flag2;
        }
        UnityEngine.Debug.Log("    ObscuredBool:\n    " + stopwatch.ElapsedMilliseconds + " ms ");
        stopwatch.Reset();
        stopwatch.Start();
        for (int k = 0; k < boolIterations; k++)
        {
            flag2 = flag;
        }
        for (int l = 0; l < boolIterations; l++)
        {
            flag = flag2;
        }
        stopwatch.Stop();
        UnityEngine.Debug.Log("    bool:\n    " + stopwatch.ElapsedMilliseconds + "  ms ");
        if (flag2)
        {
        }
        if ((bool)value)
        {
        }
        if (!flag)
        {
        }
    }
Exemplo n.º 18
0
    // Use this for initialization
    void Start()
    {
        ObscuredPrefs.SetString("Level1", "on");
        if (ObscuredPrefs.GetString("Level2") == "on")
        {
            lock1.SetActive(false);
        }
        if (ObscuredPrefs.GetString("Level3") == "on")
        {
            lock2.SetActive(false);
        }
        if (ObscuredPrefs.GetString("Level4") == "on")
        {
            lock3.SetActive(false);
        }

        UIManager2.coin_score = ObscuredPrefs.GetInt("Score");
        isLevelsold           = ObscuredPrefs.GetInt("isLevelsold") == 0 ? false:true;


        SceneIndex = SceneManager.GetActiveScene().buildIndex;
    }
Exemplo n.º 19
0
    void Awake()
    {
        //	/*
        mRemoveAds  = Saved.GetBool(SaveKey.RemoveAds);
        mStartTut   = Saved.GetBool(SaveKey.StartTutorial);
        mGameTut    = Saved.GetBool(SaveKey.GameTutorial);
        mMissionTut = Saved.GetBool(SaveKey.MissionTutorial);
        mFeverTut   = Saved.GetBool(SaveKey.FeverTutorial);


        mPlayerExp  = Saved.GetInt(SaveKey.PlayerExp);
        mMaxScore   = Saved.GetInt(SaveKey.MaxScore);
        mTotalScore = Saved.GetInt(SaveKey.TotalScore);
        mTotalPlay  = Saved.GetInt(SaveKey.TotalPlay);

        mMaxCombo          = Saved.GetInt(SaveKey.MaxCombo);
        mTotalReceipt      = Saved.GetInt(SaveKey.TotalReceipt);
        mMaxChange         = Saved.GetInt(SaveKey.MaxChange);
        mMaxFeverSuccess   = Saved.GetInt(SaveKey.MaxFeverSuccess);
        mSound             = Saved.GetBool(SaveKey.Sound);
        mDisPlayCount      = Saved.GetInt(SaveKey.DisPlayCount);
        mTotalDissatisfied = Saved.GetInt(SaveKey.TotalDissatisfied);
        mGirl = Saved.GetInt(SaveKey.GirlMission);

        mBald = Saved.GetInt(SaveKey.BaldMission);
        mBaldLastPlayedTime = Saved.GetString(SaveKey.BaldLastPlayedTime);
        mBaldPlayingTime    = Saved.GetFloat(SaveKey.BaldPlayingTime);

        GetCollectionInfo();

        mIgnorant = Saved.GetInt(SaveKey.IgnorantMission);
        mHomeless = Saved.GetInt(SaveKey.HomelessMission);
        mThief    = Saved.GetInt(SaveKey.ThiefMission);
        mSkeptic  = Saved.GetInt(SaveKey.SkepticMission);
//	*/
        //	ObscuredPrefs.DeleteAll();
    }
Exemplo n.º 20
0
    public IEnumerator TakenDamage(ObscuredInt damage)
    {
        if (isInvulnerable == false)
        {
            //Debug.Log(damage);
            //damage -= armor.GetValue();
            damage         = Mathf.Clamp(damage, 0, int.MaxValue);
            currentHealth -= damage;
            currentHealth  = Mathf.Clamp(currentHealth, 0, int.MaxValue);
            //Debug.Log(transform.name + " takes " + damage + " damage.");

            isInvulnerable = true;

            if (currentHealth <= 0)
            {
                Die();
            }

            yield return(new WaitForSeconds(1));

            isInvulnerable = false;
            //Debug.Log("activated");
        }
    }
Exemplo n.º 21
0
    void Start()
    {
        Input.multiTouchEnabled = false;

        // 1. Load GameConfigs
        // 2. Set PlayerStatus
        if (IsGameInitialize == false)
        {
            GameConfigs.LoadConfigs();
            PlayerManager.Instance().InitializePlayer();
            PlayerManager.Instance().PlayMode = GameConfigs.GetLastPlayMode();

            IsGameInitialize = true;
        }

        InitializeFireBase();
        InitializeGoogleAds();

        EffectManager.GetInstance();

        //Time_LatestStartGame = DateTime.UtcNow;

        //Screen.SetResolution(720, 1280, true, 60);
    }
Exemplo n.º 22
0
    void OnWebServerResult(Dictionary <string, object> resultDataDic)
    {
        if (resultDataDic.ContainsKey("userQuest"))
        {
            LoadingManager.Show();

            JsonReader json     = new JsonReader(JsonMapper.ToJson(resultDataDic["userQuest"]));
            JsonData   jsonData = JsonMapper.ToObject(json);

            taxGetCount = jsonData["missionCount1"].ToInt();
            if (jsonData["missionComplete1"].ToInt() != 0)
            {
                isMissionComplete[0] = false;
                isMissionRewarded[0] = true;
            }

            retreatCount = jsonData["missionCount2"].ToInt();
            if (jsonData["missionComplete2"].ToInt() != 0)
            {
                isMissionComplete[1] = false;
                isMissionRewarded[1] = true;
            }

            heroEnhanceCount = jsonData["missionCount3"].ToInt();
            if (jsonData["missionComplete3"].ToInt() != 0)
            {
                isMissionComplete[2] = false;
                isMissionRewarded[2] = true;
            }

            colaTrainingCount = jsonData["missionCount4"].ToInt();
            if (jsonData["missionComplete4"].ToInt() != 0)
            {
                isMissionComplete[3] = false;
                isMissionRewarded[3] = true;
            }

            colaLimitbreakCount = jsonData["missionCount5"].ToInt();
            if (jsonData["missionComplete5"].ToInt() != 0)
            {
                isMissionComplete[4] = false;
                isMissionRewarded[4] = true;
            }

            colaPromoteCount = jsonData["missionCount6"].ToInt();
            if (jsonData["missionComplete6"].ToInt() != 0)
            {
                isMissionComplete[5] = false;
                isMissionRewarded[5] = true;
            }

            dungeonArrivalCount = jsonData["missionCount7"].ToInt();
            if (jsonData["missionComplete7"].ToInt() != 0)
            {
                isMissionComplete[6] = false;
                isMissionRewarded[6] = true;
            }

            heroRebirthCount = jsonData["missionCount8"].ToInt();
            if (jsonData["missionComplete8"].ToInt() != 0)
            {
                isMissionComplete[7] = false;
                isMissionRewarded[7] = true;
            }

            platinumGetCount = jsonData["missionCount9"].ToInt();
            if (jsonData["missionComplete9"].ToInt() != 0)
            {
                isMissionComplete[8] = false;
                isMissionRewarded[8] = true;
            }

            //if (isMissionRewarded1 && isMissionRewarded2 && isMissionRewarded3 && isMissionRewarded4 && isMissionRewarded5 && isMissionRewarded6 && isMissionRewarded7 && isMissionRewarded8 && isMissionRewarded9)
            //    isAllClear = true;

            int count = 0;
            for (int i = 0; i < isMissionRewarded.Count; i++)
            {
                if (isMissionRewarded[i] == false)
                {
                    count += 1;
                }
            }
            if (count == 0)
            {
                isAllClear = true;
            }

            count = 0;
            for (int i = 0; i < isMissionComplete.Count; i++)
            {
                if (isMissionComplete[i] == true)
                {
                    count += 1;
                }
            }
            if (count > 0)
            {
                if (onUserQuestCheckerCallback != null)
                {
                    onUserQuestCheckerCallback(AlarmType.UserQuest, true);
                }
                else
                {
                    UpdateAlarm.updateUserQuest = true;
                }
            }
            else
            {
                if (onUserQuestCheckerCallback != null)
                {
                    onUserQuestCheckerCallback(AlarmType.UserQuest, false);
                }
            }


            //if (isMissionComplete1 || isMissionComplete2 || isMissionComplete3 || isMissionComplete4 || isMissionComplete5 || isMissionComplete6 || isMissionComplete7 || isMissionComplete8 || isMissionComplete9)
            //{
            //    if (onUserQuestCheckerCallback != null)
            //        onUserQuestCheckerCallback(AlarmType.UserQuest, true);
            //}
            //else
            //{
            //    if (onUserQuestCheckerCallback != null)
            //        onUserQuestCheckerCallback(AlarmType.UserQuest, false);
            //}



            if (UIUserQuest.Instance)
            {
                UIUserQuest.Instance.InitUI();
            }
            if (isInitialized == false)
            {
                isInitialized = true;
            }

            LoadingManager.Close();
        }
    }
Exemplo n.º 23
0
    void OnWebServerResult(Dictionary <string, object> resultDataDic)
    {
        if (resultDataDic.ContainsKey("dailyMission"))
        {
            LoadingManager.Show();

            JsonReader json     = new JsonReader(JsonMapper.ToJson(resultDataDic["dailyMission"]));
            JsonData   jsonData = JsonMapper.ToObject(json);

            heroTrainingCount = jsonData["missionCount1"].ToInt();
            if (jsonData["missionComplete1"].ToInt() != 0)
            {
                isMissionComplete1 = false;
                isMissionRewarded1 = true;
            }

            retreatCount = jsonData["missionCount2"].ToInt();
            if (jsonData["missionComplete2"].ToInt() != 0)
            {
                isMissionComplete2 = false;
                isMissionRewarded2 = true;
            }

            heroEnhanceCount = jsonData["missionCount3"].ToInt();
            if (jsonData["missionComplete3"].ToInt() != 0)
            {
                isMissionComplete3 = false;
                isMissionRewarded3 = true;
            }

            taxGetCount = jsonData["missionCount4"].ToInt();
            if (jsonData["missionComplete4"].ToInt() != 0)
            {
                isMissionComplete4 = false;
                isMissionRewarded4 = true;
            }

            if (isMissionRewarded1 && isMissionRewarded2 && isMissionRewarded3 && isMissionRewarded4)
            {
                isAllClear = true;
            }

            if (jsonData["allClear"].ToInt() != 0)
            {
                UIDailyMission.isAllClearActive = true;
                isAllClear = false;
            }

            if (isMissionComplete1 || isMissionComplete2 || isMissionComplete3 || isMissionComplete4)
            {
                if (onDailyMissionCheckerCallback != null)
                {
                    onDailyMissionCheckerCallback(AlarmType.DailyMission, true);
                }
                else
                {
                    UpdateAlarm.updateDaily = true;
                }
            }
            else
            {
                if (onDailyMissionCheckerCallback != null)
                {
                    onDailyMissionCheckerCallback(AlarmType.DailyMission, false);
                }
            }



            if (UIDailyMission.Instance)
            {
                UIDailyMission.Instance.InitUI();
            }
            if (isInitialized == false)
            {
                isInitialized = true;
            }

            LoadingManager.Close();
        }
    }
Exemplo n.º 24
0
    void Start()
    {
        if (Instance == null)
        {
            DontDestroyOnLoad(gameObject);
            Instance = this;

            #region SetMode
            if (ObscuredPrefs.GetString("isTF") != "")
            {
                if (ObscuredPrefs.GetString("isTF") == "true")
                {
                    isTF = true;
                }
                else
                {
                    isTF = false;
                }
            }
            else
            {
                isTF = true;
            }

            if (ObscuredPrefs.GetString("isMCQS") != "")
            {
                if (ObscuredPrefs.GetString("isMCQS") == "true")
                {
                    isMCQs = true;
                }
                else
                {
                    isMCQs = false;
                }
            }
            else
            {
                isMCQs = false;
            }

            if (ObscuredPrefs.GetString("isFIB") != "")
            {
                if (ObscuredPrefs.GetString("isFIB") == "true")
                {
                    isFIB = true;
                }
                else
                {
                    isFIB = false;
                }
            }
            else
            {
                isFIB = false;
            }
            #endregion
            AttachListner();
            SetMode();
            DontDestroyOnLoad(gameObject);
        }
        else if (Instance != this)
        {
            Destroy(gameObject);
        }
    }
Exemplo n.º 25
0
        public static void MigrateObscuredTypesOnPrefabs()
        {
            if (!EditorUtility.DisplayDialog("ACTk Obscured types migration",
                                             "Are you sure you wish to scan all prefabs in your project and automatically migrate values to the new format?",
                                             "Yes", "No"))
            {
                Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Obscured types migration was cancelled by user.");
                return;
            }

            AssetDatabase.SaveAssets();

            string[] assets = AssetDatabase.FindAssets("t:ScriptableObject t:Prefab");
            //string[] prefabs = AssetDatabase.FindAssets("TestPrefab");
            int touchedCount = 0;
            int count        = assets.Length;

            for (int i = 0; i < count; i++)
            {
                if (EditorUtility.DisplayCancelableProgressBar("Looking through objects", "Object " + (i + 1) + " from " + count,
                                                               i / (float)count))
                {
                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Obscured types migration was cancelled by user.");
                    break;
                }

                string guid = assets[i];
                string path = AssetDatabase.GUIDToAssetPath(guid);

                Object[] objects = AssetDatabase.LoadAllAssetsAtPath(path);
                foreach (Object unityObject in objects)
                {
                    if (unityObject == null)
                    {
                        continue;
                    }
                    if (unityObject.name == "Deprecated EditorExtensionImpl")
                    {
                        continue;
                    }

                    bool modified         = false;
                    var  so               = new SerializedObject(unityObject);
                    SerializedProperty sp = so.GetIterator();

                    if (sp == null)
                    {
                        continue;
                    }

                    while (sp.NextVisible(true))
                    {
                        if (sp.propertyType != SerializedPropertyType.Generic)
                        {
                            continue;
                        }

                        string type = sp.type;

                        switch (type)
                        {
                        case "ObscuredBool":
                        {
                            SerializedProperty hiddenValue      = sp.FindPropertyRelative("hiddenValue");
                            SerializedProperty cryptoKey        = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue        = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueChanged = sp.FindPropertyRelative("fakeValueChanged");
                            SerializedProperty fakeValueActive  = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited           = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                int  currentCryptoKey = cryptoKey.intValue;
                                bool real             = ObscuredBool.Decrypt(hiddenValue.intValue, (byte)currentCryptoKey);
                                bool fake             = fakeValue.boolValue;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.boolValue = real;
                                    if (fakeValueChanged != null)
                                    {
                                        fakeValueChanged.boolValue = true;
                                    }
                                    if (fakeValueActive != null)
                                    {
                                        fakeValueActive.boolValue = true;
                                    }
                                    modified = true;
                                }
                            }
                        }
                        break;

                        case "ObscuredDouble":
                        {
                            SerializedProperty hiddenValue = sp.FindPropertyRelative("hiddenValue");
                            if (hiddenValue == null)
                            {
                                continue;
                            }

                            SerializedProperty hiddenValue1 = hiddenValue.FindPropertyRelative("b1");
                            SerializedProperty hiddenValue2 = hiddenValue.FindPropertyRelative("b2");
                            SerializedProperty hiddenValue3 = hiddenValue.FindPropertyRelative("b3");
                            SerializedProperty hiddenValue4 = hiddenValue.FindPropertyRelative("b4");
                            SerializedProperty hiddenValue5 = hiddenValue.FindPropertyRelative("b5");
                            SerializedProperty hiddenValue6 = hiddenValue.FindPropertyRelative("b6");
                            SerializedProperty hiddenValue7 = hiddenValue.FindPropertyRelative("b7");
                            SerializedProperty hiddenValue8 = hiddenValue.FindPropertyRelative("b8");

                            SerializedProperty hiddenValueOld = sp.FindPropertyRelative("hiddenValueOld");

                            if (hiddenValueOld != null && hiddenValueOld.isArray && hiddenValueOld.arraySize == 8)
                            {
                                hiddenValue1.intValue = hiddenValueOld.GetArrayElementAtIndex(0).intValue;
                                hiddenValue2.intValue = hiddenValueOld.GetArrayElementAtIndex(1).intValue;
                                hiddenValue3.intValue = hiddenValueOld.GetArrayElementAtIndex(2).intValue;
                                hiddenValue4.intValue = hiddenValueOld.GetArrayElementAtIndex(3).intValue;
                                hiddenValue5.intValue = hiddenValueOld.GetArrayElementAtIndex(4).intValue;
                                hiddenValue6.intValue = hiddenValueOld.GetArrayElementAtIndex(5).intValue;
                                hiddenValue7.intValue = hiddenValueOld.GetArrayElementAtIndex(6).intValue;
                                hiddenValue8.intValue = hiddenValueOld.GetArrayElementAtIndex(7).intValue;

                                hiddenValueOld.arraySize = 0;

                                Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Migrated property " + sp.displayName + ":" + type +
                                          " at the object " + unityObject.name + "\n" + path);
                                modified = true;
                            }

#if UNITY_5_0_PLUS
                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                var union = new LongBytesUnion();
                                union.b8.b1 = (byte)hiddenValue1.intValue;
                                union.b8.b2 = (byte)hiddenValue2.intValue;
                                union.b8.b3 = (byte)hiddenValue3.intValue;
                                union.b8.b4 = (byte)hiddenValue4.intValue;
                                union.b8.b5 = (byte)hiddenValue5.intValue;
                                union.b8.b6 = (byte)hiddenValue6.intValue;
                                union.b8.b7 = (byte)hiddenValue7.intValue;
                                union.b8.b8 = (byte)hiddenValue8.intValue;

                                long   currentCryptoKey = cryptoKey.longValue;
                                double real             = ObscuredDouble.Decrypt(union.l, currentCryptoKey);
                                double fake             = fakeValue.doubleValue;

                                if (Math.Abs(real - fake) > 0.0000001d)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);

                                    fakeValue.doubleValue     = real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
#endif
                        }
                        break;

                        case "ObscuredFloat":
                        {
                            SerializedProperty hiddenValue = sp.FindPropertyRelative("hiddenValue");
                            if (hiddenValue == null)
                            {
                                continue;
                            }

                            SerializedProperty hiddenValue1 = hiddenValue.FindPropertyRelative("b1");
                            SerializedProperty hiddenValue2 = hiddenValue.FindPropertyRelative("b2");
                            SerializedProperty hiddenValue3 = hiddenValue.FindPropertyRelative("b3");
                            SerializedProperty hiddenValue4 = hiddenValue.FindPropertyRelative("b4");

                            SerializedProperty hiddenValueOld = sp.FindPropertyRelative("hiddenValueOld");

                            if (hiddenValueOld != null && hiddenValueOld.isArray && hiddenValueOld.arraySize == 4)
                            {
                                hiddenValue1.intValue = hiddenValueOld.GetArrayElementAtIndex(0).intValue;
                                hiddenValue2.intValue = hiddenValueOld.GetArrayElementAtIndex(1).intValue;
                                hiddenValue3.intValue = hiddenValueOld.GetArrayElementAtIndex(2).intValue;
                                hiddenValue4.intValue = hiddenValueOld.GetArrayElementAtIndex(3).intValue;

                                hiddenValueOld.arraySize = 0;

                                Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Migrated property " + sp.displayName + ":" + type +
                                          " at the object " + unityObject.name + "\n" + path);
                                modified = true;
                            }

                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                var union = new IntBytesUnion();
                                union.b4.b1 = (byte)hiddenValue1.intValue;
                                union.b4.b2 = (byte)hiddenValue2.intValue;
                                union.b4.b3 = (byte)hiddenValue3.intValue;
                                union.b4.b4 = (byte)hiddenValue4.intValue;

                                int   currentCryptoKey = cryptoKey.intValue;
                                float real             = ObscuredFloat.Decrypt(union.i, currentCryptoKey);
                                float fake             = fakeValue.floatValue;
                                if (Math.Abs(real - fake) > 0.0000001f)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);

                                    fakeValue.floatValue      = real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;

                        case "ObscuredInt":
                        {
                            SerializedProperty hiddenValue     = sp.FindPropertyRelative("hiddenValue");
                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                int currentCryptoKey = cryptoKey.intValue;
                                int real             = ObscuredInt.Decrypt(hiddenValue.intValue, currentCryptoKey);
                                int fake             = fakeValue.intValue;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.intValue        = real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;

#if UNITY_5_0_PLUS
                        case "ObscuredLong":
                        {
                            SerializedProperty hiddenValue     = sp.FindPropertyRelative("hiddenValue");
                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                long currentCryptoKey = cryptoKey.longValue;
                                long real             = ObscuredLong.Decrypt(hiddenValue.longValue, currentCryptoKey);
                                long fake             = fakeValue.longValue;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.longValue       = real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;

                        case "ObscuredShort":
                        {
                            SerializedProperty hiddenValue     = sp.FindPropertyRelative("hiddenValue");
                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                short currentCryptoKey = (short)cryptoKey.intValue;
                                short real             = ObscuredShort.EncryptDecrypt((short)hiddenValue.intValue, currentCryptoKey);
                                short fake             = (short)fakeValue.intValue;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.intValue        = real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;
#endif
                        case "ObscuredString":
                        {
                            SerializedProperty hiddenValue     = sp.FindPropertyRelative("hiddenValue");
                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                string currentCryptoKey = cryptoKey.stringValue;
                                byte[] bytes            = new byte[hiddenValue.arraySize];
                                for (int j = 0; j < hiddenValue.arraySize; j++)
                                {
                                    bytes[j] = (byte)hiddenValue.GetArrayElementAtIndex(j).intValue;
                                }

                                string real = ObscuredString.EncryptDecrypt(GetString(bytes), currentCryptoKey);
                                string fake = fakeValue.stringValue;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.stringValue     = real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;

#if UNITY_5_0_PLUS
                        case "ObscuredUInt":
                        {
                            SerializedProperty hiddenValue     = sp.FindPropertyRelative("hiddenValue");
                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                uint currentCryptoKey = (uint)cryptoKey.intValue;
                                uint real             = ObscuredUInt.Decrypt((uint)hiddenValue.intValue, currentCryptoKey);
                                uint fake             = (uint)fakeValue.intValue;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.intValue        = (int)real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;

                        case "ObscuredULong":
                        {
                            SerializedProperty hiddenValue     = sp.FindPropertyRelative("hiddenValue");
                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                ulong currentCryptoKey = (ulong)cryptoKey.longValue;
                                ulong real             = ObscuredULong.Decrypt((ulong)hiddenValue.longValue, currentCryptoKey);
                                ulong fake             = (ulong)fakeValue.longValue;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.longValue       = (long)real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;
#endif
                        case "ObscuredVector2":
                        {
                            SerializedProperty hiddenValue = sp.FindPropertyRelative("hiddenValue");
                            if (hiddenValue == null)
                            {
                                continue;
                            }

                            SerializedProperty hiddenValueX = hiddenValue.FindPropertyRelative("x");
                            SerializedProperty hiddenValueY = hiddenValue.FindPropertyRelative("y");

                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                ObscuredVector2.RawEncryptedVector2 ev = new ObscuredVector2.RawEncryptedVector2();
                                ev.x = hiddenValueX.intValue;
                                ev.y = hiddenValueY.intValue;

                                int     currentCryptoKey = cryptoKey.intValue;
                                Vector2 real             = ObscuredVector2.Decrypt(ev, currentCryptoKey);
                                Vector2 fake             = fakeValue.vector2Value;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.vector2Value    = real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;

                        case "ObscuredVector3":
                        {
                            SerializedProperty hiddenValue = sp.FindPropertyRelative("hiddenValue");
                            if (hiddenValue == null)
                            {
                                continue;
                            }

                            SerializedProperty hiddenValueX = hiddenValue.FindPropertyRelative("x");
                            SerializedProperty hiddenValueY = hiddenValue.FindPropertyRelative("y");
                            SerializedProperty hiddenValueZ = hiddenValue.FindPropertyRelative("z");

                            SerializedProperty cryptoKey       = sp.FindPropertyRelative("currentCryptoKey");
                            SerializedProperty fakeValue       = sp.FindPropertyRelative("fakeValue");
                            SerializedProperty fakeValueActive = sp.FindPropertyRelative("fakeValueActive");
                            SerializedProperty inited          = sp.FindPropertyRelative("inited");

                            if (inited != null && inited.boolValue)
                            {
                                var ev = new ObscuredVector3.RawEncryptedVector3();
                                ev.x = hiddenValueX.intValue;
                                ev.y = hiddenValueY.intValue;
                                ev.z = hiddenValueZ.intValue;

                                int     currentCryptoKey = cryptoKey.intValue;
                                Vector3 real             = ObscuredVector3.Decrypt(ev, currentCryptoKey);
                                Vector3 fake             = fakeValue.vector3Value;

                                if (real != fake)
                                {
                                    Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Fixed property " + sp.displayName + ":" + type +
                                              " at the object " + unityObject.name + "\n" + path);
                                    fakeValue.vector3Value    = real;
                                    fakeValueActive.boolValue = true;
                                    modified = true;
                                }
                            }
                        }
                        break;
                        }
                    }

                    if (modified)
                    {
                        touchedCount++;
                        so.ApplyModifiedProperties();
                        EditorUtility.SetDirty(unityObject);
                    }
                }
            }

            AssetDatabase.SaveAssets();

            EditorUtility.ClearProgressBar();

            if (touchedCount > 0)
            {
                Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "Migrated obscured types on " + touchedCount + " objects.");
            }
            else
            {
                Debug.Log(ActEditorGlobalStuff.LOG_PREFIX + "No objects were found for obscured types migration.");
            }
        }
Exemplo n.º 26
0
 // onApp Pause don't cheat.
 void OnApplicationPause(bool pauseStatus)
 {
     IsForceFail = true;
 }
Exemplo n.º 27
0
 public static void SetRemoveAdsPurchased(ObscuredBool purchased)
 {
     mRemoveAds = purchased;
     Saved.SetBool(SaveKey.RemoveAds, mRemoveAds);
 }
Exemplo n.º 28
0
 public static void SetSound(bool soundOn)
 {
     mSound = soundOn;
     SaveSound();
 }
Exemplo n.º 29
0
    /// <summary>
    /// saves every supported field of 'preset' to text at 'fullPath'
    /// </summary>
    public static string Save(vp_ComponentPreset savePreset, string fullPath, bool isDifference = false)
    {
        m_FullPath = fullPath;

        // if the targeted file already exists, we take a look
        // at it to see if it has the same type as 'component'

        // attempt to load target preset into memory, ignoring
        // load errors in the process
        bool logErrorState = LogErrors;

        LogErrors = false;
        vp_ComponentPreset preset = new vp_ComponentPreset();

        preset.LoadTextStream(m_FullPath);
        LogErrors = logErrorState;

        // if we got hold of a preset and a component type from
        // the file, confirm overwrite
        if (preset != null)
        {
            if (preset.m_ComponentType != null)
            {
                // warn user if the type is not same as the passed 'component'
                if (preset.ComponentType != savePreset.ComponentType)
                {
                    return("'" + ExtractFilenameFromPath(m_FullPath) + "' has the WRONG component type: " + preset.ComponentType.ToString() + ".\n\nDo you want to replace it with a " + savePreset.ComponentType.ToString() + "?");
                }
                // confirm that the user does in fact want to overwrite this file
                if (System.IO.File.Exists(m_FullPath))
                {
                    if (isDifference)
                    {
                        return("This will update '" + ExtractFilenameFromPath(m_FullPath) + "' with only the values modified since pressing Play or setting a state.\n\nContinue?");
                    }
                    else
                    {
                        return("'" + ExtractFilenameFromPath(m_FullPath) + "' already exists.\n\nDo you want to replace it?");
                    }
                }
            }
            // if we end up here there was a file but it didn't make sense, so confirm overwrite
            if (System.IO.File.Exists(m_FullPath))
            {
                return("'" + ExtractFilenameFromPath(m_FullPath) + "' has an UNKNOWN component type.\n\nDo you want to replace it?");
            }
        }

        // go ahead and save 'component' to the text file

        ClearTextFile();

        Append("///////////////////////////////////////////////////////////");
        Append("// Component Preset Script");
        Append("///////////////////////////////////////////////////////////\n");

        // append component type
        Append("ComponentType " + savePreset.ComponentType.Name);

        // scan component for all its fields. NOTE: any types
        // to be supported must be included here.

        string prefix;
        string value;

        foreach (Field f in savePreset.m_Fields)
        {
            prefix = "";
            value  = "";
            FieldInfo fi = FieldInfo.GetFieldFromHandle(f.FieldHandle);

            if (fi.FieldType == typeof(float))
            {
                value = String.Format("{0:0.#######}", ((float)f.Args));
            }

            else if (fi.FieldType == typeof(Vector4))
            {
                Vector4 val = ((Vector4)f.Args);
                value = String.Format("{0:0.#######}", val.x) + " " +
                        String.Format("{0:0.#######}", val.y) + " " +
                        String.Format("{0:0.#######}", val.z) + " " +
                        String.Format("{0:0.#######}", val.w);
            }
            else if (fi.FieldType == typeof(Vector3))
            {
                Vector3 val = ((Vector3)f.Args);
                value = String.Format("{0:0.#######}", val.x) + " " +
                        String.Format("{0:0.#######}", val.y) + " " +
                        String.Format("{0:0.#######}", val.z);
            }
            else if (fi.FieldType == typeof(Vector2))
            {
                Vector2 val = ((Vector2)f.Args);
                value = String.Format("{0:0.#######}", val.x) + " " +
                        String.Format("{0:0.#######}", val.y);
            }
            else if (fi.FieldType == typeof(int))
            {
                value = ((int)f.Args).ToString();
            }
            else if (fi.FieldType == typeof(bool))
            {
                value = ((bool)f.Args).ToString();
            }
            else if (fi.FieldType == typeof(string))
            {
                value = ((string)f.Args);
            }
#if ANTICHEAT
            else if (fi.FieldType == typeof(ObscuredFloat))
            {
                ObscuredFloat val = ((float)f.Args);
                value = String.Format("{0:0.#######}", val);
            }
            else if (fi.FieldType == typeof(ObscuredVector3))
            {
                ObscuredVector3 val = ((ObscuredVector3)f.Args);
                value = String.Format("{0:0.#######}", val.x) + " " +
                        String.Format("{0:0.#######}", val.y) + " " +
                        String.Format("{0:0.#######}", val.z);
            }
            else if (fi.FieldType == typeof(ObscuredVector2))
            {
                ObscuredVector2 val = ((ObscuredVector2)f.Args);
                value = String.Format("{0:0.#######}", val.x) + " " +
                        String.Format("{0:0.#######}", val.y);
            }
            else if (fi.FieldType == typeof(ObscuredInt))
            {
                ObscuredInt val = ((ObscuredInt)f.Args);
                value = val.ToString();
            }
            else if (fi.FieldType == typeof(ObscuredBool))
            {
                ObscuredBool val = ((ObscuredBool)f.Args);
                value = val.ToString();
            }
            else if (fi.FieldType == typeof(ObscuredString))
            {
                ObscuredString val = ((ObscuredString)f.Args);
                value = val.ToString();
            }
#endif
            else
            {
                prefix = "//";
                value  = "<NOTE: Type '" + fi.FieldType.Name.ToString() + "' can't be saved to preset.>";
            }

            // print field name and value to the text file
            if (!string.IsNullOrEmpty(value) && fi.Name != "Persist")
            {
                Append(prefix + fi.Name + " " + value);
            }
        }

        return(null);
    }
Exemplo n.º 30
0
 public static void SetMissionTutorial(ObscuredBool isDone)
 {
     mMissionTut = isDone;
     Saved.SetBool(SaveKey.MissionTutorial, mGameTut);
 }
Exemplo n.º 31
0
    /// <summary>
    /// this method applies a preset onto the passed component,
    /// returning true on success
    /// </summary>
    public static bool Apply(vp_Component component, vp_ComponentPreset preset)
    {
        if (preset == null)
        {
            Error("Tried to apply a preset that was null in '" + vp_Utility.GetErrorLocation() + "'");
            return(false);
        }

        if (preset.m_ComponentType == null)
        {
            Error("Preset ComponentType was null in '" + vp_Utility.GetErrorLocation() + "'");
            return(false);
        }

        if (component == null)
        {
            UnityEngine.Debug.LogWarning("Warning: Component was null when attempting to apply preset in '" + vp_Utility.GetErrorLocation() + "'");
            return(false);
        }

        if (component.Type != preset.m_ComponentType)
        {
            string type = "a '" + preset.m_ComponentType + "' preset";
            if (preset.m_ComponentType == null)
            {
                type = "an unknown preset type";
            }
            Error("Applied " + type + " to a '" + component.Type.ToString() + "' component in '" + vp_Utility.GetErrorLocation() + "'");
            return(false);
        }

        // component and preset both seem ok, so set the preset fields
        // onto the component
        for (int p = 0; p < preset.m_Fields.Count; p++)
        {
            FieldInfo destField = FieldInfo.GetFieldFromHandle(preset.m_Fields[p].FieldHandle);
#if ANTICHEAT
            if ((destField.FieldType == typeof(ObscuredFloat)) && (preset.m_Fields[p].Args.GetType() == typeof(float)))
            {
                ObscuredFloat o = (float)preset.m_Fields[p].Args;
                destField.SetValue(component, o);
            }
            else if ((destField.FieldType == typeof(ObscuredVector3)) && (preset.m_Fields[p].Args.GetType() == typeof(Vector3)))
            {
                ObscuredVector3 o = (Vector3)preset.m_Fields[p].Args;
                destField.SetValue(component, o);
            }
            else if ((destField.FieldType == typeof(ObscuredVector2)) && (preset.m_Fields[p].Args.GetType() == typeof(Vector2)))
            {
                ObscuredVector2 o = (Vector2)preset.m_Fields[p].Args;
                destField.SetValue(component, o);
            }
            else if ((destField.FieldType == typeof(ObscuredInt)) && (preset.m_Fields[p].Args.GetType() == typeof(int)))
            {
                ObscuredInt o = (int)preset.m_Fields[p].Args;
                destField.SetValue(component, o);
            }
            else if ((destField.FieldType == typeof(ObscuredBool)) && (preset.m_Fields[p].Args.GetType() == typeof(bool)))
            {
                ObscuredBool o = (bool)preset.m_Fields[p].Args;
                destField.SetValue(component, o);
            }
            else if ((destField.FieldType == typeof(ObscuredString)) && (preset.m_Fields[p].Args.GetType() == typeof(string)))
            {
                ObscuredString o = (string)preset.m_Fields[p].Args;
                destField.SetValue(component, o);
            }
            else
#endif
            destField.SetValue(component, preset.m_Fields[p].Args);
        }

        return(true);
    }