Esempio n. 1
0
    protected void RotateWeapon(Vector3 enemyPos)
    {
        Vector3 nearestEnemyPos = enemyPos;

        weaponAngle = MyUtils.GetAngle(nearestEnemyPos, this.transform.position);

        if (weaponHandler.CanRotateWeapon() == true)
        {
            if (weaponPosit != null)
            {
                weaponPosit.rotation = Quaternion.Euler(0f, 0f, weaponAngle);
            }
        }
        else
        {
            if (weaponPosit != null)
            {
                weaponPosit.rotation = Quaternion.Euler(0f, 0f, 0f);
            }
        }



        //flip
        if ((weaponAngle >= 0f && weaponAngle <= 90) ||
            weaponAngle >= 270f && weaponAngle <= 360)
        {
            if (weaponHandler != null)
            {
                if (weaponHandler.CanRotateWeapon() == true)
                {
                    weaponHandler.FlipWeapon(false);
                }

                FlipCharacter(true);
            }
        }
        else
        {
            if (weaponHandler != null)
            {
                if (weaponHandler.CanRotateWeapon() == true)
                {
                    weaponHandler.FlipWeapon(true);
                }

                FlipCharacter(false);
            }
        }
    }