Beispiel #1
0
    void PropertyEventHandler(NFGUID self, string strProperty, NFDataList.TData oldVar, NFDataList.TData newVar)
    {
        NFDataList.TData data = newVar;

        switch (type)
        {
        case ViewType.ITEM_CNFID_ICON:
        {
            Image xImage = gameObject.GetComponent <Image> ();
            if (xImage != null)
            {
                string strIconName     = NFrame.NFCKernelModule.Instance.GetElementModule().QueryPropertyString(data.ToString(), NFrame.Item.Icon);
                string strIconFileName = NFrame.NFCKernelModule.Instance.GetElementModule().QueryPropertyString(data.ToString(), NFrame.Item.SpriteFile);
                Sprite xSprite         = null;                        //load your sprite
                if (xSprite != null)
                {
                    xImage.overrideSprite = xSprite;
                    if (xImage.sprite == null)
                    {
                        xImage.enabled = false;
                    }
                    else
                    {
                        xImage.enabled = true;
                    }
                }
            }
        }
        break;

        case ViewType.HERO_GUID_ICON:
        case ViewType.NPC_CNFID_ICON:
        {
            Image xImage = gameObject.GetComponent <Image> ();
            if (xImage != null)
            {
                NFIRecord xRecord = NFCKernelModule.Instance.FindRecord(self, NFrame.Player.PlayerHero.ThisName);
                int       nRow    = xRecord.FindObject((int)NFrame.Player.PlayerHero.GUID, data.ObjectVal());
                if (nRow >= 0)
                {
                    string strCnfID        = xRecord.QueryString(nRow, (int)NFrame.Player.PlayerHero.ConfigID);
                    string strIconName     = NFrame.NFCKernelModule.Instance.GetElementModule().QueryPropertyString(strCnfID, NFrame.Item.Icon);
                    string strIconFileName = NFrame.NFCKernelModule.Instance.GetElementModule().QueryPropertyString(strCnfID, NFrame.Item.SpriteFile);
                    Sprite xSprite         = null;                            //load your sprite
                    if (xSprite != null)
                    {
                        xImage.overrideSprite = xSprite;
                        if (xImage.sprite == null)
                        {
                            xImage.enabled = false;
                        }
                        else
                        {
                            xImage.enabled = true;
                        }
                    }
                }
                else
                {
                    xImage.enabled = false;
                }
            }
        }
        break;

        default:
        {
            Text xText = gameObject.GetComponent <Text> ();
            if (xText != null)
            {
                xText.text = data.ToString();
            }
        }
        break;
        }
    }
Beispiel #2
0
    void PropertyEventHandler(NFGUID self, string strProperty, NFDataList.TData oldVar, NFDataList.TData newVar)
    {
        NFIProperty xProperty = mkernelModule.FindProperty(self, propertyName);

        NFDataList.TData data = xProperty.GetData();
        switch (type)
        {
        case ViewType.ITEM_CNFID_ICON:
        {
            Image xImage = gameObject.GetComponent <Image> ();
            if (xImage != null)
            {
                string strIconName     = mElementModule.QueryPropertyString(data.ToString(), NFrame.Item.Icon);
                string strIconFileName = mElementModule.QueryPropertyString(data.ToString(), NFrame.Item.SpriteFile);

                Sprite xSprite = null;        //NFTexturePacker.Instance.GetSprit(strIconFileName, strIconName);
                if (xSprite != null)
                {
                    xImage.overrideSprite = xSprite;
                    if (xImage.sprite == null)
                    {
                        xImage.enabled = false;
                    }
                    else
                    {
                        xImage.enabled = true;
                    }
                }
            }
        }
        break;

        case ViewType.HERO_GUID_ICON:
        {
            Image xImage = gameObject.GetComponent <Image> ();
            if (xImage != null)
            {
                NFIRecord xRecord = mkernelModule.FindRecord(self, NFrame.Player.PlayerHero.ThisName);
                int       nRow    = xRecord.FindObject((int)NFrame.Player.PlayerHero.GUID, data.ObjectVal());
                if (nRow >= 0)
                {
                    string strCnfID        = xRecord.QueryString(nRow, (int)NFrame.Player.PlayerHero.ConfigID);
                    string strIconName     = mElementModule.QueryPropertyString(strCnfID, NFrame.Item.Icon);
                    string strIconFileName = mElementModule.QueryPropertyString(strCnfID, NFrame.Item.SpriteFile);

                    Sprite xSprite = null;        //NFTexturePacker.Instance.GetSprit (strIconFileName, strIconName);
                    if (xSprite != null)
                    {
                        xImage.overrideSprite = xSprite;
                        if (xImage.sprite == null)
                        {
                            xImage.enabled = false;
                        }
                        else
                        {
                            xImage.enabled = true;
                        }
                    }
                }
                else
                {
                    xImage.enabled = false;
                }
            }
        }
        break;

        case ViewType.NPC_CNFID_ICON:
        {
            Image xImage = gameObject.GetComponent <Image> ();
            if (xImage != null)
            {
                string strCnfID        = data.StringVal();
                string strIconName     = mElementModule.QueryPropertyString(strCnfID, NFrame.NPC.Icon);
                string strIconFileName = mElementModule.QueryPropertyString(strCnfID, NFrame.NPC.SpriteFile);

                Sprite xSprite = null;        //NFTexturePacker.Instance.GetSprit (strIconFileName, strIconName);
                if (xSprite != null)
                {
                    xImage.overrideSprite = xSprite;
                    if (xImage.sprite == null)
                    {
                        xImage.enabled = false;
                    }
                    else
                    {
                        xImage.enabled = true;
                    }
                }
            }
        }
        break;

        case ViewType.SKILL_CNFID_ICON:
        {
            Image xImage = gameObject.GetComponent <Image> ();
            if (xImage != null)
            {
                string strIconName     = mElementModule.QueryPropertyString(propertyName, NFrame.Skill.Icon);
                string strIconFileName = mElementModule.QueryPropertyString(propertyName, NFrame.Skill.SpriteFile);

                Sprite xSprite = null;        //NFTexturePacker.Instance.GetSprit (strIconFileName, strIconName);
                if (xSprite != null)
                {
                    xImage.overrideSprite = xSprite;
                    if (xImage.sprite == null)
                    {
                        xImage.enabled = false;
                    }
                    else
                    {
                        xImage.enabled = true;
                    }
                }
            }
        }
        break;

        default:
        {
            Text xText = gameObject.GetComponent <Text> ();
            if (xText != null)
            {
                xText.text = data.ToString();
                if (xText.text == "0" || xText.text.Length <= 0)
                {
                    //xText.enabled = false;
                }
            }
        }
        break;
        }
    }
Beispiel #3
0
    public void Refresh(NFGUID self, NFDataList.TData data)
    {
        switch (type)
        {
        case ViewType.ITEM_CNFID_ICON:
        {
            Image xImage = gameObject.GetComponent <Image> ();
            if (xImage != null)
            {
                string strIconName     = mElementModule.QueryPropertyString(data.ToString(), NFrame.Item.Icon);
                string strIconFileName = mElementModule.QueryPropertyString(data.ToString(), NFrame.Item.SpriteFile);

                Sprite xSprite = null;        // = NFTexturePacker.Instance.GetSprit(strIconFileName, strIconName);
                if (xSprite != null)
                {
                    xImage.overrideSprite = xSprite;
                    if (xImage.sprite == null)
                    {
                        xImage.enabled = false;
                    }
                    else
                    {
                        xImage.enabled = true;
                    }
                }
            }
        }
        break;

        case ViewType.HERO_GUID_ICON:
        {
            Image xImage = gameObject.GetComponent <Image> ();
            if (xImage != null)
            {
                NFIRecord xRecord = mkernelModule.FindRecord(self, NFrame.Player.PlayerHero.ThisName);
                int       nRow    = xRecord.FindObject((int)NFrame.Player.PlayerHero.GUID, data.ObjectVal());
                if (nRow >= 0)
                {
                    string strCnfID        = xRecord.QueryString(nRow, (int)NFrame.Player.PlayerHero.ConfigID);
                    string strIconName     = mElementModule.QueryPropertyString(strCnfID, NFrame.Item.Icon);
                    string strIconFileName = mElementModule.QueryPropertyString(strCnfID, NFrame.Item.SpriteFile);

                    Sprite xSprite = null;        //= NFTexturePacker.Instance.GetSprit (strIconFileName, strIconName);
                    if (xSprite != null)
                    {
                        xImage.overrideSprite = xSprite;
                        if (xImage.sprite == null)
                        {
                            xImage.enabled = false;
                        }
                        else
                        {
                            xImage.enabled = true;
                        }
                    }
                }
                else
                {
                    xImage.enabled = false;
                }
            }
        }
        break;

        case ViewType.NPC_CNFID_ICON:
        {
        }
        break;

        default:
        {
            Text xText = gameObject.GetComponent <Text> ();
            if (xText != null)
            {
                xText.text = data.ToString();
            }
        }
        break;
        }
    }