コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        controlMouse();
        //controlWASD ();

        // Gun Input
        if (CurrentGun)
        {
            //anim.SetBool ("HoldingSword", false);
            if (Input.GetButtonDown("Shoot"))
            {
                currentGun.Shoot();
            }
            else if (Input.GetButton("Shoot"))
            {
                currentGun.ShootContinuous();
            }
            if (Input.GetButtonDown("Reload"))
            {
                if (currentGun.Reload())
                {
                    Debug.Log("Reloading");
                    // Add reload animation here
                    reloading = true;
                }
            }

            if (reloading)
            {
                currentGun.FinishReload();

                Debug.Log("Finishing Reload activated...");
                reloading = false;
            }
        }


        // Melee Input

        if (CurrentMelee)
        {
            //anim.SetBool ("HoldingSword", true);
            if (Input.GetButton("Shoot"))
            {
                holdTime += Time.deltaTime;
                Debug.Log("Holding");
            }

            if (Input.GetButtonUp("Shoot"))
            {
                if (holdTime > holdLimit)
                {
                    currentMelee.HeavyAttack();

                    //Debug.Log ("Heavy Attk Ready");
                }
                else
                {
                    currentMelee.LightAttack();

                    //Debug.Log ("perform Light Attack");
                }

                holdTime = 0;
            }
        }

        if (!CurrentMelee)
        {
            //anim.SetBool ("HoldingSword", false);
        }

        //Weapon Switch

        if (Input.GetMouseButtonDown(1))
        {
            weaponSwitch();
        }



        //sets the ammo text read out
        ammoinmag      = currentGun.currentAmmoInMag.ToString();
        totalammo      = currentGun.totalAmmo.ToString();
        outputstr      = ammoinmag + "/" + totalammo;
        AmmoCount.text = outputstr;
    }