Exemple #1
0
    public void ChangeSpriteSheet(bool isMale, int equipId)
    {
        string pathInResource = "Equip";
        string gender         = (isMale)?("/m"):("/f");

        gender = gender + "/" + equipType;
        if (equipId > 1000)
        {
            equipId = PlayerInfo.ConvertStyleId(equipType, isMale, equipId);
        }
        if (equipId > 0)
        {
            pathInResource = pathInResource + gender + "/" + equipType + equipId.ToString() + "/1/";
        }
        else
        {
            pathInResource = pathInResource + gender + "/default/1/";
        }
        if (equipType == "hair")
        {
            pathInResource = pathInResource + "B/";
        }
        if (equipType == "notype")
        {
            string armName = "axe";
            if (equipId > 100)
            {
                armName = ConnectorManager.FindItemTemplateInfo(equipId, isMale).Pic;
            }
            // Debug.Log("changing arm: " + equipId.ToString());
            pathInResource = "Equip/" + equipType + "/" + armName + "/1/1/";
        }

        clothPath = pathInResource + "game";
        Debug.Log("Changing " + equipType + " to " + pathInResource);
        // Debug.Log(pathInResource);
        subSprite = Resources.LoadAll <Sprite>(pathInResource + "game");
        if (subSprite == null)
        {
            ChangeSpriteSheet(isMale, 0);
        }
        if (equipType == "hair")
        {
            //Shift position according to hair length;
            Vector3 pos = this.transform.localPosition;
            if (subSprite.Length > 0)
            {
                this.transform.localPosition = new Vector3(pos.x, (subSprite[0].rect.height < 40)?(0.2f):(0.18f), 0f);
            }
        }
    }
Exemple #2
0
    IEnumerator LoadImageOnline(RawImage target, string equipType, bool isMale, int equipId)
    {
        Texture2D downloaded     = null;
        bool      isDone         = false;
        string    pathInResource = "/image";
        string    pic            = "default";

        if (equipId > 100)
        {
            pic = ConnectorManager.FindItemTemplateInfo(equipId, isMale).Pic;
        }
        if (equipType == "arm")
        {
            if (equipId == 0)
            {
                yield break;
            }
            if (pic == "default")
            {
                pathInResource = pathInResource + "/arm/axe/1/0/show";
            }
            else
            {
                pathInResource = pathInResource + "/arm/" + pic + "/1/0/show";
            }
        }
        else
        {
            pathInResource = pathInResource + "/equip";
            string gender = (isMale)?("/m/"):("/f/");
            // gender = gender  + equipType;
            pathInResource = pathInResource + gender + equipType + "/" + pic;
            // equipId = PlayerInfo.ConvertStyleId(equipType,isMale,equipId);
            if (equipType == "face")
            {
                pathInResource = pathInResource + "/icon_1";
            }
            else
            {
                pathInResource = pathInResource + "/1";
                if (equipType == "hair")
                {
                    pathInResource = pathInResource + "/B";
                }
                pathInResource = pathInResource + "/show";
            }
        }
        // Debug.Log(pathInResource);
        // yield return StartCoroutine(GetImage(pathInResource, downloaded, isDone));
        yield return(StartCoroutine(GetImage(pathInResource, (result) => {
            // Debug.Log("Setting " + pic);
            target.texture = result;
            if (result == null)
            {
                target.gameObject.SetActive(false);
            }
            else
            {
                target.gameObject.SetActive(true);
            }
        })));
        // while(!isDone){
        //     yield return new WaitForSeconds(0.04f);
        // }
        // Debug.Log("Setting " + pic);
        // target.texture = downloaded;
        // if (downloaded == null){
        //     target.gameObject.SetActive(false);
        // }
    }
 public void BagSlotSelected(int bagPlace, string bagPrefix, int offset = 0)
 {
     gameController.soundManager.PlayEffect("choose");
     foreach (ItemInfo item in localBag)
     {
         if (item.Place != bagPlace + offset)
         {
             continue;
         }
         ItemTemplateInfo iti = ConnectorManager.FindItemTemplateInfo(item.TemplateID, gameController.connector.localPlayerInfo.sex);
         // Debug.Log(item.ToString());
         // Debug.Log(iti);
         RectTransform slotTransform = null;
         //Touch a slot in bag
         if (bagPrefix[0] == 'B')
         {
             Debug.Log("BagSelected");
             DeselectSlotInList(ref bagSlots, ref bagSelectingPlace);
             slotTransform     = (RectTransform)bagSlots[bagPlace].transform;
             bagSelectingPlace = bagPlace;
             if (infoSelectingPlace > -1)
             {
                 Debug.Log("Swap to bagg : " + infoSelectingPlace);
                 gameController.connector.SendChangePlaceItem(eBagType.MainBag, infoSelectingPlace, eBagType.MainBag, bagSelectingPlace + 31, 0);
             }
             infoSelectingPlace = -1;
             int p = (int)getEquipType(gameController.connector.localPlayerInfo.sex, item);
             if (p > -1)
             {
                 infoSlots[p].GetComponent <BagSlotController>().Shine();
                 if (item.itemType == eItemType.ring || item.itemType == eItemType.armlet)
                 {
                     infoSlots[p + 1].GetComponent <BagSlotController>().Shine();
                 }
             }
             infoHightligting = p;
         }
         //Touch a slot in info
         else
         {
             slotTransform = (RectTransform)infoSlots[bagPlace].transform;
             if (infoSelectingPlace < 0)
             {
                 //check if want equip item
                 if (item.Place == infoHightligting ||
                     matchPlaceAndType(item, eItemType.ring, 9, 10) ||
                     matchPlaceAndType(item, eItemType.armlet, 7, 8))
                 {
                     //PERFORM CHANGE PLACE
                     gameController.connector.SendChangePlaceItem(eBagType.MainBag, bagSelectingPlace + 31, eBagType.MainBag, bagPlace, 0);
                     bagSlots[bagSelectingPlace].Select();
                     infoSlots[bagPlace].NormalbackGround();
                     infoSlots[bagPlace + 1].NormalbackGround();
                     infoSlots[bagPlace - 1].NormalbackGround();
                     // infoSelectingPlace = -1;
                     // bagSelectingPlace = -1;
                     // infoHightligting = -1;
                     // itemInfoController.Hide();
                     return;
                 }
             }
             else
             {
                 bagSelectingPlace = -1;
                 DeselectSlotInList(ref infoSlots, ref infoSelectingPlace);
             }
             infoSelectingPlace = bagPlace;
         }
         itemInfoController.ShowInfo(iti, item, slotTransform);
         // Debug.Log("BAG SLOT SELECTED " + bagPrefix + bagPlace + item.itemType);
         return;
     }
     // check if want remove item
     BagSlotDeSelected();
 }