void SpwanKnife() { GameObject knife = Instantiate(knifeGO, knifespwanpoint.position, Quaternion.identity); currknife = knife.GetComponent <knifecontroller>(); currknife.ShowAnimation(); }
void ShootAKnife() { currknife.Shoot(); currentknifecount--; knifeicons[currentknifecount].color = new Color(0, 0, 0, 0.5f); if (currentknifecount > 0) { //spwanknife SpwanKnife(); } else { currknife = null; } }
// generate knifes on target randomly public void GenerateLevel() { knifescount = Random.Range(5, 16); // already sticking knife at target 3 for (int i = 0; i < knifeicons.Count; i++) { if (i >= knifescount) { knifeicons[i].color = new Color(knifeicons[i].color.r, knifeicons[i].color.g, knifeicons[i].color.b, 0); } } int sticknigKnife = Random.Range(0, 4); // maxangle that maximam angle must knife spirite before it كل السكاكين هتتوزع قبل ماتوصل للرقم ده float maxAngle = 360 / (float)sticknigKnife; float lastAngle = 0; for (int i = 0; i < sticknigKnife; i++) { // الدرجه بتاعه السكينه الجديده هتكون بعد القديمه ب 20 درجه ومش هتزيد عن ال max float angle = lastAngle + Random.Range(20, maxAngle) * Mathf.Deg2Rad; lastAngle = angle; // postion of stcking knife i use sign and cos to draw circle and multible it by 3 this raduis of target Vector3 pos = target.transform.position + new Vector3(Mathf.Sign(angle), Mathf.Cos(angle), 0) * 1.25f; GameObject knife = Instantiate(knifeGO, pos, Quaternion.identity); // to set knife refer to center of target knife.transform.up = target.transform.position - knife.transform.position; knife.transform.parent = target.transform; knifecontroller knifeBehavior = knife.GetComponent <knifecontroller>(); knifeBehavior.myCollider.enabled = true; curhitknifes.Add(knifeBehavior.myRidgidbody); } currentknifecount = knifescount; SpwanKnife(); }