Пример #1
0
    public void NextPhaseActual()
    {
        DestroyEverything();
        spawned = false;
        bc.Increment();
        bc.ShowBanner();
        counter = 1.5f;
        P1Ammo.Reset();
        P2Ammo.Reset();

        /*		p1.transform.position = p1Spawn.transform.position;
         * p2.transform.position = p2Spawn.transform.position;*/
    }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        fireCooldown  -= Time.deltaTime;
        dashTime      -= Time.deltaTime;
        dashCooldown  -= Time.deltaTime;
        curreloadTime -= Time.deltaTime;

        s = GameObject.Find("Shield2(Clone)");

        if (dashTime <= 0)
        {
            thisTransform.GetComponent <Rigidbody2D>().velocity = Vector3.zero;
        }

        inputDirection = Vector3.zero;
        if (Input.GetAxis("left joystick 2 horizontal") * 0.5f > 0.2 || Input.GetAxis("left joystick 2 horizontal") * 0.5f < -0.2)
        {
            inputDirection.x = Input.GetAxis("left joystick 2 horizontal") * 0.5f;
        }
        if (Input.GetAxis("left joystick 2 vertical") * 0.5f > 0.2 || Input.GetAxis("left joystick 2 vertical") * 0.5f < -0.2)
        {
            inputDirection.y = -(Input.GetAxis("left joystick 2 vertical")) * 0.5f;
        }


        LSangle = Mathf.Atan2(Input.GetAxis("left joystick 2 horizontal"), Input.GetAxis("left joystick 2 vertical")) * Mathf.Rad2Deg;
        // Dead Zone

        if (Input.GetAxis("left joystick 2 horizontal") > 0.4 || Input.GetAxis("left joystick 2 vertical") > 0.4 || Input.GetAxis("left joystick 2 horizontal") < -0.4 || Input.GetAxis("left joystick 2 vertical") < -0.4)
        {
            LSoldAngle = LSangle;
        }


        if (inputDirection.x > 0)
        {
            sr.sprite = right;
        }
        else if (inputDirection.x < 0)
        {
            sr.sprite = left;
        }
        else if (inputDirection.y > 0)
        {
            sr.sprite = up;
        }
        else
        {
            sr.sprite = down;
        }


        if (Input.GetButtonDown("A 2 Button") && dashCooldown < 0)
        {
            AudioSource.PlayClipAtPoint(dodgeSound, transform.position);
            dashTime = 0.1f;
            Dash(LSoldAngle);
            Invulnerable(playerCol);
        }
        else if (dashTime < 0)
        {
            thisTransform.position += inputDirection * 0.2f;
            thisTransform.rotation  = Quaternion.identity;
            if (dashTime <= -0.2 && !permInv)
            {
                Vulnerable(playerCol);
            }
        }


        //Vector3 vNewInput = new Vector3(Input.GetAxis("right joystick 1 horizontal"), Input.GetAxis("right joystick 1 vertical"), 0.0f);
        angle = Mathf.Atan2(Input.GetAxis("right joystick 2 horizontal"), Input.GetAxis("right joystick 2 vertical")) * Mathf.Rad2Deg;
        // Dead Zone
        if (Input.GetAxis("right joystick 2 horizontal") > 0.3 || Input.GetAxis("right joystick 2 vertical") > 0.3 || Input.GetAxis("right joystick 2 horizontal") < -0.3 || Input.GetAxis("right joystick 2 vertical") < -0.3)
        {
            oldAngle = angle;
        }



        aimDirection    = Quaternion.Euler(0, 0, oldAngle - 90) * distance;
        shieldDirection = Quaternion.Euler(0, 0, oldAngle - 90) * shieldDistance;
        bulletDirection = Quaternion.Euler(0, 0, oldAngle - 90) * bulletDistance;


        aimer.transform.position = thisTransform.position + aimDirection;

        if (s == null)
        {
            if (Input.GetAxis("LT 2") > 0)
            {
                Defend();
            }
        }


        if (Input.GetAxis("RT 2") > 0.2)
        {
            if (s == null)
            {
                if (fireCooldown < 0 && curreloadTime < 0)
                {
                    AudioSource.PlayClipAtPoint(fireSound, transform.position);
                    Fire();
                    curammo--;
                    P2Ammo.Reduce();
                    fireCooldown = 1f;
                }
                if (curammo == 0)
                {
                    Reload();
                    P2Ammo.Reset();
                }
            }
        }
        if (Input.GetAxis("RT 2") <= 0.2)
        {
            fireCooldown = 0;
        }



        if (s != null)
        {
            //Debug.Log("finds object");
            if (Input.GetAxis("LT 2") <= 0.1)
            {
                Destroy(GameObject.Find("Shield2(Clone)"));
            }
            s.transform.position = thisTransform.position + shieldDirection;
            s.transform.rotation = Quaternion.Euler(0, 0, oldAngle - 135);
        }
    }