Beispiel #1
0
    /// <summary>
    /// 更新技能图标(打开时、技能升级时)
    /// </summary>
    /// <param name="button">按钮</param>
    /// <param name="skill">数据</param>
    private void UpdateSkillIcon(RectTransform button, PlayerShipSkillVO skill)
    {
        Image icon = button.Find("Image_SkillIcon").GetComponent <Image>();

        bool skillIsValid = skill != null;

        if (skill != null)
        {
            UIUtil.SetIconImage(icon, skillIsValid ? TableUtil.GetIconBundle((uint)skill.GetIcon()) : "",
                                skillIsValid ? TableUtil.GetIconAsset((uint)skill.GetIcon()) : "");
        }
        else
        {
            icon.sprite = null;
            icon.gameObject.SetActive(skillIsValid);
        }
    }
Beispiel #2
0
    /// <summary>
    /// 更新目标点
    /// </summary>
    /// <param name="view">敌方点</param>
    /// <param name="distance">距离</param>
    /// <param name="main">主角</param>
    /// <param name="target">目标</param>
    private void UpdateTarget(RectTransform view, float distance, SpacecraftEntity main, SpacecraftEntity target)
    {
        if (!view.gameObject.activeSelf)
        {
            view.gameObject.SetActive(true);
            view.Find("Image_Enemy").gameObject.SetActive(true);
        }

        Vector3 position  = target.transform.position - main.transform.position;
        Vector3 direction = new Vector3(position.x, 0, position.z).normalized *distance;

        view.anchoredPosition = new Vector2(direction.x, direction.z);

        Image     img      = view.Find("Image_Enemy").GetComponent <Image>();
        KHeroType heroType = target.GetHeroType();

        /// 玩家不再npc表
        /// 先用指定ID
        if (heroType == KHeroType.htPlayer)
        {
            UIUtil.SetIconImage(img, TableUtil.GetIconBundle(PLAYER_MAP_ICON), TableUtil.GetIconAsset(PLAYER_MAP_ICON));
        }
        else
        {
            Npc  npc     = target.GetNPCTemplateVO();
            uint mapIcon = npc.MapIcon;
            if (mapIcon != 0)
            {
                /// TODO.
                /// 暂无考虑:同一NPC不同时刻改变阵营时,是否需要显示不同图标
                UIUtil.SetIconImage(img, TableUtil.GetIconBundle(mapIcon), TableUtil.GetIconAsset(mapIcon));
            }
            else
            {
                view.gameObject.SetActive(false);
                view.Find("Image_Enemy").gameObject.SetActive(false);
            }
        }
    }