예제 #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("Shield(Clone)");

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

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


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

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


        if (inputDirection.y > 0)
        {
            animator.SetInteger("Direction", 2);
        }
        else if (inputDirection.x < 0)
        {
            animator.SetInteger("Direction", 3);
        }
        else if (inputDirection.x > 0)
        {
            animator.SetInteger("Direction", 1);
        }
        else
        {
            animator.SetInteger("Direction", 0);
        }


        if (Input.GetButtonDown("A 1 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 1 horizontal"), Input.GetAxis("right joystick 1 vertical")) * Mathf.Rad2Deg;
        // Dead Zone
        if (Input.GetAxis("right joystick 1 horizontal") > 0.3 || Input.GetAxis("right joystick 1 vertical") > 0.3 || Input.GetAxis("right joystick 1 horizontal") < -0.3 || Input.GetAxis("right joystick 1 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 1") > 0)
            {
                Defend();
            }
        }


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



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