Ejemplo n.º 1
0
 public OrbSetup(float swapTimer, float decay, Transform player, GlobalDataHandler globalData, State orbState, float[] mainTimers, float[] secondaryTimers, OrbElement orbType)
 {
     SwapTimer             = swapTimer;
     Decay                 = decay;
     Player                = player;
     GlobalData            = globalData;
     OrbState              = OrbState;
     MainAttackTimers      = mainTimers;
     SecondaryAttackTimers = secondaryTimers;
     OrbType               = orbType;
 }
Ejemplo n.º 2
0
 //Swap Methods
 private void ScrollSwap(float scroll)
 {
     if (scroll == 1)
     {
         _orbType = (int)_orbType + 1 == _globalData.OrbPrefabs.Length ? 0 : _orbType + 1;
     }
     else if (scroll == -1)
     {
         _orbType = (int)_orbType - 1 == -1 ? (OrbElement)_globalData.OrbPrefabs.Length - 1 : _orbType - 1;
     }
     Swap();
 }
Ejemplo n.º 3
0
        protected virtual void Update()
        {
            //Checks State
            switch (_state)
            {
            case State.Orbiting:
                transform.position = new Vector2(_player.position.x + Mathf.Cos(Time.time) * transform.localScale.x,
                                                 _player.position.y + Mathf.Sin(Time.time) * transform.localScale.y);
                break;

            case State.Returning:
                transform.position = Vector3.Lerp(transform.position, _player.position, _idleTimerLerp);
                _idleTimerLerp    += Time.deltaTime / Vector3.Distance(transform.position, _player.position);
                if (_idleTimerLerp >= 1)
                {
                    transform.localScale = _globalData.OrbSize;
                    _decay = 0;
                    _state = State.Orbiting;
                }
                break;

            case State.Idling:
                transform.localScale = Vector2.Lerp(_globalData.OrbSize, new Vector2(0.25f, 0.25f), _decay / 10f);
                _decay += Time.deltaTime;

                if (Input.GetKeyDown(_globalData.Keys[GlobalDataHandler.Key.Recall]))
                {
                    _state         = State.Returning;
                    _idleTimerLerp = 0;
                }
                break;
            }

            // Cooldowns
            if (!_canUseSecondary)
            {
                _canUseSecondary = _secondaryAttackTimer <= Time.time;
                transform.GetComponent <SpriteRenderer>().color = Color.Lerp(Color.white, new Color(0.7f, 0.7f, 0.7f, 0.7f), (_secondaryAttackTimer - Time.time) / _secondaryAttackDelay);
            }
            if (!_canUseMainAttack)
            {
                _canUseMainAttack = _mainAttackTimer <= Time.time;
            }

            //Secondary Attack
            if (Input.GetMouseButtonDown(1) && _canUseSecondary)
            {
                SetUpSecondaryAttackTimer();
                SecondaryAttack();
            }

            //Swapping
            if (_state != State.Attacking && _swapTimer < Time.time)
            {
                var keyPressed = SwapKeys.FirstOrDefault(k => Input.GetKeyDown(k.Key));
                if (!keyPressed.Equals(default(KeyValuePair <KeyCode, int>)))
                {
                    _orbType = (OrbElement)keyPressed.Value;
                    Swap();
                }

                var scroll = Input.GetAxis("Mouse ScrollWheel");
                if (scroll != 0)
                {
                    ScrollSwap(Mathf.Sign(scroll));
                }
            }

            //Mid Attack check to prevent 2 attacks at once
            if (!_canUseMainAttack)
            {
                return;
            }

            //Main Attack
            if (Input.GetMouseButton(0))
            {
                UpdateAimLine();
                _state = State.Aiming;
            }

            if (Input.GetMouseButtonUp(0))
            {
                _state = State.Attacking;
                MainAttack();
                SetUpMainAttackTimer();
            }
        }