• 自己写的连击文字特效


    #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;
        /// <summary>
        /// 播放连击动画
        /// </summary>
        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<SpriteActive>().SetDeActive();
                comboNumberTransforms[2].GetComponent<SpriteActive>().SetDeActive();
                comboNumberTransforms[3].GetComponent<SpriteActive>().SetDeActive();
                comboHit.sprite = null;
            }
            if (level==1)
            {
                comboNumberTransforms[1].GetComponent<SpriteActive>().SetDeActive();
                comboNumberTransforms[2].GetComponent<SpriteActive>().SetDeActive();
                comboNumberTransforms[3].GetComponent<SpriteActive>().SetDeActive();
    
                comboHit.sprite = DataCenter.Instance.GameData.comboSprites.comboHitSprites[0];
            }
            if (level>1 && level < 10) //一位数
            {
                comboNumberTransforms[2].GetComponent<SpriteActive>().SetDeActive();
                comboNumberTransforms[3].GetComponent<SpriteActive>().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<SpriteActive>().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
    
  • 相关阅读:
    怎么判断一个bug到底是前端的bug还是后端的bug
    charles抓包原理
    java基础|Properties文件解析
    java基础|break、continue和return
    Java使用JSONPath解析JSON完整内容详解
    10/23/2019
    有什么好怕的
    [转]一个急刹车,过路老人吓得病发身亡 司机要担责吗?
    [转]7岁女孩练舞下腰致残,舞蹈培训机构被判赔115万
    Salesforce权限管理
  • 原文地址:https://www.cnblogs.com/qiaogaojian/p/7109541.html
Copyright © 2020-2023  润新知