//fire main weapon public void FireWeapon() { if (destroyed || IsStunned()) { return; } if (!thisObj.activeInHierarchy) { return; } int fireState = CanFire(); if (fireState == 0) { if (weaponList[weaponID].RequireAiming()) { Vector2 cursorPos = Input.mousePosition; if (weaponList[weaponID].RandCursorForRecoil()) { float recoil = GameControl.GetPlayer().GetRecoil() * 4; cursorPos += new Vector2(Random.value - 0.5f, Random.value - 0.5f) * recoil; } Ray ray = Camera.main.ScreenPointToRay(cursorPos); RaycastHit hit; //LayerMask mask=1<<TDS.GetLayerTerrain(); //Physics.Raycast(ray, out hit, Mathf.Infinity, mask); Physics.Raycast(ray, out hit, Mathf.Infinity); ShootObject.AimInfo aimInfo = new ShootObject.AimInfo(hit); StartCoroutine(ShootRoutine(aimInfo)); } else { StartCoroutine(ShootRoutine()); } weaponList[weaponID].Fire(); } else { string text = ""; if (fireState == 1) { text = "attack disabled"; } if (fireState == 2) { text = "weapon's on cooldown"; } if (fireState == 3) { text = "weapon's out of ammo"; } if (fireState == 4) { text = "weapon's reloading"; } TDS.FireFail(text); if (GetCurrentClip() == 0 && GameControl.EnableAutoReload()) { weaponList[weaponID].Reload(); } } }