コード例 #1
0
    /// <summary>
    /// Loading all tooltips from xml file
    /// </summary>
    public static void Load(string filename)
    {
        _sAllTips = new Dictionary <string, LearningTipData>();

        var uparsedTips = AbstractObject.Load <ExcelLoading.AllTips>(filename);

        foreach (var source in uparsedTips.repetative)
        {
            var tipData = new LearningTipData();
            tipData.m_dependency   = source.targetIcon;
            tipData.m_targetObject = source.targetObject;
            tipData.m_position     = new Vector2(source.defaultX, source.defaultY);
            tipData.m_name         = source.name;
            tipData.m_text         = source.description;
            tipData.m_next         = source.nextTip;
            tipData.m_isItUI       = source.isItUI;

            string[] positionVecor = source.yellowPositionVector == null ? new string[] { "" } : source.yellowPositionVector.Split(';');
            string[] sizeVector    = source.yellowSizeVector == null ? new string[] { "" } : source.yellowSizeVector.Split(';');
            if (positionVecor.Length > 1 && sizeVector.Length > 1)
            {
                tipData.m_yellowBox = new Rect(
                    AbstractObject.FloatParse(positionVecor[0]),
                    AbstractObject.FloatParse(positionVecor[1]),
                    AbstractObject.FloatParse(sizeVector[0]),
                    AbstractObject.FloatParse(sizeVector[1])
                    );
            }
            _sAllTips.Add(tipData.m_name, tipData);
        }

        //making previous link
        foreach (var tipPair in _sAllTips)
        {
            var tip = tipPair.Value;
            if (tip.m_next != null && tip.m_next.Length > 0)
            {
                var nextTip = _sAllTips[tip.m_next];
                if (nextTip.m_previous == null || nextTip.m_previous.Length == 0)
                {
                    _sAllTips[tip.m_next].m_previous = tip.m_name;
                }
                else
                {
                    throw new Exception("tip '" + nextTip + "' has previous tip:" + nextTip.m_previous);
                }
            }
        }
    }