コード例 #1
0
        private void UpdateBuffIcon()
        {
            List <string> buffIcons = character.GetBuffIcons();

            if (buffIcons.Count == 0)
            {
                buffImg.gameObject.SetActive(false);
                return;
            }
            if (Time.time - _lastTime >= INTERVAL)
            {
                //变长集合迭代?

                /*BuffType[] buffs = character.buffEffectDic.GetKeyArray();
                 * int count = buffs.Length;
                 * _currentIndex = Mathf.RoundToInt(_buffProgress * count);//取上
                 * if (_currentIndex >= buffs.Length)
                 *  _currentIndex = 0;
                 * BuffType buff = buffs[_currentIndex];
                 * bool contrary = _existContrary;
                 * if (buff == _lastBuffType)
                 * {
                 *  if (_existContrary)
                 *      _existContrary = false;
                 *  else
                 *  {
                 *      _currentIndex++;
                 *      if (_currentIndex >= buffs.Length)
                 *          _currentIndex = 0;
                 *  }
                 *  buff = buffs[_currentIndex];
                 * }
                 * bool kindness = false;
                 * if (!contrary)
                 * {
                 *  kindness = character.ExistBuff(buff, true);
                 *  if (kindness)
                 *      _existContrary = character.ExistBuff(buff, false);
                 * }
                 * buffImg.gameObject.SetActive(true);
                 * string path = Fight.Model.FightProxy.instance.GetIconPath(buff, kindness);
                 * buffImg.SetSprite(ResMgr.instance.Load<Sprite>("sprite/" + path));
                 * _lastBuffType = buff;
                 * _buffProgress = (float)_currentIndex / (float)count;
                 * buffs = null;
                 * _lastTime = Time.time;
                 */
                int count = buffIcons.Count;
                _currentIndex = Mathf.RoundToInt(_buffProgress * count);//取上
                if (_currentIndex >= count)
                {
                    _currentIndex = 0;
                }
                string path = buffIcons[_currentIndex];
                if (path == _lastIconPath)
                {
                    _currentIndex++;
                    if (_currentIndex >= count)
                    {
                        _currentIndex = 0;
                    }
                    path = buffIcons[_currentIndex];
                }
                buffImg.gameObject.SetActive(true);
                buffImg.SetSprite(ResMgr.instance.Load <Sprite>("sprite/" + path));
                _lastIconPath = path;
                _buffProgress = (float)_currentIndex / (float)count;
                _lastTime     = Time.time;
            }
        }