Esempio n. 1
0
    void Update()
    {
        if (isInteracting)
        {
            float rotateHorizontal = Input.GetAxis(interactingPlayer.GetControls().GetHorizontal());

            float offset = base_rotation.eulerAngles.y;



            if (((transform.rotation.eulerAngles.y > AngleTo360(offset - MAX_ROTATION)) && rotateHorizontal < 0) ||
                ((transform.rotation.eulerAngles.y < AngleTo360(offset + MAX_ROTATION)) && rotateHorizontal > 0))
            {
                transform.Rotate(0, rotateHorizontal, 0, Space.Self);
                //arc.transform.Rotate(0, rotateHorizontal, 0, Space.World);
            }


            if (interactingPlayer != null && Input.GetButtonUp(interactingPlayer.GetControls().GetAction()))
            {
                if (firstClick)
                {
                    StartCoroutine(ClickWaiter());
                }
                else
                {
                    FactoryReset();
                }
            }

            if (isShooting)
            {
                shooting_strength += velocity_factor * Time.deltaTime;
                arc.velocity       = shooting_strength;
                arcArray           = arc.Render();
                Vector3 end = arcArray[arcArray.Length - 1] - arcArray[0];
                endCircle.transform.localPosition = new Vector3(endCircle.transform.localPosition.x, endCircle.transform.localPosition.y, end.x);
            }

            if (bullet != null && interactingPlayer != null && Input.GetButtonDown(interactingPlayer.GetControls().GetRelease()) && !disabled)
            {
                bullet.Load();
                isShooting        = true;
                shooting_strength = 10;
                arc.Render();
                endCircle.SetActive(true);
            }

            if (isShooting && interactingPlayer != null && Input.GetButtonUp(interactingPlayer.GetControls().GetRelease()))
            {
                endPosition = endCircle.transform.position;
                bullet.gameObject.SetActive(true);
                if (bullet.GetComponent <Bomb>() != null)
                {
                    Bomb b = bullet.GetComponent <Bomb>();
                    b.Disarm();
                    b.Clear();
                }
                bullet.GetComponent <BulletDrop>().DisablePhysics(true);
                bullet.GetComponent <Collider>().isTrigger = true;
                StartCoroutine(Shoot());
                shoot_rotation = transform.rotation;
                interactingPlayer.SetCurrentItem(null);
                bullet.SetCurrentPlayer(null);
                bullet.SetBoat(interactingPlayer.GetBoat());

                bullet.InitiateCountDown();
                bullet.transform.position = transform.position;
                FactoryReset(false);
            }
        }
    }