Пример #1
0
    public void LogSkillInfo(UnitSkill unitSkill, GameObject listUI)
    {
        var costTitle     = listUI.transform.Find("SkillInfoPanel").Find("CostTitle").GetComponent <Text>();
        var effectTitle   = listUI.transform.Find("SkillInfoPanel").Find("EffectTitle").GetComponent <Text>();
        var distanceTitle = listUI.transform.Find("SkillInfoPanel").Find("DistanceTitle").GetComponent <Text>();
        var rangeTitle    = listUI.transform.Find("SkillInfoPanel").Find("RangeTitle").GetComponent <Text>();
        var durationTitle = listUI.transform.Find("SkillInfoPanel").Find("DurationTitle").GetComponent <Text>();
        var rateTitle     = listUI.transform.Find("SkillInfoPanel").Find("RateTitle").GetComponent <Text>();

        var costInfo     = listUI.transform.Find("SkillInfoPanel").Find("CostInfo").GetComponent <Text>();
        var effectInfo   = listUI.transform.Find("SkillInfoPanel").Find("EffectInfo").GetComponent <Text>();
        var distanceInfo = listUI.transform.Find("SkillInfoPanel").Find("DistanceInfo").GetComponent <Text>();
        var rangeInfo    = listUI.transform.Find("SkillInfoPanel").Find("RangeInfo").GetComponent <Text>();
        var durationInfo = listUI.transform.Find("SkillInfoPanel").Find("DurationInfo").GetComponent <Text>();
        var rateInfo     = listUI.transform.Find("SkillInfoPanel").Find("RateInfo").GetComponent <Text>();


        var skillDescription = listUI.transform.Find("DescriptionPanel").Find("SkillDescription").GetComponent <Text>();

        switch (unitSkill.skillClass)
        {
        case UnitSkill.SkillClass.ninjutsu:
            costTitle.text = "消耗查克拉";
            costInfo.text  = unitSkill.costMP.ToString();
            break;

        case UnitSkill.SkillClass.taijutsu:
            costTitle.text = "消耗体力";
            costInfo.text  = unitSkill.costHP.ToString();
            break;

        default:
            costTitle.text = "";
            costInfo.text  = "";
            break;
        }

        var skillLog = unitSkill.LogSkillEffect();

        effectTitle.text = skillLog[0];
        effectInfo.text  = skillLog[1];

        if (unitSkill.skillRange > 0)
        {
            distanceTitle.text = "距离";
            distanceInfo.text  = unitSkill.skillRange.ToString();
        }
        else
        {
            distanceTitle.text = "";
            distanceInfo.text  = "";
        }
        if (unitSkill.hoverRange >= 0 && unitSkill.skillRange > 0)
        {
            rangeTitle.text = "范围";
            rangeInfo.text  = (unitSkill.hoverRange + 1).ToString();
            switch (unitSkill.rangeType)
            {
            case UnitSkill.RangeType.common:
                rangeTitle.text += "      普通型";

                break;

            case UnitSkill.RangeType.straight:
                rangeTitle.text += "      直线型";
                break;
            }
        }
        else
        {
            rangeTitle.text = "";
            rangeInfo.text  = "";
        }

        durationTitle.text = "";
        durationInfo.text  = "";

        if (skillLog.Count == 3)
        {
            durationTitle.text = "持续回合";
            durationInfo.text  = skillLog[2];
        }

        rateTitle.text = "成功率";
        rateInfo.text  = unitSkill.skillRate + "%";
        if (listUI.transform.Find("DescriptionPanel").Find("SkillDescription").Find("SkillCombo").gameObject.activeInHierarchy)
        {
            skillDescription.text = "  " + unitSkill.CName + "\n" + unitSkill.description;
        }
        else
        {
            skillDescription.text = unitSkill.CName + "\n" + unitSkill.description;
        }
    }
Пример #2
0
    private void LogSkillInfo(UnitSkill unitSkill, Transform descriptionPanel, Transform skillInfoPanel, Transform roleInfoPanel, Transform button)
    {
        //确保不出边界。
        var skillPanelRect     = descriptionPanel.parent.Find("SkillPanel").GetComponent <RectTransform>();
        var skillInfoPanelRect = skillInfoPanel.GetComponent <RectTransform>();

        var syncY = button.position.y - button.GetComponent <RectTransform>().sizeDelta.y / 2;
        var minY  = descriptionPanel.parent.position.y + skillInfoPanelRect.sizeDelta.y / 2 * skillInfoPanelRect.lossyScale.y;
        var maxY  = descriptionPanel.parent.position.y + skillPanelRect.sizeDelta.y * skillPanelRect.lossyScale.y - skillInfoPanelRect.sizeDelta.y / 2 * skillInfoPanelRect.lossyScale.y;

        float y;

        if (syncY >= maxY)
        {
            y = maxY;
        }
        else if (syncY <= minY)
        {
            y = minY;
        }
        else
        {
            y = syncY;
        }

        //Debug.Log("y:" + y + " syncY:" + syncY + " minY:" + minY);

        skillInfoPanel.position = new Vector3(skillInfoPanel.position.x, y, skillInfoPanel.position.z);

        var costTitle     = skillInfoPanel.Find("CostTitle").GetComponent <Text>();
        var effectTitle   = skillInfoPanel.Find("EffectTitle").GetComponent <Text>();
        var distanceTitle = skillInfoPanel.Find("DistanceTitle").GetComponent <Text>();
        var rangeTitle    = skillInfoPanel.Find("RangeTitle").GetComponent <Text>();
        var durationTitle = skillInfoPanel.Find("DurationTitle").GetComponent <Text>();
        var rateTitle     = skillInfoPanel.Find("RateTitle").GetComponent <Text>();

        var costInfo     = skillInfoPanel.Find("CostInfo").GetComponent <Text>();
        var effectInfo   = skillInfoPanel.Find("EffectInfo").GetComponent <Text>();
        var distanceInfo = skillInfoPanel.Find("DistanceInfo").GetComponent <Text>();
        var rangeInfo    = skillInfoPanel.Find("RangeInfo").GetComponent <Text>();
        var durationInfo = skillInfoPanel.Find("DurationInfo").GetComponent <Text>();
        var rateInfo     = skillInfoPanel.Find("RateInfo").GetComponent <Text>();


        var skillDescription = descriptionPanel.Find("SkillDescription").GetComponent <Text>();

        switch (unitSkill.skillClass)
        {
        case UnitSkill.SkillClass.ninjutsu:
            costTitle.text = "消耗查克拉";
            costInfo.text  = unitSkill.costMP.ToString();
            break;

        case UnitSkill.SkillClass.taijutsu:
            costTitle.text = "消耗体力";
            costInfo.text  = unitSkill.costHP.ToString();
            break;

        default:
            costTitle.text = "";
            costInfo.text  = "";
            break;
        }

        var skillLog = unitSkill.LogSkillEffect();

        effectTitle.text = skillLog[0];
        effectInfo.text  = skillLog[1];

        if (unitSkill.skillRange > 0)
        {
            distanceTitle.text = "距离";
            distanceInfo.text  = unitSkill.skillRange.ToString();
        }
        else
        {
            distanceTitle.text = "";
            distanceInfo.text  = "";
        }
        if (unitSkill.hoverRange >= 0 && unitSkill.skillRange > 0)
        {
            rangeTitle.text = "范围";
            rangeInfo.text  = (unitSkill.hoverRange + 1).ToString();
            switch (unitSkill.rangeType)
            {
            case UnitSkill.RangeType.common:
                rangeTitle.text += "      普通型";

                break;

            case UnitSkill.RangeType.straight:
                rangeTitle.text += "      直线型";
                break;
            }
        }
        else
        {
            rangeTitle.text = "";
            rangeInfo.text  = "";
        }

        durationTitle.text = "";
        durationInfo.text  = "";

        if (skillLog.Count == 3)
        {
            durationTitle.text = "持续回合";
            durationInfo.text  = skillLog[2];
        }

        rateTitle.text = "成功率";
        rateInfo.text  = unitSkill.skillRate + "%";

        //if (descriptionPanel.Find("SkillDescription").Find("SkillCombo").gameObject.activeInHierarchy)
        //{
        //    skillDescription.text = "  " + unitSkill.description;
        //}
        //else
        //{
        //    skillDescription.text = unitSkill.description;
        //}
        skillDescription.text = unitSkill.description;
    }