Esempio n. 1
0
        public void CreateLight()
        {
            ChannelingHandler.PlExists = true;

            Vector3 pilotedLightPosition = Transform.localScale.x > 0f
                                ? transform.position + new Vector3(0.4f, 0, 0)
                                : transform.position + new Vector3(-0.4f, 0, 0);

            var pl = (GameObject)Instantiate(
                PilotedLight,
                pilotedLightPosition,
                transform.rotation);

            pl.GetComponent <PilotedLightController>().Player = this;
            _camera.Pl = pl.transform;

            if (AbilityState.IsActive(Ability.Tether))
            {
                var tetherObject = Instantiate(Tether);

                var tether = tetherObject.GetComponent <Tether>();
                tether.Player = transform;
                tether.Pl     = pl.transform;
            }
        }
Esempio n. 2
0
 private void UpdateControlBorder()
 {
     if (_currentControl != _controlLastFrame || _isScoutActive != AbilityState.IsActive(Ability.Scout))
     {
         _controlBorder.SetSize(DistanceFromPlayer * (AbilityState.IsActive(Ability.Scout) ? 4 : 2));
         _isScoutActive    = AbilityState.IsActive(Ability.Scout);
         _controlLastFrame = _currentControl;
     }
 }
Esempio n. 3
0
 public bool InteractWithStilt(Stilt stilt)
 {
     if (stilt.IsExtended)
     {
         Anim.PlayAnimation(Animations.LowerStilt);
         return(true);
     }
     else if (stilt.IsExtended == false && AbilityState.IsActive(Ability.Tools))
     {
         Anim.PlayAnimation(Animations.RaiseStilt);
         return(true);
     }
     return(false);
 }
Esempio n. 4
0
        public void Burst()
        {
            if (IsScouting)
            {
                return;
            }

            if (_fireplace != null && AbilityState.IsActive(Ability.Ignite))
            {
                _fireplace.Burst();
            }
            else if (AbilityState.IsActive(Ability.Flash))
            {
                _controller.Flash();
            }
        }
Esempio n. 5
0
        private void HandleActions()
        {
            if (KeyBindings.GetKeyDown(Controls.Light) && Pointer.IsPointerOverUIObject() == false)
            {
                float timeClicked = Time.realtimeSinceStartup;
                if (Mathf.Abs(timeClicked - _timeClicked) < 0.4f)
                {
                    Destroy(gameObject);
                }
                else
                {
                    _timeClicked = timeClicked;
                }
            }

            if (((AbilityState.IsActive(Ability.Flash) && _fireplace == null) ||
                 (AbilityState.IsActive(Ability.Ignite) && _fireplace != null)) &&
                IsScouting == false)
            {
                if (KeyBindings.GetKeyDown(Controls.Light) && Pointer.IsPointerOverUIObject() == false)
                {
                    _burstTime += Time.deltaTime;
                }

                if (KeyBindings.GetKey(Controls.Light) && Pointer.IsPointerOverUIObject() == false)
                {
                    if (_burstTime > 0)
                    {
                        float maxTime = 2f;
                        _burstTime += Time.deltaTime;
                        _burstTime  = _burstTime > maxTime ? maxTime : _burstTime;
                        DecreaseVariables();
                    }
                }

                if (KeyBindings.GetKeyUp(Controls.Light))
                {
                    _burstTime = 0;
                    _controller.ResetVariables();
                    Burst();
                }
            }
            else
            {
                _burstTime = 0;
            }
        }
Esempio n. 6
0
        void FixedUpdate()
        {
            if (ChannelingHandler.ChannelingSet == false)
            {
                return;
            }

            Rigidbody.isKinematic = false;

            if (MovementState.MovementOverridden == false)
            {
                HandleMovementInputs();
            }

            if (MovementState.MovementOverridden == false)
            {
                float appliedGravity = _noGravity ? 0 : Gravity;

                _velocity.x = Mathf.SmoothDamp(_velocity.x, _normalizedHorizontalSpeed * FlySpeed, ref _velocity.x, Time.deltaTime * AirDamping);
                _velocity.y = Mathf.SmoothDamp(_velocity.y, _normalizedVerticalSpeed * FlySpeed - appliedGravity, ref _velocity.y, Time.deltaTime * AirDamping);

                Transform.Translate(_velocity, Space.World);
            }
            else
            {
                _normalizedHorizontalSpeed = 0;
                _normalizedVerticalSpeed   = 0;
            }

            GetComponentInChildren <CircleCollider2D>().enabled = IsScouting == false;

            if (_fireplace != null)
            {
                _controller.ResetVariables();
                _timeAwayFromPlayer = 0;

                if (OnPoint())
                {
                    MoveTowardsPoint();
                    MovementState.MovementOverridden = false;

                    if (_isFireplaceActive)
                    {
                        ActivatePoint();
                        _isFireplaceActive = false;
                    }

                    if (_fireplace.IsLit && _fireplaceWasLit == false && IsScouting == false)
                    {
                        _controller.EnterFireplace(_fireplace);
                        _fireplaceWasLit = true;
                    }
                    else if (_fireplace.IsLit == false && _fireplaceWasLit && IsScouting == false)
                    {
                        _controller.LeaveFireplace(_fireplace);
                        _fireplaceWasLit = false;
                    }
                }
                else if (OnPoint() == false && MovementState.MovementOverridden == false)
                {
                    if (_fireplace.IsLit && IsScouting == false)
                    {
                        _controller.LeaveFireplace(_fireplace);
                    }

                    _fireplaceWasLit = false;
                    LeaveSpot();
                }
                else
                {
                    MoveTowardsPoint();
                }
            }
            else if (_controller.IsWithinPlayerDistance() == false)
            {
                if (AbilityState.IsActive(Ability.Scout))
                {
                    if (_controller.IsWithinScoutingDistance())
                    {
                        if (IsScouting == false)
                        {
                            _controller.DecreaseVariables(0);
                        }
                        IsScouting = true;
                    }
                    else
                    {
                        DestroyObject(gameObject);
                    }
                }
                else
                {
                    DecreaseOverTimeDependingOnStability();
                    IsScouting = false;
                }
            }
            else
            {
                _controller.ResetVariables();
                _timeAwayFromPlayer = 0;
                IsScouting          = false;
            }
        }