Пример #1
0
    IEnumerator Idle()
    {
        if (TrainingMode == "AimAndReaction")
        {
            ResetGame();
        }
        CharacterAnim.enabled = true;
        CharacterAnim.SetBool("Idle", true);
        AimLineAnim.SetBool("AimLine", true);
        AimLineRotator.freeze = false;
        yield return(new WaitForSeconds(1f));

        ableToShoot           = true;
        btnShoot.interactable = true;
    }
Пример #2
0
    IEnumerator StopWalking()
    {
        yield return(new WaitForSeconds(2.5f));

        CharacterAnim.SetBool("Walking", false);
        AimLineAnim.SetBool("AimLine", true);
        yield return(new WaitForSeconds(0.5f));

        CharacterPhysics.velocity = new Vector2(0f, 0f);
        CharacterAnim.SetBool("Idle", true);
        yield return(new WaitForSeconds(0.5f));

        ableToShoot           = true;
        btnShoot.interactable = true;
    }
Пример #3
0
    public void Shoot()
    {
        if ((TrainingMode == "AimOnly") || (time <= 0 && TrainingMode == "AimAndReaction"))
        {
            int shots = int.Parse(total.text);
            shots++;
            total.text            = shots + "";
            AimLineRotator.freeze = true;
            btnShoot.interactable = false;
            ableToShoot           = false;
            AimLineAnim.SetBool("AimLine", false);
            AimLineCollider.enabled = false;
            RaycastHit2D hit = Physics2D.Raycast(AimLine.position, AimLine.right * -50);
            didHit       = false;
            didHitGround = false;
            if (hit.collider != null)
            {
                HitPosition = hit.point;
                Distance    = hit.distance;
                if (hit.collider.name != "Ground")
                {
                    didHit = true;
                    if (hit.collider.name == "Head")
                    {
                        // DISABLE CAMERA ZOOM CODES START
                        //StartCoroutine(StartTimePassed());
                        //didPlayerHeadshot = true;
                        // END
                        Headshots++;
                        GameObject.Find("Headshots").GetComponent <Text>().text = Headshots + " Headshots";
                    }
                    GameObject.Find("txtShotStatus").GetComponent <Text>().text = hit.collider.name;
                }
                else
                {
                    didHitGround = true;
                }
            }
            else
            {
                GameObject.Find("txtShotStatus").GetComponent <Text>().text = "Missed";
            }

            AimLineCollider.enabled = true;
            BulletRotation          = AimLine.eulerAngles.z;
            ShotAngle = AimLine.eulerAngles.z;
            if (ShotAngle > 180)
            {
                ShotAngle -= 360;
            }
            ShotAngle = -ShotAngle;
            StartCoroutine(ShootAnimation());

            if (time <= 0 && TrainingMode == "AimAndReaction")
            {
                GameObject.Find("txtReaction").GetComponent <Text>().text = System.Math.Round(shot_time, 2) + "s";
                float LastBestReaction = float.Parse(GameObject.Find("txtBestReaction").GetComponent <Text>().text.Replace("s", ""));
                if (LastBestReaction > shot_time || LastBestReaction == 0)
                {
                    GameObject.Find("txtBestReaction").GetComponent <Text>().text = System.Math.Round(shot_time, 2) + "s";
                }
            }
        }
        else
        {
            t = Random.Range(1, 4);
            btnShoot.interactable = false;
            parent.enabled        = true;
            foreach (Renderer child in listOfChildren)
            {
                child.enabled = true;
            }
            txtCooldown.text  = t.ToString();
            txtCooldownS.text = "s";
            t--;
            StartCoroutine(Cooldown());
            GameObject.Find("GunBlow").GetComponent <AudioSource>().Play();
        }
    }