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; } }
public Script_HealingVisualEffect(Script_GameManager p_manager, Script_IEntity p_entityToRecieveEffect) { _lifeTimer = 1.0f; _lifeTimerCurrent = 0.0f; _manager = p_manager; _effectObject = new GameObject(); _effectObject.name = "SheepObject"; _effectObject.transform.position = p_entityToRecieveEffect.GetPosition(); _textMesh = _effectObject.AddComponent <TextMesh> (); _textMesh.text = "Healing Target!"; _textMesh.fontSize = 8; _textMesh.color = Color.green; _textMesh.transform.rotation = Quaternion.Euler(90, 0, 0); _directionToMove = new Vector3(0.0f, 1.0f, 0.0f); }