Exemplo n.º 1
0
 private void CastTo(ElementBall magic, Vector3 direction)
 {
     magic.rigidbody.velocity = new Vector3(
         direction.x * magicSpeed,
         0f,
         direction.z * magicSpeed);
 }
Exemplo n.º 2
0
    private void ProcessDamage(Collider other)
    {
        damage = other.GetComponent <ElementBall>();
        var _modifiedDamage = ModifyDamageByStatus(damage.CombinedMagicDamage);

        enemyHealth -= _modifiedDamage;
        healthBar.SetHealth(enemyHealth);

        if (enemyHealth <= 0)
        {
            SpawnElement();
            enemyCounter.EnemyCountDecrease();
            Destroy(gameObject);
        }
        else
        {
            enemyStatus   = ChangeEnemyStatus(damage.CombinedMagicType);
            textMesh.text = enemyStatus.ToString();
        }
    }
Exemplo n.º 3
0
    private void Update()
    {
        var speedPercent = _agent.velocity.magnitude / _agent.speed;

        _animator.SetFloat(SpeedPercent, speedPercent, 0.1f, Time.deltaTime);

        var ray = _camera.ScreenPointToRay(Input.mousePosition);

        if (!Physics.Raycast(ray.origin, ray.direction, out _hitInfo))
        {
            return;
        }
        if (Input.GetMouseButtonDown(1)) // right mouse
        {
            _agent.destination = _hitInfo.point;
        }
        else if (Input.GetMouseButtonDown(0)) // left mouse
        {
            print(_hitInfo.point);
            print(_hitInfo.collider.name);

            var direction = StopMovementAndGetFaceDirection();
            if (elementBag.LeadElementAvailable())
            {
                _magic = GenerateSpell();
                CastTo(_magic, direction);
            }
            else
            {
                print("Press space to assign a lead element to be able to cast spell");
            }
        }

        if (Math.Abs(speedPercent) < Mathf.Epsilon)
        {
            _animator.SetFloat(SpeedPercent, 0f);
        }
    }