public void LootParticlesHandler(object sender, ObjectPropertyChangeEventArgs args) { AtavismObjectNode worldObj = ClientAPI.WorldManager.GetObjectNode(args.Oid); if (worldObj == null) { AtavismLogger.LogWarning("Loot Particles: found no object"); return; } if (worldObj.CheckBooleanProperty("lootable")) { GameObject newLootParticle = (GameObject)GameObject.Instantiate(lootParticle, worldObj.GameObject.transform.position, Quaternion.identity); newLootParticle.transform.parent = worldObj.GameObject.transform; if (attachedLootParticles.ContainsKey(args.Oid)) { if (attachedLootParticles[args.Oid] != null) { Destroy(attachedLootParticles[args.Oid]); } attachedLootParticles.Remove(args.Oid); } attachedLootParticles.Add(args.Oid, newLootParticle); } else if (attachedLootParticles.ContainsKey(args.Oid)) { Destroy(attachedLootParticles[args.Oid]); attachedLootParticles.Remove(args.Oid); } }
/// <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); } }
public void CraftItemBook(int recipeID, int count) { try { AtavismLogger.LogInfoMessage("Got Message CraftItemBook"); Dictionary <string, object> props = new Dictionary <string, object>(); //properties["CraftType"] = craftType; LinkedList <object> items = new LinkedList <object>(); LinkedList <object> itemCounts = new LinkedList <object>(); props.Add("count", count); props.Add("gridSize", gridSize); props.Add("components", items); props.Add("componentCounts", itemCounts); props.Add("RecipeId", recipeID); props.Add("stationType", stationType.ToString()); if (recipeItem != null) { props.Add("recipeItemID", recipeItem.templateId); } else { props.Add("recipeItemID", -1); } props.Add("coordEffect", coordEffect); NetworkAPI.SendExtensionMessage(ClientAPI.GetPlayerOid(), false, "crafting.CRAFT_ITEM", props); // Debug.LogError("CraftItemBook End"); } catch (System.Exception e) { AtavismLogger.LogError("Got Exeption " + e.Message); } AtavismLogger.LogInfoMessage("CraftItemBook End"); }
protected void ObjectNodeReady() { GetComponent <AtavismNode>().RegisterObjectPropertyChangeHandler("model", ModelHandler); foreach (string displayProperty in displayProperties) { GetComponent <AtavismNode>().RegisterObjectPropertyChangeHandler(displayProperty, EquipPropertyHandler); if (GetComponent <AtavismNode>().PropertyExists(displayProperty)) { string displayID = (string)GetComponent <AtavismNode>().GetProperty(displayProperty); UpdateEquipDisplay(displayProperty, displayID); } } GetComponent <AtavismNode>().RegisterObjectPropertyChangeHandler("combatstate", HandleCombatState); if (GetComponent <AtavismNode>().PropertyExists("combatstate")) { inCombat = (bool)GetComponent <AtavismNode>().GetProperty("combatstate"); SetWeaponsAttachmentSlot(); } AtavismLogger.LogInfoMessage("Registered display properties for: " + name); GetComponent <AtavismNode>().RegisterObjectPropertyChangeHandler("weaponType", HandleWeaponType); if (GetComponent <AtavismNode>().PropertyExists("weaponType")) { // weaponType = (string)GetComponent<AtavismNode>().GetProperty("weaponType"); } GetComponent <AtavismNode>().RegisterObjectPropertyChangeHandler("deadstate", HandleDeadState); if (GetComponent <AtavismNode>().PropertyExists("deadstate")) { dead = (bool)GetComponent <AtavismNode>().GetProperty("deadstate"); } }
protected void UpdateCursorVisibility(bool mouseButtonDown) { if (cameraGrabbed) { return; } if (mouseOverUI) { if (AtavismLogger.logLevel <= LogLevel.Info) { AtavismLogger.LogInfoMessage("Mouse over UI"); } if (!mouseButtonDown) { Cursor.lockState = CursorLockMode.None; } //return; } else if (Input.GetMouseButtonDown(0) || Input.GetMouseButtonDown(1)) { mousePosition = UnityEngine.Input.mousePosition; //Screen.lockCursor = true; ClientAPI.mouseLook = true; } if (!mouseButtonDown) { Cursor.lockState = CursorLockMode.None; ClientAPI.mouseLook = false; } }
/// <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); } }
/// <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); }
public void ScaleHandler(object sender, PropertyChangeEventArgs args) { AtavismLogger.LogDebugMessage("Got scale"); Vector3 scaleObj = (Vector3)GetComponent <AtavismNode>().GetProperty("scale"); gameObject.transform.localScale = scaleObj; }
private IEnumerator LoadAssets() { // Profiler.BeginSample("AtavismAssetBundlesManager.LoadAssets"); foreach (string asset in listBundlesNames) { if (!String.IsNullOrEmpty(asset)) { if (File.Exists(Path.Combine(Application.streamingAssetsPath, asset))) { var mbundleLoadRequest = AssetBundle.LoadFromFileAsync(Path.Combine(Application.streamingAssetsPath, asset)); yield return(mbundleLoadRequest); AssetBundle m_asset = mbundleLoadRequest.assetBundle; if (m_asset == null) { AtavismLogger.LogError("Failed to load Asset " + asset + "!"); yield break; } if (m_asset != null) { if (!assetBundles.Contains(m_asset)) { assetBundles.Add(m_asset); } } } else { Debug.LogError("Asset Bundle File " + asset + " not exist"); } } } // Profiler.EndSample(); }
/// <summary> /// Handles the Claim Action Message from the server. Passes the data onto the voxel editor. /// </summary> /// <param name="props">Properties.</param> public void ClaimObjectMessage(Dictionary <string, object> props) { // Debug.LogError("ClaimObjectMessage "); try { int objectID = (int)props["id"]; int templateID = (int)props["templateID"]; string prefabName = (string)props["gameObject"]; Vector3 loc = (Vector3)props["loc"]; Quaternion orient = (Quaternion)props["orient"]; int claimID = (int)props["claimID"]; //string state = (string)props["state"]; AtavismLogger.LogDebugMessage("Got claim object: " + gameObject); //SpawnClaimObject(objectID, claimID, prefabName, loc, orient); ClaimObjectData objectData = new ClaimObjectData(); objectData.objectID = objectID; objectData.claimID = claimID; objectData.templateID = templateID; objectData.prefabName = prefabName; objectData.loc = loc; objectData.orient = orient; objectData.state = ""; objectData.health = (int)props["health"]; objectData.maxHealth = (int)props["maxHealth"]; objectData.complete = (bool)props["complete"]; objectsToLoad.Add(objectData); } catch (System.Exception e) { Debug.LogError("ClaimObjectMessage Exception=" + e); } // Debug.LogError("ClaimObjectMessage objectsToLoad=" + objectsToLoad.Count); }
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"); }
public void HandleBuildingGridProbe(string args_str) { GameObject probe = (GameObject)Resources.Load("Content/BuildingGridProbe"); Instantiate(probe, ClientAPI.GetPlayerObject().Position, ClientAPI.GetPlayerObject().Orientation); AtavismLogger.LogDebugMessage("Created probe"); }
public void AbilitiesPropertyHandler(object sender, ObjectPropertyChangeEventArgs args) { if (args.Oid != ClientAPI.GetPlayerOid()) { return; } List <object> abilities_prop = (List <object>)ClientAPI.GetPlayerObject().GetProperty("abilities"); AtavismLogger.LogDebugMessage("Got player abilities property change: " + abilities_prop); playerAbilities.Clear(); //int pos = 0; foreach (int abilityNum in abilities_prop) { if (!abilities.ContainsKey(abilityNum)) { AtavismLogger.LogWarning("Ability " + abilityNum + " does not exist"); continue; } AtavismAbility ability = abilities[abilityNum].Clone(tempCombatDataStorage); playerAbilities.Add(ability); } // dispatch a ui event to tell the rest of the system string[] event_args = new string[1]; AtavismEventSystem.DispatchEvent("ABILITY_UPDATE", event_args); }
/// <summary> /// Use the information from the mouse movement to update the camera. /// </summary> /// <param name="x">the relative x offset of the mouse (in mouse units)</param> /// <param name="y">the relative y offset of the mouse (in mouse units)</param> protected void ApplyMouseToCamera(float x, float y) { if (cameraGrabbed) { return; } Camera camera = Camera.main; camera.transform.RotateAround(Vector3.up, x * MouseVelocity); // camera.transform.Rotate(Vector3.up, x * MouseVelocity); //this.CameraYaw += x * MouseVelocity; //float cameraPitch = camera.transform.eulerAngles.x; float cameraPitch = this.CameraPitch; cameraPitch -= y * MouseVelocity * 100; if (cameraPitch < 0) { cameraPitch = 360 + cameraPitch; } if (AtavismLogger.logLevel <= LogLevel.Info) { AtavismLogger.LogInfoMessage("Camera pitch: " + CameraPitch + " and new pitch: " + cameraPitch); } idealPitch = cameraPitch; CameraPitch = cameraPitch; }
public void GetAuctionList() { AtavismLogger.LogDebugMessage("GetAuctionList Start"); Dictionary <string, object> props = new Dictionary <string, object>(); NetworkAPI.SendExtensionMessage(0, false, "auction.list", props); AtavismLogger.LogDebugMessage("GetAuctionList End"); }
public static void SendCommandToServer(string command, long targetOid) { CommandMessage commandMessage = new CommandMessage(); commandMessage.ObjectId = targetOid; commandMessage.Command = command; AtavismNetworkHelper.Instance.SendMessage(commandMessage); AtavismLogger.LogDebugMessage("Sending command to server"); }
// Use this for initialization void Start() { if (modelName == "") { AtavismLogger.LogError("AtavismGetModel No Model Name :" + name); return; } StartCoroutine(GetModel(modelName)); }
public static void HandleCommand(string message) { //This is the standard implementation of HandleCommand for handling commands entered on the client. AtavismLogger.LogDebugMessage("HandleCommand: " + message); if (message.Length == 0) { return; } if (!message.StartsWith("/")) { message = "/say " + message; } // Handle some client side commands string[] tokens = message.Split(' '); if (tokens.Length <= 0) { return; } string args = ""; //for (int i = 0; i < tokens.Length-1; i++) { // args[i] = tokens[i+1]; //} if (message.Length > tokens[0].Length) { args = message.Substring(tokens[0].Length + 1); } string command = tokens[0].Substring(1); AtavismLogger.LogDebugMessage("num args: " + tokens.Length + " with command: " + command); if (_commandHandlers.ContainsKey(command)) { // We have a local handler for this command on the client. CommandHandler function = _commandHandlers[command]; try { function(args); } catch (Exception e) { UnityEngine.Debug.LogWarning("Failed to run command handler " + command + " for command line: " + message); UnityEngine.Debug.LogWarning("Exception: " + e); } } else { // This command is not handled on the client. Send it to the server. long target = ClientAPI.GetTargetOid(); if (target == -1) { target = ClientAPI.GetPlayerOid(); } SendCommandToServer(message, target); } }
public void ClaimIDMessage(Dictionary <string, object> props) { int claimID = (int)props["claimID"]; // Debug.LogWarning("WorldBuilder Got Cliam id="+claimID); Claim claim = new Claim(); if (GetClaim(claimID) != null) { claim = GetClaim(claimID); } else { claim.id = claimID; } claim.name = (string)props["claimName"]; claim.sizeX = (int)props["claimSizeX"]; claim.sizeZ = (int)props["claimSizeZ"]; claim.loc = (Vector3)props["claimLoc"]; claim.GenerateBounds(); claim.claimType = (ClaimType)props["claimType"]; claim.ownerName = (string)props["ownerName"]; claim.forSale = (bool)props["forSale"]; claim.permissionlevel = (int)props["permissionLevel"]; if (claim.forSale) { claim.cost = (int)props["cost"]; claim.currency = (int)props["currency"]; } claim.purchaseItemReq = (int)props["purchaseItemReq"]; claim.playerOwned = (bool)props["myClaim"]; // Player permissions claim.permissions.Clear(); int permissionCount = (int)props["permissionCount"]; for (int i = 0; i < permissionCount; i++) { ClaimPermission per = new ClaimPermission(); per.playerName = (string)props["permission_" + i]; per.permissionLevel = (int)props["permissionLevel_" + i]; claim.permissions.Add(per); } if (GetClaim(claimID) == null) { // Debug.LogWarning("WorldBuilder add to Cliam list id=" + claim.id); claims.Add(claim); } if (claim == activeClaim) { string[] args = new string[1]; AtavismEventSystem.DispatchEvent("CLAIM_CHANGED", args); } AtavismLogger.LogDebugMessage("Got new claim data: " + claim.id); }
/// <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); } }
public void ClaimRemoveDataMessage(Dictionary <string, object> props) { int claimID = (int)props["claimID"]; if (GetClaim(claimID) != null) { claims.Remove(GetClaim(claimID)); } AtavismLogger.LogDebugMessage("Removed claim data: " + claimID); }
void ObjectNodeReady() { GetComponent <AtavismNode>().RegisterObjectPropertyChangeHandler("scale", ScaleHandler); if (GetComponent <AtavismNode>().PropertyExists("scale")) { AtavismLogger.LogDebugMessage("Got scale"); Vector3 scaleObj = (Vector3)GetComponent <AtavismNode>().GetProperty("scale"); gameObject.transform.localScale = scaleObj; } }
void SpawnClaimObject(ClaimObjectData objectData) { // Add the gameObject to the claim Claim claim = GetClaim(objectData.claimID); if (claim == null) { AtavismLogger.LogWarning("No Claim found for Claim Object"); return; } if (claim.claimObjects.ContainsKey(objectData.objectID)) { return; } // Spawn the object in the world string prefabName = objectData.prefabName; int resourcePathPos = prefabName.IndexOf("Resources/"); prefabName = prefabName.Substring(resourcePathPos + 10); prefabName = prefabName.Remove(prefabName.Length - 7); GameObject prefab = (GameObject)Resources.Load(prefabName); if (prefab == null) { Debug.LogError("Builder prefab " + prefabName + " not found in the resources"); return; } GameObject claimObject = (GameObject)UnityEngine.Object.Instantiate(prefab, objectData.loc + claim.loc, objectData.orient); // TEMP: set claim object to don't delete on load DontDestroyOnLoad(claimObject); // Get the Claim Object Component ClaimObject cObject = claimObject.GetComponentInChildren <ClaimObject>(); if (cObject == null) { cObject = claimObject.AddComponent <ClaimObject>(); } cObject.ClaimID = objectData.claimID; cObject.StateUpdated(objectData.state); cObject.ID = objectData.objectID; cObject.TemplateID = objectData.templateID; cObject.Health = objectData.health; cObject.MaxHealth = objectData.maxHealth; cObject.Complete = objectData.complete; //cObject.ItemReqs = objectData. claim.claimObjects.Add(objectData.objectID, cObject); if (cObject.ID == selectedID) { SelectedObject = cObject; } }
public void HandleOrient(string args_str) { AtavismLogger.LogDebugMessage("Got orient command"); AtavismPlayer player = ClientAPI.GetPlayerObject(); #if AT_I2LOC_PRESET ClientAPI.Write(I2.Loc.LocalizationManager.GetTranslation("Player Position") + ": " + player.Orientation); #else ClientAPI.Write("Player Position: " + player.Orientation); #endif }
public void GetAuctionsForGroup(string groupId = "", long itemOid = 0L) { AtavismLogger.LogDebugMessage("GetAuctionsForGroup Start"); Dictionary <string, object> props = new Dictionary <string, object>(); props.Add("groupId", groupId); props.Add("itemOid", itemOid); NetworkAPI.SendExtensionMessage(0, false, "auction.getAuctionForGroup", props); AtavismLogger.LogDebugMessage("GetAuctionsForGroup End"); }
public void CancelAuction(Auction auction, bool selling, bool buying) { AtavismLogger.LogDebugMessage("CancelAuction Start"); Dictionary <string, object> props = new Dictionary <string, object>(); props.Add("auctionId", auction.id); props.Add("selling", selling); props.Add("buying", buying); NetworkAPI.SendExtensionMessage(0, false, "auction.cancel", props); AtavismLogger.LogDebugMessage("CancelAuction End"); }
public override void PlayAnimation(string animationName, float length) { // Debug.LogWarning("PlayAnimation: >" + animationName + "< length:" + length); if (_animator != null && overrideAnimationName != null && overrideAnimationName != "") { AtavismLogger.LogDebugMessage("clearing old animation"); _animator.SetBool(overrideAnimationName, false); } overrideAnimationName = animationName; overrideAnimationExpires = Time.time + length; }
public void HandleSay(string args_str) { AtavismLogger.LogDebugMessage("Got say command with message: " + args_str); //ClientAPI.Network.SendCommMessage(args_str); CommMessage commMessage = new CommMessage(); commMessage.ChannelId = 1; // CommChannel.Say commMessage.Message = args_str; commMessage.SenderName = ClientAPI.GetPlayerObject().Name; AtavismNetworkHelper.Instance.SendMessage(commMessage); AtavismLogger.LogDebugMessage("Sent chat message: " + commMessage); }
public void TakeReward(bool buying, bool selling, bool bought, bool sold, bool expired) { AtavismLogger.LogDebugMessage("TakeReward Start"); Dictionary <string, object> props = new Dictionary <string, object>(); props.Add("buying", buying); props.Add("selling", selling); props.Add("bought", bought); props.Add("sold", sold); props.Add("expired", expired); NetworkAPI.SendExtensionMessage(0, false, "auction.takeAll", props); AtavismLogger.LogDebugMessage("TakeReward End"); }
public void GetOwnAuctionList(bool buying, bool selling, bool bought, bool sold, bool expired) { AtavismLogger.LogDebugMessage("GetOwnAuctionList Start"); Dictionary <string, object> props = new Dictionary <string, object>(); props.Add("buying", buying); props.Add("selling", selling); props.Add("bought", bought); props.Add("sold", sold); props.Add("expired", expired); NetworkAPI.SendExtensionMessage(0, false, "auction.ownerList", props); AtavismLogger.LogDebugMessage("GetOwnAuctionList End"); }