Esempio n. 1
0
    public Vector3 PoolInput()
    {
        float h = stick.GetHorizontalValue();
        float v = stick.GetVerticalValue();

        if (this.transform.position.z > 17 && v > 0)
        {
            v = 0f;
        }
        if (this.transform.position.z < -7 && v < 0)
        {
            v = 0f;
        }

        if (this.transform.position.x > 21 && h > 0)
        {
            h = 0f;
        }
        if (this.transform.position.x < -21 && h < 0)
        {
            h = 0f;
        }


        Vector3 moveDir = new Vector3(h, 0, v).normalized;

        return(moveDir);
    }
Esempio n. 2
0
    public Vector3 PoolInput()
    {
        float   h       = joystick.GetHorizontalValue();
        float   v       = joystick.GetVerticalValue();
        Vector3 moveDir = new Vector3(h, v, 0).normalized;

        return(moveDir);
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        joystick stick = GetComponent <joystick>();

        if ((stick.GetHorizontalValue() != 0.0f ||
             stick.GetVerticalValue() != 0.0f) &&
            delay >= bulletdelay)
        {
            Vector3 gameWorldpos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            GameObject newPrefab = Instantiate(SomPrefab);
            newPrefab.transform.position             = startpoint.transform.position;
            newPrefab.GetComponent <bullet>().player = player;

            Vector2 direction = new Vector2(stick.GetHorizontalValue(), stick.GetVerticalValue());
            direction.Normalize();
            newPrefab.GetComponent <Rigidbody2D>().AddForce(direction * BulletSpeed);
            delay = 0.0f;
        }
    }
Esempio n. 4
0
    // Update is called once per frame
    void Update()
    {
        joystick stick = GetComponent <joystick>();

        if (stick.GetHorizontalValue() != 0.0f ||
            stick.GetVerticalValue() != 0.0f)
        {
            GetComponent <AudioSource>().Play();
        }
        else
        {
            GetComponent <AudioSource>().Stop();
        }
    }
Esempio n. 5
0
    // Update is called once per frame
    void Update()
    {
        joystick stick = GetComponent <joystick>();

        if ((stick.GetHorizontalValue() != 0.0f ||
             stick.GetVerticalValue() != 0.0f) &&
            delay >= bulletdelay)
        {
            if (PlayerPrefs.GetString("equip") == "gun-r2")
            {
                Vector3 gameWorldpos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

                GameObject newPrefab = Instantiate(SomPrefab);
                newPrefab.transform.position             = startpoint.transform.position;
                newPrefab.GetComponent <bullet>().player = player;

                Vector2 direction = new Vector2(stick.GetHorizontalValue(), stick.GetVerticalValue());
                direction.Normalize();
                newPrefab.GetComponent <Rigidbody2D>().AddForce(direction * BulletSpeed * 1.05f);
                delay = bulletdelay * 0.05f;
            }
            else if (PlayerPrefs.GetString("equip") == "gun-b1")
            {
                Vector3 gameWorldpos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

                GameObject newPrefab = Instantiate(SomPrefab);
                newPrefab.transform.position             = startpoint.transform.position;
                newPrefab.GetComponent <bullet>().player = player;

                Vector2 direction = new Vector2(stick.GetHorizontalValue(), stick.GetVerticalValue());
                direction.Normalize();
                newPrefab.GetComponent <Rigidbody2D>().AddForce(direction * BulletSpeed * 1.06f);
                delay = bulletdelay * 0.1f;
            }
            else if (PlayerPrefs.GetString("equip") == "gun-g1")
            {
                Vector3 gameWorldpos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

                GameObject newPrefab = Instantiate(SomPrefab);
                newPrefab.transform.position             = startpoint.transform.position;
                newPrefab.GetComponent <bullet>().player = player;

                Vector2 direction = new Vector2(stick.GetHorizontalValue(), stick.GetVerticalValue());
                direction.Normalize();
                newPrefab.GetComponent <Rigidbody2D>().AddForce(direction * BulletSpeed * 1.1f);
                delay = bulletdelay * 0.1f;
            }
            else if (PlayerPrefs.GetString("equip") == "gun-y3")
            {
                Vector3 gameWorldpos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

                GameObject newPrefab = Instantiate(SomPrefab);
                newPrefab.transform.position             = startpoint.transform.position;
                newPrefab.GetComponent <bullet>().player = player;

                Vector2 direction = new Vector2(stick.GetHorizontalValue(), stick.GetVerticalValue());
                direction.Normalize();
                newPrefab.GetComponent <Rigidbody2D>().AddForce(direction * BulletSpeed * 1.15f);
                delay = bulletdelay * 0.1f;
            }
            else if (PlayerPrefs.GetString("equip") == "gun-g3")
            {
                Vector3 gameWorldpos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

                GameObject newPrefab = Instantiate(SomPrefab);
                newPrefab.transform.position             = startpoint.transform.position;
                newPrefab.GetComponent <bullet>().player = player;

                Vector2 direction = new Vector2(stick.GetHorizontalValue(), stick.GetVerticalValue());
                direction.Normalize();
                newPrefab.GetComponent <Rigidbody2D>().AddForce(direction * BulletSpeed * 1.16f);
                delay = bulletdelay * 0.11f;
            }
            else
            {
                Vector3 gameWorldpos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

                GameObject newPrefab = Instantiate(SomPrefab);
                newPrefab.transform.position             = startpoint.transform.position;
                newPrefab.GetComponent <bullet>().player = player;

                Vector2 direction = new Vector2(stick.GetHorizontalValue(), stick.GetVerticalValue());
                direction.Normalize();
                newPrefab.GetComponent <Rigidbody2D>().AddForce(direction * BulletSpeed);
                delay = 0.0f;
            }
        }
        delay += Time.deltaTime;
        if (Input.GetKey(KeyCode.Q) && Qnowofftime <= 0)
        {
            Qnowofftime = Qcooltime;

            Vector3 gameWorldpos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

            GameObject newPrefab = Instantiate(QPrefab);
            newPrefab.transform.position            = transform.position;
            newPrefab.GetComponent <skill>().player = gameObject;

            Vector2 direction = gameWorldpos - transform.position;
            direction.Normalize();
            newPrefab.GetComponent <Rigidbody2D>().AddForce(direction * BulletSpeed);
        }

        if (Qnowofftime > 0.0)
        {
            Qnowofftime -= Time.deltaTime;
        }
    }