Beispiel #1
0
    public void DamageTakingAnimation(float angle, float force) // alinan hasarin gorsel sekli
    {
        Vector2 direction = CommonCalculateFunctions.FromAngleToDirection(angle);

        _rb.AddForce(direction * 100);
        _animationScript.DamageTaking();
    }
Beispiel #2
0
 public void FireTarget() // Menzil ekle .
 {
     if (target.magnitude != 0)
     {
         Vector2 direction = CommonCalculateFunctions.FromVectorsToDirection(target, transform.position);
         Attack(direction);
     }
 }
    private void Attack()
    {
        bool rotateControl = _animationScript.Attack();

        _healingSmokeParticle.Play();
        if (rotateControl)
        {
            RotateEnemy(CommonCalculateFunctions.FromVectorsToDirection(_target.position, transform.position));
        }
    }
Beispiel #4
0
 private void Attack(Vector2 direction)
 {
     if (Math.Abs(direction.magnitude) > 0)
     {
         float angle = CommonCalculateFunctions.FromDirectionToAngle(direction);
         lastTopPartAngle = angle;
         RotateTopPart(angle);
         BottomRotateControl(angle);
         _gun.Fire(angle);
     }
 }
Beispiel #5
0
    private void Attack()
    {
        _animationScript.Attack();
        _animationScript.Move(false);
        bool rotateControl = _animationScript.Attack();

        if (rotateControl)
        {
            RotateEnemy(CommonCalculateFunctions.FromVectorsToDirection(_target.position, transform.position));
        }
    }
Beispiel #6
0
 public void Attack(Vector2 direction)
 {
     if (Math.Abs(direction.magnitude) > 0)    //direction boyutunu ölçmek şuan için anlamsız.
     {
         float angle = CommonCalculateFunctions.FromDirectionToAngle(direction);
         RotateTurret(angle);
         if (turretRotateIsComplete)
         {
             Fire(angle);
         }
     }
 }
    public IEnumerator TurretRotatingEffect(float targetAngle)
    {
        turretRotateIsComplete = false;
        float   currentAngle, addedAngleCounter = 0;
        Vector3 tempRotateSpeed = Vector3.forward * rotateSpeed;

        currentAngle = CommonCalculateFunctions.PositiveAngleConverter(_transform.eulerAngles.z);
        targetAngle  = CommonCalculateFunctions.PositiveAngleConverter(targetAngle);

        if (currentAngle == targetAngle)
        {
            turretRotateIsComplete = true;
            yield break;
        }

        bool isItTurningLeftControl = IsItTurningLeft(currentAngle, targetAngle);

        if (isItTurningLeftControl)
        {
            while (true)
            {
                if ((addedAngleCounter + tempRotateSpeed.z) >= targetPathValue)
                {
                    _transform.eulerAngles = _transform.eulerAngles + Vector3.forward * (targetPathValue - addedAngleCounter);
                    turretRotateIsComplete = true;
                    yield break;
                }
                _transform.eulerAngles = _transform.eulerAngles + tempRotateSpeed;
                addedAngleCounter     += tempRotateSpeed.z;
                yield return(new WaitForSeconds(0.05f));
            }
        }
        else
        {
            tempRotateSpeed = -tempRotateSpeed;
            while (true)
            {
                if ((addedAngleCounter + Math.Abs(tempRotateSpeed.z)) >= targetPathValue)
                {
                    _transform.eulerAngles = _transform.eulerAngles + Vector3.forward * (addedAngleCounter - targetPathValue);
                    turretRotateIsComplete = true;
                    yield break;
                }
                _transform.eulerAngles = _transform.eulerAngles + tempRotateSpeed;
                addedAngleCounter     += Math.Abs(tempRotateSpeed.z); // Value - olduğu için cıkarmak zorundayım.
                yield return(new WaitForSeconds(0.05f));
            }
        }
    }
    public bool IsItTurningLeft(float currentAngle, float targetAngle)
    {
        float leftPath = CommonCalculateFunctions.LeftPathCalculator(currentAngle, targetAngle);

        if (leftPath <= 180)
        {
            targetPathValue = leftPath;
            return(true);
        }
        else
        {
            float rightPath = 360 - leftPath;
            targetPathValue = rightPath;
            return(false);
        }
    }
    public bool IsAngleGreaterThanNinenty() // Top ve bot part arasindaki aci 90 dan buyukmu
    {
        float topPart    = CommonCalculateFunctions.PositiveAngleConverter(lastTopPartAngle);
        float bottomPart = CommonCalculateFunctions.PositiveAngleConverter(lastBottomPartAngle);
        float leftPath   = CommonCalculateFunctions.LeftPathCalculator(bottomPart, topPart);

        if (leftPath <= 180)
        {
            return(leftPath > 90);
        }
        else
        {
            float rightPath = 360 - leftPath;
            return(rightPath > 90);
        }
    }
Beispiel #10
0
    public void Move()
    {
        float angle = CommonCalculateFunctions.FromDirectionToAngle(movement);

        if (Math.Abs(movement.x) > 0 || Math.Abs(movement.y) > 0)
        {
            _rb.MovePosition(_rb.position + movement * moveSpeed * Time.fixedDeltaTime);
            lastBottomPartAngle = angle;

            backWalking    = IsAngleGreaterThanNinenty();
            forwardWalking = !backWalking;

            RotateBottomPart(angle);
            CreateDust(); // Particle burda olusturuluyor.
        }
        else
        {
            backWalking    = false;
            forwardWalking = false;
        }

        _playerAnimation.Move(backWalking, forwardWalking);
    }
Beispiel #11
0
    public void RotateEnemy(Vector2 _movementDirection)
    {
        float angle = CommonCalculateFunctions.FromDirectionToAngle(_movementDirection);

        _enemy.eulerAngles = Vector3.forward * (angle);
    }