Esempio n. 1
0
        private void SetNewCurrentPoint(int key, AbilityPoint abilityPoint)
        {
            abilityPoint.IsActivated = true;
            _abilityPoints[key]      = abilityPoint;
            _currentPoint            = key;

            AbilityState.SetActive(abilityPoint.Ability, true);
            PlayerPrefs.SetFloat(Meter, (abilityPoint.Point.y * 10) + 1);
            AddToSpentPoints(1);
            PlayerPrefs.Save();
            SaveAbilityPoints();

            CreateLight(key, abilityPoint.Point);
        }
Esempio n. 2
0
        private void DeactivateCurrentPoint()
        {
            AbilityPoint abilityPoint = _abilityPoints[_currentPoint];

            abilityPoint.IsActivated      = false;
            _abilityPoints[_currentPoint] = abilityPoint;
            AbilityState.SetActive(abilityPoint.Ability, false);
            AddToSpentPoints(-1);
            PlayerPrefs.Save();
            SaveAbilityPoints();

            Transform t = transform.FindChild(_currentPoint.ToString());

            if (t != null)
            {
                Destroy(t.gameObject);
            }
        }
Esempio n. 3
0
        private void SetAbilityPoints(Ability one, Ability two, Ability three)
        {
            AbilityState.SetActive(one, false);
            AbilityState.SetActive(two, false);
            AbilityState.SetActive(three, false);
            PlayerPrefs.Save();

            _abilityPoints = new Dictionary <int, AbilityPoint>
            {
                { 1, new AbilityPoint(_straight[0], new [] { 2, 12 }, true, Ability.None) },
                { 2, new AbilityPoint(_straight[1], new [] { 1, 3 }, false, Ability.None) },
                { 3, new AbilityPoint(_straight[2], new [] { 2, 4 }, false, Ability.None) },
                { 4, new AbilityPoint(_straight[3], new [] { 3, 5, 18, 19 }, false, Ability.None) },
                { 5, new AbilityPoint(_straight[4], new [] { 4, 6 }, false, Ability.None) },
                { 6, new AbilityPoint(_straight[5], new [] { 5, 7 }, false, Ability.None) },
                { 7, new AbilityPoint(_straight[6], new [] { 6, 8, 25, 26 }, false, Ability.None) },
                { 8, new AbilityPoint(_straight[7], new [] { 7, 9 }, false, Ability.None) },
                { 9, new AbilityPoint(_straight[8], new [] { 8, 10 }, false, Ability.None) },
                { 10, new AbilityPoint(_straight[9], new [] { 9, 11, 32 }, false, Ability.None) },
                { 11, new AbilityPoint(_straight[10], new [] { 10 }, false, Ability.None) },
                { 12, new AbilityPoint(_firstCurve[0], new [] { 13, 1 }, false, Ability.None) },
                { 13, new AbilityPoint(_firstCurve[1], new [] { 12, 14 }, false, Ability.None) },
                { 14, new AbilityPoint(_firstCurve[2], new [] { 13, 15 }, false, Ability.None) },
                { 15, new AbilityPoint(_firstCurve[3], new [] { 14, 16 }, false, one) },
                { 16, new AbilityPoint(_firstCurve[4], new [] { 15, 17 }, false, Ability.None) },
                { 17, new AbilityPoint(_firstCurve[5], new [] { 16, 18 }, false, Ability.None) },
                { 18, new AbilityPoint(_firstCurve[6], new [] { 17, 4 }, false, Ability.None) },
                { 19, new AbilityPoint(_secondCurve[0], new [] { 20, 4 }, false, Ability.None) },
                { 20, new AbilityPoint(_secondCurve[1], new [] { 19, 21 }, false, Ability.None) },
                { 21, new AbilityPoint(_secondCurve[2], new [] { 20, 22 }, false, Ability.None) },
                { 22, new AbilityPoint(_secondCurve[3], new [] { 21, 23 }, false, two) },
                { 23, new AbilityPoint(_secondCurve[4], new [] { 22, 24 }, false, Ability.None) },
                { 24, new AbilityPoint(_secondCurve[5], new [] { 23, 25 }, false, Ability.None) },
                { 25, new AbilityPoint(_secondCurve[6], new [] { 24, 7 }, false, Ability.None) },
                { 26, new AbilityPoint(_thirdCurve[0], new [] { 27, 7 }, false, Ability.None) },
                { 27, new AbilityPoint(_thirdCurve[1], new [] { 26, 28 }, false, Ability.None) },
                { 28, new AbilityPoint(_thirdCurve[2], new [] { 27, 29 }, false, Ability.None) },
                { 29, new AbilityPoint(_thirdCurve[3], new [] { 28, 30 }, false, three) },
                { 30, new AbilityPoint(_thirdCurve[4], new [] { 29, 31 }, false, Ability.None) },
                { 31, new AbilityPoint(_thirdCurve[5], new [] { 30, 32 }, false, Ability.None) },
                { 32, new AbilityPoint(_thirdCurve[6], new [] { 31, 10 }, false, Ability.None) },
            };
        }
Esempio n. 4
0
        void Start()
        {
            if (SetupAbilityPoints() == false)
            {
                Destroy(transform.gameObject);
                return;
            }

            string directory = Path.Combine(Application.persistentDataPath, "Data");

            _path = Path.Combine(directory, Meter);
            Directory.CreateDirectory(directory);

            if (File.Exists(_path))
            {
                try
                {
                    using (Stream stream = File.Open(_path, FileMode.Open))
                    {
                        BinaryFormatter bin = new BinaryFormatter();

                        int spentPoints = 0;
                        var abilityTemp = (List <AbilityTemp>)bin.Deserialize(stream);
                        foreach (var tempAp in abilityTemp)
                        {
                            AbilityPoint ap = _abilityPoints[tempAp.Key];
                            ap.IsActivated = tempAp.IsActive;
                            if (ap.IsActivated)
                            {
                                spentPoints++;
                                if (ap.Ability != Ability.None)
                                {
                                    AbilityState.SetActive(ap.Ability, true);
                                }
                            }
                            _abilityPoints[tempAp.Key] = ap;
                        }
                        AddToSpentPoints(spentPoints);
                    }
                }
                catch (Exception)
                {
                }
            }

            _uiLight = Resources.Load(string.Format("particles/{0}Light", Meter)) as GameObject;
            float maxY = 0;

            foreach (var ap in _abilityPoints)
            {
                if (ap.Value.IsActivated)
                {
                    if (maxY < ap.Value.Point.y)
                    {
                        maxY          = ap.Value.Point.y;
                        _currentPoint = ap.Key;
                    }
                    CreateLight(ap.Key, ap.Value.Point);
                }
            }
            PlayerPrefs.SetFloat(Meter, (_abilityPoints[_currentPoint].Point.y * 10) + 1);
            PlayerPrefs.Save();
        }