Пример #1
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0) && controller.hasBow && !controller.gameManager.GamePaused)
        {
            shoot   = true;
            waiting = 0.5f;
            controller.SetAllAnims("shoot");
            tempDestination = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            CheckFlip(tempDestination.x);
        }

        if (shoot)
        {
            if (waiting > 0)
            {
                waiting -= Time.deltaTime;
            }
            else
            {
                _audi.PlayOneShot(BowShoot);

                Vector3 mouseWorldPos = tempDestination;

                bool    inrange;
                Vector3 tempStartPos;
                if (controller.partsOfBody[0].flipX)
                {
                    tempStartPos = new Vector3(ArrowStartPosition.position.x - 2.8f, ArrowStartPosition.position.y, ArrowStartPosition.position.z);
                }
                else
                {
                    tempStartPos = ArrowStartPosition.position;
                }
                Vector3 direction = DirectionOfLaunchForArc(mouseWorldPos, tempStartPos, speed, false, out inrange);


                Rigidbody2D newarrow = PoolManager.getGameObjectFromPool(ArrowPrefab).GetComponent <Rigidbody2D>();
                newarrow.GetComponent <SpriteRenderer>().flipX = controller.SR.flipX;
                newarrow.transform.position = tempStartPos;
                newarrow.velocity           = transform.TransformDirection(direction * speed * 1.7f);
                ArrowScript newArrow = newarrow.GetComponent <ArrowScript>();
                newArrow.SetNewArrow();
                newArrow.Hunter       = controller;
                newArrow.timer        = 5f;
                newArrow.Timberwolf1  = Timberwolf1;
                newArrow.Timberwolf2  = Timberwolf2;
                newArrow.Ursa         = Ursa;
                newArrow.unicornSpawn = UniSpawn;
                newArrow.pegasusSpawn = PegaSpawn;
                shoot = false;
            }
        }
    }
Пример #2
0
    void CheckShooting()
    {
        if (shoot)
        {
            if (waiting > 0)
            {
                waiting -= Time.deltaTime;
            }
            else
            {
                _audi.PlayOneShot(BowShoot);

                Vector3 mouseWorldPos = tempDestination;
                bool    inrange;
                Vector3 tempStartPos;
                if (SR.flipX)
                {
                    tempStartPos = new Vector3(ArrowStartPosition.position.x - 2.8f, ArrowStartPosition.position.y, ArrowStartPosition.position.z);
                }
                else
                {
                    tempStartPos = ArrowStartPosition.position;
                }
                Vector3 direction = ArrowTest.DirectionOfLaunchForArc(mouseWorldPos, tempStartPos, speed, false, out inrange);

                Rigidbody2D newarrow = PoolManager.getGameObjectFromPool(ArrowPrefab).GetComponent <Rigidbody2D>();
                newarrow.GetComponent <SpriteRenderer>().flipX = SR.flipX;
                newarrow.transform.position = tempStartPos;
                newarrow.velocity           = transform.TransformDirection(direction * speed * 2.2f);
                ArrowScript newArrow = newarrow.GetComponent <ArrowScript>();
                newArrow.Hunter = this;
                newArrow.SetNewArrow();
                newArrow.timer        = 5f;
                newArrow.unicornSpawn = UniSpawn;
                newArrow.pegasusSpawn = PegaSpawn;
                newArrow.Timberwolf1  = Timberwolf1;
                newArrow.Timberwolf2  = Timberwolf2;
                newArrow.Ursa         = ursa;
                shoot = false;
            }
        }
    }