// Use this for initialization // void Start () { // // } void OnEnable() { instance = this; // windvalue = 1; // verificar se exixte vento ou não if (GameObject.Find("Terrain").GetComponent <TurnWindOnOff> ().estadoVento) { windSet = 1; } if (!GameObject.Find("Terrain").GetComponent <TurnWindOnOff> ().estadoVento) { windSet = 0; } Debug.Log("WindSet está a: " + windSet); if (windSet == 0) { rigidB = GetComponent <Rigidbody> (); rigidB.velocity = Vector3.zero; ApplyForce(); } if (windSet == 1) { rigidB = GetComponent <Rigidbody> (); rigidB.velocity = Vector3.zero; ApplyForce(); ArrowWind(); } }
void ShootLogic() { if (numberOfArrow > 0) { if (pullAmount > 100) { pullAmount = 100; } SkinnedMeshRenderer _bowSkin = bow.transform.GetComponent <SkinnedMeshRenderer>(); SkinnedMeshRenderer _arrowSkin = arrow.transform.GetComponent <SkinnedMeshRenderer>(); Rigidbody _arrowRigidB = arrow.transform.GetComponent <Rigidbody>(); ProjectileAddForce _arrowProjectile = arrow.transform.GetComponent <ProjectileAddForce>(); //string sound play if (Input.GetMouseButtonDown(0)) { stringSound.Play(); } if (Input.GetMouseButton(0)) { pullAmount += Time.deltaTime * pullSpeed; //to stop string sound if (pullAmount >= 100) { stringSound.Stop(); } } if (Input.GetMouseButtonUp(0)) { //firesound when mouse button is up fireSound.Play(); //when arrow is released stringSound.Stop(); arrowSlotted = false; _arrowRigidB.isKinematic = false; arrow.transform.parent = null; // _arrowProjectile.enabled = true; _arrowProjectile.shootForce = _arrowProjectile.shootForce * ((pullAmount / 300) + 0.5f); numberOfArrow -= 1; pullAmount = 0; _arrowProjectile.enabled = true; } _bowSkin.SetBlendShapeWeight(0, pullAmount); _arrowSkin.SetBlendShapeWeight(0, pullAmount); // _arrowProjectile.enabled = true; if (Input.GetMouseButtonDown(0) && arrowSlotted == false) { SpawnArrow(); } } else { gameOver.text = "Game Over"; } }
void ShootLogic() { if (numberOfArrows > 0) { if (pullAmount > 100) { pullAmount = 100; } SkinnedMeshRenderer _bowSkin = bow.transform.GetComponent <SkinnedMeshRenderer>(); SkinnedMeshRenderer _arrowSkin = arrow.transform.GetComponent <SkinnedMeshRenderer>(); Rigidbody _arrowRigidB = arrow.transform.GetComponent <Rigidbody> (); ProjectileAddForce _arrowProjectile = arrow.transform.GetComponent <ProjectileAddForce>(); if (Input.GetMouseButton(0)) { stringSound.Play(); } if (Input.GetMouseButton(0)) { pullAmount += Time.deltaTime * pullSpeed; if (pullAmount >= 100) { stringSound.Stop(); } } if (Input.GetMouseButtonUp(0)) { fireSound.Play(); stringSound.Stop(); arrowSlotted = false; _arrowRigidB.isKinematic = false; arrow.transform.parent = null; _arrowProjectile.shootForce = _arrowProjectile.shootForce * ((pullAmount / 100) + .05f); numberOfArrows -= 1; pullAmount = 0; _arrowProjectile.enabled = true; } _bowSkin.SetBlendShapeWeight(0, pullAmount); _arrowSkin.SetBlendShapeWeight(0, pullAmount); if (Input.GetMouseButtonDown(0) && arrowSlotted == false) { SpawnArrow(); } } }