コード例 #1
0
        void Update()
        {
            if (_elapsed > 0 && _elapsed < _delay)
            {
                _elapsed += Time.deltaTime;
                return;
            }
            else if (_elapsed > _delay)
            {
                _elapsed = 0;
            }
            if (KeyBindings.GetKey(Controls.Light) == false)
            {
                _setting = false;
            }

            if (_setting)
            {
                var direction = new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"));

                foreach (int connection in _abilityPoints[_currentPoint].Connections)
                {
                    if (Vector2.Angle(direction, _abilityPoints[connection].Point - _abilityPoints[_currentPoint].Point) < 30f)
                    {
                        _elapsed += Time.deltaTime;

                        if ((_currentPoint == 4 && connection == 3 && _abilityPoints[3].IsActivated == false) ||
                            (_currentPoint == 4 && connection == 18 && _abilityPoints[18].IsActivated == false) ||
                            (_currentPoint == 7 && connection == 6 && _abilityPoints[6].IsActivated == false) ||
                            (_currentPoint == 7 && connection == 25 && _abilityPoints[25].IsActivated == false) ||
                            (_currentPoint == 10 && connection == 9 && _abilityPoints[9].IsActivated == false) ||
                            (_currentPoint == 10 && connection == 32 && _abilityPoints[32].IsActivated == false))
                        {
                            return;
                        }

                        AbilityPoint abilityPoint = _abilityPoints[connection];
                        if (abilityPoint.IsActivated)
                        {
                            PlayerPrefs.SetFloat(Meter, (abilityPoint.Point.y * 10) + 1);
                            DeactivateCurrentPoint();
                            _currentPoint = connection;
                        }
                        else if (PlayerPrefs.GetInt(IntVariable.AvailablePoints.ToString()) - PlayerPrefs.GetInt(IntVariable.SpentPoints.ToString()) > 0)
                        {
                            SetNewCurrentPoint(connection, abilityPoint);
                        }
                        return;
                    }
                }
            }
        }
コード例 #2
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);
        }
コード例 #3
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);
            }
        }
コード例 #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();
        }