#region 处理连击文字特效 private float comboTimer=0.3f; private int comboNumber=0; private Coroutine comboCoroutine; protected GameObject comboPrefab; protected Transform[] comboNumberTransforms; protected Transform comboNumberTransform; protected SpriteRenderer[] comboNumberSprites; protected SpriteRenderer comboHit; protected Animator comboAnimator; /// /// 播放连击动画 /// public void PlayComboEffect() { comboNumber += 1; if (comboCoroutine != null) { StopCoroutine(comboCoroutine); } comboCoroutine = StartCoroutine(CountComboNumber()); comboAnimator.SetBool("ComboAni",true); InitNunber(comboNumber); } private IEnumerator CountComboNumber() { yield return new WaitForSeconds(comboTimer); comboNumber = 0; InitNunber(comboNumber); } void InitNunber(int level) { if (level==0) { comboNumberTransforms[1].GetComponent ().SetDeActive(); comboNumberTransforms[2].GetComponent ().SetDeActive(); comboNumberTransforms[3].GetComponent ().SetDeActive(); comboHit.sprite = null; } if (level==1) { comboNumberTransforms[1].GetComponent ().SetDeActive(); comboNumberTransforms[2].GetComponent ().SetDeActive(); comboNumberTransforms[3].GetComponent ().SetDeActive(); comboHit.sprite = DataCenter.Instance.GameData.comboSprites.comboHitSprites[0]; } if (level>1 && level < 10) //一位数 { comboNumberTransforms[2].GetComponent ().SetDeActive(); comboNumberTransforms[3].GetComponent ().SetDeActive(); comboNumberSprites[0].sprite = DataCenter.Instance.GameData.comboSprites.comboNumberSprites[level]; comboHit.sprite = DataCenter.Instance.GameData.comboSprites.comboHitSprites[1]; } else if (level>=10 && level < 100) //二位数 { if (level==10) { comboNumberTransform.localPosition = new Vector3(comboNumberTransform.localPosition.x-0.25f,comboNumberTransform.localPosition.y,comboNumberTransform.localPosition.z); } comboNumberTransforms[3].GetComponent ().SetDeActive(); comboNumberSprites[0].sprite = DataCenter.Instance.GameData.comboSprites.comboNumberSprites[level/10]; comboNumberSprites[1].sprite = DataCenter.Instance.GameData.comboSprites.comboNumberSprites[level%10]; comboHit.sprite = DataCenter.Instance.GameData.comboSprites.comboHitSprites[1]; } else if (level>=100&&level <1000) //三位数 { if (level==100) { comboNumberTransform.localPosition = new Vector3(comboNumberTransform.localPosition.x-0.5f,comboNumberTransform.localPosition.y,comboNumberTransform.localPosition.z); } comboNumberSprites[0].sprite = DataCenter.Instance.GameData.comboSprites.comboNumberSprites[level/100]; comboNumberSprites[1].sprite = DataCenter.Instance.GameData.comboSprites.comboNumberSprites[level/10%10]; comboNumberSprites[2].sprite = DataCenter.Instance.GameData.comboSprites.comboNumberSprites[level%10]; comboHit.sprite = DataCenter.Instance.GameData.comboSprites.comboHitSprites[1]; } } #endregion