コード例 #1
0
        IEnumerator DefenseOperation(DamageDealerComponent damageDealer)
        {
            float _internalCdw = 0f;

            if (damageDealer != null)
            {
                InteractableComponent enemyInteractableComponent = damageDealer.GetComponent <InteractableComponent>();

                while (_internalCdw <= damageDealer.CdwDamage)
                {
                    _internalCdw += Time.deltaTime;
                    yield return(new WaitForFixedUpdate());
                }

                if (enemyInteractableComponent.IsAttackingThisMonster(this.GetInstanceID()) && _readyToCombat)
                {
                    damageDealer.StartAtackAnimation(this);
                    StartCoroutine(DefenseOperation(damageDealer));
                }
                else
                {
                    _instanceIdEnemyList.Remove(damageDealer.GetInstanceID());
                }
            }
        }
コード例 #2
0
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     _isAttacking           = false;
     _damageDealerComponent = animator.GetComponentInParent <DamageDealerComponent>();
     _interactableComponent = animator.GetComponentInParent <InteractableComponent>();
     _damageTakerComponent  = animator.GetComponentInParent <DamageTakerComponent>();
 }
コード例 #3
0
        public bool StartCombat(DamageDealerComponent damageDealer)
        {
            if (!_readyToCombat)
            {
                return(false);
            }

            PlayerStructure playerStructure = _playerState.GetActivePlayerStructure();

            InteractableComponent interactableComponent = playerStructure.GetInteractableComponent();

            if (interactableComponent is null)
            {
                return(false);
            }
            if (!interactableComponent.CheckIfCanAtack())
            {
                return(false);
            }

            damageDealer.event_AlertAttack.Invoke();
            interactableComponent.SetInteractableState(EnumInteractableState.Atack, this.GetInstanceID());

            // Go to the correct position to attack
            playerStructure.GetMovementMouseComponent().ObjectGoTo(this.transform.position, _colliderToStopMovement.GetInstanceID());

            return(true);
        }
コード例 #4
0
        protected override void SetInitialValues()
        {
            _animatorVariables = new PlayerAnimatorVariables();
            _cinemachine       = GameObject.FindObjectOfType <CinemachineVirtualCamera>();
            _uIManager         = GameObject.FindObjectOfType <UIManager>();
            _playerStateManage = GameObject.FindObjectOfType <PlayerStateManager>();
            _activePlayerUI    = GameObject.FindObjectOfType <ActivePlayersUIComponent>();
            _animator          = this.GetComponent <Animator>();
            _audioComponent    = this.GetComponent <AudioComponent>();

            _damageDealerComponent = this.GetComponent <DamageDealerComponent>();
            _damageTakerComponent  = this.GetComponent <DamageTakerComponent>();

            _miniMapComponent = GameObject.FindObjectOfType <MiniMapComponent>();


            if (_canMoveByClick)
            {
                _movementMouseComponent = this.GetComponent <MovementMouseComponent>();
            }
            if (_canInteract)
            {
                _interactableComponent = this.GetComponent <InteractableComponent>();
            }
            if (_canPoop)
            {
                _stomachComponent = this.GetComponent <StomachComponent>();
            }
        }
コード例 #5
0
 protected override void SetInitialValues()
 {
     _hasTurnedIntoAMob     = false;
     _damageDealerComponent = this.GetComponent <DamageDealerComponent>();
     _mobAnimator           = this.GetComponent <Animator>();
     _damageTakerComponent  = this.GetComponent <DamageTakerComponent>();
 }
コード例 #6
0
ファイル: HurtComponent.cs プロジェクト: Morgawr/LD46
    public void GetHurt(DamageDealerComponent damageDealer)
    {
        SFXManager.GetInstance().PlayFX("Impact");
        var healthComponent = GetComponent <AbstractVulnerableComponent>();

        if (healthComponent != null)
        {
            healthComponent.GetDamaged(damageDealer.Damage);
        }
        if (OnHurtReaction != null)
        {
            OnHurtReaction();
        }
    }
コード例 #7
0
        public void StartDefenseOperation(DamageDealerComponent damageDealer)
        {
            if (damageDealer is null)
            {
                return;
            }
            if (_instanceIdEnemyList.Any(e => e == damageDealer.GetInstanceID()))
            {
                return;
            }
            _instanceIdEnemyList.Add(damageDealer.GetInstanceID());

            StartCoroutine(DefenseOperation(damageDealer));
        }
コード例 #8
0
        private void Attack(Collider2D collision)
        {
            DamageTakerComponent damageTakerComponent = collision.gameObject.GetComponentInParent <DamageTakerComponent>();

            if (damageTakerComponent == null)
            {
                return;
            }
            if (damageTakerComponent.GetInstanceID() != _interactableInstanceId)
            {
                return;
            }

            DamageDealerComponent damageDealer = this.GetComponent <DamageDealerComponent>();

            damageTakerComponent.StartDefenseOperation(damageDealer);
        }
コード例 #9
0
 public void TakeDamage(DamageDealerComponent damageDealer)
 {
     _healthComponent.ChangeHealth(damageDealer.Damage);
 }
コード例 #10
0
 protected override void SetInitialValues()
 {
     _damageDealerComponent = this.GetComponentInChildren <DamageDealerComponent>();
     _bossAnimator          = this.GetComponent <Animator>();
     _damageTakerComponent  = this.GetComponent <DamageTakerComponent>();
 }
コード例 #11
0
        private void ManageMouseUniqueLeftClick()
        {
            if (_inputManager.MouseLeftButton == 1 && !_leftButtomPressed)
            {
                _leftButtomPressed = true;
                _audioComponent.PlayAudio("click");

                List <IInteractable>   interactableList        = new List <IInteractable>();
                List <Button>          buttonList              = new List <Button>();
                List <IPlayer>         playersList             = new List <IPlayer>();
                InventorySlotComponent _inventorySlotComponent = null;

                bool hitSomeUIComponent = false;
                _canMove = true;

                Vector2 mousePosition = this.ManageMouseClick((hitUI) =>
                {
                    hitSomeUIComponent = true;
                    if (_inventorySlotComponent is null)
                    {
                        _inventorySlotComponent = hitUI.gameObject.GetComponent <InventorySlotComponent>();
                    }
                },
                                                              (hit) =>
                {
                    buttonList.AddRange(hit.collider.gameObject.GetComponents <Button>());
                    interactableList.AddRange(hit.collider.gameObject.GetComponents <IInteractable>().Where(e => e.PlayerInteractWith).ToList());
                    playersList.AddRange(hit.collider.gameObject.GetComponents <IPlayer>().ToList());
                });
                // => UI INTERACTIONS
                if (_inventorySlotComponent != null)
                {
                    _inventorySlotComponent.StartInteraction();
                }

                if (hitSomeUIComponent)
                {
                    return;
                }

                // => NORMAL INTERACTIONS
                IInteractable interactableChoice = interactableList.OrderBy(e => e.Order()).FirstOrDefault();

                if (playersList.Any() && interactableChoice is IDamageTaker)
                {
                    interactableChoice = interactableList.Where(e => !(e is IDamageTaker)).OrderBy(e => e.Order()).FirstOrDefault();
                }

                if (interactableChoice is IDamageTaker damagable)
                {
                    DamageDealerComponent damageDealerComponent = _playerStateManager.GetActivePlayerStructure().GetDamageDealerComponent();

                    if (damageDealerComponent is null)
                    {
                        return;
                    }

                    damagable.StartCombat(damageDealerComponent);
                }

                if (interactableChoice is IPickable pickable)
                {
                    pickable.PickUp();
                }

                if (interactableChoice is IPlantable plantable)
                {
                    plantable.Interact();
                }
            }
            else if (_inputManager.MouseLeftButton == 0 && _leftButtomPressed)
            {
                _leftButtomPressed = false;
            }
        }