private NodeState ForwardSwing(float p_delta, Vector3Int p_anchorPoint, Script_IEntity p_attackerEntity, Script_IEntity p_targetEntity) { GameObject attackerObject = p_attackerEntity.GetGameObject(); GameObject targetObject = p_targetEntity.GetGameObject(); Vector3 forwardSwingPoint = (targetObject.transform.position - attackerObject.transform.position).normalized; Vector3 nextPosition = attackerObject.transform.position + (forwardSwingPoint * p_delta); float forwardSwingSpeed = p_attackerEntity.GetStats()._attackSpeed * 3; if (Vector3.Distance(p_anchorPoint, nextPosition) > _swingDistance) { attackerObject.transform.position = p_anchorPoint + (forwardSwingPoint * _swingDistance); Script_Projectile projectile = new Script_Projectile(_manager, p_attackerEntity, p_targetEntity, _projectileColor); _manager.CreateProjectile(projectile as Script_IProjectile); _tree.SetBlackboardElement(_isForwardSwingFlag, false); return(NodeState.Success); } else { attackerObject.transform.position += forwardSwingPoint * p_delta * forwardSwingSpeed; } return(NodeState.Running); }
public override NodeState RunNode(float p_delta) { Script_IEntity targetEntity = _tree.GetBlackBoardElement <Script_IEntity>(_targetEnemyFlag); bool isForwardSwing = _tree.GetBlackBoardElement <bool> (_isForwardSwingFlag); if (targetEntity == null || targetEntity.GetGameObject() == null) { return(NodeState.Failed); } if (isForwardSwing) { NodeState success = ForwardSwing(p_delta, _entityToAttack.GetGridLocation(), _entityToAttack, targetEntity); if (success == NodeState.Success) { targetEntity.TakeDamage(_entityToAttack, _entityToAttack.GetStats()._damage); return(NodeState.Success); } } else if (!isForwardSwing) { BackSwing(p_delta, _entityToAttack.GetGridLocation(), _entityToAttack, targetEntity); } return(NodeState.Running); }
private NodeState ForwardSwing(float p_delta, Vector3Int p_anchorPoint, Script_IEntity p_attackerEntity, Script_IEntity p_targetEntity) { GameObject attackerObject = p_attackerEntity.GetGameObject(); GameObject targetObject = p_targetEntity.GetGameObject(); Vector3 forwardSwingPoint = (targetObject.transform.position - attackerObject.transform.position).normalized; Vector3 nextPosition = attackerObject.transform.position + (forwardSwingPoint * p_delta); float forwardSwingSpeed = p_attackerEntity.GetStats()._attackSpeed * 3; float upSwingSpeed = forwardSwingSpeed * 0.5f; if (attackerObject == targetObject) { NodeState state = JumpForwardAnimation(p_attackerEntity, upSwingSpeed); if (state == NodeState.Success) { return(state); } } else { if (Vector3.Distance(p_anchorPoint, nextPosition) > _swingDistance) { attackerObject.transform.position = p_anchorPoint + (forwardSwingPoint * _swingDistance); _tree.SetBlackboardElement(_isForwardSwingFlag, false); return(NodeState.Success); } else { attackerObject.transform.position += forwardSwingPoint * p_delta * forwardSwingSpeed; } } return(NodeState.Running); }
public override NodeState RunNode(float p_delta) { Script_IEntity targetEntity = _tree.GetBlackBoardElement <Script_IEntity>(_targetEnemyFlag); bool isForwardSwing = _tree.GetBlackBoardElement <bool> (_isForwardSwingFlag); if (targetEntity == null || targetEntity.GetGameObject() == null) { return(NodeState.Failed); } if (isForwardSwing) { NodeState success = ForwardSwing(p_delta, _entityToAttack.GetGridLocation(), _entityToAttack, targetEntity); if (success == NodeState.Success) { Script_HealingVisualEffect healingEffect = new Script_HealingVisualEffect(_manager, targetEntity); _manager.CreateVisual(healingEffect); targetEntity.Heal(_entityToAttack.GetStats()._healPower); return(NodeState.Success); } } else if (!isForwardSwing) { BackSwing(p_delta, _entityToAttack.GetGridLocation(), _entityToAttack, targetEntity); } return(NodeState.Running); }
private NodeState BackSwing(float p_delta, Vector3Int p_anchorPoint, Script_IEntity p_attackerEntity, Script_IEntity p_targetEntity) { GameObject attackerObject = p_attackerEntity.GetGameObject(); GameObject targetObject = p_targetEntity.GetGameObject(); Vector3 backSwingPoint = (attackerObject.transform.position - targetObject.transform.position).normalized; Vector3 nextPosition = attackerObject.transform.position + (backSwingPoint * p_delta); float backSwingSpeed = p_attackerEntity.GetStats()._attackSpeed; float downSwingSpeed = backSwingSpeed * 0.5f; if (attackerObject == targetObject) { JumpDownAnimation(p_attackerEntity, downSwingSpeed); } else { if (Vector3.Distance(p_anchorPoint, nextPosition) > _swingDistance) { attackerObject.transform.position = p_anchorPoint + (backSwingPoint * _swingDistance); _tree.SetBlackboardElement(_isForwardSwingFlag, true); } else { attackerObject.transform.position += backSwingPoint * p_delta * backSwingSpeed; } } return(NodeState.Running); }
private void MoveTowardsEntity(Script_IEntity p_attackerEntity, Script_IEntity p_toEntity, float p_delta) { Vector3 movementDirection = (p_toEntity.GetPosition() - _projectileObject.transform.position).normalized; Vector3 nextStep = _projectileObject.transform.position + (movementDirection * _speed * Time.deltaTime); if (Vector3.Distance(nextStep, p_toEntity.GetPosition()) >= Vector3.Distance(_projectileObject.transform.position, p_toEntity.GetPosition())) { _projectileObject.transform.position = p_toEntity.GetPosition(); p_toEntity.TakeDamage(p_attackerEntity, _startEntity.GetStats()._damage); Destruction(); } if (Vector3.Distance(nextStep, p_toEntity.GetPosition()) < Vector3.Distance(_projectileObject.transform.position, p_toEntity.GetPosition())) { _projectileObject.transform.position = nextStep; } }