示例#1
0
    IEnumerator Start()
    {
        yield return(null);

        int slot = PlayerPrefs.GetInt("Slot");

        if (slot > 0)
        {
            foreach (var obj in PlayerPrefsX.GetStringArray("ITriggers" + slot))
            {
                var trigger = FindObjectsOfTypeAll <MonoBehaviour>().OfType <ITrigger>().FirstOrDefault(e => e.GameObject.name == obj);
                if (trigger != null)
                {
                    if (trigger.Parent != null)
                    {
                        trigger.Parent.OnTrigger(trigger.GameObject);
                    }

                    if (trigger is EnemyController)
                    {
                        Destroy(trigger.GameObject);
                    }
                }
            }
            CharacterController.Player.transform.position   = PlayerPrefsX.GetVector3("Position" + slot);
            CharacterController.Player.transform.rotation   = PlayerPrefsX.GetQuaternion("Rotation" + slot);
            CharacterController.Player.Health.CurrentHealth = PlayerPrefs.GetFloat("Health" + slot);
            CharacterController.Player.Energy.CurrentEnergy = PlayerPrefs.GetFloat("Energy" + slot);
        }
    }
        public override void OnEnter()
        {
            for (int i = 0; i < keys.Length; i++)
            {
                if (!keys[i].IsNone || !keys[i].Value.Equals(""))
                {
                    string key    = keys[i].Value;
                    FsmVar fsmVar = values[i];
                    string _name  = fsmVar.variableName;

                    switch (fsmVar.Type)
                    {
                    case VariableType.Int:
                        this.Fsm.Variables.GetFsmInt(_name).Value = PlayerPrefs.GetInt(key);
                        break;

                    case VariableType.Float:
                        this.Fsm.Variables.GetFsmFloat(_name).Value = PlayerPrefs.GetFloat(key);
                        break;

                    case VariableType.Bool:
                        this.Fsm.Variables.GetFsmBool(_name).Value = PlayerPrefsX.GetBool(key);
                        break;

                    case VariableType.Color:
                        this.Fsm.Variables.GetFsmColor(_name).Value = PlayerPrefsX.GetColor(key);
                        break;

                    case VariableType.Quaternion:
                        this.Fsm.Variables.GetFsmQuaternion(_name).Value = PlayerPrefsX.GetQuaternion(key);
                        break;

                    case VariableType.Rect:
                        this.Fsm.Variables.GetFsmRect(_name).Value = PlayerPrefsX.GetRect(key);
                        break;

                    case VariableType.Vector2:
                        this.Fsm.Variables.GetFsmVector2(_name).Value = PlayerPrefsX.GetVector2(key);
                        break;

                    case VariableType.Vector3:
                        this.Fsm.Variables.GetFsmVector3(_name).Value = PlayerPrefsX.GetVector3(key);
                        break;

                    case VariableType.String:
                        this.Fsm.Variables.GetFsmString(_name).Value = PlayerPrefs.GetString(key);
                        break;

                    default:
                        LogError("PlayerPrefsx does not support saving " + fsmVar.Type);
                        break;
                    }
                }
            }

            Finish();
        }
示例#3
0
    IEnumerator delayStart()
    {
        //wait until evertyhing loads
        yield return(new WaitForSeconds(1.2f));

        //When we load the application we want to load our position and rotation
        if (PlayerPrefsX.GetVector3(this.name + "_Scale") != Vector3.zero)
        {
            transform.localPosition = PlayerPrefsX.GetVector3(this.name + "_Position");
            transform.localRotation = PlayerPrefsX.GetQuaternion(this.name + "_Rotation");
            transform.localScale    = PlayerPrefsX.GetVector3(this.name + "_Scale");
        }
    }
示例#4
0
    // Use this for initialization
    void Start()
    {
        cubeID = currentCubeID;
        currentCubeID++;

        if (PlayerPrefs.HasKey("CubePosition" + cubeID.ToString()))
        {
            transform.position = PlayerPrefsX.GetVector3("CubePosition" + cubeID.ToString());
            transform.rotation = PlayerPrefsX.GetQuaternion("CubeRotation" + cubeID.ToString());

            GetComponent <Rigidbody>().velocity        = PlayerPrefsX.GetVector3("CubeRigidbodyVelocity" + cubeID.ToString(), GetComponent <Rigidbody>().velocity);
            GetComponent <Rigidbody>().angularVelocity = PlayerPrefsX.GetVector3("CubeRigidbodyAngularVelocity" + cubeID.ToString(), GetComponent <Rigidbody>().angularVelocity);
        }
    }