Exemple #1
0
        // --------------------------------------------------------------------------------------------
        public override void OnInspectorGUI()
        {
            if (EditorApplication.isPlaying)
            {
                string showHideButtonLabel = _showDebugControls ? "Hide Debug Tools" : "Show Debug Tools";
                if (GUILayout.Button(showHideButtonLabel))
                {
                    _showDebugControls = !_showDebugControls;
                }

                if (_showDebugControls)
                {
                    Destructible destructible = (Destructible)target;

                    _debugDamageType = (EDamageType)EditorGUILayout.EnumPopup(_debugDamageType);

                    if (GUILayout.Button("Take Damage"))
                    {
                        destructible.TakeDamage(_debugDamageType);
                    }
                }
            }

            base.OnInspectorGUI();
        }
Exemple #2
0
        // --------------------------------------------------------------------------------------------
        public override bool CanAttackDestructible(Destructible destructible)
        {
            if (!owner)
            {
                return(false);
            }

            if (Vector2.Distance(owner.transform.position, destructible.transform.position) > 1.1f)
            {
                return(false);
            }

            return(base.CanAttackDestructible(destructible));
        }
Exemple #3
0
        // --------------------------------------------------------------------------------------------
        public virtual bool CanAttackDestructible(Destructible destructible)
        {
            if (!owner)
            {
                return(false);
            }

            Actor destructibleActor = destructible.gameObject.GetComponentInParent <Actor>();

            if (destructibleActor)
            {
                return(!owner.IsAlliedWith(destructibleActor));
            }

            return(true);
        }
Exemple #4
0
        // --------------------------------------------------------------------------------------------
        private void OnOwnerInteracted(Interactable.InteractedEventInfo info)
        {
            if (_attackSequence != null)
            {
                return;
            }

            if (!owner.EquipedWeapon == this)
            {
                return;
            }

            Destructible destructible = info.interactedWith.GetComponent <Destructible>();

            if (!destructible)
            {
                return;
            }

            CurrentlyAttacking = destructible;

            _attackSequence = new TofuAnimation()
                              .Execute(() =>
            {
                PreAttackAnimation().Play();
            })
                              .Wait(_preAttackDelay)
                              .Then()
                              .Execute(() =>
            {
                DoAttack();
            })
                              .Then()
                              .Execute(() =>
            {
                PostAttackAnimation().Play();
            })
                              .Wait(_postAttackCooldown)
                              .Then()
                              .Execute(() =>
            {
                _attackSequence    = null;
                CurrentlyAttacking = null;
            })
                              .Play();
        }
Exemple #5
0
        // --------------------------------------------------------------------------------------------
        private void UpdateReticleColor()
        {
            Color changeTo = _defaultColor;

            Destructible facingDestructible = null;

            Collider2D[] facingColliders = Physics2D.OverlapCircleAll(_actor.transform.position + _actor.InteractOffset, 0.4f);
            foreach (Collider2D collider in facingColliders)
            {
                if (!facingDestructible && collider.gameObject != _actor.gameObject)
                {
                    facingDestructible = collider.gameObject.GetComponent <Destructible>();
                }
            }

            if (facingDestructible && _actor.EquipedWeapon && _actor.EquipedWeapon.CanAttackDestructible(facingDestructible))
            {
                changeTo = _attackColor;
            }

            if (!((Vector4)changeTo).IsApproximately(_targetColor))
            {
                Color startColor = _spriteRenderer.color;
                _targetColor = changeTo;

                _reticleColorAnimation?.Stop();
                _reticleColorAnimation = new TofuAnimation()
                                         .Value01(_colorAnimTime, EEaseType.EaseOutExpo, (float newValue) =>
                {
                    _currentColor = Color.LerpUnclamped(startColor, _targetColor, newValue);
                })
                                         .Then()
                                         .Execute(() =>
                {
                    _reticleColorAnimation = null;
                })
                                         .Play();
            }
        }