Ejemplo n.º 1
0
 /// <summary>
 /// Sets the cursor item to the specified item. This will result in the items icon replacing the cursor
 /// and allow it to be placed.
 /// </summary>
 /// <param name="item"></param>
 public void SetCursorAbility(AtavismAbility ability)
 {
     _cursorItem    = null;
     _cursorAbility = ability;
     _UpdateCursor();
     AtavismLogger.LogDebugMessage("Set cursor ability: " + ability + "," + ability.icon);
 }
Ejemplo n.º 2
0
        public void SetAction(int bar, int slot, Activatable action, bool movingSlot, int sourceBar, int sourceSlot)
        {
            string actionString = "";

            if (action is AtavismAbility)
            {
                AtavismAbility ability = (AtavismAbility)action;
                actionString = "a" + ability.id;
            }
            else if (action is AtavismInventoryItem)
            {
                AtavismInventoryItem item = (AtavismInventoryItem)action;
                actionString = "i" + item.templateId;
            }
            //NetworkAPI.SendTargetedCommand(ClientAPI.GetPlayerOid(), "/updateActionBar " + slot + " " + actionString);
            Dictionary <string, object> props = new Dictionary <string, object>();

            props.Add("bar", bar);
            props.Add("slot", slot);
            props.Add("action", actionString);
            props.Add("movingSlot", movingSlot);
            props.Add("sourceBar", sourceBar);
            props.Add("sourceSlot", sourceSlot);
            NetworkAPI.SendExtensionMessage(ClientAPI.GetPlayerOid(), false, "combat.UPDATE_ACTIONBAR", props);
        }
Ejemplo n.º 3
0
        public void SellItemToMerchant(AtavismInventoryItem item)
        {
            if (!item.sellable || item.cost < 1)
            {
                AtavismEventMessageHandler.Instance.ProcessErrorEvent("CannotSellItem", item.templateId, "");
                return;
            }
            long amount   = item.cost;
            int  currency = item.currencyType;

            Inventory.Instance.ConvertCurrencyToBaseCurrency(item.currencyType, item.cost, out currency, out amount);
            int price = (int)Mathf.Round(amount * Inventory.Instance.sellFactor);

            if (price < 1)
            {
                price = 1;
            }
            string costString = Inventory.Instance.GetCostString(currency, item.Count * price);

#if AT_I2LOC_PRESET
            UGUIConfirmationPanel.Instance.ShowConfirmationBox(I2.Loc.LocalizationManager.GetTranslation("Do you want to sell") + " " + I2.Loc.LocalizationManager.GetTranslation("Items/" + item.name) + " " + I2.Loc.LocalizationManager.GetTranslation("for") + " " + costString + "?", item, SellItemConfirmed);
#else
            UGUIConfirmationPanel.Instance.ShowConfirmationBox("Do you want to sell " + item.name + " for " + costString + "?", item, SellItemConfirmed);
#endif
        }
Ejemplo n.º 4
0
        public void OnEvent(AtavismEventData eData)
        {
            if (eData.eventType == "INVENTORY_UPDATE")
            {
                if (!removeEmptyItemsFromActionBar)
                {
                    return;
                }

                for (int i = 0; i < actions.Count; i++)
                {
                    for (int j = 0; j < actions[i].Count; j++)
                    {
                        AtavismAction action = actions[i][j];
                        if (action != null && action.actionObject != null && action.actionType == ActionType.Item)
                        {
                            // verify the item count is still > 0
                            AtavismInventoryItem actionItem = (AtavismInventoryItem)action.actionObject;
                            if (Inventory.Instance.GetCountOfItem(actionItem.templateId) < 1)
                            {
                                SetAction(i, j, null, false, 0, 0);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
 public void OnEvent(EventData eData)
 {
     if (eData.eventType == "PLACE_CLAIM_OBJECT") {
         if (GetBuildingState() != WorldBuildingState.PlaceItem)
             return;
         if (!open)
             ToggleOpen();
         OID itemOID = OID.fromString(eData.eventArgs[0]);
         itemBeingPlaced = ClientAPI.ScriptObject.GetComponent<Inventory>().GetInventoryItem(itemOID);
         // Does the item have a ClaimObject effect?
         List<int> effectPositions = itemBeingPlaced.GetEffectPositionsOfTypes("ClaimObject");
         if (effectPositions.Count == 0) {
             itemBeingPlaced = null;
             return;
         } else {
             string prefabName = itemBeingPlaced.itemEffectValues[effectPositions[0]];
             prefabName = prefabName.Remove(0, 17);
             prefabName = prefabName.Remove(prefabName.Length - 7);
             // Create an instance of the game Object
             GameObject prefab = (GameObject)Resources.Load(prefabName);
             GetHitLocation();
             SetCurrentReticle((GameObject)UnityEngine.Object.Instantiate(prefab, hitPoint, Quaternion.identity));
         }
     } else if (eData.eventType == "CLAIM_OBJECT_CLICKED") {
         int objectID = int.Parse(eData.eventArgs[0]);
         if (GetBuildingState() == WorldBuildingState.SelectItem && activeClaim.claimObjects.ContainsKey(objectID)) {
             SetCurrentReticle(activeClaim.claimObjects[objectID]);
         }
     }
 }
Ejemplo n.º 6
0
        public void ClearGrid()
        {
            int gridCount = gridSize * gridSize;

            for (int i = 0; i < gridCount; i++)
            {
                if (gridItems[i].item != null)
                {
                    gridItems[i].item.ResetUseCount();
                }
            }
            gridItems.Clear();
            for (int i = 0; i < gridCount; i++)
            {
                gridItems.Add(new CraftingComponent());
            }

            // Also clear special slots
            resultItems.Clear();
            dye          = null;
            essence      = null;
            recipeItem   = null;
            recipeItemID = -1;

            string[] args = new string[1];
            AtavismEventSystem.DispatchEvent("CRAFTING_GRID_UPDATE", args);
            AtavismEventSystem.DispatchEvent("INVENTORY_UPDATE", args);
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Pick up (or drop) an item from a given container and slot.
 /// This will set the cursor to the item.
 /// </summary>
 /// <param name="bagNum"></param>
 /// <param name="slotNum"></param>
 /// <param name="item"></param>
 public void PickupOrPlaceBagItem(int bagNum, int slotNum, AtavismInventoryItem item)
 {
     if (CursorHasItem())
     {
         // Place the item in the slot (possibly taking the item that was in the slot)
         AtavismLogger.LogDebugMessage("Drop item to: " + bagNum + "," + slotNum);
         AtavismLogger.LogDebugMessage("Old item: " + item);
         //_SetContainerItem(containerId, slotId, MarsCursor._cursorItem)
         PlaceCursorItemInInventory(bagNum, slotNum);
         _cursorItem = item;
         _UpdateCursor();
     }
     else if (CursorHasBag())
     {
         // Place the item in the slot (possibly taking the item that was in the slot)
         AtavismLogger.LogDebugMessage("Drop item to: " + bagNum + "," + slotNum);
         AtavismLogger.LogDebugMessage("Old item: " + item);
         //_SetContainerItem(containerId, slotId, MarsCursor._cursorItem)
         PlaceCursorBagAsItem(bagNum, slotNum);
         _cursorItem = item;
         _UpdateCursor();
     }
     else if (CursorHasAbility())
     {
         AtavismLogger.LogDebugMessage("Cannot currently use abilities on items");
     }
     else
     {
         SetCursorItem(item);
     }
 }
Ejemplo n.º 8
0
        public void HandleBlueprintMessage(Dictionary <string, object> props)
        {
            int numBlueprints = (int)props["numBlueprints"];

            for (int i = 0; i < numBlueprints; i++)
            {
                Blueprint bp = new Blueprint();
                bp.recipeID     = (int)props["recipeID" + i];
                bp.resultID     = (int)props["itemID" + i];
                bp.recipeItemID = (int)props["recipeItemID" + i];
                bp.station      = (string)props["station" + i];
                int numRows = (int)props["numRows" + i];
                List <List <CraftingComponent> > slots = new List <List <CraftingComponent> >();
                for (int j = 0; j < numRows; j++)
                {
                    List <CraftingComponent> columnSlots = new List <CraftingComponent>();
                    int numColumns = (int)props["numColumns" + i + "_" + j];
                    for (int k = 0; k < numColumns; k++)
                    {
                        int itemID = (int)props["item" + i + "_" + j + "_" + k];
                        if (itemID == -1)
                        {
                            continue;
                        }
                        AtavismInventoryItem item      = Inventory.Instance.GetItemByTemplateID(itemID);
                        CraftingComponent    component = new CraftingComponent();
                        component.item = item;
                        columnSlots.Add(component);
                    }
                    slots.Add(columnSlots);
                }
                bp.slots = slots;
                blueprints.Add(bp);
            }
        }
Ejemplo n.º 9
0
 public void HandleCraftingGridResponse(Dictionary <string, object> props)
 {
     try
     {
         AtavismLogger.LogInfoMessage("Got Message HandleCraftingGridResponse");
         recipeID     = (int)props["recipeID"];
         recipeName   = (string)props["recipeName"];
         recipeItemID = (int)props["recipeItem"];
         int numResults = (int)props["numResults"];
         resultItems.Clear();
         for (int i = 0; i < numResults; i++)
         {
             int itemID = (int)props["resultItem" + i];
             AtavismInventoryItem resultItem = GetComponent <Inventory>().GetItemByTemplateID(itemID);
             resultItem.Count = (int)props["resultItemCount" + i];
             resultItems.Add(resultItem);
         }
         if (recipeItemID != -1)
         {
             recipeItem = GetComponent <Inventory>().GetItemByTemplateID(recipeItemID);
         }
         else
         {
             recipeItem = null;
         }
         string[] args = new string[1];
         AtavismEventSystem.DispatchEvent("CRAFTING_GRID_UPDATE", args);
     }
     catch (System.Exception e)
     {
         AtavismLogger.LogError("Got Exeption " + e.Message);
     }
     AtavismLogger.LogInfoMessage("Got Message HandleCraftingGridResponse End");
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Try to pickup an item that is equipped, or place an item that can be equipped if the cursor is currently
        /// holding an item.
        /// </summary>
        /// <param name="slotNum"></param>
        /// <param name="item"></param>
        public void PickupOrPlaceEquippedItem(string slotName, AtavismInventoryItem item)
        {
            if (item.slot != slotName)
            {
                return;
            }

            if (CursorHasItem())
            {
                // Place the item in the slot (possibly taking the item that was in the slot)
                AtavismLogger.LogDebugMessage("Drop item to equipped slot Old item: " + item);
                //TODO: this needs changed as an ability item could be activated if a person was to try equip it
                _cursorItem.Activate();
                ResetCursor();
                _UpdateCursor();
            }
            else if (CursorHasAbility())
            {
                AtavismLogger.LogDebugMessage("Cannot currently use abilities on items");
            }
            else
            {
                // Cursor is empty so set the item as the cursor item
                SetCursorItem(item);
            }
        }
Ejemplo n.º 11
0
        public void SetMailItem(int gridPos, AtavismInventoryItem item)
        {
            if (item == null)
            {
                if (mailBeingComposed.items[gridPos].item != null)
                {
                    mailBeingComposed.items[gridPos].item.AlterUseCount(-mailBeingComposed.items[gridPos].count);
                }
                mailBeingComposed.items[gridPos].item  = null;
                mailBeingComposed.items[gridPos].count = 1;
            }
            else if (mailBeingComposed.items[gridPos].item == item)
            {
                mailBeingComposed.items[gridPos].count++;
            }
            else
            {
                mailBeingComposed.items[gridPos].item  = item;
                mailBeingComposed.items[gridPos].count = 1;
            }

            if (item != null)
            {
                item.AlterUseCount(1);
            }
        }
Ejemplo n.º 12
0
        void ConvertList(bool myOfferList, List <object> itemList)
        {
            int slotId = 0;

            foreach (object obj in itemList)
            {
                List <object> itemData = (List <object>)obj;
                int           itemID   = (int)itemData[1];
                if (myOfferList)
                {
                    AtavismInventoryItem item = Inventory.Instance.GetInventoryItem((OID)itemData[0]);
                    if (item != null)
                    {
                        item.Count = (int)itemData[2];
                    }
                    myOffers[slotId] = item;
                }
                else
                {
                    AtavismInventoryItem item = Inventory.Instance.GetItemByTemplateID(itemID);
                    if (item != null)
                    {
                        item.Count = (int)itemData[2];
                    }
                    theirOffers[slotId] = item;
                }
                slotId++;
            }
        }
Ejemplo n.º 13
0
        public void LootResource(AtavismInventoryItem item)
        {
            Dictionary <string, object> props = new Dictionary <string, object>();

            props.Add("resourceID", CurrentResourceNode);
            props.Add("gatherAll", false);
            props.Add("itemID", item.TemplateId);
            NetworkAPI.SendExtensionMessage(ClientAPI.GetPlayerOid(), false, "crafting.GATHER_RESOURCE", props);
        }
Ejemplo n.º 14
0
 public bool HandleItemUseOverride(AtavismInventoryItem item)
 {
     if (itemClickedOverride != null)
     {
         itemClickedOverride(item);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Reset the cursor to its initial state (point)
 /// </summary>
 public void ResetCursor()
 {
     // reset our state
     _cursorItem    = null;
     _cursorAbility = null;
     _cursorBag     = null;
     // Reset the texture
     //	cursorTexture = null;
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Sets the cursor item to the specified item. This will result in the items icon replacing the cursor
 /// and allow it to be placed.
 /// </summary>
 /// <param name="item"></param>
 public void SetCursorItem(AtavismInventoryItem item)
 {
     if (item != null)
     {
         _cursorItem    = item;
         _cursorAbility = null;
         _UpdateCursor();
         AtavismLogger.LogDebugMessage("Set cursor item: " + item + "," + item.icon);
     }
 }
Ejemplo n.º 17
0
 void DrawItemTooltip(string slot, AtavismInventoryItem item, float x, float y)
 {
     if (item != null) {
         item.DrawTooltip(x, y);
     } else {
         Rect tooltipRect = new Rect(x, y-30, 90, 30);
         GUI.Box(tooltipRect, "");
         GUI.Label(new Rect(tooltipRect.x + 5, tooltipRect.y + 5, 80, 20), slot);
     }
 }
Ejemplo n.º 18
0
 public void StartPlaceClaimObject(AtavismInventoryItem item)
 {
     if (activeClaim == null)
     {
         return;
     }
     string[] args = new string[1];
     args[0] = item.ItemId.ToString();
     AtavismEventSystem.DispatchEvent("PLACE_CLAIM_OBJECT", args);
 }
Ejemplo n.º 19
0
        public void SellItemConfirmed(object item, bool response)
        {
            if (!response)
            {
                return;
            }

            AtavismInventoryItem mItem = (AtavismInventoryItem)item;

            SellItemToMerchant(mItem.ItemId, mItem.Count);
        }
Ejemplo n.º 20
0
        void showAdditionalTooltip(int Id)
        {
            AtavismInventoryItem item  = Inventory.Instance.GetItemByTemplateID(Id);
            AtavismInventoryItem item2 = GetComponent <AtavismInventoryItem>();

            if (item2 == null)
            {
                item2 = gameObject.AddComponent <AtavismInventoryItem>();
            }
            item2.showAdditionalTooltip(item);
        }
Ejemplo n.º 21
0
        public void ImproveBuildObject(GameObject objectBeingEdited, AtavismInventoryItem item, int count)
        {
            Dictionary <string, object> props = new Dictionary <string, object>();

            props.Add("claimID", activeClaim.id);
            props.Add("objectID", objectBeingEdited.GetComponent <ClaimObject>().ID);
            props.Add("itemID", item.templateId);
            props.Add("itemOID", item.ItemId);
            props.Add("count", count);
            NetworkAPI.SendExtensionMessage(ClientAPI.GetPlayerOid(), false, "voxel.UPGRADE_BUILDING_OBJECT", props);
        }
Ejemplo n.º 22
0
        public void RepairItem(AtavismInventoryItem item)
        {
            float  cost       = item.cost * repairRate * (item.MaxDurability - item.Durability) / item.MaxDurability;
            string costString = Inventory.Instance.GetCostString(item.currencyType, (int)(cost * item.Count * Inventory.Instance.sellFactor));

#if AT_I2LOC_PRESET
            UGUIConfirmationPanel.Instance.ShowConfirmationBox(I2.Loc.LocalizationManager.GetTranslation("Do you want to repair") + " " + I2.Loc.LocalizationManager.GetTranslation("Items/" + item.name) + " for " + costString + "?", item, RepairItemConfirmed);
#else
            UGUIConfirmationPanel.Instance.ShowConfirmationBox("Do you want to repair " + item.name + " for " + costString + "?", item, RepairItemConfirmed);
#endif
        }
Ejemplo n.º 23
0
        public void RepairItemConfirmed(object item, bool response)
        {
            if (!response)
            {
                return;
            }

            AtavismInventoryItem mItem = (AtavismInventoryItem)item;

            SendRepairItem(mItem.ItemId);
        }
Ejemplo n.º 24
0
 public void ItemPlacedInTradeSlot(AtavismInventoryItem item, int slotId, bool send)
 {
     if (myOffers.Count < slotId)
     {
         return;
     }
     myOffers[slotId] = item;
     if (send)
     {
         SendTradeOffer();
     }
 }
Ejemplo n.º 25
0
        public void CreateAuction(AtavismInventoryItem item, Dictionary <string, object> currencies, int count, string itemGroupId)
        {
            AtavismLogger.LogDebugMessage("CreateAuction Start");
            Dictionary <string, object> props = new Dictionary <string, object>();

            props.Add("startbid", 0);
            props.Add("buyout", currencies);

            props.Add("item_oid", item.ItemId);
            props.Add("item_count", count);
            props.Add("itemgroup", itemGroupId);
            props.Add("auctioneer_oid", OID.fromLong(0));
            NetworkAPI.SendExtensionMessage(0, false, "auction.createSell", props);
            AtavismLogger.LogDebugMessage("CreateAuction End");
        }
Ejemplo n.º 26
0
        public void OnEvent(AtavismEventData eData)
        {
            if (eData.eventType == "INVENTORY_UPDATE")
            {
                // The inventory has updated, we need to see if it effects the crafting UI
                int gridCount = gridSize * gridSize;
                for (int i = 0; i < gridCount; i++)
                {
                    if (gridItems[i].item != null)
                    {
                        AtavismInventoryItem item = gridItems[i].item;
                        gridItems[i].item = Inventory.Instance.GetInventoryItem(item.ItemId);
                    }
                }

                if (station != null)
                {
                    SendGridUpdated();
                }
                //string[] args = new string[1];
                //AtavismEventSystem.DispatchEvent("CRAFTING_GRID_UPDATE", args);
            }
        }
Ejemplo n.º 27
0
        public void SetGridItem(int gridPos, AtavismInventoryItem item, bool send)
        {
            if (item == null)
            {
                //if (gridItems[gridPos].item != null)
                //	gridItems[gridPos].item.AlterUseCount(-gridItems[gridPos].count);
                gridItems[gridPos].item  = null;
                gridItems[gridPos].count = 1;
            }/* else if (gridItems[gridPos].item == item) {
              *         gridItems[gridPos].count++;
              * }*/
            else
            {
                gridItems[gridPos].item  = item;
                gridItems[gridPos].count = item.Count;
            }

            //if (item != null)
            //	item.AlterUseCount(1);
            if (send)
            {
                SendGridUpdated();
            }
        }
Ejemplo n.º 28
0
    public void ClearGrid()
    {
        int gridCount = gridSize * gridSize;
        for (int i = 0; i < gridCount; i++) {
            if (gridItems[i].item != null) {
                gridItems[i].item.ResetUseCount();
            }
        }
        gridItems.Clear();
        for (int i = 0; i < gridCount; i++) {
            gridItems.Add(new CraftingComponent());
        }

        // Also clear special slots
        resultItem = null;
        resultItemID = -1;
        dye = null;
        essence = null;
        recipeItem = null;
        recipeItemID = -1;

        string[] args = new string[1];
        EventSystem.DispatchEvent("CRAFTING_GRID_UPDATE", args);
    }
Ejemplo n.º 29
0
        public void SendPlaceClaimObject(int buildObjectID, AtavismInventoryItem item, Transform transform, int parent)
        {
            Dictionary <string, object> props = new Dictionary <string, object>();

            props.Add("claim", activeClaim.id);
            props.Add("loc", transform.position);
            props.Add("orient", transform.rotation);
            props.Add("parent", parent);

            if (item != null)
            {
                props.Add("buildObjectTemplateID", buildObjectID);
                props.Add("itemID", item.templateId);
                props.Add("itemOID", item.ItemId);
            }
            else
            {
                props.Add("buildObjectTemplateID", buildObjectID);
                props.Add("itemID", -1);
                props.Add("itemOID", null);
            }

            NetworkAPI.SendExtensionMessage(ClientAPI.GetPlayerOid(), false, "voxel.PLACE_CLAIM_OBJECT", props);
        }
Ejemplo n.º 30
0
        public void StartPlaceClaimObject(UGUIAtavismActivatable activatable)
        {
            AtavismInventoryItem item = (AtavismInventoryItem)activatable.ActivatableObject;

            StartPlaceClaimObject(item);
        }
Ejemplo n.º 31
0
 public void HandleItemUseOverride(AtavismInventoryItem item)
 {
     if (interfaceOverrideState == InterfaceOverrideState.Merchant) {
         string[] args = new string[1];
         args[0] = item.ItemId.ToString();
         AtavismEventSystem.DispatchEvent("SELL_ITEM", args);
     }
     if (interfaceOverrideState == InterfaceOverrideState.WorldBuilding) {
         string[] args = new string[1];
         args[0] = item.ItemId.ToString();
         AtavismEventSystem.DispatchEvent("PLACE_CLAIM_OBJECT", args);
     }
 }
Ejemplo n.º 32
0
 public void DeleteItemStack(AtavismInventoryItem item)
 {
     long targetOid = ClientAPI.GetPlayerObject().Oid;
     NetworkAPI.SendTargetedCommand(targetOid, "/deleteItemStack " + item.ItemId.ToString());
 }
Ejemplo n.º 33
0
 public void SetDye(AtavismInventoryItem item)
 {
     dye = item;
     SendGridUpdated();
 }
Ejemplo n.º 34
0
        // Update is called once per frame
        void Update()
        {
            if (AtavismCursor.Instance == null || AtavismCursor.Instance.IsMouseOverUI())
            {
                return;
            }
            if (WorldBuilder.Instance.ActiveClaim != null)
            {
                if (WorldBuilder.Instance.ActiveClaim.permissionlevel < 1 && !WorldBuilder.Instance.ActiveClaim.playerOwned)
                {
                    return;
                }
            }
            if (GetBuildingState() == WorldBuildingState.SelectItem)
            {
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit hit;
                // Casts the ray and get the first game object hit
                if (Physics.Raycast(ray, out hit, Mathf.Infinity, objectSelectLayers))
                {
                    ClaimObject cObject = hit.transform.gameObject.GetComponent <ClaimObject>();
                    if (cObject == null)
                    {
                        cObject = hit.transform.gameObject.GetComponentInChildren <ClaimObject>();
                    }
                    if (cObject == null && hit.transform.parent != null)
                    {
                        cObject = hit.transform.parent.GetComponent <ClaimObject>();
                    }
                    if (cObject != null)
                    {
                        int objectID = cObject.ID;
                        if (WorldBuilder.Instance.ActiveClaim.claimObjects.ContainsKey(objectID))
                        {
                            if (hoverObject != cObject)
                            {
                                if (hoverObject != null)
                                {
                                    hoverObject.ResetHighlight();
                                }
                                hoverObject = cObject;
                                cObject.Highlight();
                            }
                            if (Input.GetMouseButtonDown(0))
                            {
                                StopSelectObject();
                                //SetBuildingState(WorldBuildingState.EditItem);
                                //objectBeingEdited = activeClaim.claimObjects[objectID].gameObject;
                                WorldBuilder.Instance.RequestClaimObjectInfo(objectID);
                                cObject.Highlight();
                                WorldBuilder.Instance.SelectedObject = cObject;
                            }
                        }
                    }
                    else if (hoverObject != null)
                    {
                        hoverObject.ResetHighlight();
                        hoverObject = null;
                    }
                }
                else if (hoverObject != null)
                {
                    hoverObject.ResetHighlight();
                    hoverObject = null;
                }
            }

            if ((GetBuildingState() == WorldBuildingState.PlaceItem || GetBuildingState() == WorldBuildingState.MoveItem) && currentReticle != null)
            {
                if (Input.GetMouseButtonDown(1))
                {
                    ClearCurrentReticle(true);
                    WorldBuilder.Instance.BuildingState = WorldBuildingState.None;
                    return;
                }

                GetHitLocation();
                bool legalPlacement = IsLegalClaimObjectPlacement();
                if (!legalPlacement)
                {
                    currentReticle.GetComponentInChildren <ClaimObject>().HighlightError();
                }
                else
                {
                    currentReticle.GetComponentInChildren <ClaimObject>().ResetHighlight();
                }

                float delta = Input.GetAxis("Mouse ScrollWheel");
                if (mouseWheelBuildMode == MouseWheelBuildMode.Rotate)
                {
                    Vector3 currentRotation = currentReticle.transform.rotation.eulerAngles;
                    if (delta > 0)
                    {
                        //currentReticle.transform.Rotate (new Vector3 (0, -rotationAmount, 0));
                        currentRotation.y -= 90;
                    }
                    else if (delta < 0)
                    {
                        //currentReticle.transform.Rotate (new Vector3 (0, rotationAmount, 0));
                        currentRotation.y += 90;
                    }
                    Quaternion rotation = Quaternion.Euler(currentRotation);
                    currentReticle.transform.rotation = rotation;
                }
                else if (mouseWheelBuildMode == MouseWheelBuildMode.MoveVertical)
                {
                    if (delta > 0)
                    {
                        if (currentClaimObject.verticalSnapDistance > 0)
                        {
                            currentVerticalOffset += currentClaimObject.verticalSnapDistance;
                        }
                        else
                        {
                            currentVerticalOffset += verticalMovementAmount;
                        }
                    }
                    else if (delta < 0)
                    {
                        if (currentClaimObject.verticalSnapDistance > 0)
                        {
                            currentVerticalOffset -= currentClaimObject.verticalSnapDistance;
                        }
                        else
                        {
                            currentVerticalOffset -= verticalMovementAmount;
                        }
                    }
                }

                //snapped = false;
                if ((currentReticle != null) && (WorldBuilder.Instance.ActiveClaim != null) &&
                    (WorldBuilder.Instance.InsideClaimArea(WorldBuilder.Instance.ActiveClaim, hitPoint)))
                {
                    if (snap)
                    {
                        float newX = Mathf.Round(hitPoint.x * (1 / snapGap)) / (1 / snapGap);
                        float newZ = Mathf.Round(hitPoint.z * (1 / snapGap)) / (1 / snapGap);
                        float newY = hitPoint.y + currentVerticalOffset;
                        // If the claimobject has a horizontal snap value, override default snap values
                        if (currentClaimObject.horizontalSnapDistance > 0)
                        {
                            newX = Mathf.Round(hitPoint.x * (1 / currentClaimObject.horizontalSnapDistance)) / (1 / currentClaimObject.horizontalSnapDistance);
                            newZ = Mathf.Round(hitPoint.z * (1 / currentClaimObject.horizontalSnapDistance)) / (1 / currentClaimObject.horizontalSnapDistance);
                        }
                        // If the claimobject has a vertical snap value, set that as well
                        if (currentClaimObject.verticalSnapDistance > 0)
                        {
                            newY = Mathf.Round((hitPoint.y + currentVerticalOffset) * (1 / currentClaimObject.verticalSnapDistance)) / (1 / currentClaimObject.verticalSnapDistance);
                        }
                        hitPoint = new Vector3(newX, newY, newZ);
                        //	snapped = true;
                    }

                    if (currentClaimObject.placementType == BuildObjectPlacementType.Terrain && hitObject != null &&
                        (hitObject.GetComponent <ClaimObject>() != null || hitObject.GetComponentInParent <ClaimObject>() != null))
                    {
                        // Custom snap system to line them up with each other
                        // Get size of block
                        Vector3 baseSize = GetSizeOfBase(currentReticle).size;
                        // Move block along z axis by size / 2, set y to same as hit object
                        if (hitNormal == Vector3.back)
                        {
                            hitPoint    = hitObject.transform.position;
                            hitPoint.z -= baseSize.z;
                            //	snapped = true;
                        }
                        else if (hitNormal == Vector3.forward)
                        {
                            hitPoint    = hitObject.transform.position;
                            hitPoint.z += baseSize.z;
                            //	snapped = true;
                        }
                        else if (hitNormal == Vector3.right)
                        {
                            hitPoint    = hitObject.transform.position;
                            hitPoint.x += baseSize.x;
                            //	snapped = true;
                        }
                        else if (hitNormal == Vector3.left)
                        {
                            hitPoint    = hitObject.transform.position;
                            hitPoint.x -= baseSize.x;
                            //	snapped = true;
                        }

                        // Check terrain height
                        if (baseOverTerrainThreshold > 0)
                        {
                            float height = Terrain.activeTerrain.SampleHeight(hitPoint) + Terrain.activeTerrain.GetPosition().y;
                            //Debug.Log("Hitpoint y = " + hitPoint.y + " with terrain height: " + height);
                            if (hitPoint.y - baseOverTerrainThreshold > height)
                            {
                                legalPlacement = false;
                                currentClaimObject.HighlightError();
                                Debug.Log("Too high above terrain");
                            }
                        }
                    }
                    currentReticle.transform.position = hitPoint;

                    if (currentClaimObject.autoRotateToHitNormal)
                    {
                        //Rotate the object to match normals
                        Vector3 currentRotation = currentReticle.transform.rotation.eulerAngles;
                        if (hitNormal == Vector3.back)
                        {
                            currentRotation.y = 180;
                            //currentReticle.transform.rotation = Quaternion.AngleAxis(180, Vector3.up);
                            //hitPoint = new Vector3(newX, newY, hitPoint.z);
                        }
                        else if (hitNormal == Vector3.forward)
                        {
                            currentRotation.y = 0;
                        }
                        else if (hitNormal == Vector3.right)
                        {
                            currentRotation.y = 90;
                        }
                        else if (hitNormal == Vector3.left)
                        {
                            currentRotation.y = -90;
                        }
                        Quaternion rotation = Quaternion.Euler(currentRotation);
                        currentReticle.transform.rotation = rotation;
                    }
                }

                if (Input.GetKeyDown(KeyCode.LeftShift))
                {
                    if (mouseWheelBuildMode == MouseWheelBuildMode.MoveVertical)
                    {
                        mouseWheelBuildMode = MouseWheelBuildMode.Rotate;
#if AT_I2LOC_PRESET
                        ClientAPI.Write(I2.Loc.LocalizationManager.GetTranslation("Changed to Rotate Mode"));
#else
                        ClientAPI.Write("Changed to Rotate Mode");
#endif
                    }
                    else
                    {
                        mouseWheelBuildMode = MouseWheelBuildMode.MoveVertical;
#if AT_I2LOC_PRESET
                        ClientAPI.Write(I2.Loc.LocalizationManager.GetTranslation("Changed to Move Vertical Mode"));
#else
                        ClientAPI.Write("Changed to Move Vertical Mode");
#endif
                    }
                }

                if (Input.GetMouseButtonDown(0) && !AtavismUiSystem.IsMouseOverFrame())
                {
                    if (!legalPlacement)
                    {
                        string[] args = new string[1];
#if AT_I2LOC_PRESET
                        args[0] = I2.Loc.LocalizationManager.GetTranslation("That object cannot be placed there");
#else
                        args[0] = "That object cannot be placed there";
#endif
                        AtavismEventSystem.DispatchEvent("ERROR_MESSAGE", args);
                    }
                    else if (GetBuildingState() == WorldBuildingState.PlaceItem)
                    {
                        int parent = -1;
                        if (currentClaimObject.canHaveParent && hitObject.GetComponentInParent <ClaimObject>() != null)
                        {
                            parent = hitObject.GetComponentInParent <ClaimObject>().ID;
                        }

                        WorldBuilder.Instance.SendPlaceClaimObject(buildTemplate.id, itemBeingPlaced, currentReticle.transform, parent);
                        // Play a coord effect
                        if (placementCoordEffect != null)
                        {
                            Dictionary <string, object> props = new Dictionary <string, object>();
                            props["gameObject"] = ClientAPI.GetPlayerObject().GameObject;
                            CoordinatedEffectSystem.ExecuteCoordinatedEffect(placementCoordEffect.name, props);
                        }

#if AT_I2LOC_PRESET
                        ClientAPI.Write(I2.Loc.LocalizationManager.GetTranslation("Send place claim object message"));
#else
                        ClientAPI.Write("Send place claim object message");
#endif
                        ClearCurrentReticle(true);
                        itemBeingPlaced = null;
                        SetBuildingState(WorldBuildingState.Standard);
                        AtavismCursor.Instance.ClearItemClickedOverride(WorldBuilder.Instance.StartPlaceClaimObject);
                    }
                    else if (GetBuildingState() == WorldBuildingState.MoveItem)
                    {
                        int parent = -1;
                        if (hitObject.GetComponent <ClaimObject>() != null)
                        {
                            parent = hitObject.GetComponent <ClaimObject>().ID;
                        }
                        WorldBuilder.Instance.SendEditObjectPosition(WorldBuilder.Instance.SelectedObject, parent);
                        //SetBuildingState(WorldBuildingState.EditItem);
                        SetBuildingState(WorldBuildingState.Standard);
                        ClearCurrentReticle(false);
                        itemBeingPlaced = null;
                        //objectBeingEdited.GetComponent<ClaimObject>().ResetHighlight();
                        //objectBeingEdited = null;
                    }
                }
            }
        }
Ejemplo n.º 35
0
 public void SetEssence(AtavismInventoryItem item)
 {
     essence = item;
     SendGridUpdated();
 }
Ejemplo n.º 36
0
    public void SetGridItem(int gridPos, AtavismInventoryItem item)
    {
        if (item == null) {
            if (gridItems[gridPos].item != null)
                gridItems[gridPos].item.AlterUseCount(-gridItems[gridPos].count);
            gridItems[gridPos].item = null;
            gridItems[gridPos].count = 1;
        } else if (gridItems[gridPos].item == item) {
            gridItems[gridPos].count++;
        } else {
            gridItems[gridPos].item = item;
            gridItems[gridPos].count = 1;
        }

        if (item != null)
            item.AlterUseCount(1);

        SendGridUpdated();
    }
Ejemplo n.º 37
0
 /// <summary>
 /// Sets the cursor item to the specified item. This will result in the items icon replacing the cursor
 /// and allow it to be placed.
 /// </summary>
 /// <param name="item"></param>
 public void SetCursorAbility(Ability ability)
 {
     _cursorItem = null;
     _cursorAbility = ability;
     _UpdateCursor();
     AtavismLogger.LogDebugMessage("Set cursor ability: " + ability + "," + ability.icon);
 }
Ejemplo n.º 38
0
 /// <summary>
 /// Sets the cursor item to the specified item. This will result in the items icon replacing the cursor
 /// and allow it to be placed.
 /// </summary>
 /// <param name="item"></param>
 public void SetCursorItem(AtavismInventoryItem item)
 {
     if (item != null)
     {
         _cursorItem = item;
         _cursorAbility = null;
         _UpdateCursor();
         AtavismLogger.LogDebugMessage("Set cursor item: " + item + "," + item.icon);
     }
 }
Ejemplo n.º 39
0
 public void SetDye(AtavismInventoryItem item)
 {
     dye = item;
 }
Ejemplo n.º 40
0
 public void SetEssence(AtavismInventoryItem item)
 {
     essence = item;
 }
Ejemplo n.º 41
0
    public void SetGridItem(int gridPos, AtavismInventoryItem item)
    {
        if (item == null) {
            gridItems[gridPos].item.AlterUseCount(-gridItems[gridPos].count);
            gridItems[gridPos].item = null;
            gridItems[gridPos].count = 1;
        } else if (gridItems[gridPos].item == item) {
            gridItems[gridPos].count++;
        } else {
            gridItems[gridPos].item = item;
            gridItems[gridPos].count = 1;
        }

        item.AlterUseCount(1);

        // Send message to server to work out if we have a valid recipe
        Dictionary<string, object> props = new Dictionary<string, object> ();
        LinkedList<object> itemIds = new LinkedList<object>();
        LinkedList<object> itemCounts = new LinkedList<object>();
        for (int i = 0; i < gridItems.Count; i++) {
            if (gridItems[i].item != null) {
                itemIds.AddLast(gridItems[i].item.templateId);
            } else {
                itemIds.AddLast(-1);
            }
            itemCounts.AddLast(gridItems[i].count);
        }
        props.Add ("componentIDs", itemIds);
        props.Add ("componentCounts", itemCounts);
        NetworkAPI.SendExtensionMessage (ClientAPI.GetPlayerOid(), false, "crafting.GRID_UPDATED", props);
    }
Ejemplo n.º 42
0
 public void SetRecipeItem(AtavismInventoryItem item)
 {
     recipeItem = item;
 }
Ejemplo n.º 43
0
 public void SetRecipeItem(AtavismInventoryItem item)
 {
     recipeItem = item;
     SendGridUpdated();
 }
Ejemplo n.º 44
0
    // Update is called once per frame
    void Update()
    {
        // Get the active claim on each frame
        activeClaim = ClientAPI.ScriptObject.GetComponent<WorldBuilder>().ActiveClaim;

        if (GetBuildingState() == WorldBuildingState.SelectItem) {
            Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
            RaycastHit hit;
            // Casts the ray and get the first game object hit
            if (Physics.Raycast (ray, out hit, Mathf.Infinity)) {
                ClaimObject cObject = hit.transform.gameObject.GetComponent<ClaimObject>();
                if (cObject == null)
                    cObject = hit.transform.gameObject.GetComponentInChildren<ClaimObject>();
                if (cObject == null && hit.transform.parent != null)
                    cObject = hit.transform.parent.GetComponent<ClaimObject>();
                if (cObject != null) {
                    int objectID = cObject.ID;
                    if (activeClaim.claimObjects.ContainsKey(objectID)) {
                        if (hoverObject != cObject) {
                            if (hoverObject != null) {
                                hoverObject.ResetHighlight();
                            }
                            hoverObject = cObject;
                            cObject.Highlight();
                        }
                        if (Input.GetMouseButtonDown(0)) {
                            StopSelectObject();
                            SetBuildingState(WorldBuildingState.EditItem);
                            objectBeingEdited = activeClaim.claimObjects[objectID];
                            cObject.Selected = true;
                        }
                    }
                } else if (hoverObject != null) {
                    hoverObject.ResetHighlight();
                    hoverObject = null;
                }
            } else if (hoverObject != null) {
                hoverObject.ResetHighlight();
                hoverObject = null;
            }
        }

        if ((GetBuildingState() == WorldBuildingState.PlaceItem || GetBuildingState() == WorldBuildingState.MoveItem) && currentReticle != null) {
            GetHitLocation();
            float delta = Input.GetAxis ("Mouse ScrollWheel");
            if (mouseWheelBuildMode == MouseWheelBuildMode.Rotate) {
                if (delta > 0)
                    currentReticle.transform.Rotate (new Vector3 (0, -rotationAmount, 0));
                else if (delta < 0)
                    currentReticle.transform.Rotate (new Vector3 (0, rotationAmount, 0));
            } else if (mouseWheelBuildMode == MouseWheelBuildMode.MoveVertical) {
                if (delta > 0) {
                    currentVerticalOffset += verticalMovementAmount;
                } else if (delta < 0) {
                    currentVerticalOffset -= verticalMovementAmount;
                }
            }

            if ((currentReticle != null) && (activeClaim != null) &&
                (ClientAPI.ScriptObject.GetComponent<WorldBuilder>().InsideClaimArea (activeClaim, hitPoint))) {
                if (snap) {
                    float newX = Mathf.Round(hitPoint.x * (1 / snapGap)) / (1 / snapGap);
                    float newZ = Mathf.Round(hitPoint.z * (1 / snapGap)) / (1 / snapGap);
                    hitPoint = new Vector3(newX, hitPoint.y + currentVerticalOffset, newZ);
                }
                currentReticle.transform.position = hitPoint;
            }

            if (Input.GetKeyDown(KeyCode.LeftShift)) {
                if (mouseWheelBuildMode == MouseWheelBuildMode.MoveVertical) {
                    mouseWheelBuildMode = MouseWheelBuildMode.Rotate;
                    ClientAPI.Write("Changed to Rotate Mode");
                } else {
                    mouseWheelBuildMode = MouseWheelBuildMode.MoveVertical;
                    ClientAPI.Write("Changed to Move Vertical Mode");
                }
            }

            if (Input.GetMouseButtonDown (0) && !AtavismUiSystem.IsMouseOverFrame()) {
                if (GetBuildingState() == WorldBuildingState.PlaceItem) {
                    List<int> effectPositions = itemBeingPlaced.GetEffectPositionsOfTypes("ClaimObject");
                    Dictionary<string, object> props = new Dictionary<string, object>();
                    props.Add("claim", activeClaim.id);
                    props.Add("gameObject", itemBeingPlaced.itemEffectValues[effectPositions[0]]);
                    props.Add("loc", currentReticle.transform.position);
                    props.Add("orient", currentReticle.transform.rotation);
                    props.Add("itemID", itemBeingPlaced.templateId);
                    props.Add("itemOID", itemBeingPlaced.ItemId);
                    NetworkAPI.SendExtensionMessage(ClientAPI.GetPlayerOid(), false, "voxel.PLACE_CLAIM_OBJECT", props);
                    ClientAPI.Write("Send place claim object message");
                    ClearCurrentReticle(true);
                    itemBeingPlaced = null;
                    SetBuildingState(WorldBuildingState.Standard);
                    AtavismCursor.Instance.ChangeWorldBuilderState(false);
                } else if (GetBuildingState() == WorldBuildingState.MoveItem) {
                    Dictionary<string, object> props = new Dictionary<string, object>();
                    props.Add("action", "save");
                    props.Add("claimID", activeClaim.id);
                    props.Add("objectID", objectBeingEdited.GetComponent<ClaimObject>().ID);
                    props.Add("loc", objectBeingEdited.transform.position);
                    props.Add("orient", objectBeingEdited.transform.rotation);
                    NetworkAPI.SendExtensionMessage(ClientAPI.GetPlayerOid(), false, "voxel.EDIT_CLAIM_OBJECT", props);
                    //SetBuildingState(WorldBuildingState.EditItem);
                    SetBuildingState(WorldBuildingState.Standard);
                    ClearCurrentReticle(false);
                    itemBeingPlaced = null;
                    objectBeingEdited.GetComponent<ClaimObject>().Selected = false;
                    objectBeingEdited = null;
                }

            }
        }
    }
Ejemplo n.º 45
0
 /// <summary>
 /// Reset the cursor to its initial state (point)
 /// </summary>
 public void ResetCursor()
 {
     // reset our state
     _cursorItem = null;
     _cursorAbility = null;
     _cursorBag = null;
     // Reset the texture
     cursorTexture = null;
 }
Ejemplo n.º 46
0
    // Update is called once per frame
    void Update()
    {
        // Get the active claim on each frame
        activeClaim = ClientAPI.ScriptObject.GetComponent<WorldBuilder>().ActiveClaim;

        if (GetBuildingState() == WorldBuildingState.SelectItem && Input.GetMouseButtonDown(0)) {
            Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
            RaycastHit hit;
            // Casts the ray and get the first game object hit
            if (Physics.Raycast (ray, out hit, Mathf.Infinity)) {
                ClaimObject cObject = hit.transform.gameObject.GetComponent<ClaimObject>();
                if (cObject != null) {
                    int objectID = cObject.ID;
                    if (activeClaim.claimObjects.ContainsKey(objectID)) {
                        SetBuildingState(WorldBuildingState.EditItem);
                        objectBeingEdited = activeClaim.claimObjects[objectID];
                    }
                }
            }
        }

        if ((GetBuildingState() == WorldBuildingState.PlaceItem || GetBuildingState() == WorldBuildingState.MoveItem) && currentReticle != null) {
            GetHitLocation();
            float delta = Input.GetAxis ("Mouse ScrollWheel");
            if (delta > 0)
                currentReticle.transform.Rotate (new Vector3 (0, -90, 0));
            else if (delta < 0)
                currentReticle.transform.Rotate (new Vector3 (0, 90, 0));

            if ((currentReticle != null) && (activeClaim != null) &&
                (ClientAPI.ScriptObject.GetComponent<WorldBuilder>().InsideClaimArea (activeClaim, hitPoint)))
                currentReticle.transform.position = hitPoint;

            if (Input.GetMouseButtonDown (0) && !UiSystem.IsMouseOverFrame()) {
                if (GetBuildingState() == WorldBuildingState.PlaceItem) {
                    List<int> effectPositions = itemBeingPlaced.GetEffectPositionsOfTypes("ClaimObject");
                    Dictionary<string, object> props = new Dictionary<string, object>();
                    props.Add("claim", activeClaim.id);
                    props.Add("gameObject", itemBeingPlaced.itemEffectValues[effectPositions[0]]);
                    props.Add("loc", currentReticle.transform.position);
                    props.Add("orient", currentReticle.transform.rotation);
                    props.Add("itemID", itemBeingPlaced.templateId);
                    props.Add("itemOID", itemBeingPlaced.ItemId);
                    NetworkAPI.SendExtensionMessage(ClientAPI.GetPlayerOid(), false, "voxel.PLACE_CLAIM_OBJECT", props);
                    ClientAPI.Write("Send place claim object message");
                    ClearCurrentReticle(true);
                    itemBeingPlaced = null;
                    SetBuildingState(WorldBuildingState.Standard);
                    gameObject.GetComponent<Cursor>().ChangeWorldBuilderState(false);
                } else if (GetBuildingState() == WorldBuildingState.MoveItem) {
                    SetBuildingState(WorldBuildingState.EditItem);
                    ClearCurrentReticle(false);
                }

            }
        }
    }
Ejemplo n.º 47
0
 /// <summary>
 /// Try to pickup an item that is equipped, or place an item that can be equipped if the cursor is currently
 /// holding an item.
 /// </summary>
 /// <param name="slotNum"></param>
 /// <param name="item"></param>
 public void PickupOrPlaceEquippedItem(int slotNum, AtavismInventoryItem item)
 {
     if (CursorHasItem ()) {
         // Place the item in the slot (possibly taking the item that was in the slot)
         AtavismLogger.LogDebugMessage ("Drop item to equipped slot: " + slotNum + ". Old item: " + item);
         //TODO: this needs changed as an ability item could be activated if a person was to try equip it
         _cursorItem.Activate ();
         ResetCursor ();
         _UpdateCursor ();
     } else if (CursorHasAbility ()) {
         AtavismLogger.LogDebugMessage ("Cannot currently use abilities on items");
     } else {
         // Cursor is empty so set the item as the cursor item
         SetCursorItem(item);
     }
 }
Ejemplo n.º 48
0
        public void OnEvent(AtavismEventData eData)
        {
            if (eData.eventType == "PLACE_CLAIM_OBJECT")
            {
                //if (GetBuildingState() != WorldBuildingState.PlaceItem)
                //	return;

                OID itemOID = OID.fromString(eData.eventArgs[0]);
                itemBeingPlaced = Inventory.Instance.GetInventoryItem(itemOID);
                // Does the item have a ClaimObject effect?
                List <int> effectPositions = itemBeingPlaced.GetEffectPositionsOfTypes("ClaimObject");
                if (effectPositions.Count == 0)
                {
                    itemBeingPlaced = null;
                    return;
                }
                else
                {
                    SetBuildingState(WorldBuildingState.PlaceItem);
                    int buildObjectID = int.Parse(itemBeingPlaced.itemEffectValues[effectPositions[0]]);
                    buildTemplate = WorldBuilder.Instance.GetBuildObjectTemplate(buildObjectID);

                    string prefabName = buildTemplate.gameObject.Remove(0, 17);
                    prefabName = prefabName.Remove(prefabName.Length - 7);
                    // Create an instance of the game Object
                    GameObject prefab = (GameObject)Resources.Load(prefabName);
                    GetHitLocation();
                    SetCurrentReticle((GameObject)UnityEngine.Object.Instantiate(prefab, hitPoint, prefab.transform.rotation));
                }
            }
            else if (eData.eventType == "START_BUILD_CLAIM_OBJECT")
            {
                int buildTemplateID = int.Parse(eData.eventArgs[0]);
                buildTemplate = WorldBuilder.Instance.GetBuildObjectTemplate(buildTemplateID);
                Debug.Log("Checking claim type: " + WorldBuilder.Instance.ActiveClaim.claimType + " against: " + buildTemplate.validClaimTypes);
                // Verify the claim type matches
                ClaimType activeClaimType = WorldBuilder.Instance.ActiveClaim.claimType;
                if (activeClaimType != ClaimType.Any && buildTemplate.validClaimTypes != ClaimType.Any)
                {
                    if (activeClaimType != buildTemplate.validClaimTypes)
                    {
                        string[] args = new string[1];
#if AT_I2LOC_PRESET
                        args[0] = I2.Loc.LocalizationManager.GetTranslation("That object cannot be placed in this Claim");
#else
                        args[0] = "That object cannot be placed in this Claim";
#endif
                        AtavismEventSystem.DispatchEvent("ERROR_MESSAGE", args);
                        return;
                    }
                }
                SetBuildingState(WorldBuildingState.PlaceItem);
                itemBeingPlaced = null;
                StartPlaceBuildObject(buildTemplateID);
            }
            else if (eData.eventType == "CLAIM_OBJECT_CLICKED")
            {
                int objectID = int.Parse(eData.eventArgs[0]);
                if (GetBuildingState() == WorldBuildingState.SelectItem && WorldBuilder.Instance.ActiveClaim.claimObjects.ContainsKey(objectID))
                {
                    SetCurrentReticle(WorldBuilder.Instance.ActiveClaim.claimObjects[objectID].gameObject);
                }
            }
            else if (eData.eventType == "CLAIM_CHANGED")
            {
                ClearCurrentReticle(true);
                WorldBuilder.Instance.BuildingState = WorldBuildingState.None;
            }
        }
Ejemplo n.º 49
0
 void ShowSellWindow(AtavismInventoryItem item)
 {
     confirmBoxRect = new Rect((Screen.width - 200) / 2, (Screen.height - 75) / 2, 150, 100);
     mState = MerchantState.Sell;
     itemBeingSold = item;
     AtavismUiSystem.AddFrame("MerchantDialog", uiRect);
 }
Ejemplo n.º 50
0
        public void HandleAuctionListUpdate(Dictionary <string, object> props)
        {
            AtavismLogger.LogDebugMessage("HandleAuctionListUpdate");

            /*    string keys = " [ ";
             *  foreach (var it in props.Keys)
             *  {
             *      keys += " ; " + it + " => " + props[it];
             *  }
             *  Debug.LogWarning("HandleAuctionListUpdate: keys:" + keys+" ]");
             */
            int numItems = 0;

            try
            {
                auctions.Clear();
                costStartValue = (long)props["sPriceVal"];
                costStartPer   = (float)props["SPricePerc"];
                costEndValue   = (long)props["cPriceVal"];
                costEndPer     = (float)props["cPricePerc"];
                currecnyType   = (int)props["currency"];
                auctionsLimit  = (int)props["auctionLimit"];
                createLmit     = (int)props["auctionOwnLimit"];
                numItems       = (int)props["numItems"];
            }
            catch (Exception e)
            {
                AtavismLogger.LogError("AtavismAuction.HandleAuctionListUpdate | Exception " + e.Message);
            }
            try
            {
                for (int i = 0; i < numItems; i++)
                {
                    //     Debug.LogWarning("HandleAuctionListUpdate i:"+i);

                    Auction auctionInfo = new Auction();
                    if (props.ContainsKey("auction_" + i + "Id"))
                    {
                        auctionInfo.id = (int)props["auction_" + i + "Id"];
                    }
                    if (props.ContainsKey("auction_" + i + "GroupId"))
                    {
                        auctionInfo.groupId = (string)props["auction_" + i + "GroupId"];
                    }
                    //     Debug.LogWarning("HandleAuctionListUpdate i:" + i + " 0-1");
                    try
                    {
                        auctionInfo.buyout = (long)props["auction_" + i + "Buyout"];
                    }
                    catch (Exception e)
                    {
                        AtavismLogger.LogError("AtavismAuction.HandleAuctionListUpdate || Exception " + e.Message);
                    }
                    auctionInfo.currency   = (int)props["auction_" + i + "Currency"];
                    auctionInfo.countSell  = (int)props["auction_" + i + "CountsSell"];
                    auctionInfo.countOrder = (int)props["auction_" + i + "CountsOrder"];
                    //      Debug.LogWarning("HandleAuctionListUpdate i:" + i + " 0-2");

                    string baseName   = (string)props["auction_" + i + "ExpirateDate"];
                    int    templateID = (int)props["item_" + i + "TemplateID"];
                    //    Debug.LogWarning("HandleAuctionListUpdate i:" + i + " 0-3");
                    AtavismInventoryItem invInfo = Inventory.Instance.LoadItemPrefabData(templateID);
                    AtavismLogger.LogDebugMessage("Got item: " + invInfo.BaseName);
                    //invInfo.copyData(GetGenericItemData(invInfo.baseName));
                    invInfo.Count = (int)props["item_" + i + "Count"];
                    //ClientAPI.Log("ITEM: item count for item %s is %s" % (invInfo.name, invInfo.count))
                    invInfo.ItemId  = (OID)props["item_" + i + "Id"];
                    invInfo.name    = (string)props["item_" + i + "Name"];
                    invInfo.IsBound = (bool)props["item_" + i + "Bound"];

                    //     Debug.LogWarning("HandleAuctionListUpdate i:" + i + " 0-4");

                    //  invInfo.EnergyCost = (int)props["item_" + i + "EnergyCost"];
                    if (props["item_" + i + "MaxDurability"] == null)
                    {
                        invInfo.MaxDurability = 0;
                    }
                    else
                    {
                        invInfo.MaxDurability = (int)props["item_" + i + "MaxDurability"];
                    }

                    //     Debug.LogWarning("HandleAuctionListUpdate i:" + i + " 1");

                    if (invInfo.MaxDurability > 0)
                    {
                        invInfo.Durability = (int)props["item_" + i + "Durability"];
                    }
                    int numResists = (int)props["item_" + i + "NumResistances"];

                    //    Debug.LogWarning("HandleAuctionListUpdate i:" + i + " 2");

                    for (int j = 0; j < numResists; j++)
                    {
                        string resistName  = (string)props["item_" + i + "Resist_" + j + "Name"];
                        int    resistValue = (int)props["item_" + i + "Resist_" + j + "Value"];
                        invInfo.Resistances[resistName] = resistValue;
                    }
                    int numStats = (int)props["item_" + i + "NumStats"];

                    //    Debug.LogWarning("HandleAuctionListUpdate i:" + i + " 3");

                    for (int j = 0; j < numStats; j++)
                    {
                        string statName  = (string)props["item_" + i + "Stat_" + j + "Name"];
                        int    statValue = (int)props["item_" + i + "Stat_" + j + "Value"];
                        invInfo.Stats[statName] = statValue;
                    }

                    int NumEStats = (int)props["item_" + i + "NumEStats"];
                    for (int j = 0; j < NumEStats; j++)
                    {
                        string statName  = (string)props["item_" + i + "EStat_" + j + "Name"];
                        int    statValue = (int)props["item_" + i + "EStat_" + j + "Value"];
                        invInfo.EnchantStats[statName] = statValue;
                        //  Debug.LogError("Enchant Stat : " + statName + " " + statValue);
                    }
                    //    Debug.LogWarning("HandleAuctionListUpdate i:" + i + " 4");

                    int NumSocket = (int)props["item_" + i + "NumSocket"];
                    for (int j = 0; j < NumSocket; j++)
                    {
                        string socType    = (string)props["item_" + i + "socket_" + j + "Type"];
                        int    socItem    = (int)props["item_" + i + "socket_" + j + "Item"];
                        long   socItemOid = (long)props["item_" + i + "socket_" + j + "ItemOid"];
                        int    socId      = (int)props["item_" + i + "socket_" + j + "Id"];
                        if (invInfo.SocketSlots.ContainsKey(socType))
                        {
                            invInfo.SocketSlots[socType].Add(socId, socItem);
                            invInfo.SocketSlotsOid[socType].Add(socId, socItemOid);
                        }
                        else
                        {
                            Dictionary <int, int> dic = new Dictionary <int, int>();
                            dic.Add(socId, socItem);
                            Dictionary <int, long> dicLong = new Dictionary <int, long>();
                            dicLong.Add(socId, socItemOid);
                            invInfo.SocketSlots.Add(socType, dic);
                            invInfo.SocketSlotsOid.Add(socType, dicLong);
                        }
                    }

                    //    Debug.LogWarning("HandleAuctionListUpdate i:" + i + " 5");

                    int NumOfSet = (int)props["item_" + i + "NumOfSet"];
                    invInfo.setCount = NumOfSet;

                    int ELevel = (int)props["item_" + i + "ELevel"];
                    invInfo.enchantLeval = ELevel;
                    //ClientAPI.Log("InventoryUpdateEntry fields: %s, %d, %d, %s" % (invInfo.itemId, bagNum, slotNum, invInfo.name))
                    if (invInfo.itemType == "Weapon")
                    {
                        invInfo.DamageValue    = (int)props["item_" + i + "DamageValue"];
                        invInfo.DamageMaxValue = (int)props["item_" + i + "DamageValueMax"];
                        invInfo.DamageType     = (string)props["item_" + i + "DamageType"];
                        invInfo.WeaponSpeed    = (int)props["item_" + i + "Delay"];
                    }
                    auctionInfo.item = invInfo;
                    auctions.Add(auctionInfo.groupId, auctionInfo);
                    //    Debug.LogWarning("HandleAuctionListUpdate i:" + i+" end");
                }
                string[] args = new string[1];
                AtavismEventSystem.DispatchEvent("AUCTION_LIST_UPDATE", args);
            }
            catch (Exception e)
            {
                AtavismLogger.LogError("AtavismAuction.HandleAuctionListUpdate Exception " + e.Message);
            }
            AtavismLogger.LogDebugMessage("HandleAuctionListUpdate End");
        }
Ejemplo n.º 51
0
 /// <summary>
 /// Pick up (or drop) an item from a given container and slot.
 /// This will set the cursor to the item.
 /// </summary>
 /// <param name="bagNum"></param>
 /// <param name="slotNum"></param>
 /// <param name="item"></param>
 public void PickupOrPlaceBagItem(int bagNum, int slotNum, AtavismInventoryItem item)
 {
     if (CursorHasItem ()) {
         // Place the item in the slot (possibly taking the item that was in the slot)
         AtavismLogger.LogDebugMessage ("Drop item to: " + bagNum + "," + slotNum);
         AtavismLogger.LogDebugMessage ("Old item: " + item);
         //_SetContainerItem(containerId, slotId, MarsCursor._cursorItem)
         PlaceCursorItemInInventory(bagNum, slotNum);
         _cursorItem = item;
         _UpdateCursor ();
     } else if (CursorHasBag()) {
         // Place the item in the slot (possibly taking the item that was in the slot)
         AtavismLogger.LogDebugMessage("Drop item to: " + bagNum + "," + slotNum);
         AtavismLogger.LogDebugMessage("Old item: " + item);
         //_SetContainerItem(containerId, slotId, MarsCursor._cursorItem)
         PlaceCursorBagAsItem(bagNum, slotNum);
         _cursorItem = item;
         _UpdateCursor();
     } else if (CursorHasAbility ()) {
         AtavismLogger.LogDebugMessage ("Cannot currently use abilities on items");
     } else {
         SetCursorItem(item);
     }
 }
Ejemplo n.º 52
0
    public void SetMailItem(int gridPos, AtavismInventoryItem item)
    {
        if (item == null) {
            if (mailBeingComposed.items[gridPos].item != null)
                mailBeingComposed.items[gridPos].item.AlterUseCount(-mailBeingComposed.items[gridPos].count);
            mailBeingComposed.items[gridPos].item = null;
            mailBeingComposed.items[gridPos].count = 1;
        }
        else if (mailBeingComposed.items[gridPos].item == item)
        {
            mailBeingComposed.items[gridPos].count++;
        } else {
            mailBeingComposed.items[gridPos].item = item;
            mailBeingComposed.items[gridPos].count = 1;
        }

        if (item != null)
            item.AlterUseCount(1);
    }
Ejemplo n.º 53
0
    public void HandleCraftingGridResponse(Dictionary<string, object> props)
    {
        recipeID = (int)props["recipeID"];
        recipeName = (string)props["recipeName"];
        recipeItemID = (int)props["recipeItem"];
        resultItemID = (int)props["resultItem"];

        if (resultItemID != -1) {
            resultItem = GetComponent<Inventory>().GetItemByTemplateID(resultItemID);
        } else {
            resultItem = null;
        }
        if (recipeItemID != -1) {
            recipeItem = GetComponent<Inventory>().GetItemByTemplateID(recipeItemID);
        } else {
            recipeItem = null;
        }
        string[] args = new string[1];
        EventSystem.DispatchEvent("CRAFTING_GRID_UPDATE", args);
    }