Beispiel #1
0
    private void OnGUI()
    {
        if (arrayKeys == null)
        {
            return;
        }

        if (arrayKeys.Length == 0)
        {
            return;
        }

        for (int i = 0; i < arrayKeys.Length; i++)
        {
            int              index   = i;
            string           key     = arrayKeys[index];
            InventoryElement element = _inventoryControl.GetByKey(key);

            GUI.Box(GetRect(index, 50, 75), GetContent(element));
            GUI.Box(GetRect(index, 150, 220), element.elementScript.elementSprite.texture);

            if (GUI.Button(GetRect(index, 400, 30), "Inc " + key))
            {
                _inventoryControl.IncCountByKey(key);
            }
        }
    }
    protected override void onShiftClick(InventoryElement element)
    {
//		if(InventoryManager.actionBar.enabled)
//		{
//			InventoryManager.actionBar.AddItem(element, true);
//		}
    }
    public void SplitStack(InventoryElement element)
    {
        InventoryElement temp = new InventoryElement(element);

        CreateDraggedGameObject(element);

        //Even
        if (element.stack % 2 == 0)
        {
            temp.stack     = element.stack / 2;
            element.stack /= 2;
        }
        //Odd
        else
        {
            temp.stack    = Mathf.CeilToInt(element.stack / 2);
            element.stack = temp.stack + 1;
        }

        if (temp.stack > 1)
        {
            if (draggedGameObjectStack != null)
            {
                draggedGameObjectStack.text = temp.stack.ToString();
            }
        }

        //temp.originSlot = element.slot;
        draggedItem      = temp;
        draggedItem.slot = null;
    }
Beispiel #4
0
    public void MajInventory(OnUpdateInventory e)
    {
        List <Item> items  = InventoryPlayer.Instance.itemsWornArray;
        int         length = items.Count;
        Item        item;

        for (int i = length - 1; i >= 0; i--)
        {
            item = items[i];
            InventoryElement ie = scrollElement.Find(el => el.itemType == item.itemType);
            if (InventoryPlayer.Instance.nbItems[item.itemType] <= 0)
            {
                InventoryPlayer.Instance.itemsWornArray.Remove(item);
                scrollElement.Remove(ie);
                scroller.Remove(ie);
            }
            else
            {
                if (ie != null)
                {
                    ie.MajText();
                }
                else
                {
                    InventoryElement newE = scroller.Add <InventoryElement>(elementModel);
                    newE.itemType = item.itemType;
                    newE.Init();
                    scrollElement.Add(newE);
                }
            }
        }
        scroller.Scale();
    }
Beispiel #5
0
        ///
        /// This method is only used within toa client to create InventoryElement object
        ///
        internal InventoryElement GetInventoryElement()
        {
            var inventoryElement = new InventoryElement();

            PropertyElement[] properties = null;
            int size = 1;

            if (null != _serial_number && _serial_number.Trim().Length > 0)
            {
                size = 2;
            }
            properties          = new PropertyElement[size];
            properties[0]       = new PropertyElement();
            properties[0].label = ActivityProperty.InvTypeLabel;
            properties[0].value = Type;

            if (size == 2)
            {
                properties[1]       = new PropertyElement();
                properties[1].label = ActivityProperty.Invsn;
                properties[1].value = SerialNumber;
            }
            inventoryElement.properties = properties;
            return(inventoryElement);
        }
Beispiel #6
0
    void DisplayItems()
    {
        if (selectedType != null)
        {
            //for(int i = 0; i < InventoryDatabase.ElementCount; i++)
            for (int i = 0; i < selectedType.elementIDs.Count; i++)
            {
                InventoryElement item = InventoryDatabase.GetElement(selectedType.elementIDs[i]);

                if (item != null)
                {
                    if (item.type != null)
                    {
                        //if(selectedType.ID == item.type.ID)
                        {
                            EditorGUILayout.BeginHorizontal();
                            if (GUILayout.Button(item.name, GUILayout.ExpandWidth(true)))
                            {
                                GUI.FocusControl(null);
                                editItem  = item;
                                editState = EditState.EDITITEM;
                            }
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                }
            }
        }
    }
    private void AddOneStock(GoodType good)
    {
        GameObject       go    = ResourceManager.Singleton.LoadResource <GameObject>(elmPath);
        GameObject       elmGO = Instantiate(go, table.content.transform);
        InventoryElement ie    = elmGO.GetComponent <InventoryElement>();

        //if (ie != null)
        {
            elementGOs.Add(elmGO);
            ie.good           = good;
            ie.sold          += SoldByPlayer;
            ie.colorImg.color = InvestmentManager.Singleton.GetGoodColor(good);
        }

        switch (ie.good)
        {
        case GoodType.TOMATO:
            ie.label.text = "番茄";
            break;

        case GoodType.SILK:
            ie.label.text = "絲綢";
            break;

        case GoodType.PADDY:
            ie.label.text = "稻米";
            break;

        case GoodType.JADE:
            ie.label.text = "翠玉";
            break;
        }
    }
    public void Equip(ref InventoryElement e)
    {
        CharacterMenu charMenu = FindObjectOfType <CharacterMenu>();

        if (charMenu != null)
        {
            List <Slot> fitSlots = new List <Slot>();          // charMenu.Slots.FindAll (s => s.acceptedTypes.Exists(x => x.ID == e.type.ID || x.isAncestorOf(e.type)));

            foreach (Slot s in charMenu.Slots)
            {
                foreach (ElementType eType in s.acceptedTypes)
                {
                    if (eType.ID == e.type.ID || eType.isAncestorOf(e.type))
                    {
                        fitSlots.Add(s);
                    }
                }
            }

            Slot fitSlot = fitSlots.Find(s => s.IsEmpty());

            if (fitSlot != null)
            {
                fitSlot.inventoryElement = e;
                e = null;
            }
            else
            {
                fitSlots[0].inventoryElement = e;
                e = null;
            }
        }
    }
    public void DamageBlock(string stringDamage)
    {
        RaycastHit hit;

        if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, 10f, 1))
        {
            GameObject go = hit.transform.gameObject;

            if (!InventoryManager.inventory.isFull() || !InventoryManager.actionBar.isFull())
            {
                int    damage  = int.Parse(stringDamage);
                Health _health = go.GetComponent <Health>();
                _health.health -= damage;

                if (_health.health <= 0)
                {
                    LootableObject lo = _health.GetComponent <LootableObject>();

                    InventoryElement ie = new InventoryElement(InventoryDatabase.GetElement(lo.elementID));

                    if (!InventoryManager.inventory.isFull())
                    {
                        InventoryManager.inventory.AddItem(ref ie, false);
                    }
                    else if (!InventoryManager.actionBar.isFull())
                    {
                        InventoryManager.actionBar.AddItem(ref ie, false);
                    }

                    Destroy(go);
                }
            }
        }
    }
Beispiel #10
0
    public InventoryElement(InventoryElement inventoryElement)
    {
        if (inventoryElement != null)
        {
            id          = inventoryElement.id;
            name        = inventoryElement.name;
            gameObject  = inventoryElement.gameObject;
            description = inventoryElement.description;
            typeID      = inventoryElement.typeID;
            //type = inventoryElement.type;
            selectedType = inventoryElement.selectedType;
            icon         = inventoryElement.icon;
            stack        = inventoryElement.stack;
            isStackable  = inventoryElement.isStackable;
            maxStack     = inventoryElement.maxStack;
            actions      = inventoryElement.actions;

            //This means it is the original
            if (inventoryElement.prototype == null)
            {
                prototype = inventoryElement;
            }
            //This means that inventoryElement is an instance
            else
            {
                prototype = inventoryElement.prototype;
            }
        }
    }
    public void CreateDraggedGameObject(InventoryElement element)
    {
        if (draggedGameObjectStack != null)
        {
            draggedGameObjectStack.text = element.stack.ToString();
        }

        if (draggedGameObject == null)
        {
            draggedGameObject = new GameObject("Dragged Item");
            draggedGameObject.transform.SetParent(canvas.transform, false);
            draggedIcon         = draggedGameObject.AddComponent <RawImage>();
            draggedIcon.texture = element.icon;
            draggedIcon.rectTransform.sizeDelta = new Vector2(45, 45);
            draggedGameObject.AddComponent <CanvasGroup>().blocksRaycasts = false;
            draggedIcon.enabled = false;

            if (element.stack > 1)
            {
                draggedGameObjectTextGO = new GameObject("Item Stack");
                draggedGameObjectTextGO.transform.SetParent(draggedGameObject.transform, false);
                draggedGameObjectStack = draggedGameObjectTextGO.AddComponent <Text>();
                draggedGameObjectStack.rectTransform.sizeDelta = new Vector2(45, 45);
                if (draggedGameObjectStack.font == null)
                {
                    draggedGameObjectStack.font = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf");
                }
                draggedGameObjectStack.alignment = TextAnchor.LowerRight;
            }
        }
    }
Beispiel #12
0
    private static string GetContent(InventoryElement element)
    {
        string elementKey  = element.elementScript.elementKey;
        string elementInfo = element.elementScript.elementInfo;
        int    count       = element.count;

        return(elementKey + "\n" + elementInfo + "\n" + "\n" + count + "\n");
    }
 private void SoldByPlayer(InventoryElement element)
 {
     if (elementGOs.Contains(element.gameObject))
     {
         elementGOs.Remove(element.gameObject);
         Destroy(element.gameObject);
     }
 }
    private void Update()
    {
        if (remainingTime == -1)
        {
            remainingTime = pCDS.cooldownTime;
        }
        remainingTime -= Time.deltaTime;

        foreach (Slot s in Slot.allSlots)
        {
            if (s != null)
            {
                if (s.inventoryElement != null)
                {
                    if (s.inventoryElement.id > -1)
                    {
                        InventoryElement temp = pItemCooldown as InventoryElement;

                        if (temp != null)
                        {
                            if (s.inventoryElement.id == temp.id)
                            {
                                DrawCooldown(s);
                            }
                        }
                    }
                    else if (s.transform.FindChild("Cooldown") != null)
                    {
                        DestroyImmediate(s.transform.FindChild("Cooldown").gameObject);
                    }

                    ElementType e = pItemCooldown as ElementType;

                    if (e != null)
                    {
                        if (s.inventoryElement.type == e || e.isAncestorOf(s.inventoryElement.type))
                        {
                            DrawCooldown(s);
                        }
                    }

                    if (s.inventoryElement.actions.Contains(pItemCooldown as ElementAction))
                    {
                        DrawCooldown(s);
                    }
                }
                else if (s.transform.FindChild("Cooldown") != null)
                {
                    DestroyImmediate(s.transform.FindChild("Cooldown").gameObject);
                }

                if (remainingTime <= 0 && s.transform.FindChild("Cooldown") != null)
                {
                    DestroyImmediate(s.transform.FindChild("Cooldown").gameObject);
                }
            }
        }
    }
 public void Wield(InventoryElement element)
 {
     Debug.Log("Wielded");
     if (element.gameObject != null)
     {
         wieldedGameObject = (GameObject)Instantiate(element.gameObject, transform.position + Camera.main.transform.forward, Camera.main.transform.rotation);
         wieldedGameObject.transform.localScale = new Vector3(.20f, .10f, .10f);
     }
 }
Beispiel #16
0
    // Update is called once per frame
    void Update()
    {
        if (cameraComponent != null)
        {
            if (Physics.Raycast(transform.position, cameraComponent.transform.forward, out hit, distance, layerMask))
            {
                if (hit.transform.gameObject != null)
                {
                    GameObject possibleItem = hit.transform.gameObject;

                    if (possibleItem.GetComponent <LootableObject>() != null)
                    {
                        if (Input.GetKeyDown(lootKey))
                        {
                            if (lootableObject != possibleItem.GetComponent <LootableObject>())
                            {
                                lootableObject = possibleItem.GetComponent <LootableObject>();

                                InventoryElement invElem = InventoryDatabase.GetElement(lootableObject.elementID);

                                temp = new InventoryElement(invElem);
                            }
                            else
                            {
                                lootableObject.stack = temp.stack;
                            }

                            if (temp != null)
                            {
                                temp.stack = lootableObject.stack;

                                if (priority.Count > 0)
                                {
                                    foreach (InventoryObject invOb in priority)
                                    {
                                        if (invOb != null)
                                        {
                                            if (invOb.AddItem(ref temp, false))
                                            {
                                                Destroy(lootableObject.gameObject);
                                            }

                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    Debug.Log("Set up the priority system in FirstPersonLooting!");
                                }
                            }
                        }
                    }
                }
            }
        }
    }
Beispiel #17
0
        public void Load(ByteBuffer buff, int statsyesno)
        {
            uint  previousEquipted = 0;
            ulong previousCount    = 0;

            //ch(hdddqhhhdhhdddhhhhhhhhhhhhd)
            ID       = buff.ReadUInt32();
            ItemID   = buff.ReadUInt32();
            Location = buff.ReadUInt32(); //Location slot

            if (statsyesno == 1)
            {
                foreach (InventoryInfo inv_inf in Globals.gamedata.inventory.Values)
                {
                    if (Util.GetInventoryItemID(inv_inf.ID) == ItemID || inv_inf.ID == ID)
                    {
                        previousEquipted = inv_inf.isEquipped;
                        previousCount    = inv_inf.Count;
                        break;
                    }
                }
            }

            Count      = buff.ReadUInt64();
            Type2      = buff.ReadUInt16();
            Type3      = buff.ReadUInt16();
            isEquipped = buff.ReadUInt16();
            Slot       = (InventorySlots)buff.ReadUInt32();
            Enchant    = buff.ReadUInt16();
            Type4      = buff.ReadUInt16();
            AugID      = buff.ReadUInt32();
            Mana       = buff.ReadUInt32();
            lease_time = buff.ReadInt32();

            buff.ReadUInt16();

            attack_element   = (InventoryElement)buff.ReadUInt16();
            attack_magnitude = buff.ReadInt16();
            fire_defense     = buff.ReadInt16();
            water_defense    = buff.ReadInt16();
            wind_defense     = buff.ReadInt16();
            earth_defense    = buff.ReadInt16();
            unholy_defense   = buff.ReadInt16();
            holy_defense     = buff.ReadInt16();
            //enchant_effect_0 = buff.ReadUInt16();
            //enchant_effect_1 = buff.ReadUInt16();
            //enchant_effect_2 = buff.ReadUInt16();

            buff.ReadUInt32();

            //stats stuff
            if (statsyesno == 1)
            {
                updateStats(ID, ItemID, previousEquipted, isEquipped, previousCount, Count);
            }
        }
    public InventoryElement PickupElement()
    {
        InventoryElement temp;

        temp = inventoryElement;

        inventoryElement = InventoryElement.Empty;

        return(temp);
    }
Beispiel #19
0
 public static void Remove(InventoryElement element)
 {
     if (Instance != null && element != null)
     {
         if (element.id > -1 && element.type.ID > -1 && element.id < Instance.elementDatabase.Count && element.type.ID < Instance.typeDatabase.Count)
         {
             Instance.typeDatabase[element.type.ID].elementIDs.Remove(element.id);
             Instance.elementDatabase [element.id] = InventoryElement.Empty;
         }
     }
 }
    public void PlaceBlock(InventoryElement block)
    {
        RaycastHit hit;

        if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hit, 10f, 1))
        {
            if (hit.transform.tag == "Block")
            {
                Instantiate(block.gameObject, hit.transform.position + hit.normal, block.gameObject.transform.rotation);
            }
        }
    }
    public void DropElement(InventoryElement draggedItem)
    {
        bool matchingType = acceptedTypes.Exists(x => x.ID == draggedItem.type.ID || x.isAncestorOf(draggedItem.type));

        //If there is NO item type OR the item types match
        if ((acceptedTypes.Count == 0 || matchingType) && !lockItem)
        {
            if (inventoryElement.name != "")
            {
                //If Stacking is allowed, and items match - stack them.
                if (inventoryElement.isStackable && inventoryElement.stack < inventoryElement.maxStack && inventoryElement.id == draggedItem.id)
                {
                    //Stacks fit into 1 Slot
                    if (inventoryElement.stack + draggedItem.stack <= inventoryElement.maxStack)
                    {
                        DestroyImmediate(InventoryManager.draggedGameObject);
                        inventoryElement.stack      += draggedItem.stack;
                        InventoryManager.draggedItem = null;
                    }
                    //Stack overflow
                    else
                    {
                        int Diff = Mathf.Abs(inventoryElement.maxStack - inventoryElement.stack);
                        inventoryElement.stack += Diff;
                        draggedItem.stack      -= Diff;
                    }
                }
                //Else, just swap them.
                else
                {
                    Transform cd = this.transform.FindChild("Cooldown");
                    if (cd != null)
                    {
                        DestroyImmediate(cd.gameObject);
                    }
                    InventoryElement temp = inventoryElement;
                    inventoryElement = draggedItem;
                    DestroyImmediate(InventoryManager.draggedGameObject);
                    InventoryManager.draggedItem = temp;
                    InventoryManager.Instance.CreateDraggedGameObject(temp);
                }
            }
            //No Item
            else
            {
                DestroyImmediate(InventoryManager.draggedGameObject);
                inventoryElement             = draggedItem;
                InventoryManager.draggedItem = null;
            }
        }
    }
Beispiel #22
0
    public void init(InventoryElement e)
    {
        gm      = GameManager.gm;
        player  = gm.getPlayer();
        element = e;
        //inventory = gm.getInventory();
        inventoryScript = GetComponentInParent <Inventory>();

        count.text  = e.count.ToString();
        name        = e.item.getName();
        description = e.item.getDescription();

        icon.sprite = e.item.getIcon();
    }
Beispiel #23
0
    void Search()
    {
        if (InventoryDatabase.ElementCount > 0)
        {
            GUILayout.Label("Elements", EditorStyles.boldLabel);
        }

        for (int i = 0; i < InventoryDatabase.ElementCount; i++)
        {
            InventoryElement item = InventoryDatabase.GetElement(i);

            if (item != null)
            {
                if (item.name.IndexOf(searchString, StringComparison.CurrentCultureIgnoreCase) != -1)
                {
                    if (GUILayout.Button(item.name))
                    {
                        editItem  = item;
                        editState = EditState.EDITITEM;
                    }
                }
            }
        }

        if (InventoryDatabase.ElementTypeCount > 0)
        {
            GUILayout.Label("Types", EditorStyles.boldLabel);
        }

        for (int i = 0; i < InventoryDatabase.ElementTypeCount; i++)
        {
            ElementType elemType = InventoryDatabase.GetElementType(i);

            if (elemType != null)
            {
                if (elemType.name != null)
                {
                    if (elemType.name.IndexOf(searchString, StringComparison.CurrentCultureIgnoreCase) != -1)
                    {
                        if (GUILayout.Button(elemType.name))
                        {
                            editType  = elemType;
                            editState = EditState.EDITTYPE;
                        }
                    }
                }
            }
        }
    }
Beispiel #24
0
    // Use this for initialization
    void Start()
    {
        Cursor.lockState = CursorLockMode.None;
        Cursor.visible   = true;
        allElements      = new InventoryElement[38];

        for (int i = 0; i < allElements.Length; i++)
        {
            allElements[i]          = new InventoryElement();
            allElements[i].partType = (PartType)(i + 1);
            allElements[i].amount   = 500;
        }

        buttonTestCar.enabled = false;
    }
Beispiel #25
0
 public static void Add(InventoryElement element, ElementType type)
 {
     if (Instance != null)
     {
         if (element != null && type != null)
         {
             //Set ID of the element
             element.id = Instance.elementDatabase.Count;
             //Set the Element's type
             element.typeID = type.ID;
             //Add element to Element Type list
             Instance.typeDatabase[type.ID].elementIDs.Add(element.id);
             //Add element to the database
             Instance.elementDatabase.Add(element);
         }
     }
 }
    void Loot()
    {
        if (hit.transform.gameObject != null)
        {
            GameObject possibleItem = hit.transform.gameObject;

            LootableObject cache = possibleItem.GetComponent <LootableObject>();

            if (cache != null)
            {
                InventoryElement invElem = InventoryDatabase.GetElement(cache.elementID);

                temp = new InventoryElement(invElem);

                if (temp != null)
                {
                    temp.stack = cache.stack;

                    if (priority.Count > 0)
                    {
                        foreach (InventoryObject invOb in priority)
                        {
                            if (invOb != null)
                            {
                                if (temp.stack > 0)
                                {
                                    invOb.AddItem(ref temp, false);
                                }

                                if (temp.stack == 0)
                                {
                                    Destroy(cache.gameObject);
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        Debug.Log("Set up the priority system in FirstPersonLooting!");
                    }
                }
            }
        }
    }
Beispiel #27
0
    public void init(InventoryElement e, int type)
    {
        this.type = type;
        element   = e;

        gm              = GameManager.gm;
        player          = gm.getPlayer();
        baseObject      = gm.getBoardManager().getBase();
        playerInventory = player.getInventory();
        baseInventory   = baseObject.getInventory();
        keeperPanel     = GetComponentInParent <KeeperPanel>();

        count.text  = e.count.ToString();
        name        = e.item.getName();
        description = e.item.getDescription();

        icon.sprite = e.item.getIcon();
    }
Beispiel #28
0
        public void UpdateCommonlyUsedData()
        {
            //reset
            RarityContainerItems = new List <RarityContainer>();
            _hoverElementRec     = new RectangleF(0, 0, 0, 0);

            _IngameUiElements = GameController.Game.IngameState.IngameUi;
            _InventoryElement = _IngameUiElements.InventoryPanel;
            _StashElement     = _IngameUiElements.StashElement;
            _VisibleStash     = _StashElement.VisibleStash;

            _hoverElement = GameController.Game.IngameState.UIHover;

            if (_hoverElement.Tooltip != null && _hoverElement.Tooltip.IsVisibleLocal)
            {
                _hoverElementRec = _hoverElement.Tooltip.GetClientRect();
            }
        }
Beispiel #29
0
    /// <summary>
    /// Checks if this inventory object is full for this item
    /// </summary>
    public bool isFull(InventoryElement element)
    {
        for (int i = 0; i < Slots.Count; i++)
        {
            InventoryElement slotItem = Slots[i].inventoryElement;
            Slot             slot     = Slots[i];

            if (slotItem == null)
            {
                return(false);
            }
            else
            {
                if (slot.acceptedTypes.Count == 0 || slot.acceptedTypes.Exists(x => x.ID == element.type.ID))
                {
                    if (slotItem.name == null)
                    {
                        return(false);
                    }

                    if (slotItem.name == "")
                    {
                        return(false);
                    }

                    if (InventoryManager.Instance != null)
                    {
                        if (InventoryManager.Instance.stackingActive)
                        {
                            if (slotItem.id == element.id && (slotItem.stack < slotItem.maxStack))
                            {
                                return(false);
                            }
                        }
                    }
                }
            }
        }

        return(true);
    }
    public void Fireball(InventoryElement element)
    {
        Debug.Log("SSD");
        GameObject go = Instantiate(GameObject.CreatePrimitive(PrimitiveType.Sphere), origin.position, transform.rotation) as GameObject;

        go.AddComponent <Rigidbody>();
        ParticleSystem ps = go.AddComponent <ParticleSystem>();

        ps.startColor = Color.red;

        if (useGravity)
        {
            go.GetComponent <Rigidbody>().useGravity = true;
        }
        else
        {
            go.GetComponent <Rigidbody>().useGravity = false;
        }

        go.GetComponent <Rigidbody>().velocity = origin.transform.TransformDirection(Vector3.forward * 50);
    }
        ///
        /// This method is only used within toa client to create InventoryElement object
        /// 
        internal InventoryElement GetInventoryElement()
        {
            var inventoryElement = new InventoryElement();
            PropertyElement[] properties = null;
            int size = 1;
            if (null != _serial_number && _serial_number.Trim().Length > 0)
            {
                size = 2;
            }
            properties = new PropertyElement[size];
            properties[0] = new PropertyElement();
            properties[0].label = ActivityProperty.InvTypeLabel;
            properties[0].value = Type;

            if (size == 2)
            {
                properties[1] = new PropertyElement();
                properties[1].label = ActivityProperty.Invsn;
                properties[1].value = SerialNumber;
            }
            inventoryElement.properties = properties;
            return inventoryElement;
        }
        ///
        /// This method is only used within toa client to create AppointmentElement object
        /// 
        internal AppointmentElement GetActivityElement()
        {
            var activity = new AppointmentElement();
            //key fields 
            activity.customer_number = _customerNumber;
            activity.appt_number = _apptNumber;
            //mandatory fields
            activity.worktype = _workType;
            //Other fields
            if (null != _name)
                activity.name = _name;

            activity.action_if_completed = ToaStringsUtil.GetString(_actionIfCompleted);

            if (null != _address)
                activity.address = _address;

            if (null != _cell)
                activity.cell = _cell;

            if (null != _city)
                activity.city = _city;

            if (null != _coordinateX)
                activity.coordx = _coordinateX;

            if (null != _coordinateY)
                activity.coordy = _coordinateY;

            if (null != _email)
                activity.email = _email;

            if (null != _duration)
                activity.duration = _duration;

            if (null != _language)
                activity.language = _language;

            if (null != _points)
                activity.points = _points.ToString();

            if (null != _phone)
                activity.phone = _phone;

            if (null != _reminderTime)
                activity.reminder_time = _reminderTime.ToString();

            if (null != _serviceWindowStart)
                activity.service_window_start = _serviceWindowStart;

            if (null != _serviceWindowEnd)
                activity.service_window_end = _serviceWindowEnd;

            //if(null != _slaWindowStart)
            //    activity.sla_window_start = _slaWindowStart.ToString("yyyy'-'MM'-'dd HH':'mm");

            if (null != _slaWindowEnd)
            {
                activity.sla_window_end = ((DateTime)_slaWindowEnd).ToString("yyyy'-'MM'-'dd HH':'mm");

                //Below 2 null checks and fix is required as ETA is not behaving correctly.
                //If it has sla_window_end parameter then it should override the date and timeslot as mandatory fields in Inbound Request.
                //But it is not doing so, hence we are explictly required to send TimeSlot and Date.
                //If we do not provide them and if they are empty then activity creation fails in ETA.
                if (null == TimeSlot)
                {
                    TimeSlot = ActivityProperty.ALL_DAY_TIME_SLOT_LABEL;
                }
                if (null == AssignedDate)
                {
                    AssignedDate = "";
                }
            }


            if (null != _state)
                activity.state = _state;

            if (null != _teamId)
                activity.team_id = _teamId;

            if (null != _timeSlot)
                activity.time_slot = _timeSlot;

            if (null != _timeZone)
                activity.time_zone = _timeZone;
            //activity.worktype = _workType;
            //Below code is for using worktype label. We plan to use only WorkType and not the label.
            //if (null != _workTypeLabel)
            //    activity.worktype_label = _workTypeLabel;

            if (null != _zip)
                activity.zip = _zip;


            // Activity Properties
            if (null != Properties)
            {
                var noOfInventories = Properties.Count;                
                var propertyElements = new PropertyElement[noOfInventories];
                foreach (var property in Properties)
                {
                    var propertyElement = new PropertyElement();
                    propertyElement.label = property.Key;
                    propertyElement.value = property.Value;
                    propertyElements[--noOfInventories] = propertyElement;                    
                }
                activity.properties = propertyElements;
            }


            // Activity Inventories
            if (null != _inventories)
            {
                var noOfInventories = _inventories.Count;
                var inventoryElements = new InventoryElement[noOfInventories];
                foreach (var inventoryModel in _inventories)
                {
                    var inventoryElement = inventoryModel.GetInventoryElement();
                    inventoryElements[--noOfInventories] = inventoryElement;
                }
                activity.inventories = inventoryElements;
            }

            // Preference Provideres
            if (null != _providerPreferences)
            {
                var noOfProviders = _providerPreferences.Count;
                var providers = new ProviderPreferenceElement[noOfProviders];
                foreach (var providerModel in _providerPreferences)
                {
                    var ProviderPreferenceElement = providerModel.GetProviderPreferenceElement();
                    providers[--noOfProviders] = ProviderPreferenceElement;
                }
                activity.provider_preferences = providers;
            }

            // Required Inventories
            if (null != _requiredInventories && _requiredInventories.Count > 0)
            {
                var noOfRequiedInventories = _requiredInventories.Count;                
                var requiredInventoryElements = new RequiredInventoryElement[noOfRequiedInventories];
                foreach (var requiredInventoryModel in _requiredInventories)
                {
                    var requiredInventory = requiredInventoryModel.GetRequiredInventoryElement();
                    requiredInventoryElements[--noOfRequiedInventories] = requiredInventory;
                }
                activity.required_inventories = requiredInventoryElements;
            }
            if (null != UserData && UserData.Trim().Length > 0)
            {
                activity.userdata = UserData;
            }

            return activity;
        }
Beispiel #33
0
        public void Load(ByteBuffer buff, int statsyesno)
        {
            uint previousEquipted = 0;
            ulong previousCount = 0;
            //ch(hdddqhhhdhhdddhhhhhhhhhhhhd)
            ID = buff.ReadUInt32();
            ItemID = buff.ReadUInt32();
            Location = buff.ReadUInt32(); //Location slot

            if (statsyesno == 1)
            {
                foreach (InventoryInfo inv_inf in Globals.gamedata.inventory.Values)
                {
                    if (Util.GetInventoryItemID(inv_inf.ID) == ItemID || inv_inf.ID == ID)
                    {
                        previousEquipted = inv_inf.isEquipped;
                        previousCount = inv_inf.Count;
                        break;
                    }
                }
            }

            Count = buff.ReadUInt64();
            Type2 = buff.ReadUInt16();
            Type3 = buff.ReadUInt16();
            isEquipped = buff.ReadUInt16();
            Slot = (InventorySlots)buff.ReadUInt32();
            Enchant = buff.ReadUInt16();
            Type4 = buff.ReadUInt16();
            AugID = buff.ReadUInt32();
            Mana = buff.ReadUInt32();
            lease_time = buff.ReadInt32();

            buff.ReadUInt16();

            attack_element = (InventoryElement)buff.ReadUInt16();
            attack_magnitude = buff.ReadInt16();
            fire_defense = buff.ReadInt16();
            water_defense = buff.ReadInt16();
            wind_defense = buff.ReadInt16();
            earth_defense = buff.ReadInt16();
            unholy_defense = buff.ReadInt16();
            holy_defense = buff.ReadInt16();
            enchant_effect_0 = buff.ReadUInt16();
            enchant_effect_1 = buff.ReadUInt16();
            enchant_effect_2 = buff.ReadUInt16();

            buff.ReadUInt32();

            //stats stuff
            if (statsyesno == 1)
            {
                updateStats(ID, ItemID, previousEquipted, isEquipped, previousCount, Count);
            }
        }