Example #1
0
        public virtual bool TryInteract(LinkBeam linkBeam)
        {
            if (linkBeam.Strength >= _toughness)
            {
                if ((!Activated || !_permanent) &&
                    !_hitTimer.Active)
                {
                    Activated = true;
                    _hitTimer.Activate();

                    if (_playSoundWhenActivated)
                    {
                        if (!_hasPlayedActivateSound)
                        {
                            SFXPlayer.Instance.Play(_activateSound, volumeFactor: _volumeFactor);

                            _hasPlayedActivateSound = true;
                        }
                    }

                    return(true);
                }
            }

            return(false);
        }
Example #2
0
        public bool HandleActionInput()
        {
            bool inputHeld         = false;
            bool inputjustReleased = false;

            Input.GetActionInput(out inputHeld, out inputjustReleased);
            bool result = false;

            if (LinkBeam != null)
            {
                if (inputjustReleased)
                {
                    if (!IsLinkTarget)
                    {
                        // TODO: Can the link beam link also to certain level objects?
                        LinkBeam.Activate(!LinkBeam.Active, _otherPlayer);
                    }
                    else
                    {
                        LinkedLinkBeam.Activate(false);
                    }
                }

                // Starts link start-up/shutdown animation
                //Animator.SetBool("Link Active", Link.Active);

                result = LinkBeam.Active;
            }

            return(result);
        }
Example #3
0
        protected virtual void AttachToBeam(bool attach, LinkBeam linkBeam = null)
        {
            if (AttachedToBeam != attach)
            {
                if (!attach && TargetLinkBeam != null)
                {
                    TargetLinkBeam.linkInteractables.Remove(this);
                    FallToGround();
                }

                AttachedToBeam = attach;
                TargetLinkBeam = linkBeam;
                _toughnessLeft = _toughness;
                _speed         = _defaultSpeed;
                _hitTimer.Reset();

                if (attach)
                {
                    linkBeam.linkInteractables.Add(this);

                    if (_playSoundWhenAttachedToBeam)
                    {
                        SFXPlayer.Instance.Play(_attachSound, volumeFactor: _volumeFactor);
                    }
                }
                else if (_playSoundWhenDetachedFromBeam)
                {
                    SFXPlayer.Instance.Play(_detachSound, volumeFactor: _volumeFactor);
                }
            }
        }
Example #4
0
        protected virtual void AttachToBeam(bool attach, LinkBeam linkBeam = null)
        {
            if (AttachedToBeam != attach)
            {
                //if (attach)
                //{
                //    Debug.Log("Attached to " + linkBeam.Player.name + "'s beam");
                //}
                //else
                //{
                //    Debug.Log("Detached from " + TargetLinkBeam.Player.name + "'s beam");
                //}

                if (!attach && TargetLinkBeam != null)
                {
                    TargetLinkBeam.linkInteractables.Remove(this);
                }

                AttachedToBeam = attach;
                TargetLinkBeam = linkBeam;
                _toughnessLeft = _toughness;
                _speed         = _defaultSpeed;
                _moveForward   = true; // TODO
                _hitTimer.Reset();

                if (attach)
                {
                    linkBeam.linkInteractables.Add(this);
                }
            }
        }
Example #5
0
 /// <summary>
 /// Starts moving the object.
 /// </summary>
 public void StartMoving(LinkBeam linkBeam, Vector3 currentPosition)
 {
     this.linkBeam = linkBeam;
     position      = currentPosition;
     isMoving      = true;
     beamReached   = false;
 }
Example #6
0
        /// <summary>
        /// Initializes the object.
        /// </summary>
        private void Start()
        {
            if (_player1SpawnPoint == null)
            {
                Debug.LogError(Utils.GetFieldNullString("Player 1 spawn point"));
            }
            if (_player2SpawnPoint == null)
            {
                Debug.LogError(Utils.GetFieldNullString("Player 2 spawn point"));
            }

            _ui                  = GameManager.Instance.GetUI();
            _currentLevel        = GameManager.Instance.CurrentLevel;
            _ui.levelName.text   = _currentLevel.LevelName;
            _levelTimer          = new Timer(_levelTime, true);
            _hurryUpWarnTimer    = new Timer(_hurryUpWarnFlashTime, true);
            _scoreMultDecayTimer = new Timer(_scoreMultiplierDecayTime, true);

            _lb = FindObjectOfType <LinkBeam>();

            orichalcumPickupPool = new Pool <OrichalcumPickup>(128, true, orichalcumPickupPrefab);
            stoneDebrisPool      = new Pool <Debris>(128, true, stoneDebrisPrefabArray);
            woodDebrisPool       = new Pool <Debris>(64, true, woodDebrisPrefabArray);
            terracottaDebrisPool = new Pool <Debris>(128, true, terracottaDebrisPrefabArray);
        }
Example #7
0
 public bool TryInteract(LinkBeam linkBeam)
 {
     if (!mtb.isMoving)
     {
         mtb.StartMoving(linkBeam, _movableObject.position);
     }
     return(true);
 }
Example #8
0
 public bool TryInteract(LinkBeam linkBeam)
 {
     if (!mtb.isMoving)
     {
         mtb.StartMoving(linkBeam, transform.position);
     }
     return(true);
 }
Example #9
0
        public virtual bool TryInteractInstant(LinkBeam linkBeam)
        {
            if (!IsDestroyed && linkBeam.Strength >= _toughness)
            {
                Destroy();
                return(true);
            }

            return(false);
        }
Example #10
0
 /// <summary>
 /// Initializes the object.
 /// </summary>
 protected override void Start()
 {
     base.Start();
     LinkBeam = GetComponentInChildren <LinkBeam>();
     LinkBeam.Init(this, ActivateShield);
     LinkObject     = LinkBeam.gameObject;
     Animator       = GetComponentInChildren <Animator>();
     ShieldAnimator = ShieldModel.GetComponent <Animator>();
     _otherPlayer   = GameManager.Instance.GetAnyOtherPlayer(this, true);
 }
Example #11
0
        public bool TryInteractInstant(LinkBeam linkBeam)
        {
            if (linkBeam.Strength >= _toughness)
            {
                _toughnessLeft = 0f;
                Collect(linkBeam.Player);
                return(true);
            }

            return(false);
        }
Example #12
0
        public virtual bool TryInteractInstant(LinkBeam linkBeam)
        {
            if (linkBeam.Strength >= _toughness)
            {
                _toughnessLeft = 0f;
                AttachToBeam(true, linkBeam);
                return(true);
            }

            return(false);
        }
Example #13
0
        /// <summary>
        /// Resets things common to both ResetBaseValues() and CancelActions().
        /// </summary>
        private void ResetCommon()
        {
            IsLinkTarget   = false;
            LinkedLinkBeam = null;
            Jumping        = false;
            Respawning     = false;

            if (LinkBeam != null)
            {
                LinkBeam.ResetLinkBeam();
            }
        }
Example #14
0
        public bool HandleAltActionInput()
        {
            bool active = Input.GetAltActionInput();
            bool result = false;

            if (active && BeamOn)
            {
                if (LinkBeam != null)
                {
                    LinkBeam.Pulse();
                }
            }

            return(result);
        }
Example #15
0
        public virtual bool TryInteract(LinkBeam linkBeam)
        {
            if (available && !AttachedToBeam && !_hitTimer.Active)
            {
                _toughnessLeft -= linkBeam.Strength;
                if (_toughnessLeft <= 0f)
                {
                    _toughnessLeft = 0f;
                    AttachToBeam(true, linkBeam);
                    return(true);
                }
                else
                {
                    _hitTimer.Activate();
                }
            }

            return(false);
        }
Example #16
0
        public virtual bool TryInteract(LinkBeam linkBeam)
        {
            if (!IsDestroyed && !_hitTimer.Active)
            {
                //Debug.Log("collectStrength: " + collectStrength);
                _toughnessLeft -= linkBeam.Strength;
                if (_toughnessLeft <= 0f)
                {
                    Destroy();
                    return(true);
                }
                else
                {
                    _hitTimer.Activate();

                    if (_regenMode != ToughnessRegenMode.Off)
                    {
                        _regenTimer.Activate();
                    }
                }
            }

            return(false);
        }
Example #17
0
 public virtual bool TryInteractInstant(LinkBeam linkBeam)
 {
     return(TryInteract(linkBeam));
 }
Example #18
0
 /// <summary>
 /// Stops moving the object.
 /// </summary>
 public void StopMoving()
 {
     linkBeam    = null;
     isMoving    = false;
     beamReached = false;
 }
Example #19
0
 public bool GivePulse(LinkBeam linkBeam, float speedModifier)
 {
     return(false);
 }
Example #20
0
 public bool TryInteractInstant(LinkBeam linkBeam)
 {
     return(false);
 }
Example #21
0
 public bool TryInteract(LinkBeam linkBeam)
 {
     return(TryInteract(linkBeam.Player, linkBeam.Strength));
 }
Example #22
0
 public bool GivePulse(LinkBeam linkBeam, float speedModifier)
 {
     _speed = Mathf.Abs(_defaultSpeed * speedModifier);
     SetDirection(speedModifier > 0f);
     return(true);
 }