示例#1
0
    private void loadVillagerData()
    {
        try
        {
            string newVillager   = Selector.LastSelectedVillager;
            byte[] villagerDump  = ((TextAsset)Resources.Load("DefaultVillagers/" + newVillager + "V")).bytes;
            byte[] villagerHouse = ((TextAsset)Resources.Load("DefaultVillagers/" + newVillager + "H")).bytes;
            if (villagerDump == null || villagerHouse == null)
            {
                return;
            }

            Villager newV = new Villager(villagerDump);
            newV.SetMemories(loadedVillager.GetMemories());
            newV.CatchPhrase = GameInfo.Strings.GetVillagerDefaultPhrase(newVillager);
            VillagerHouse newVH = new VillagerHouse(villagerHouse);
            newVH.NPC1 = loadedVillagerHouse.NPC1;


            loadedVillager      = newV;
            loadedVillagerHouse = newVH;

            SetCurrentVillager(true);
            TenVillagers[currentlyLoadedVillagerIndex].texture = SpriteBehaviour.PullTextureFromParser(villagerSprites, newVillager);
            VillagerToUI(loadedVillager);
        }
        catch (Exception e)
        {
            Debug.LogError(e.Message);
            PopupHelper.CreateError(e.Message, 2f);
        }
    }
示例#2
0
    // Use this for initialization
    void Start()
    {
        player = FindObjectOfType <SpriteBehaviour> ();
        star   = GameObject.FindGameObjectWithTag("Star");
//		spawnedStar = GameObject.FindWithTag ("Star");
//		Debug.Log (spawnedStar.GetType ());
    }
示例#3
0
    public void InitialiseFor(string val, string contains, int itemId, ItemFilter uiFilter, UI_SearchWindow parentWindow)
    {
        //IL_00a1: Unknown result type (might be due to invalid IL or missing references)
        //IL_00ab: Expected O, but got Unknown
        ItemId         = itemId;
        UIFilter       = uiFilter;
        sWindow        = parentWindow;
        RawValue       = val;
        ProcessedValue = RawValue;
        int num        = val.ToLower().IndexOf(contains);
        int startIndex = num + contains.Length;

        ProcessedValue     = ProcessedValue.Insert(startIndex, "</color>");
        ProcessedValue     = ProcessedValue.Insert(num, "<color=cyan>");
        SelectionText.text = (ProcessedValue);
        SelectionButton.onClick.RemoveAllListeners();
        SelectionButton.onClick.AddListener(delegate
        {
            SetSelection();
        });

        // Sprite image
        Color     c;
        Texture2D t2d = SpriteBehaviour.ItemToTexture2D((ushort)itemId, 0, out c, uiFilter);

        ItemImage.texture = t2d;
        ItemImage.color   = c;
    }
示例#4
0
    private void loadVillagerData(Villager2 v, VillagerHouse vh, bool raw = false)
    {
        try
        {
            Villager2     newV  = v;
            VillagerHouse newVH = vh;
            VillagerHouse loadedVillagerHouse = GetCurrentLoadedVillagerHouse(); // non indexed so search for the correct one
            int           index = loadedVillagerHouses.IndexOf(loadedVillagerHouse);
            if (!raw && index != -1)
            {
                newV.SetMemories(loadedVillager.GetMemories());
                newV.SetEventFlagsSave(loadedVillager.GetEventFlagsSave());
                newV.CatchPhrase = GameInfo.Strings.GetVillagerDefaultPhrase(newV.InternalName);
            }

            if (index == -1)
            {
                //inject to earliest available house
                foreach (var house in loadedVillagerHouses)
                {
                    if (house.NPC1 == -1)
                    {
                        loadedVillagerHouse = house;
                        index      = loadedVillagerHouses.IndexOf(loadedVillagerHouse);
                        house.NPC1 = (sbyte)currentlyLoadedVillagerIndex;
                        break;
                    }
                }

                if (index == -1)
                {
                    throw new Exception("Selected villager has no house, and no houses are available.");
                }
            }

            // check if they are moving in
            if (loadedVillagerHouse.WallUniqueID == WallType.HouseWallNForSale || loadedVillagerHouse.WallUniqueID == WallType.HouseWallNSoldOut)
            {
                loadedVillagerHouse.WallUniqueID = newVH.WallUniqueID;
            }
            if (checkIfMovingIn(loadedVillagerHouse))
            {
                newVH = combineHouseOrders(newVH, loadedVillagerHouse);
            }
            newVH.NPC1 = loadedVillagerHouse.NPC1;

            loadedVillagerHouses[index] = newVH;
            loadedVillager = newV;
            loadedVillagerShellsList[currentlyLoadedVillagerIndex] = newV;

            TenVillagers[currentlyLoadedVillagerIndex].texture = SpriteBehaviour.PullTextureFromParser(villagerSprites, newV.InternalName);
            setCurrentVillager(); // where the magic happens
            VillagerToUI(loadedVillager);
        }
        catch (Exception e)
        {
            Debug.LogError(e.Message);
            PopupHelper.CreateError(e.Message, 2f);
        }
    }
示例#5
0
        internal Sprite AddSprite(string imageName, SpriteBehaviour spriteBehaviour)
        {
            AddImage(imageName);
            Sprite sprite = new Sprite(imageName, spriteBehaviour, images);

            sprites.Add(sprite);
            return(sprite);
        }
示例#6
0
    public void VillagerToUI(Villager v)
    {
        VillagerName.text           = GameInfo.Strings.GetVillager(v.InternalName);
        VillagerPhrase.text         = v.CatchPhrase;
        MainVillagerTexture.texture = SpriteBehaviour.PullTextureFromParser(villagerSprites, v.InternalName);
        MovingOutToggle.isOn        = v.MovingOut;

        SaveVillagerLabel.text = string.Format("Save villager ({0})", VillagerName.text);
    }
示例#7
0
    public void InitialiseFor(string internalName, UI_VillagerSelect caller, SpriteParser sp)
    {
        this.internalName = internalName;
        root = caller;

        SelectButton.onClick.AddListener(delegate { SelectMe(); });
        VillagerName.text       = GameInfo.Strings.GetVillager(internalName);
        ImageToPutGuyOn.texture = SpriteBehaviour.PullTextureFromParser(sp, internalName);
    }
示例#8
0
    public void ClearItemsOld()
    {
        Func <Item, bool>          weedDeleter       = new Func <Item, bool>(DeleteWeed);
        ReferenceContainer <float> itemFunctionValue = new ReferenceContainer <float>(0f);
        Texture2D lawnMower = SpriteBehaviour.ItemToTexture2D(338, 0, out var _);

        UI_Popup.CurrentInstance.CreateProgressBar("Mowing lawn, please run around but don't place anything on your island...", itemFunctionValue, lawnMower, Vector3.up * 180, null, "Cancel", () => { CancelCurrentFunction(); });

        StartCoroutine(functionTiles(weedDeleter, itemFunctionValue));
    }
示例#9
0
    public void Assign(Item item)
    {
        //IL_0026: Unknown result type (might be due to invalid IL or missing references)
        //IL_006f: Unknown result type (might be due to invalid IL or missing references)

        ItemAssigned = item;

        if (item.IsMoneyTree() && SpriteBehaviour.SpritesExist())
        {
            TreeMultiImage.gameObject.SetActive(true);
            ImageComponent.enabled = false;
            //var firstInstance = IconSpriteHelper.CurrentInstance.GetCurrentParser().SpritePointerTable.FirstOrDefault(x => x.Key == item.Count.ToString("X"));
            Texture2D t2d = IconSpriteHelper.CurrentInstance.GetIconTexture(item.Count.ToString("X"));
            TreeMultiImage.SetRawImageAll(t2d);
        }
        else
        {
            TreeMultiImage.gameObject.SetActive(false);
            ImageComponent.enabled = true;
            Texture2D imageToAssign = SpriteBehaviour.ItemToTexture2D(ItemAssigned, out var c);
            if (imageToAssign)
            {
                ImageComponent.texture = imageToAssign;
            }
            else
            {
                ImageComponent.texture = blank;
            }
            ImageComponent.color = c;
        }

        if (item.IsInternalItem())
        {
            TopRightImage.texture = ResourceLoader.GetExclaimImage();
            TopRightImage.gameObject.SetActive(true);
        }
        else
        {
            TopRightImage.gameObject.SetActive(false);
        }

        FiveInts[0].text = item.Count.ToString();
        FiveInts[1].text = item.SystemParam.ToString();
        FiveInts[2].text = item.AdditionalParam.ToString();
        FiveInts[3].text = 0.ToString();
        FiveInts[4].text = item.UseCount.ToString();
        Text[] fiveInts = FiveInts;
        foreach (Text val in fiveInts)
        {
            if (val.text == 0.ToString())
            {
                val.text = "";
            }
        }
    }
示例#10
0
 // Start is called before the first frame update
 void Start()
 {
     if (PlayerPrefs.GetString(POPUPKEY, "Y") == "N")
     {
         return;
     }
     if (!SpriteBehaviour.SpritesExist())
     {
         UEP.FireAfterFrames(1);
     }
 }
    public void UpdateSprite()
    {
        if (CurrentItemID < 0)
        {
            return;
        }
        Texture2D toSet = SpriteBehaviour.ItemToTexture2D(Convert.ToUInt16(CurrentItemID), Convert.ToUInt16(SetController.FCount.text), out var col);

        SpriteImageMain.texture = toSet;
        col.a = toSet == null ? 0.0f : 0.75f;
        SpriteImageMain.color = col;
    }
示例#12
0
    public void VillagerToUI(Villager2 v)
    {
        VillagerName.text           = GameInfo.Strings.GetVillager(v.InternalName);
        VillagerPhrase.text         = v.CatchPhrase;
        MainVillagerTexture.texture = SpriteBehaviour.PullTextureFromParser(villagerSprites, v.InternalName);
        MovingOutToggle.isOn        = v.MovingOut;
        ForceMoveOutToggle.isOn     = v.GetEventFlagsSave()[24] != 0;

        SaveVillagerLabel.text = string.Format("Save villager ({0})", VillagerName.text);

        DataButton.interactable = true;
    }
示例#13
0
    void sendNewBytes()
    {
        const int  acreSizeItems = 32 * 32;
        const uint acreSizeBytes = acreSizeItems * Item.SIZE;

        // convert all to lists
        var listLayer1     = new List <Item>(fieldManager.Layer1.Tiles);
        var listLayer2     = new List <Item>(fieldManager.Layer2.Tiles);
        var templateLayer1 = new List <Item>(layerTemplate1);
        var templateLayer2 = new List <Item>(layerTemplate2);

        // split everything into acres
        var splitl1  = listLayer1.ChunkBy(acreSizeItems);
        var splitl2  = listLayer2.ChunkBy(acreSizeItems);
        var splitlt1 = templateLayer1.ChunkBy(acreSizeItems);
        var splitlt2 = templateLayer2.ChunkBy(acreSizeItems);

        var offset       = (uint)OffsetHelper.FieldItemStart;
        var offsetl2     = offset + (MapGrid.MapTileCount32x32 * Item.SIZE);
        var dataSendList = new List <OffsetData>();

        // layer 1
        for (uint i = 0; i < splitl1.Count; ++i)
        {
            int ix = (int)i;
            if (splitl1[ix].IsDifferent(splitlt1[ix]))
            {
                dataSendList.Add(new OffsetData(offset + (i * acreSizeBytes), splitl1[ix].SetArray(Item.SIZE)));
            }
        }

        // layer 2
        for (uint i = 0; i < splitl2.Count; ++i)
        {
            int ix = (int)i;
            if (splitl2[ix].IsDifferent(splitlt2[ix]))
            {
                dataSendList.Add(new OffsetData(offsetl2 + (i * acreSizeBytes), splitl2[ix].SetArray(Item.SIZE)));
            }
        }

        var layerBytes = new List <byte>(listLayer1.SetArray(Item.SIZE));

        layerBytes.AddRange(listLayer2.SetArray(Item.SIZE));

        ReferenceContainer <float> progressValue = new ReferenceContainer <float>(0f);
        Texture2D itemTex = SpriteBehaviour.ItemToTexture2D(5984, 0, out var _); // large star fragment

        UI_Popup.CurrentInstance.CreateProgressBar("Placing new acres... Go in then out of a building to view changes.", progressValue, itemTex, Vector3.up * 180, null, "Cancel", () => { StopAllCoroutines(); });
        StartCoroutine(writeData(dataSendList.ToArray(), progressValue, () => { field = layerBytes.ToArray(); generateAll(); }));
    }
示例#14
0
    public void InitialiseFor(string val, string contains, int itemId, ItemFilter uiFilter, UI_SearchWindow parentWindow)
    {
        //IL_00a1: Unknown result type (might be due to invalid IL or missing references)
        //IL_00ab: Expected O, but got Unknown
        ItemId         = itemId;
        UIFilter       = uiFilter;
        sWindow        = parentWindow;
        RawValue       = val;
        ProcessedValue = RawValue;
        int num        = val.ToLower().IndexOf(contains);
        int startIndex = num + contains.Length;

        ProcessedValue     = ProcessedValue.Insert(startIndex, "</color>");
        ProcessedValue     = ProcessedValue.Insert(num, "<color=cyan>");
        SelectionText.text = (ProcessedValue);
        SelectionButton.onClick.RemoveAllListeners();
        SelectionButton.onClick.AddListener(delegate
        {
            SetSelection();
        });

        // Sprite image
        Color     c;
        Texture2D t2d = SpriteBehaviour.ItemToTexture2D((ushort)itemId, 0, out c, uiFilter);

        ItemImage.texture = t2d;
        ItemImage.color   = c;

        // Menu icon
        t2d = MenuSpriteHelper.CurrentInstance.GetIconTexture((ushort)itemId);
        MenuIconImage.texture = t2d;
        MenuIconImage.color   = Color.white;

        if (ItemExtensions.IsInternalItem((ushort)itemId))
        {
            ColorBlock cb = SelectionButton.colors;
            cb.normalColor         = cb.normalColor * internalColor;
            cb.highlightedColor    = cb.highlightedColor * internalColor;
            cb.pressedColor        = cb.pressedColor * internalColor;
            cb.disabledColor       = cb.disabledColor * internalColor;
            cb.selectedColor       = cb.selectedColor * internalColor;
            SelectionButton.colors = cb;

            WarningImage.gameObject.SetActive(true);
        }
        else
        {
            WarningImage.gameObject.SetActive(false);
        }
    }
示例#15
0
    public void DumpTwoLayers()
    {
        layer1Dump = new Item[MapGrid.MapTileCount32x32]; layer2Dump = new Item[MapGrid.MapTileCount32x32];
        Func <Item, bool>          dumpL1            = new Func <Item, bool>(x => DumpItemToLayer(x, 0));
        Func <Item, bool>          dumpL2            = new Func <Item, bool>(x => DumpItemToLayer(x, 1));
        ReferenceContainer <float> itemFunctionValue = new ReferenceContainer <float>(0f);
        Texture2D itemTex = SpriteBehaviour.ItemToTexture2D(8574, 0, out var _);

        UI_Popup.CurrentInstance.CreateProgressBar("Getting item layout template, please run around but don't place anything on your island...", itemFunctionValue, itemTex, Vector3.up * 180, null, "Cancel", () => { CancelCurrentFunction(); KeepAliveButton.interactable = ResendButton.interactable = false; });

        StartCoroutine(functionTiles(dumpL1, itemFunctionValue, dumpL2));
        KeepAliveButton.interactable = true;
        ResendButton.interactable    = true;
    }
示例#16
0
    public void PlaceNMT()
    {
        Item nmt = new Item(5851);

        nmt.Count            = 9;
        CurrentlyPlacingItem = nmt;

        Func <Item, bool>          itemPlacer        = new Func <Item, bool>(PlaceItemIfEmpty);
        ReferenceContainer <float> itemFunctionValue = new ReferenceContainer <float>(0f);
        Texture2D itemTex = SpriteBehaviour.ItemToTexture2D(5851, 0, out var _);

        UI_Popup.CurrentInstance.CreateProgressBar("Placing items, please run around but don't place anything on your island...", itemFunctionValue, itemTex, Vector3.up * 180, null, "Cancel", () => { CancelCurrentFunction(); });

        StartCoroutine(functionTiles(itemPlacer, itemFunctionValue));
    }
示例#17
0
    public void UpdateSprite()
    {
        if (CurrentItemID < 0)
        {
            return;
        }

        var toUseVariation = ItemInfo.GetItemKind(Convert.ToUInt16(CurrentItemID)) == ItemKind.Kind_Fence ? SetController.FUses.text : SetController.FCount.text;

        Debug.Log(toUseVariation);
        Texture2D toSet = SpriteBehaviour.ItemToTexture2D(Convert.ToUInt16(CurrentItemID), Convert.ToUInt16(toUseVariation), out var col);

        SpriteImageMain.texture = toSet;
        col.a = toSet == null ? 0.0f : 0.75f;
        SpriteImageMain.color = col;
    }
示例#18
0
    private void loadAllVillagers()
    {
        for (int i = 0; i < 10; ++i)
        {
            byte[]    loaded        = CurrentConnection.ReadBytes(CurrentVillagerAddress + (uint)(i * Villager.SIZE), 3);
            Villager  villagerShell = new Villager(loaded);
            Texture2D pic           = SpriteBehaviour.PullTextureFromParser(villagerSprites, villagerShell.InternalName);
            if (pic != null)
            {
                TenVillagers[i].texture = pic;
            }
        }

        loadedVillagerShells = true;
        BlockerRoot.gameObject.SetActive(false);
    }
示例#19
0
    private void loadAllVillagers()
    {
        try
        {
            // load all houses
            loadAllHouses();

            loadedVillagerShellsList = new List <Villager2>();
            for (int i = 0; i < 10; ++i)
            {
                byte[]    loaded        = CurrentConnection.ReadBytes(CurrentVillagerAddress + (uint)(i * Villager2.SIZE), 3);
                Villager2 villagerShell = new Villager2(loaded);
                loadedVillagerShellsList.Add(villagerShell);
                if (villagerShell.Species == (byte)VillagerSpecies.non)
                {
                    TenVillagers[i].GetComponent <Button>().interactable = false;
                    continue;
                }
                else
                {
                    TenVillagers[i].GetComponent <Button>().interactable = true;
                }

                var ourHouse = loadedVillagerHouses.Find(x => x.NPC1 == (sbyte)i);
                if (ourHouse != null)
                {
                    if (checkIfMovingIn(ourHouse))
                    {
                        TenVillagers[i].GetComponent <Button>().interactable = false; // but still show them
                    }
                }
                Texture2D pic = SpriteBehaviour.PullTextureFromParser(villagerSprites, villagerShell.InternalName);
                if (pic != null)
                {
                    TenVillagers[i].texture = pic;
                }
            }

            loadedVillagerShells = true;
            BlockerRoot.gameObject.SetActive(false);
        }
        catch (Exception e)
        {
            PopupHelper.CreateError(e.Message, 2f);
        }
    }
示例#20
0
    public void VillagerToUI(Villager2 v)
    {
        currentSelectedGSaveMemory = 0;
        var mem = v.GetMemory(currentSelectedGSaveMemory);

        VillagerName.text           = GameInfo.Strings.GetVillager(v.InternalName);
        VillagerPhrase.text         = v.CatchPhrase;
        VillagerFriendship.text     = mem.Friendship.ToString();
        PlayerNameGSave.text        = mem.PlayerName;
        PlayerNameGSave.color       = Color.white;
        MainVillagerTexture.texture = SpriteBehaviour.PullTextureFromParser(villagerSprites, v.InternalName);
        MovingOutToggle.isOn        = v.MovingOut;
        ForceMoveOutToggle.isOn     = v.GetEventFlagsSave()[24] != 0;

        SaveVillagerLabel.text = string.Format("Save villager ({0})", VillagerName.text);

        DataButton.interactable = true;
    }
示例#21
0
    private void loadVillagerData(Villager2 v, VillagerHouse vh, bool raw = false)
    {
        try
        {
            Villager2     newV  = v;
            VillagerHouse newVH = vh;
            if (!raw)
            {
                newV.SetMemories(loadedVillager.GetMemories());
                newV.SetEventFlagsSave(loadedVillager.GetEventFlagsSave());
                newV.CatchPhrase = GameInfo.Strings.GetVillagerDefaultPhrase(newV.InternalName);
            }

            VillagerHouse loadedVillagerHouse = GetCurrentLoadedVillagerHouse(); // non indexed so search for the correct one
            int           index = loadedVillagerHouses.IndexOf(loadedVillagerHouse);
            if (index == -1)
            {
                throw new Exception("The villager being replaced doesn't have a house on your island.");
            }

            // check if they are moving in
            if (checkIfMovingIn(loadedVillagerHouse))
            {
                newVH = combineHouseOrders(newVH, loadedVillagerHouse);
            }
            newVH.NPC1 = loadedVillagerHouse.NPC1;

            loadedVillagerHouses[index] = newVH;
            loadedVillager = newV;
            loadedVillagerShellsList[currentlyLoadedVillagerIndex] = newV;

            TenVillagers[currentlyLoadedVillagerIndex].texture = SpriteBehaviour.PullTextureFromParser(villagerSprites, newV.InternalName);
            setCurrentVillager(); // where the magic happens
            VillagerToUI(loadedVillager);
        }
        catch (Exception e)
        {
            Debug.LogError(e.Message);
            PopupHelper.CreateError(e.Message, 2f);
        }
    }
示例#22
0
 public Sprite(string imageName, SpriteBehaviour behaviour, Dictionary <string, Texture2D> images)
 {
     MyImage     = imageName;
     MyBehaviour = behaviour;
     GameImages  = images;
     switch (behaviour)
     {
     case SpriteBehaviour.Bounce:
         xvel = rnd.Next(10) - 5;
         if (xvel == 0)
         {
             xvel = 1;
         }
         yvel = rnd.Next(10) - 5;
         if (yvel == 0)
         {
             yvel = 1;
         }
         break;
     }
 }
示例#23
0
    public void ClearItems()
    {
        Func <Item, bool>          deleter           = new Func <Item, bool>(x => DeleteType(x, currentRemovalItem));
        ReferenceContainer <float> itemFunctionValue = new ReferenceContainer <float>(0f);
        Texture2D imgToShow;
        string    progressString;
        Vector3   rot;

        switch (currentRemovalItem)
        {
        case RemovalItem.Bush:
        case RemovalItem.Flower:
        case RemovalItem.Weed:
            imgToShow      = SpriteBehaviour.ItemToTexture2D(338, 0, out var _); // red lawnmover
            progressString = "Mowing lawn, please run around but don't place anything on your island...";
            rot            = Vector3.up * 180;
            break;

        case RemovalItem.Fence:
        case RemovalItem.Tree:
        case RemovalItem.Stone:
        case RemovalItem.TreeBranch:
            imgToShow      = SpriteBehaviour.ItemToTexture2D(9617, 0, out var _); // golden axe
            progressString = $"Chopping up every {currentRemovalItem.ToString().ToLower()}, please run around but don't place anything on your island...";
            rot            = Vector3.up * 180;
            break;

        default:
            imgToShow      = ResourceLoader.GetAngryIsabelle(); // \_/
            progressString = "Isabelle is cleaning up your mess, please run around but don't place anything on your island...";
            rot            = Vector3.up * 180;
            break;
        }

        UI_Popup.CurrentInstance.CreateProgressBar(progressString, itemFunctionValue, imgToShow, rot, null, "Cancel", () => { CancelCurrentFunction(); });

        StartCoroutine(functionTiles(deleter, itemFunctionValue));
    }
示例#24
0
    private void loadAllVillagers()
    {
        try
        {
            // load all houses
            loadAllHouses();

            loadedVillagerShellsList = new List <Villager2>();
            for (int i = 0; i < 10; ++i)
            {
                byte[]    loaded        = CurrentConnection.ReadBytes(CurrentVillagerAddress + (uint)(i * Villager2.SIZE), 3);
                Villager2 villagerShell = new Villager2(loaded);
                loadedVillagerShellsList.Add(villagerShell);
                if (villagerShell.Species == (byte)VillagerSpecies.non)
                {
                    Texture2D pic = ResourceLoader.GetTreeImage();
                    TenVillagers[i].texture = pic;
                }
                else
                {
                    Texture2D pic = SpriteBehaviour.PullTextureFromParser(villagerSprites, villagerShell.InternalName);
                    if (pic != null)
                    {
                        TenVillagers[i].texture = pic;
                    }
                }
            }

            loadedVillagerShells = true;
            BlockerRoot.gameObject.SetActive(false);
        }
        catch (Exception e)
        {
            PopupHelper.CreateError(e.Message, 2f);
        }
    }
示例#25
0
    public void Assign(Item item)
    {
        //IL_0026: Unknown result type (might be due to invalid IL or missing references)
        //IL_006f: Unknown result type (might be due to invalid IL or missing references)
        ItemAssigned = item;
        Texture2D imageToAssign = SpriteBehaviour.ItemToTexture2D(ItemAssigned, out var c);

        ImageComponent.texture = imageToAssign;
        ImageComponent.color   = c;

        FiveInts[0].text = item.Count.ToString();
        FiveInts[1].text = item.SystemParam.ToString();
        FiveInts[2].text = item.AdditionalParam.ToString();
        FiveInts[3].text = 0.ToString();
        FiveInts[4].text = item.UseCount.ToString();
        Text[] fiveInts = FiveInts;
        foreach (Text val in fiveInts)
        {
            if (val.text == 0.ToString())
            {
                val.text = "";
            }
        }
    }
示例#26
0
 void Start()
 {
     //player = FindObjectOfType<SpriteBehaviour> ();
     player = GameObject.FindGameObjectWithTag("Player").GetComponent <SpriteBehaviour>();
     star1  = GameObject.FindGameObjectWithTag("StarPlayer").GetComponent <StarPlayerPointScript> ();
 }
示例#27
0
 // Use this for initialization
 private void Start()
 {
     renderer = GetComponent <SpriteBehaviour> ();
     flasher  = new Flasher(totalFlashes, delay);
 }
示例#28
0
 public void SetUp()
 {
     subject = new SpriteBehaviour();
 }
    public void SetItem(FieldItemBlock block, Color bg, UI_MapTerrain editorCallback)
    {
        if (Recipes == null)
        {
            Recipes = GameInfo.Strings.CreateItemDataSource(RecipeList.Recipes, false);
            Fossils = GameInfo.Strings.CreateItemDataSource(GameLists.Fossils, false);
        }
        // Manually destroy any cached images
        if (Image.texture)
        {
            if (Image.texture != ResourceLoader.GetLeafImage())
            {
                Destroy(Image.texture);
            }
        }

        callback = editorCallback;
        var rootItem = block.SelectedItem;
        var isNone   = rootItem.IsNone;

        OverlayText.text = string.Empty;
        item             = block;

        Texture2D tex;
        Color     c = Color.white;

        if (rootItem.SystemParam == 0x20)
        {
            // use menuicon for fish/bugs that are "placed"
            var kind = ItemInfo.GetItemKind(rootItem);
            if (kind == ItemKind.Kind_Insect || ItemKindExtensions.IsFish(kind))
            {
                tex = MenuSpriteHelper.CurrentInstance.GetIconTexture(rootItem.ItemId);
            }
            else
            {
                tex = SpriteBehaviour.ItemToTexture2D(rootItem, out c);
            }
        }
        else
        {
            tex = SpriteBehaviour.ItemToTexture2D(rootItem, out c);
        }
        Image.texture    = tex;
        Background.color = isNone ? bg : c;
        Image.gameObject.SetActive(!isNone);

        if (tex != null)
        {
            if (tex.name.StartsWith("leaf")) // all defaults are "leaf"
            {
                // default image/no sprites loaded/field item
                OverlayText.text = GetName(rootItem.DisplayItemId);
                Image.gameObject.SetActive(false);
            }
        }

        if (rootItem.ItemId >= 60_000 && !isNone)
        {
            OverlayText.text = GetName(rootItem.DisplayItemId);
        }
        if (rootItem.ItemId == Item.MessageBottle || rootItem.ItemId == Item.DIYRecipe || rootItem.ItemId == Item.MessageBottleEgg)
        {
            OverlayText.text = Recipes.Find(x => x.Value == rootItem.Count).Text;
        }
        if (rootItem.ItemId == UI_SearchWindow.FOSSILITEM)
        {
            OverlayText.text = Fossils.Find(x => x.Value == rootItem.Count).Text;
        }

        ViewId = rootItem.ItemId;
    }
 void Start()
 {
     player = FindObjectOfType <SpriteBehaviour> ();
 }