// Update is called once per frame void Update() { if (IsShoot) { if (firstItem && shootGap >= timeGap) { itemCount = 0; itemTime = itemTimeGap; firstItem = false; } for (; itemCount < count && itemTime >= itemTimeGap; itemCount++) { GameObject item = Instantiate(shootPrefab, shootTrans.position, transform.localRotation) as GameObject; ShootItem info = item.GetComponent <ShootItem>(); info.boomAnimation = boomAnimation; float scale = (gameObject.transform.lossyScale.x > 0 ? 1 : -1); float rot = startRotation + gapRotation * itemCount + randomRotation * Random.Range(-0.5f, 0.5f); item.transform.Rotate(new Vector3(0f, 0f, rot)); info.vx = speed * scale * Mathf.Cos(rot * Mathf.PI / 180); info.vy = speed * scale * Mathf.Sin(rot * Mathf.PI / 180); item.transform.localScale = new Vector3(scale * item.transform.localScale.x, scale * item.transform.localScale.y, 1); shootGap = 0; itemTime = 0; } if (itemCount == count) { firstItem = true; } } shootGap++; itemTime++; }
/// <summary> /// 踢球状态 /// </summary> /// <param name="shootProp"></param> /// <returns></returns> ShootItem GetShootResult(int shootProp) { var rand = RandomPicker.GetRandom(); var obj = new ShootItem(); int val = RandomPicker.RandomInt(0, 100, rand); if (val <= _aDRateShootFly) { obj.ShootPos = 2;//射飞 } else if (val <= _aDRateShootFrame) { obj.ShootPos = 1;//射中门框 } else { obj.ShootPos = 0;//射中 } bool diveSame = val <= _aDRateDiveSame; obj.DiveDir = diveSame; if (obj.ShootPos == 0) { if (!diveSame || RandomPicker.RandomInt(1, 100) <= shootProp * 100 / (shootProp + 200)) { obj.IsGoals = true; return(obj); } } obj.IsGoals = false; return(obj); }