private void FixedUpdate()
 {
     if (!DetectionUtils.IsOnPauseButton(position))
     {
         var lookDirection = position - rb.position;
         var angle         = Mathf.Atan2(lookDirection.y, lookDirection.x) * Mathf.Rad2Deg;
         rb.rotation = angle;
     }
 }
Exemple #2
0
    private void Update()
    {
        if (Input.touchCount != 0 || Input.GetButton("Fire1"))
        {
            if (!DetectionUtils.IsOnPauseButton(DetectionUtils.GetOnScreenInputPosition()))
            {
                if (timeBeforeNextShot <= 0)
                {
                    //TODO REMOVEEE

                    /*CannonPart part = _cannonPartFactory.GetCommonBoxPart();
                     * if (part is CannonBase)
                     * {
                     *  CannonBase cannonBase = part as CannonBase;
                     *  Debug.Log("CannonBase: Name = [" + cannonBase.Name + "], Dmg = [" + cannonBase.Damage +
                     *            "], AS = [" + cannonBase.AttackSpeed + "], PS = [" + cannonBase.ProjectileSpeed +
                     *            "], Rang = [" + cannonBase.Rang + "]");
                     * }
                     * else if (part is Barrel)
                     * {
                     *  Barrel barrel = part as Barrel;
                     *  Debug.Log("Barrel: Name = [" + barrel.Name + "], DmgMult = [" + barrel.DamageMultiplier +
                     *            "], ASMult = [" + barrel.AttackSpeedMultiplier + "], Addit = [" + barrel.AdditionalShotsAmount +
                     *            "], Rang = [" + barrel.Rang + "]");
                     * }*/

                    Shoot();
                    GetShotAnimator().SetTrigger(ShootTrigger);
                    timeBeforeNextShot = 1f / _playerState.CurrentCannonLoadout.AttackSpeed;
                    Debug.Log(_playerState.CurrentBase);
                }
                else
                {
                    timeBeforeNextShot -= Time.deltaTime;
                }
            }
        }
        else
        {
            if (timeBeforeNextShot >= 0.1f)
            {
                timeBeforeNextShot -= Time.deltaTime;
            }
        }
    }
    private void Update()
    {
//        if (Input.touchCount != 0)
//        {
//            var touch = Input.GetTouch(0);
//            position = Camera.main.ScreenToWorldPoint(touch.position);
//        }
//        else if (Input.GetMouseButton(0))
//        {
//            position = Camera.main.ScreenToWorldPoint(Input.mousePosition);
//        }

        if (!PauseMenu.GameIsPaused && (Input.touchCount != 0 || Input.GetMouseButton(0)))
        {
            Vector2 positionToSet = DetectionUtils.GetOnScreenInputPosition();
            if (!Vector2.negativeInfinity.Equals(positionToSet))
            {
                position = positionToSet;
            }
        }
    }