Example #1
0
	public override void AddSlot(SlotData slot)
	{
		ValidateDictionary();
		var hash = UMASkeleton.StringToHash(slot.slotName);
		if (slotDictionary.ContainsKey(hash))
		{
			for (int i = 0; i < slotElementList.Length; i++)
			{
				if (slotElementList[i].slotName == slot.slotName)
				{
					slotElementList[i] = slot;
					break;
				}
			}
		}
		else
		{
			var list = new SlotData[slotElementList.Length + 1];
			for (int i = 0; i < slotElementList.Length; i++)
			{
				list[i] = slotElementList[i];
			}
			list[list.Length - 1] = slot;
			slotElementList = list;
		}
		slotDictionary[hash] = slot;
	}
 void AddSlotToTable(Slot slot)
 {
     slotTable[InternalGetSlotName(slot)] = new SlotData() { Slot = slot };
     foreach (var child in slot.Children)
     {
         AddSlotToTable(child);
     }
 }
 public PlayerBlockPlacementPacket(Int32 x = 0, sbyte y = 0, Int32 z = 0, sbyte direction = 0, SlotData heldItem = null)
     : base(PacketType.PlayerBlockPlacement)
 {
     X = x;
     Y = y;
     Z = z;
     Direction = direction;
     HeldItem = heldItem;
 }
Example #4
0
	private SlotData[] GetSlotDataArray()
	{

		int arrayCount = m_SlotDataCount.intValue;
		SlotData[] SlotDataArray = new SlotData[arrayCount];

		for (int i = 0; i < arrayCount; i++)
		{

			SlotDataArray[i] = m_Object.FindProperty(string.Format(kArrayData, i)).objectReferenceValue as SlotData;

		}
		return SlotDataArray;

	}
Example #5
0
    public void PopulateSlot()
    {
        slot = player.GetCritter().GetSpecificSlot(type, index);

        if(!slot.GetEvo()){
            activeEvo = null;
            Icon.sprite = null;
            Icon.color = new Color32(255, 255, 255, 0);
        }
        else{
            activeEvo = slot.GetEvo();
            Icon.sprite = slot.GetEvo().GetIcon();
            Icon.color = new Color32(255, 255, 255, 255);
        }
    }
Example #6
0
 public void AddSlot(string name, SlotData slot)
 {
     var list = new SlotData[slotElementList.Length + 1];
     for (int i = 0; i < slotElementList.Length; i++)
     {
         if (slotElementList[i].slotName == name)
         {
             slotElementList[i] = slot;
             return;
         }
         list[i] = slotElementList[i];
     }
     list[list.Length - 1] = slot;
     slotElementList = list;
     slotDictionary.Add(name, slot);
 }
Example #7
0
 public override void Decode(MinecraftStream stream)
 {
     EntityId = stream.ReadVarInt();
     Slot     = (SlotEnum)stream.ReadVarInt();
     Item     = stream.ReadSlot();
 }
Example #8
0
    private bool RemoveNumberFromData(SudokuData sData, int count)
    {
        // 1. Remove value of a "Filled" slot randomly
        // 2. Check this data is solvable.
        //    If solvable, count by one, if not solvable, undo step 1.

        sData.Update();
        List <int> filledSlotList = sData.GetAllFilledSlotIndex();
        int        retryCount     = filledSlotList.Count;
        int        exeCount       = 0;
        int        rndSlotIndex   = -1;
        int        rndSlotValue   = -1;
        FillReason rndSlotReason  = FillReason.None;

        while (exeCount < retryCount)
        {
            // Revert if previous try is available (previous try failed)
            if (rndSlotIndex != -1)
            {
                sData.SetSlotValueAndReason(rndSlotIndex, rndSlotValue, rndSlotReason);
            }

            // Try remove random slot
            if (filledSlotList.Count == 0)
            {
                return(false);
            }

            int rndListIndex = Random.Range(0, filledSlotList.Count);
            rndSlotIndex = filledSlotList[rndListIndex];
            SlotData slotData = sData.GetSlotData(rndSlotIndex);
            rndSlotValue  = slotData.Value;
            rndSlotReason = slotData.Reason;
            filledSlotList.RemoveAt(rndListIndex);

            sData.SetSlotValueAndReason(rndSlotIndex, 0, FillReason.None);
            exeCount += 1;

            if (!sData.IsSolvable())
            {
                continue;
            }

            if (count <= 1)
            {
                return(true);
            }

            bool success = RemoveNumberFromData(sData, count - 1);
            if (success)
            {
                return(true);
            }
            else
            {
                continue;
            }
        }

        return(false);
    }
Example #9
0
 public override void Decode(MinecraftStream stream)
 {
     WindowId = (byte)stream.ReadByte();
     SlotId   = stream.ReadShort();
     Slot     = stream.ReadSlot();
 }
Example #10
0
	static Slot GetExtractionSlot () {
		if (extractionSlot != null)
			return extractionSlot;

		Bone bone = GetExtractionBone();

		SlotData data = new SlotData("temp", bone.Data);
		Slot slot = new Slot(data, bone);
		extractionSlot = slot;
		return extractionSlot;
	}
Example #11
0
 public abstract void AddSlot(SlotData slot);
Example #12
0
            public override bool OnGUI(string targetName, ref bool _dnaDirty, ref bool _textureDirty, ref bool _meshDirty)
            {
                bool changed = false;

                if (_sharedColorsEditor.OnGUI(_recipe))
                {
                    changed       = true;
                    _textureDirty = true;
                }

                GUILayout.Space(6);
                Rect dropArea = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true));

                GUI.Box(dropArea, "Drag Slots and Overlays here. Click to pick");
                if (DropAreaGUI(dropArea))
                {
                    changed       |= true;
                    _dnaDirty     |= true;
                    _textureDirty |= true;
                    _meshDirty    |= true;
                }
                GUILayout.Space(10);

                if (_baseSlotOptions.Count > 0)
                {
                    var baseSlotsNamesList = new List <string>()
                    {
                        "None"
                    };
                    for (int i = 0; i < _baseSlotOptionsLabels.Count; i++)
                    {
                        baseSlotsNamesList.Add(_baseSlotOptionsLabels[i]);
                    }
                    EditorGUI.BeginChangeCheck();
                    var baseAdded = EditorGUILayout.Popup("Add Base Slot", 0, baseSlotsNamesList.ToArray());
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (baseAdded != 0)
                        {
                            var slotName = _baseSlotOptions[baseAdded - 1];
                            LastSlot = slotName;
                            //we know there should be one because we created a virtual one when we unpacked the recipe if it didn't exist
                            var context   = UMAContext.FindInstance();
                            var slotToAdd = context.InstantiateSlot(slotName);
                            _recipe.MergeSlot(slotToAdd, false);
                            changed       |= true;
                            _dnaDirty     |= true;
                            _textureDirty |= true;
                            _meshDirty    |= true;
                        }
                    }
                }

                var added = (SlotDataAsset)EditorGUILayout.ObjectField("Add Slot", null, typeof(SlotDataAsset), false);

                if (added != null)
                {
                    LastSlot = added.slotName;
                    var slot = new SlotData(added);
                    _recipe.MergeSlot(slot, false);
                    changed       |= true;
                    _dnaDirty     |= true;
                    _textureDirty |= true;
                    _meshDirty    |= true;
                }

                GUILayout.Space(20);
                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Clear Recipe"))
                {
                    _recipe.slotDataList = new SlotData[0];
                    changed       |= true;
                    _dnaDirty     |= true;
                    _textureDirty |= true;
                    _meshDirty    |= true;
                }
                if (GUILayout.Button("Remove Nulls"))
                {
                    var newList = new List <SlotData>(_recipe.slotDataList.Length);
                    foreach (var slotData in _recipe.slotDataList)
                    {
                        if (slotData != null)
                        {
                            newList.Add(slotData);
                        }
                    }
                    _recipe.slotDataList = newList.ToArray();
                    changed       |= true;
                    _dnaDirty     |= true;
                    _textureDirty |= true;
                    _meshDirty    |= true;
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                if (GUILayout.Button("Collapse All"))
                {
                    foreach (SlotEditor se in _slotEditors)
                    {
                        se.FoldOut = false;
                    }
                }
                if (GUILayout.Button("Expand All"))
                {
                    foreach (SlotEditor se in _slotEditors)
                    {
                        se.FoldOut = true;
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();

                if (GUILayout.Button("Select All Slots"))
                {
                    SelectAllSlots();
                }
                if (GUILayout.Button("Select All Overlays"))
                {
                    SelectAllOverlays();
                }

                GUILayout.EndHorizontal();

                for (int i = 0; i < _slotEditors.Count; i++)
                {
                    var editor = _slotEditors[i];

                    if (editor == null)
                    {
                        GUILayout.Label("Empty Slot");
                        continue;
                    }

                    changed |= editor.OnGUI(ref _dnaDirty, ref _textureDirty, ref _meshDirty);

                    if (editor.Delete)
                    {
                        _dnaDirty     = true;
                        _textureDirty = true;
                        _meshDirty    = true;

                        _slotEditors.RemoveAt(i);
                        _recipe.SetSlot(editor.idx, null);
                        i--;
                        changed = true;
                    }
                }

                return(changed);
            }
Example #13
0
 private void UMARemoveOverlay(SlotData slot, string overlayName)
 {
     slot.RemoveOverlay(overlayName);
 }
 protected void SetSlot(int x, int y, SlotData value)
 {
     UpdateMatrix();
     slotMatrix[x + grid.width * y] = value;
 }
Example #15
0
 private void Start()
 {
     c = GameObject.Find("SlotData").GetComponent <SlotData>();
 }
Example #16
0
 public virtual void AddSlot(SlotData slot)
 {
     throw new NotFiniteNumberException();
 }
Example #17
0
    static ArmatureData DecodeArmature(JSONClass parent, JSONClass json)
    {
        ArmatureData data = new ArmatureData();

        data.name        = json["name"].Value;
        data.frameRate   = TryGetInt(json, "frameRate", parent["frameRate"].AsInt);
        data.type        = TryGetString(json, "type", "Armature");
        data.vertexDatas = new VertexData();

        //bone
        JSONArray bones = json["bone"].AsArray;

        BoneData[] boneDatas = new BoneData[bones.Count];
        for (int i = 0; i < bones.Count; i++)
        {
            boneDatas[i] = DecodeBone(bones[i].AsObject);
        }
        data.boneDatas = boneDatas;



        //slot
        JSONArray slots = json["slot"].AsArray;

        SlotData[] slotDatas = new SlotData[slots.Count];
        for (int i = 0; i < slots.Count; i++)
        {
            slotDatas[i] = DecodeSlot(slots[i].AsObject);
        }
        data.slotDatas = slotDatas;


        JSONArray          skins       = json["skin"].AsArray;
        List <DisplayData> displayData = new List <DisplayData>();

        for (int i = 0; i < skins.Count; i++)
        {
            JSONClass skin    = skins[i].AsObject;
            JSONArray d_slots = skin["slot"].AsArray;
            for (int j = 0; j < d_slots.Count; j++)
            {
                JSONClass d_slot      = d_slots[j].AsObject;
                string    d_slot_name = d_slot["name"];
                JSONArray d_displays  = d_slot["display"].AsArray;
                for (int k = 0; k < d_displays.Count; k++)
                {
                    displayData.Add(DecodeDisplay(d_displays[k].AsObject, d_slot_name));
                }
            }
        }
        data.displayDatas          = displayData.ToArray();
        data.vertexDatas.vertices  = vertices.ToArray();
        data.vertexDatas.uvs       = uvs.ToArray();
        data.vertexDatas.triangles = triangles.ToArray();
        data.vertexDatas.weights   = weights.ToArray();
        JSONArray animations = json["animation"].AsArray;

        data.animations = new AnimationData[animations.Count];
        for (int i = 0; i < animations.Count; i++)
        {
            data.animations[i] = DecodeAnimation(animations[i].AsObject);
        }

        return(data);
    }
Example #18
0
 public CreativeInventoryActionPacket(Int16 slot = 0, SlotData clickedItem = null) : base(PacketType.CreativeInventoryAction)
 {
     Slot        = slot;
     ClickedItem = clickedItem;
 }
Example #19
0
 public void LoadInfo(SlotData data)
 {
     Items = data.items;
 }
Example #20
0
        public void SwapItem(SlotData slot1, SlotData slot2)
        {
            Entity en1 = Parent.GetEntity(slot1.ObjectId);
            Entity en2 = Parent.GetEntity(slot2.ObjectId);

            (en1 as IContainer)?.UpdateInventorySlot(slot1.SlotId);
            (en2 as IContainer)?.UpdateInventorySlot(slot2.SlotId);

            //Undefined entities
            if (en1 == null || en2 == null)
            {
#if DEBUG
                Program.Print(PrintType.Error, "Undefined entities");
#endif
                Client.Send(InvalidInvSwap);
                return;
            }

            //Entities which are not containers???
            if (!(en1 is IContainer) || !(en2 is IContainer))
            {
#if DEBUG
                Program.Print(PrintType.Error, "Not containers");
#endif
                Client.Send(InvalidInvSwap);
                return;
            }

            if (en1.Position.Distance(en2) > ContainerMinimumDistance)
            {
#if DEBUG
                Program.Print(PrintType.Error, "Too far away from container");
#endif
                Client.Send(InvalidInvSwap);
                return;
            }

            //Player manipulation attempt
            if ((en1 is Player && slot1.ObjectId != Id) ||
                (en2 is Player && slot2.ObjectId != Id))
            {
#if DEBUG
                Program.Print(PrintType.Error, "Player manipulation attempt");
#endif
                Client.Send(InvalidInvSwap);
                return;
            }

            //Container manipulation attempt
            if ((en1 is Container &&
                 (en1 as Container).OwnerId != -1 &&
                 Id != (en1 as Container).OwnerId) ||
                (en2 is Container &&
                 (en2 as Container).OwnerId != -1 &&
                 Id != (en2 as Container).OwnerId))
            {
#if DEBUG
                Program.Print(PrintType.Error, "Container manipulation attempt");
#endif
                Client.Send(InvalidInvSwap);
                return;
            }

            IContainer con1 = en1 as IContainer;
            IContainer con2 = en2 as IContainer;

            //Invalid slots
            if (!con1.ValidSlot(slot1.SlotId) || !con2.ValidSlot(slot2.SlotId))
            {
#if DEBUG
                Program.Print(PrintType.Error, "Invalid inv swap");
#endif
                Client.Send(InvalidInvSwap);
                return;
            }

            //Invalid slot types
            int        item1 = con1.Inventory[slot1.SlotId];
            int        data1 = con1.ItemDatas[slot1.SlotId];
            int        item2 = con2.Inventory[slot2.SlotId];
            int        data2 = con2.ItemDatas[slot2.SlotId];
            PlayerDesc d     = Desc as PlayerDesc;
            ItemDesc   d1;
            ItemDesc   d2;
            Resources.Type2Item.TryGetValue((ushort)item1, out d1);
            Resources.Type2Item.TryGetValue((ushort)item2, out d2);

            if (con1 is Player)
            {
                for (int i = 0; i < 4; i++)
                {
                    if (slot1.SlotId == i)
                    {
                        if ((d1 != null && d.SlotTypes[i] != d1.SlotType) ||
                            (d2 != null && d.SlotTypes[i] != d2.SlotType))
                        {
#if DEBUG
                            Program.Print(PrintType.Error, "Invalid slot type");
#endif
                            Client.Send(InvalidInvSwap);
                            return;
                        }
                    }
                }
            }

            if (con2 is Player)
            {
                for (int i = 0; i < 4; i++)
                {
                    if (slot2.SlotId == i)
                    {
                        if ((d1 != null && d.SlotTypes[i] != d1.SlotType) ||
                            (d2 != null && d.SlotTypes[i] != d2.SlotType))
                        {
#if DEBUG
                            Program.Print(PrintType.Error, "Invalid slot type");
#endif
                            Client.Send(InvalidInvSwap);
                            return;
                        }
                    }
                }
            }

            con1.Inventory[slot1.SlotId] = item2;
            con1.ItemDatas[slot1.SlotId] = data2;
            con2.Inventory[slot2.SlotId] = item1;
            con2.ItemDatas[slot2.SlotId] = data1;
            con1.UpdateInventorySlot(slot1.SlotId);
            con2.UpdateInventorySlot(slot2.SlotId);
            RecalculateEquipBonuses();
            Client.Send(ValidInvSwap);
        }
Example #21
0
    private void DropAreaGUI(Rect dropArea)
    {
        var evt = Event.current;

        if (evt.type == EventType.DragUpdated)
        {
            if (dropArea.Contains(evt.mousePosition))
            {
                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
            }
        }

        if (evt.type == EventType.DragPerform)
        {
            if (dropArea.Contains(evt.mousePosition))
            {
                DragAndDrop.AcceptDrag();

                UnityEngine.Object[] draggedObjects = DragAndDrop.objectReferences as UnityEngine.Object[];
                var slots    = new List <SlotData>();
                var overlays = new List <OverlayData>();

                for (int i = 0; i < draggedObjects.Length; i++)
                {
                    if (draggedObjects[i])
                    {
                        SlotData tempSlotData = draggedObjects[i] as SlotData;
                        if (tempSlotData)
                        {
                            slots.Add(tempSlotData);
                        }

                        OverlayData tempOverlayData = draggedObjects[i] as OverlayData;
                        if (tempOverlayData)
                        {
                            overlays.Add(tempOverlayData);
                        }
                    }
                }
                if (slots.Count > 0 && overlays.Count > 0)
                {
                    var randomSet        = target as UMACrowdRandomSet;
                    var crowdSlotElement = new UMACrowdRandomSet.CrowdSlotElement();
                    crowdSlotElement.possibleSlots = new UMACrowdRandomSet.CrowdSlotData[slots.Count];
                    for (int i = 0; i < slots.Count; i++)
                    {
                        var crowdSlotData = new UMACrowdRandomSet.CrowdSlotData();
                        crowdSlotData.slotID          = slots[i].slotName;
                        crowdSlotData.overlayElements = new UMACrowdRandomSet.CrowdOverlayElement[overlays.Count];
                        for (int j = 0; j < overlays.Count; j++)
                        {
                            var crowdOverlayElement = new UMACrowdRandomSet.CrowdOverlayElement();
                            crowdOverlayElement.possibleOverlays = new UMACrowdRandomSet.CrowdOverlayData[]
                            {
                                new UMACrowdRandomSet.CrowdOverlayData()
                                {
                                    maxRGB = Color.white, minRGB = Color.white, overlayID = overlays[j].overlayName
                                }
                            };
                            crowdSlotData.overlayElements[j] = crowdOverlayElement;
                        }
                        crowdSlotElement.possibleSlots[i] = crowdSlotData;
                    }
                    ArrayUtility.Add(ref randomSet.data.slotElements, crowdSlotElement);
                    EditorUtility.SetDirty(randomSet);
                    AssetDatabase.SaveAssets();
                }
            }
        }
    }
Example #22
0
        public static void GenerateSkeletonRendererInstruction(SkeletonRendererInstruction instructionOutput, Skeleton skeleton, Dictionary <Slot, Material> customSlotMaterials, List <Slot> separatorSlots, bool generateMeshOverride, bool immutableTriangles = false)
        {
            ExposedList <Slot> drawOrder = skeleton.drawOrder;
            int count = drawOrder.Count;

            instructionOutput.Clear();
            ExposedList <SubmeshInstruction> submeshInstructions = instructionOutput.submeshInstructions;

            instructionOutput.attachments.Resize(count);
            Attachment[]       items              = instructionOutput.attachments.Items;
            int                num                = 0;
            bool               hasActiveClipping  = false;
            SubmeshInstruction submeshInstruction = default(SubmeshInstruction);

            submeshInstruction.skeleton = skeleton;
            submeshInstruction.preActiveClippingSlotSource = -1;
            SubmeshInstruction submeshInstruction2 = submeshInstruction;
            bool     flag  = customSlotMaterials != null && customSlotMaterials.Count > 0;
            int      num2  = (separatorSlots != null) ? separatorSlots.Count : 0;
            bool     flag2 = num2 > 0;
            int      num3  = -1;
            int      preActiveClippingSlotSource = -1;
            SlotData slotData = null;
            int      num4     = 0;

            Slot[] items2 = drawOrder.Items;
            for (int i = 0; i < count; i++)
            {
                Slot             slot             = items2[i];
                Attachment       attachment       = items[i] = slot.attachment;
                int              num5             = 0;
                int              num6             = 0;
                object           obj              = null;
                bool             flag3            = false;
                RegionAttachment regionAttachment = attachment as RegionAttachment;
                if (regionAttachment != null)
                {
                    obj  = regionAttachment.RendererObject;
                    num5 = 4;
                    num6 = 6;
                }
                else
                {
                    MeshAttachment meshAttachment = attachment as MeshAttachment;
                    if (meshAttachment != null)
                    {
                        obj  = meshAttachment.RendererObject;
                        num5 = meshAttachment.worldVerticesLength >> 1;
                        num6 = meshAttachment.triangles.Length;
                    }
                    else
                    {
                        ClippingAttachment clippingAttachment = attachment as ClippingAttachment;
                        if (clippingAttachment != null)
                        {
                            slotData = clippingAttachment.endSlot;
                            num3     = i;
                            submeshInstruction2.hasClipping = true;
                            hasActiveClipping = true;
                        }
                        flag3 = true;
                    }
                }
                if (slotData != null && slot.data == slotData)
                {
                    slotData = null;
                    num3     = -1;
                }
                if (flag2)
                {
                    submeshInstruction2.forceSeparate = false;
                    for (int j = 0; j < num2; j++)
                    {
                        if (object.ReferenceEquals(slot, separatorSlots[j]))
                        {
                            submeshInstruction2.forceSeparate = true;
                            break;
                        }
                    }
                }
                if (flag3)
                {
                    if (submeshInstruction2.forceSeparate && generateMeshOverride)
                    {
                        submeshInstruction2.endSlot = i;
                        submeshInstruction2.preActiveClippingSlotSource = preActiveClippingSlotSource;
                        submeshInstructions.Resize(num4 + 1);
                        submeshInstructions.Items[num4] = submeshInstruction2;
                        num4++;
                        submeshInstruction2.startSlot           = i;
                        preActiveClippingSlotSource             = num3;
                        submeshInstruction2.rawTriangleCount    = 0;
                        submeshInstruction2.rawVertexCount      = 0;
                        submeshInstruction2.rawFirstVertexIndex = num;
                        submeshInstruction2.hasClipping         = (num3 >= 0);
                    }
                    continue;
                }
                Material value;
                if (flag)
                {
                    if (!customSlotMaterials.TryGetValue(slot, out value))
                    {
                        value = (Material)((AtlasRegion)obj).page.rendererObject;
                    }
                }
                else
                {
                    value = (Material)((AtlasRegion)obj).page.rendererObject;
                }
                if (submeshInstruction2.forceSeparate || (submeshInstruction2.rawVertexCount > 0 && !object.ReferenceEquals(submeshInstruction2.material, value)))
                {
                    submeshInstruction2.endSlot = i;
                    submeshInstruction2.preActiveClippingSlotSource = preActiveClippingSlotSource;
                    submeshInstructions.Resize(num4 + 1);
                    submeshInstructions.Items[num4] = submeshInstruction2;
                    num4++;
                    submeshInstruction2.startSlot           = i;
                    preActiveClippingSlotSource             = num3;
                    submeshInstruction2.rawTriangleCount    = 0;
                    submeshInstruction2.rawVertexCount      = 0;
                    submeshInstruction2.rawFirstVertexIndex = num;
                    submeshInstruction2.hasClipping         = (num3 >= 0);
                }
                submeshInstruction2.material            = value;
                submeshInstruction2.rawTriangleCount   += num6;
                submeshInstruction2.rawVertexCount     += num5;
                submeshInstruction2.rawFirstVertexIndex = num;
                num += num5;
            }
            if (submeshInstruction2.rawVertexCount > 0)
            {
                submeshInstruction2.endSlot = count;
                submeshInstruction2.preActiveClippingSlotSource = preActiveClippingSlotSource;
                submeshInstruction2.forceSeparate = false;
                submeshInstructions.Resize(num4 + 1);
                submeshInstructions.Items[num4] = submeshInstruction2;
            }
            instructionOutput.hasActiveClipping  = hasActiveClipping;
            instructionOutput.rawVertexCount     = num;
            instructionOutput.immutableTriangles = immutableTriangles;
        }
Example #23
0
    void DetectDrop()
    {
        PointerEventData eventData = new PointerEventData(es);

        eventData.position = Input.mousePosition;

        List <RaycastResult> results = new List <RaycastResult>();

        _raycaster.Raycast(eventData, results);

        foreach (RaycastResult result in results)
        {
            if (result.gameObject.name == "Slot A" || result.gameObject.name == "Slot B")
            {
                PlayerData _pData = GameObject.Find("PlayerMaster").GetComponent <PlayerData>();
                if (_pData._currCreature != null && _pData._currCreatureData != null)
                {
                    SlotData sd = result.gameObject.GetComponent <SlotData>();
                    if (sd._slotCreature == null)
                    {
                        sd._slotCreature = _pData._currCreature;
                        if (result.gameObject.name == "Slot A")
                        {
                            _cl.ToCombine[0] = _pData._currCreature;
                        }
                        else
                        {
                            _cl.ToCombine[1] = _pData._currCreature;
                        }

                        _pData._currCreature.transform.GetChild(0).position = new Vector3(10000f, 0f, 0f);
                        _cMaster._creatures.Remove(_pData._currCreature);
                    }
                    result.gameObject.transform.GetChild(0).GetComponent <Image>().sprite = _pData._currCreatureData.CreatureImage;
                }
                _pData._currCreature     = null;
                _pData._currCreatureData = null;
            }

            if (result.gameObject.name == "Shop Item")
            {
                SpawnItemInHand(result.gameObject);
            }

            if (result.gameObject.name == "Free Menu")
            {
                FreeCreature();
            }

            if (result.gameObject.name == "Toolbar Slot 01")
            {
                if (_pData._pi != null)
                {
                    AddCreatureToToolbar(1, result.gameObject);
                }
            }

            if (result.gameObject.name == "Toolbar Slot 02")
            {
                if (_pData._pi != null)
                {
                    AddCreatureToToolbar(2, result.gameObject);
                }
            }

            if (result.gameObject.name == "Toolbar Slot 03")
            {
                if (_pData._pi != null)
                {
                    AddCreatureToToolbar(3, result.gameObject);
                }
            }
        }
    }
Example #24
0
        public override void OnInspectorGUI()
        {
            EditorGUIUtility.LookLikeControls();

            race.raceName  = EditorGUILayout.TextField("Race Name", race.raceName);
            race.umaTarget = (UMA.RaceData.UMATarget)EditorGUILayout.EnumPopup("UMA Target", race.umaTarget);
            race.genericRootMotionTransformName = EditorGUILayout.TextField("Root Motion Transform", race.genericRootMotionTransformName);
            race.racePrefab = EditorGUILayout.ObjectField("Prefab", race.racePrefab, typeof(GameObject), false) as GameObject;
            race.TPose      = EditorGUILayout.ObjectField("TPose", race.TPose, typeof(UmaTPose), false) as UmaTPose;

            if (race.baseSlot != null)
            {
                race.baseSlot = EditorGUILayout.ObjectField("Base Slot", race.baseSlot, typeof(SlotData), false) as SlotData;
            }
            else
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Base Slot");
                if (race.racePrefab == null)
                {
                    GUI.enabled = false;
                }

                if (GUILayout.Button("Create"))
                {
                    UMAData[] umaDataSet = race.racePrefab.GetComponentsInChildren <UMAData>(true);

                    if (umaDataSet.Length == 1)
                    {
                        UMAData  umaData = umaDataSet[0];
                        SlotData newSlot = ScriptableObject.CreateInstance <SlotData>();
                        newSlot.slotName = race.raceName + "Base";
                        int boneCount = umaData.tempBoneData.Length;
                        newSlot.umaBoneData = new Transform[boneCount];
                        for (int i = 0; i < boneCount; i++)
                        {
                            newSlot.umaBoneData[i] = umaData.tempBoneData[i].boneTransform;
                        }
                        boneCount             = umaData.animatedBones.Length;
                        newSlot.animatedBones = new Transform[boneCount];
                        System.Array.Copy(umaData.animatedBones, newSlot.animatedBones, boneCount);
                        if (race.AnimatedBones != null)
                        {
                            Debug.LogWarning("AnimatedBones may be missing from base slot!");
                        }
//						newSlot.meshRenderer = race.racePrefab.GetComponentInChildren<SkinnedMeshRenderer>();
                        string assetPath   = AssetDatabase.GetAssetPath(race);
                        string assetFolder = assetPath.Substring(0, assetPath.LastIndexOf('/') + 1);
                        AssetDatabase.CreateAsset(newSlot, assetFolder + race.name + " Base.asset");
                        AssetDatabase.SaveAssets();

                        race.baseSlot = newSlot;
                    }
                    else if (umaDataSet.Length > 1)
                    {
                        Debug.LogWarning("More than 1 UMAData found in race prefab!");
                    }
                    else
                    {
                        Debug.LogWarning("No UMAData found in race prefab!");
                    }
                }

                EditorGUILayout.EndHorizontal();
                GUI.enabled = true;
            }

            EditorGUILayout.Space();

            SerializedProperty dnaConverters = serializedObject.FindProperty("dnaConverterList");

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(dnaConverters, true);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }

            EditorGUIUtility.LookLikeControls();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(race);
                AssetDatabase.SaveAssets();
            }
        }
Example #25
0
    //Equips Major evo to critter's dataSlot; then pushes all new requirements
    public void Equip(Critter critter, SlotData dataSlot)
    {
        dataSlot.EquipSlot(this);
        LockConflicts(critter);
        ModifyStats(critter);

        if(critter.GetIsPlayer()){
            CheckCurrentBuyState(critter);

            foreach (Adaptation item in Prerequisites1)
            {
                item.CheckCurrentBuyState(critter);
            }
            foreach (Adaptation item in Prerequisites2)
            {
                item.CheckCurrentBuyState(critter);
            }
            foreach (Adaptation item in Unlocks)
            {
                item.CheckCurrentBuyState(critter);
            }
        }

        critter.GenerateDiet();
        critter.GenerateLocomotion();
    }
    public override void OnInspectorGUI()
    {
        m_Object.Update();

        GUILayout.Label("slotElementList", EditorStyles.boldLabel);

        SlotData[] slotElementList = GetSlotDataArray();

        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Order by Name"))
        {
            canUpdate = false;

            List <SlotData> SlotDataTemp = slotElementList.ToList();

            //Make sure there's no invalid data
            for (int i = 0; i < SlotDataTemp.Count; i++)
            {
                if (SlotDataTemp[i] == null)
                {
                    SlotDataTemp.RemoveAt(i);
                    i--;
                }
            }

            SlotDataTemp.Sort((x, y) => x.name.CompareTo(y.name));

            for (int i = 0; i < SlotDataTemp.Count; i++)
            {
                SetSlotData(i, SlotDataTemp[i]);
            }
        }

        if (GUILayout.Button("Update List"))
        {
            isDirty   = true;
            canUpdate = false;
        }


        GUILayout.EndHorizontal();

        GUILayout.Space(20);
        Rect dropArea = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true));

        GUI.Box(dropArea, "Drag Slots here");
        GUILayout.Space(20);


        for (int i = 0; i < m_SlotDataCount.intValue; i++)
        {
            GUILayout.BeginHorizontal();

            SlotData result = EditorGUILayout.ObjectField(slotElementList[i], typeof(SlotData), true) as SlotData;

            if (GUI.changed && canUpdate)
            {
                SetSlotData(i, result);
            }

            if (GUILayout.Button("-", GUILayout.Width(20.0f)))
            {
                canUpdate = false;
                RemoveSlotDataAtIndex(i);
            }

            GUILayout.EndHorizontal();

            if (i == m_SlotDataCount.intValue - 1)
            {
                canUpdate = true;

                if (isDirty)
                {
                    slotLibrary.UpdateDictionary();
                    isDirty = false;
                }
            }
        }

        DropAreaGUI(dropArea);

        if (GUILayout.Button("Add SlotData"))
        {
            AddSlotData(null);
        }

        if (GUILayout.Button("Clear List"))
        {
            m_SlotDataCount.intValue = 0;
        }


        m_Object.ApplyModifiedProperties();
    }
 public SlotPanel()
 {
     topSlotData = new SlotData() { Slot = new Slot() { Name = "" } };
 }
 private void SetSlotData(int index, SlotData slotElement)
 {
     m_Object.FindProperty(string.Format(kArrayData, index)).objectReferenceValue = slotElement;
     isDirty = true;
 }
 public PlayerBlockPlacementPacket(Int32 x = 0, sbyte y = 0, Int32 z = 0, sbyte direction = 0, SlotData heldItem = null) : base(PacketType.PlayerBlockPlacement)
 {
     X         = x;
     Y         = y;
     Z         = z;
     Direction = direction;
     HeldItem  = heldItem;
 }
 private void AddSlotData(SlotData slotElement)
 {
     m_SlotDataCount.intValue++;
     SetSlotData(m_SlotDataCount.intValue - 1, slotElement);
 }
Example #31
0
 public MetadataSlot(byte index, SlotData value) : base(index, MetadataType.Slot)
 {
     Value = value;
 }
Example #32
0
 public static bool SlotIsValid(SlotData slotData)
 {
     return(slotData != null && slotData.asset != null && !string.IsNullOrEmpty(slotData.asset.slotName));
 }
 public CreativeInventoryActionPacket(Int16 slot = 0, SlotData clickedItem = null)
     : base(PacketType.CreativeInventoryAction)
 {
     Slot = slot;
     ClickedItem = clickedItem;
 }
Example #34
0
 private void AddSlotData(SlotData slotElement)
 {
     m_SlotDataCount.intValue ++;
     SetSlotData(m_SlotDataCount.intValue - 1, slotElement);
 }
Example #35
0
	public virtual void AddSlot(SlotData slot) { throw new NotFiniteNumberException(); }
Example #36
0
 private void SetSlotData(int index,SlotData slotElement)
 {
     m_Object.FindProperty(string.Format(kArrayData,index)).objectReferenceValue = slotElement;
     isDirty = true;
 }
Example #37
0
 public SlotData SaveInfo()
 {
     SlotData data = new SlotData();
     data.items = items;
     return data;
 }
Example #38
0
        public RendererBase CreateRenderer(AtomicBlockBase parent, DisplayData data, SlotData slotData, SlotStyleData slotStyleData, TableLayoutItemInfo layout)
        {
            RendererBase res = null;

            if (data != null)
            {
                switch (data.DisplayType)
                {
                case DisplayType.String:
                    res = new TextRenderer(parent);
                    break;

                case DisplayType.ContentReference:
                {
                    ContentReference cref = data.Data as ContentReference;

                    if (cref != null)
                    {
                        switch (cref.MediaType)
                        {
                        case MediaPrimitiveType.Image:
                        case MediaPrimitiveType.ImageStrip:
                            res = new ImageRenderer(parent);
                            break;

                        default:
                            DebugHelper.Out("Unsupported content reference media type: {0}", cref.MediaType);
                            break;
                        }
                    }

                    break;
                }

                case DisplayType.MediaMetaData:
                {
                    MediaMetaData mmd = data.Data as MediaMetaData;

                    if (mmd != null)
                    {
                        ContentReference cref = mmd[Core.System.CurrentDeviceGroup];

                        if (cref != null)
                        {
                            switch (cref.MediaType)
                            {
                            case MediaPrimitiveType.Image:
                            case MediaPrimitiveType.ImageStrip:
                                res = new ImageRenderer(parent);
                                break;

                            case MediaPrimitiveType.String:
                                res = new TextRenderer(parent);
                                break;

                            default:
                                DebugHelper.Out("Unsupported content reference media type: {0}", cref.MediaType);
                                break;
                            }
                        }
                    }

                    break;
                }

                case DisplayType.EditableString:
                    res = new TextEntryRenderer(parent);
                    break;

                default:     //IMPLEMENT: more display types
                    DebugHelper.Out("Unsupported renderer type: {0}", data.DisplayType);
                    break;
                }

                if (res != null)
                {
                    res.SetDisplayData(data);
                    res.ApplyFormattingAndLayout(slotData, slotStyleData, layout);
                }
            }

            return(res);
        }
Example #39
0
    public static void UnpackRecipe(UMA.UMAData.UMARecipe umaRecipe, UMAPackRecipe umaPackRecipe, UMAContext context)
    {
        umaRecipe.slotDataList = new SlotData[umaPackRecipe.packedSlotDataList.Length];
        umaRecipe.SetRace(context.GetRace(umaPackRecipe.race));

        umaRecipe.ClearDna();
        for (int dna = 0; dna < umaPackRecipe.packedDna.Count; dna++)
        {
            Type dnaType = UMADna.GetType(umaPackRecipe.packedDna[dna].dnaType);
            umaRecipe.AddDna(UMADna.LoadInstance(dnaType, umaPackRecipe.packedDna[dna].packedDna));
        }

        for (int i = 0; i < umaPackRecipe.packedSlotDataList.Length; i++)
        {
            if (umaPackRecipe.packedSlotDataList[i] != null && umaPackRecipe.packedSlotDataList[i].slotID != null)
            {
                SlotData tempSlotData = SlotData.CreateInstance <SlotData>();
                tempSlotData = context.InstantiateSlot(umaPackRecipe.packedSlotDataList[i].slotID);
                tempSlotData.overlayScale = umaPackRecipe.packedSlotDataList[i].overlayScale * 0.01f;
                umaRecipe.slotDataList[i] = tempSlotData;

                if (umaPackRecipe.packedSlotDataList[i].copyOverlayIndex == -1)
                {
                    for (int overlay = 0; overlay < umaPackRecipe.packedSlotDataList[i].OverlayDataList.Length; overlay++)
                    {
                        Color tempColor;
                        Rect  tempRect;

                        if (umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay].colorList != null)
                        {
                            tempColor = new Color(umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay].colorList[0] / 255.0f, umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay].colorList[1] / 255.0f, umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay].colorList[2] / 255.0f, umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay].colorList[3] / 255.0f);
                        }
                        else
                        {
                            tempColor = new Color(1.0f, 1.0f, 1.0f, 1.0f);
                        }

                        if (umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay].rectList != null)
                        {
                            Rect originalRect = context.InstantiateOverlay(umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay].overlayID).rect;
                            tempRect = new Rect(umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay].rectList[0], umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay].rectList[1], umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay].rectList[2], umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay].rectList[3]);

                            Vector2 aspectRatio = new Vector2(tempRect.width / originalRect.width, tempRect.height / originalRect.height);

                            tempRect = new Rect(tempRect.x / aspectRatio.x, tempRect.y / aspectRatio.y, tempRect.width / aspectRatio.x, tempRect.height / aspectRatio.y);
                        }
                        else
                        {
                            tempRect = new Rect(0, 0, 0, 0);
                        }

                        tempSlotData.AddOverlay(context.InstantiateOverlay(umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay].overlayID));
                        tempSlotData.GetOverlay(tempSlotData.OverlayCount - 1).color = tempColor;
                        tempSlotData.GetOverlay(tempSlotData.OverlayCount - 1).rect  = tempRect;

                        if (umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay].channelMaskList != null)
                        {
                            for (int channelAdjust = 0; channelAdjust < umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay].channelMaskList.Length; channelAdjust++)
                            {
                                packedOverlayData tempData = umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay];
                                tempSlotData.GetOverlay(tempSlotData.OverlayCount - 1).SetColor(channelAdjust, new Color32((byte)tempData.channelMaskList[channelAdjust][0],
                                                                                                                           (byte)tempData.channelMaskList[channelAdjust][1],
                                                                                                                           (byte)tempData.channelMaskList[channelAdjust][2],
                                                                                                                           (byte)tempData.channelMaskList[channelAdjust][3]));
                            }
                        }

                        if (umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay].channelAdditiveMaskList != null)
                        {
                            for (int channelAdjust = 0; channelAdjust < umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay].channelAdditiveMaskList.Length; channelAdjust++)
                            {
                                packedOverlayData tempData = umaPackRecipe.packedSlotDataList[i].OverlayDataList[overlay];
                                tempSlotData.GetOverlay(tempSlotData.OverlayCount - 1).SetAdditive(channelAdjust, new Color32((byte)tempData.channelAdditiveMaskList[channelAdjust][0],
                                                                                                                              (byte)tempData.channelAdditiveMaskList[channelAdjust][1],
                                                                                                                              (byte)tempData.channelAdditiveMaskList[channelAdjust][2],
                                                                                                                              (byte)tempData.channelAdditiveMaskList[channelAdjust][3]));
                            }
                        }
                    }
                }
                else
                {
                    tempSlotData.SetOverlayList(umaRecipe.slotDataList[umaPackRecipe.packedSlotDataList[i].copyOverlayIndex].GetOverlayList());
                }
            }
        }
    }
Example #40
0
 public virtual void ApplyFormattingAndLayout(SlotData slotData, SlotStyleData slotStyleData, TableLayoutItemInfo layout)
 {
 }
Example #41
0
    private void AddSlot(Adaptation.BodySlot slotType)
    {
        int index = 0;
        SlotData newSlot = new SlotData();

        foreach(SlotData item in slots){
            if(item.GetSlotType() == slotType){
                index++;
            }
        }

        if(index < 3){
            newSlot.Initialize(this, index, slotType);
            slots.Add(newSlot);
            slots.TrimExcess();
        }
    }
Example #42
0
 private void AssignSlot()
 {
     slot = player.GetCritter().GetSpecificSlot(type, index);
 }
 public void SetSlotData(SlotData objSlotData)
 {
     this.objSlotData = objSlotData;
 }
        void ArrangeSlot(SlotData slotData, Point upperLeft, Size finalSize)
        {
            UVHelper uv = UVHelper.CreateInstance(slotData.Slot.Orientation);
            Point runningUpperLeft = upperLeft;
            double maxU = uv.U(runningUpperLeft) + uv.U(finalSize);
            bool addSizer = false;
            Slot previousSlot = null;

            foreach (var child in slotData.Slot.Children)
            {
                if (addSizer)
                {
                    SlotSizer sizer = GetNextSizer();
                    sizer.SizeDirection = slotData.Slot.Orientation;
                    sizer.Slot1 = previousSlot;
                    sizer.Slot2 = child;
                    sizer.Measure(uv.Size(SlotSpacing, uv.V(finalSize)));
                    sizer.Arrange(new Rect(uv.Point(uv.U(runningUpperLeft), uv.V(runningUpperLeft)), uv.Size(SlotSpacing, uv.V(finalSize))));
                    runningUpperLeft = uv.Point(Math.Min(maxU, uv.U(runningUpperLeft) + SlotSpacing), uv.V(runningUpperLeft));
                }

                var childSlot = slotTable[InternalGetSlotName(child)];
                var childFinalSize = uv.Size(Math.Min(uv.U(finalSize), uv.U(childSlot.FinalSize)), uv.V(finalSize));

                ArrangeSlot(childSlot, runningUpperLeft, childFinalSize);
                runningUpperLeft = uv.Point(Math.Min(maxU, uv.U(runningUpperLeft) + uv.U(childFinalSize)), uv.V(runningUpperLeft));
                addSizer = (SlotSpacing > 0);
                previousSlot = child;
            }

            if (slotData.Elements != null)
            {
                foreach (UIElement element in slotData.Elements)
                {
                    element.Arrange(new Rect(upperLeft, finalSize));
                }
            }

            slotData.Slot.ActualSize = finalSize;
            slotData.Slot.UpperLeft = upperLeft;
        }
Example #45
0
 private void DeselectSlot()
 {
     TraitsPanel.SetSelectedSlot(null);
     slot = null;
 }
Example #46
0
        void CharacterBegun(UMAData umaData)
        {
            //If mesh is not dirty then we haven't changed slots.
            if (!umaData.isMeshDirty)
            {
                return;
            }

            SlotData[] slots = umaData.umaRecipe.slotDataList;
            slotsToAdd.Clear();

            foreach (RendererElement element in RendererElements)
            {
                if (element.rendererAssets == null || element.rendererAssets.Count <= 0)
                {
                    continue;
                }

                wardrobeSlotAssets.Clear();

                //First, lets collect a list of the slotDataAssets that are present in the wardrobe recipes of the wardrobe slots we've specified
                foreach (string wardrobeSlot in element.wardrobeSlots)
                {
                    UMATextRecipe recipe = avatar.GetWardrobeItem(wardrobeSlot);
                    if (recipe != null)
                    {
                        recipe.Load(umaRecipe, context);

                        if (umaRecipe.slotDataList != null)
                        {
                            for (int i = 0; i < umaRecipe.slotDataList.Length; i++)
                            {
                                SlotData slotData = umaRecipe.slotDataList[i];
                                if (slotData != null && slotData.asset != null)
                                {
                                    wardrobeSlotAssets.Add(slotData.asset);
                                }
                            }
                        }
                    }
                }

                //Next, check each slot for if they are in the list of specified slots or exist in one of the wardrobe recipes of the wardrobe slot we specified.
                foreach (SlotData slot in slots)
                {
                    if (element.slotAssets.Contains(slot.asset) || wardrobeSlotAssets.Contains(slot.asset))
                    {
                        //We check for at least one rendererAsset at the top level for loop.
                        //Set our existing slot to the first renderer in our renderer list.
                        slot.rendererAsset = element.rendererAssets[0];

                        //If we have more renderers then make a copy of the SlotData and set that copy's rendererAsset to this item's renderer.
                        //Add the newly created slots to a running list to combine back with the entire slot list at the end.
                        for (int i = 1; i < element.rendererAssets.Count; i++)
                        {
                            SlotData addSlot = slot.Copy();
                            addSlot.rendererAsset = element.rendererAssets[i];
                            slotsToAdd.Add(addSlot);
                        }
                    }
                }
            }

            //If we have added Slots, then add the first slots to the list and set the recipe's slots to the new combined list.
            if (slotsToAdd.Count > 0)
            {
                slotsToAdd.AddRange(slots);
                umaData.umaRecipe.SetSlots(slotsToAdd.ToArray());
                slotsToAdd.Clear();
            }

            wardrobeSlotAssets.Clear();
        }
        private void ReadSkeletonSlots(SkeletonData skeletonData, JObject data)
        {
            foreach (JToken slot in data["slots"].Children())
            {
                var slotName = (String) slot["name"];
                var boneName = (String) slot["bone"];
                BoneData boneData = skeletonData.FindBone(boneName);
                if (boneData == null)
                {
                    throw new SerializationException("Slot bone not found: " + boneName);
                }

                var slotData = new SlotData(slotName, boneData);

                var color = (String) slot["color"];

                if (color != null)
                {
                    slotData.Color = ReadColor(color);
                }

                slotData.AttachmentName = (String) slot["attachment"];

                skeletonData.AddSlot(slotData);
            }
        }
    async void Start()//상점 입장 시 아이템 목록 각각 이미지 프리팹으로 불러와서 보여줌
    {
        Instantiate(loading, GameObject.Find("PopUpLocation").transform, false);

        ////인포매니저에서 비밀번호 받아옴
        infoManager   = GameObject.Find("GameInformationManager").GetComponent <gameInformationManager>();
        userPassword  = infoManager.passwd;
        newGunsInShop = infoManager.newGuns;



        text = GameObject.Find("Money").GetComponent <Text>();
        if (GameManagerContractClient.GetAbi() == null)
        {
            Debug.Log("Error: no ABI file found");
            return;
        }

        if (ItemFactoryContractClient.GetAbi() == null)
        {
            Debug.Log("Error: no ABI file found");
            return;
        }

        if (ItemOwnershipContractClient.GetAbi() == null)
        {
            Debug.Log("Error: no ABI file found");
            return;
        }

        playerWallet = LoadWallet(userPassword);
        var playerPrivateKey = playerWallet.privateKey;
        var playerPublicKey  = playerWallet.publicKey;

        Address factoryContractAddress   = Address.FromString(FactoryContractAddress);
        Address managerContractAddress   = Address.FromString(GameManagerContractAddress);
        Address ownershipContractAddress = Address.FromString(OwnershipContractAddress);

        this.FactoryClient = new ItemFactoryContractClient(playerPrivateKey, playerPublicKey, factoryContractAddress, Debug.unityLogger);
        this.OwnerClient   = new ItemOwnershipContractClient(playerPrivateKey, playerPublicKey, ownershipContractAddress, Debug.unityLogger);
        this.ManagerClient = new GameManagerContractClient(playerPrivateKey, playerPublicKey, managerContractAddress, Debug.unityLogger);


        await setUserWeapons();
        await ConnectFactoryClient();
        await ConnectManagerClient();

        slotPanel = GameObject.Find("useitempanel");//캔버스에서 슬롯을 생성시킬 위치
        int j = 0;

        foreach (JsonGunState.Gun g in this.getManagerGunState.guns)//이 슬롯들에 레이캐스트 입력 받는 컴포넌트 추가 - 선택하면 색 변하는 효과?(캔버스에 반투명 덮어씌우는 식으로?)
        {
            if (j < 10)
            {
                Debug.Log("Start Foreach  " + g.index);
                GameObject go = Instantiate(slotPrefab, slotPanel.transform, false);     //slotPrefab을 slotPanel위치에 생성
                prefabname[j] = g.name;
                priceString.GetComponent <Text>().text = g.price.ToString();
                itemName.GetComponent <Text>().text    = g.name;
                go.name = prefabname[j] + "/" + g.price; //생성된 슬롯의 이름
                SlotData slot = new SlotData();          //슬롯 객체 생성
                slot.isEmpty = true;                     //슬롯 객체 상태
                slot.slotObj = go;                       //슬롯 객체에 오브젝트 할당
                Instantiate(Resources.Load("prefabs/" + "image_" + prefabname[j]), go.transform, false);
                //현재 문자열 배열에 해당되는 오브젝트명 앞에 image를 붙여 해당 오브젝트의 이미지를 슬롯에 생성
                Instantiate(priceString, go.transform, false);
                Instantiate(itemName, go.transform, false);
                slots.Add(slot);//슬롯 추가
                j++;
            }
            else
            {
                break;
            }
        }

        money = this.tokenBalance;
        text.GetComponent <Text>().text = "보유금액:" + money;

        Destroy(GameObject.Find("Loading(Clone)").gameObject);
    }
Example #49
0
    //Unequips evo from selected slot on selected critter and updates buttons for player.
    public void Unequip(Critter critter, SlotData dataSlot)
    {
        dataSlot.UnequipSlot();
        UnlockConflicts(critter);

        RefundStats(critter);

        if(critter.GetIsPlayer()){
            CheckCurrentBuyState(critter);

            foreach (Adaptation item in Prerequisites1)
            {
                item.CheckCurrentBuyState(critter);
            }
            foreach (Adaptation item in Prerequisites2)
            {
                item.CheckCurrentBuyState(critter);
            }
            foreach (Adaptation item in Unlocks)
            {
                item.CheckCurrentBuyState(critter);
            }
            foreach (Adaptation item in Conflicts)
            {
                item.CheckCurrentBuyState(critter);
            }
        }
        critter.UnequipSpecials(this);
    }
 public CheckedSlot(SlotData slotData, bool isChecked)
 {
     Slot    = slotData;
     Checked = isChecked;
 }
Example #51
0
 public void MoveSlot(SlotData newSlot, SlotData oldSlot)
 {
     newSlot.SetEvo(this);
 }
Example #52
0
    public void CraftItem(Blueprint blueprint, Slot[] slots)
    {
        Slot freeSlot = null;

        foreach (Slot s in slots)
        {
            if (s.item == null)
            {
                return;
            }
            if (s.item is Tool)
            {
                break;
            }
            if (s.item.Permanent)
            {
                continue;
            }
            for (int i = 0; i < blueprint.ItemsRequired.Count; i++)
            {
                //if(blueprint.Crafted.Keys.ElementAt(0) == s.Data.Item.ID)
                //{
                //    equals = true;
                //    freeSlot = s;
                //    break;
                //}

                int qnt = blueprint.ItemsRequired[s.item.ID];
                if (s.Quantity == qnt)
                {
                    freeSlot = s;
                    break;
                }
            }
        }

        ItemController itemController = new ItemController();
        Item           newItem        = itemController.Index(blueprint.Crafted.First().Key);

        if (freeSlot == null)
        {
            foreach (Slot s in table.SlotGrid)
            {
                if (s.Free())
                {
                    freeSlot = s;
                    break;
                }
            }
            if (freeSlot == null)
            {
                return;
            }
        }

        foreach (Slot s in slots)
        {
            if (!(s.item is Tool))
            {
                int qntToRemove = blueprint.ItemsRequired[s.item.ID];
                s.RemoveItem(qntToRemove);
            }
        }
        SlotData data = new SlotData();

        data.SetData(newItem, blueprint.Crafted.First().Value, integrity: newItem.Integrity, lifeTime: newItem.LifeTime);
        freeSlot.SwapItem(data);
    }
Example #53
0
        public virtual void RandomizeRecipe(UMAData umaData)
        {
            UMARecipeMixer mixer = recipeMixers[Random.Range(0, recipeMixers.Length)];

            mixer.FillUMARecipe(umaData.umaRecipe, context);

            OverlayColorData[] recipeColors = umaData.umaRecipe.sharedColors;
            if ((recipeColors != null) && (recipeColors.Length > 0))
            {
                foreach (var sharedColor in sharedColors)
                {
                    if (sharedColor == null)
                    {
                        continue;
                    }
                    int index = Random.Range(0, sharedColor.colors.Length);
                    for (int i = 0; i < recipeColors.Length; i++)
                    {
                        if (recipeColors[i].name == sharedColor.sharedColorName)
                        {
                            recipeColors[i].color = sharedColor.colors[index].color;
                        }
                    }
                }
            }

            // This is a HACK - maybe there should be a clean way
            // of removing a conflicting slot via the recipe?
            int maleJeansIndex = -1;
            int maleLegsIndex  = -1;

            SlotData[] slots = umaData.umaRecipe.GetAllSlots();
            for (int i = 0; i < slots.Length; i++)
            {
                SlotData slot = slots[i];
                if (slot == null)
                {
                    continue;
                }
                if (slot.asset.name == null)
                {
                    continue;
                }

                if (slot.asset.slotName == "MaleJeans01")
                {
                    maleJeansIndex = i;
                }
                else if (slot.asset.slotName == "MaleLegs")
                {
                    maleLegsIndex = i;
                }
            }
            if ((maleJeansIndex >= 0) && (maleLegsIndex >= 0))
            {
                umaData.umaRecipe.SetSlot(maleLegsIndex, null);
            }

        #if UNITY_EDITOR
            if (saveCrowd)
            {
                SaveRecipe(umaData, context);
            }
        #endif
        }
        void MeasureSlot(SlotData slotData, Size availableSize)
        {
            UVHelper uv = UVHelper.CreateInstance(slotData.Slot.Orientation);

            // Measure all 'auto' and 'absolute' children; add up the * values as we go.
            double totalU = 0, maxV = 0;
            double totalStars = 0;
            bool addPad = false;
            foreach (var child in slotData.Slot.Children)
            {
                var length = child.Length;
                var childSlot = slotTable[InternalGetSlotName(child)];

                if (addPad)
                {
                    totalU += SlotSpacing;
                }

                if (length.IsAuto)
                {
                    var childU = Math.Max(Math.Min(uv.U(availableSize), childSlot.Slot.MaxLength), childSlot.Slot.MinLength);
                    var childAvailableSize = uv.Size(childU, uv.V(availableSize));
                    MeasureSlot(childSlot, childAvailableSize);
                    childSlot.FinalSize = childSlot.DesiredSize;
                    totalU += uv.U(childSlot.FinalSize);
                    maxV = Math.Max(maxV, uv.V(childSlot.FinalSize));
                }
                else if (length.IsAbsolute)
                {
                    var childU = Math.Max(Math.Min(length.Value, childSlot.Slot.MaxLength), childSlot.Slot.MinLength);
                    MeasureSlot(childSlot, uv.Size(childU, uv.V(availableSize)));
                    childSlot.FinalSize = uv.Size(childU, uv.V(childSlot.DesiredSize));
                    totalU += childU;
                    maxV = Math.Max(maxV, uv.V(childSlot.FinalSize));
                }
                else
                {
                    totalStars += length.Value;
                }

                addPad = (SlotSpacing > 0);
            }

            // Now measure the * values.
            double spaceLeft = Math.Max(uv.U(availableSize) - totalU, 0);

            List<Slot> slots = (from child in slotData.Slot.Children where child.Length.IsStar select child).ToList();
            List<Slot> proportional = new List<Slot>();

            // Determined the size for stars that are over the min or max length
            int constrained;
            do
            {
                constrained = 0;

                for (int idx = 0; idx < slots.Count; idx++)
                {
                    Slot child = slots[idx];
                    var childSlot = slotTable[InternalGetSlotName(child)];
                    var childU = (spaceLeft / totalStars) * child.Length.Value;

                    if (childU < childSlot.Slot.MinLength)
                    {
                        spaceLeft -= childSlot.Slot.MinLength - childU;
                        childU = childSlot.Slot.MinLength;
                    }
                    else if (childU > childSlot.Slot.MaxLength)
                    {
                        spaceLeft += childSlot.Slot.MaxLength - childU;
                        childU = childSlot.Slot.MaxLength;
                    }
                    else
                    {
                        proportional.Add(child);
                        continue;
                    }

                    constrained++;
                    var childAvailableSize = uv.Size(Math.Max(0, childU), uv.V(availableSize));
                    MeasureSlot(childSlot, childAvailableSize);
                    childSlot.FinalSize = uv.Size(MaxNonInfinite(childU, uv.U(childSlot.DesiredSize)), uv.V(childSlot.DesiredSize));
                    totalU += uv.U(childSlot.FinalSize);
                    maxV = Math.Max(maxV, uv.V(childSlot.FinalSize));
                }

                slots = proportional;
                proportional = new List<Slot>();
            } while (slots.Count > 0 && constrained > 0);

            // Determine the size of remaining star children
            foreach (var child in slots)
            {
                var childSlot = slotTable[InternalGetSlotName(child)];
                var childU = (spaceLeft / totalStars) * child.Length.Value;
                var childAvailableSize = uv.Size(Math.Max(0, childU), uv.V(availableSize));
                MeasureSlot(childSlot, childAvailableSize);
                childSlot.FinalSize = uv.Size(MaxNonInfinite(childU, uv.U(childSlot.DesiredSize)), uv.V(childSlot.DesiredSize));
                totalU += uv.U(childSlot.FinalSize);
                maxV = Math.Max(maxV, uv.V(childSlot.FinalSize));
            }

            // Finally, measure any child elements we have
            if (slotData.Elements != null)
            {
                foreach (var e in slotData.Elements)
                {
                    e.Measure(availableSize);
                    totalU = Math.Max(totalU, uv.U(e.DesiredSize));
                    maxV = Math.Max(maxV, uv.V(e.DesiredSize));
                }
            }

            slotData.DesiredSize = uv.Size(totalU, maxV);
        }