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()); } } }
override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) { _isAttacking = false; _damageDealerComponent = animator.GetComponentInParent <DamageDealerComponent>(); _interactableComponent = animator.GetComponentInParent <InteractableComponent>(); _damageTakerComponent = animator.GetComponentInParent <DamageTakerComponent>(); }
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); }
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>(); } }
protected override void SetInitialValues() { _hasTurnedIntoAMob = false; _damageDealerComponent = this.GetComponent <DamageDealerComponent>(); _mobAnimator = this.GetComponent <Animator>(); _damageTakerComponent = this.GetComponent <DamageTakerComponent>(); }
public void GetHurt(DamageDealerComponent damageDealer) { SFXManager.GetInstance().PlayFX("Impact"); var healthComponent = GetComponent <AbstractVulnerableComponent>(); if (healthComponent != null) { healthComponent.GetDamaged(damageDealer.Damage); } if (OnHurtReaction != null) { OnHurtReaction(); } }
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)); }
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); }
public void TakeDamage(DamageDealerComponent damageDealer) { _healthComponent.ChangeHealth(damageDealer.Damage); }
protected override void SetInitialValues() { _damageDealerComponent = this.GetComponentInChildren <DamageDealerComponent>(); _bossAnimator = this.GetComponent <Animator>(); _damageTakerComponent = this.GetComponent <DamageTakerComponent>(); }
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; } }