/// <summary> /// Works out what cursor should be displayed based on the properties of the object it is over /// </summary> /// <param name="mouseOverObject">Mouse over object.</param> private void _UpdateContextCursor(AtavismNode mouseOverObject) { // Update the context cursor based on what object it is currently over.""" if (ClientAPI.mouseLook) { return; } if (IsMouseOverUI()) { SetCursor(CursorState.Default); return; } if (mouseOverObject == null) { SetCursor(CursorState.Default); return; } else { if (ClientAPI.GetPlayerObject() == null) { return; } float dist = (mouseOverObject.Position - ClientAPI.GetPlayerObject().Position).magnitude; if (mouseOverObject.CheckBooleanProperty("lootable")) { if (dist < 4.0) { SetCursor(CursorState.Loot); } else { SetCursor(CursorState.Loot_Error); } } else if (mouseOverObject.CheckBooleanProperty("questconcludable")) { //ClientAPI.Log ("questconcludable"); if (dist < 6.0) { SetCursor(CursorState.Speak); } else { SetCursor(CursorState.Speak_Error); } } else if (mouseOverObject.CheckBooleanProperty("questavailable")) { //ClientAPI.Log ("questavailable"); if (dist < 6.0) { SetCursor(CursorState.Speak); } else { SetCursor(CursorState.Speak_Error); } } else if (mouseOverObject.CheckBooleanProperty("questinprogress")) { //ClientAPI.Log ("questavailable"); if (dist < 6.0) { SetCursor(CursorState.Speak); } else { SetCursor(CursorState.Speak_Error); } } else if (mouseOverObject.CheckBooleanProperty("itemstosell")) { if (dist < 6.0) { SetCursor(CursorState.Speak); } else { SetCursor(CursorState.Speak_Error); } } else if (mouseOverObject.CheckBooleanProperty("bankteller")) { if (dist < 6.0) { SetCursor(CursorState.Speak); } else { SetCursor(CursorState.Speak_Error); } } else if (mouseOverObject.PropertyExists("specialUse")) { string use = (string)mouseOverObject.GetProperty("specialUse"); if (use == "arenaMaster") { if (dist < 6.0) { SetCursor(CursorState.Speak); } else { SetCursor(CursorState.Speak_Error); } } if (use == "Intro") { if (dist < 6.0) { SetCursor(CursorState.Speak); } else { SetCursor(CursorState.Speak_Error); } } } else if (mouseOverObject.PropertyExists("arena_portal")) { if (dist < 6.0) { SetCursor(CursorState.Loot); } else { SetCursor(CursorState.Loot_Error); } } else if (mouseOverObject.PropertyExists("arena_flag")) { if (dist < 6.0) { SetCursor(CursorState.Loot); } else { SetCursor(CursorState.Loot_Error); } } else if (mouseOverObject.PropertyExists("DomeWarden")) { if (dist < 6.0) { SetCursor(CursorState.Speak); } else { SetCursor(CursorState.Speak_Error); } } else if (mouseOverObject.PropertyExists("dialogue_available")) { int use = (int)mouseOverObject.GetProperty("dialogue_available"); if (use > 0) { if (dist < 6.0) { SetCursor(CursorState.Speak); } else { SetCursor(CursorState.Speak_Error); } } } else if (mouseOverObject.PropertyExists("Usable")) { if (dist < 6.0) { SetCursor(CursorState.Speak); } else { SetCursor(CursorState.Speak_Error); } } else if (mouseOverObject.PropertyExists("itemavailable")) { if (dist < 6.0) { SetCursor(CursorState.Loot); } else { SetCursor(CursorState.Loot_Error); } } else if (mouseOverObject.PropertyExists("skinnableLevel")) { if (dist < 6.0) { SetCursor(CursorState.Skin); } else { SetCursor(CursorState.Skin_Error); } } else if (mouseOverObject.CheckBooleanProperty("attackable")) { if (mouseOverObject.PropertyExists("targetType")) { int targetType = (int)mouseOverObject.GetProperty("targetType"); if (!mouseOverObject.IsPlayer() && targetType < 1) { if (dist < 4.0) { SetCursor(CursorState.Attack); } else { SetCursor(CursorState.Attack_Error); } } } } else { SetCursor(CursorState.Default); } } }
/// <summary> /// Works out what cursor should be displayed based on the properties of the object it is over /// </summary> /// <param name="mouseOverObject">Mouse over object.</param> private void _UpdateContextCursor(AtavismNode mouseOverObject) { // Update the context cursor based on what object it is currently over.""" if (ClientAPI.mouseLook) return; if (_IsMouseOverUIButton ()) return; if (mouseOverObject == null) { SetCursor (CursorState.Default); return; } else { float dist = (mouseOverObject.Position - ClientAPI.GetPlayerObject ().Position).magnitude; if (mouseOverObject.CheckBooleanProperty ("lootable")) { if (dist < 4.0) SetCursor (CursorState.Loot); else SetCursor (CursorState.Loot_Error); } else if (mouseOverObject.CheckBooleanProperty ("questconcludable")) { //ClientAPI.Log ("questconcludable"); if (dist < 6.0) SetCursor (CursorState.Speak); else SetCursor (CursorState.Speak_Error); } else if (mouseOverObject.CheckBooleanProperty ("questavailable")) { //ClientAPI.Log ("questavailable"); if (dist < 6.0) SetCursor (CursorState.Speak); else SetCursor (CursorState.Speak_Error); } else if (mouseOverObject.CheckBooleanProperty ("questinprogress")) { //ClientAPI.Log ("questavailable"); if (dist < 6.0) SetCursor (CursorState.Speak); else SetCursor (CursorState.Speak_Error); } else if (mouseOverObject.CheckBooleanProperty ("itemstosell")) { if (dist < 6.0) SetCursor (CursorState.Speak); else SetCursor (CursorState.Speak_Error); } else if (mouseOverObject.PropertyExists ("specialUse")) { string use = (string)mouseOverObject.GetProperty ("specialUse"); if (use == "arenaMaster") { if (dist < 6.0) SetCursor (CursorState.Speak); else SetCursor (CursorState.Speak_Error); } if (use == "Intro") { if (dist < 6.0) SetCursor (CursorState.Speak); else SetCursor (CursorState.Speak_Error); } } else if (mouseOverObject.PropertyExists ("arena_portal")) { if (dist < 6.0) SetCursor (CursorState.Loot); else SetCursor (CursorState.Loot_Error); } else if (mouseOverObject.PropertyExists ("arena_flag")) { if (dist < 6.0) SetCursor (CursorState.Loot); else SetCursor (CursorState.Loot_Error); } else if (mouseOverObject.PropertyExists ("DomeWarden")) { if (dist < 6.0) SetCursor (CursorState.Speak); else SetCursor (CursorState.Speak_Error); } else if (mouseOverObject.PropertyExists ("dialogue_available")) { int use = (int)mouseOverObject.GetProperty ("dialogue_available"); if (use > 0) { if (dist < 6.0) SetCursor (CursorState.Speak); else SetCursor (CursorState.Speak_Error); } } else if (mouseOverObject.PropertyExists ("Usable")) { if (dist < 6.0) SetCursor (CursorState.Speak); else SetCursor (CursorState.Speak_Error); } else if (mouseOverObject.PropertyExists ("itemavailable")) { if (dist < 6.0) SetCursor (CursorState.Loot); else SetCursor (CursorState.Loot_Error); } else if (mouseOverObject.CheckBooleanProperty ("attackable")) { if (mouseOverObject.PropertyExists ("targetType")) { int targetType = (int)mouseOverObject.GetProperty("targetType"); if (!mouseOverObject.IsPlayer () && targetType < 1) { if (dist < 4.0) SetCursor (CursorState.Attack); else SetCursor (CursorState.Attack_Error); } } } else if (mouseOverObject.PropertyExists("harvestType")) { if (mouseOverObject.CheckBooleanProperty("active")) { hoverObject = mouseOverObject.gameObject; if (dist < 4.0) { mouseOverObject.gameObject.SendMessage("Highlight", SendMessageOptions.DontRequireReceiver); SetCursor(CursorState.Loot); } else SetCursor(CursorState.Loot_Error); } } else if (mouseOverObject.PropertyExists("craftingStation")) { if (dist < 6.0) SetCursor(CursorState.Loot); else SetCursor(CursorState.Loot_Error); } else { SetCursor(CursorState.Default); } } }
public void OnRightClick(bool down, AtavismNode mouseOverObject) { if (ClientAPI.GetPlayerObject() == null) { return; } // Handle the right click event (perhaps over an object). // For now, we can just always reset the cursor on a right click. // At some point, perhaps picking up an item or ability and right clicking // on an object in the world will do something, but it doesn't now. // Make right mouse up reset the cursor if (!down && !AtavismUiSystem.IsMouseOverFrame()) { ResetCursor(); } if (down) { // ClientAPI.Write("Mouse down object = " + str(objNode)) // store the mouse down object _mouseDownObject2 = mouseOverObject; return; } if (mouseOverObject == null) { return; } if (mouseOverObject != _mouseDownObject2) { return; } if (mouseOverObject.PropertyExists("targetable")) { if ((bool)mouseOverObject.GetProperty("targetable") == true) { ClientAPI.SetTarget(mouseOverObject.Oid); bool dead = false; if (mouseOverObject.PropertyExists("deadstate")) { dead = (bool)mouseOverObject.GetProperty("deadstate"); } MobSoundSet soundSet = mouseOverObject.gameObject.GetComponent <MobSoundSet>(); if (!dead && soundSet != null && ClientAPI.GetTargetOid() != ClientAPI.GetPlayerOid()) { soundSet.PlaySoundEvent(MobSoundEvent.Response); } } } else { ClientAPI.SetTarget(mouseOverObject.Oid); bool dead = false; if (mouseOverObject.PropertyExists("deadstate")) { dead = (bool)mouseOverObject.GetProperty("deadstate"); } MobSoundSet soundSet = mouseOverObject.gameObject.GetComponent <MobSoundSet>(); if (!dead && soundSet != null && ClientAPI.GetTargetOid() != ClientAPI.GetPlayerOid()) { soundSet.PlaySoundEvent(MobSoundEvent.Response); } } float dist = (mouseOverObject.Position - ClientAPI.GetPlayerObject().Position).magnitude; // On a right click, do the context sensitive action if (mouseOverObject.PropertyExists("click_handler")) { //ClientAPI.Write ("Invoking custom click handler for object"); //mouseOverObject.GetProperty ("click_handler") (mouseOverObject, None); } else if (mouseOverObject.CheckBooleanProperty("lootable")) { if (dist < 4.0) { NetworkAPI.SendTargetedCommand(mouseOverObject.Oid, "/getLootList"); } else #if AT_I2LOC_PRESET { ClientAPI.Write(I2.Loc.LocalizationManager.GetTranslation("That object is too far away (") + dist + " " + I2.Loc.LocalizationManager.GetTranslation("meters)")); } #else { ClientAPI.Write("That object is too far away (" + dist + " meters)"); } #endif } else if (mouseOverObject.CheckBooleanProperty("questconcludable")) { AtavismLogger.LogDebugMessage("questconcludable"); //NetworkAPI.SendQuestConcludeRequestMessage (mouseOverObject.Oid); if (dist < 6.0) { NpcInteraction.Instance.GetInteractionOptionsForNpc(mouseOverObject.Oid); } else #if AT_I2LOC_PRESET { ClientAPI.Write(I2.Loc.LocalizationManager.GetTranslation("That object is too far away (") + dist + " " + I2.Loc.LocalizationManager.GetTranslation("meters)")); } #else { ClientAPI.Write("That object is too far away (" + dist + " meters)"); } #endif } else if (mouseOverObject.CheckBooleanProperty("questavailable")) { AtavismLogger.LogDebugMessage("questavailable"); // NetworkAPI.SendQuestInfoRequestMessage (mouseOverObject.Oid); if (dist < 6.0) { NpcInteraction.Instance.GetInteractionOptionsForNpc(mouseOverObject.Oid); } else #if AT_I2LOC_PRESET { ClientAPI.Write(I2.Loc.LocalizationManager.GetTranslation("That object is too far away (") + dist + " " + I2.Loc.LocalizationManager.GetTranslation("meters)")); } #else { ClientAPI.Write("That object is too far away (" + dist + " meters)"); } #endif } else if (mouseOverObject.CheckBooleanProperty("questinprogress")) { AtavismLogger.LogDebugMessage("questinprogress"); // NetworkAPI.SendQuestInfoRequestMessage (mouseOverObject.Oid); if (dist < 6.0) { NpcInteraction.Instance.GetInteractionOptionsForNpc(mouseOverObject.Oid); } else #if AT_I2LOC_PRESET { ClientAPI.Write(I2.Loc.LocalizationManager.GetTranslation("That object is too far away (") + dist + " " + I2.Loc.LocalizationManager.GetTranslation("meters)")); } #else { ClientAPI.Write("That object is too far away (" + dist + " meters)"); } #endif } else if (mouseOverObject.CheckBooleanProperty("itemstosell")) { if (dist < 6.0) { NpcInteraction.Instance.GetInteractionOptionsForNpc(mouseOverObject.Oid); } else #if AT_I2LOC_PRESET { ClientAPI.Write(I2.Loc.LocalizationManager.GetTranslation("That object is too far away (") + dist + " " + I2.Loc.LocalizationManager.GetTranslation("meters)")); } #else { ClientAPI.Write("That object is too far away (" + dist + " meters)"); } #endif } else if (mouseOverObject.PropertyExists("dialogue_available")) { int dialogueID = (int)mouseOverObject.GetProperty("dialogue_available"); if (dialogueID > 0) { if (dist < 6.0) { NpcInteraction.Instance.GetInteractionOptionsForNpc(mouseOverObject.Oid); } } } else if (mouseOverObject.CheckBooleanProperty("bankteller")) { if (dist < 6.0) { NpcInteraction.Instance.GetInteractionOptionsForNpc(mouseOverObject.Oid); } else #if AT_I2LOC_PRESET { ClientAPI.Write(I2.Loc.LocalizationManager.GetTranslation("That object is too far away (") + dist + " " + I2.Loc.LocalizationManager.GetTranslation("meters)")); } #else { ClientAPI.Write("That object is too far away (" + dist + " meters)"); } #endif } else if (mouseOverObject.CheckBooleanProperty("attackable")) { int targetType = -1; if (mouseOverObject.PropertyExists("targetType")) { targetType = (int)mouseOverObject.GetProperty("targetType"); } if (!mouseOverObject.IsPlayer() && targetType < 1) { NetworkAPI.SendAttackMessage(mouseOverObject.Oid, "strike", true); } } else if (mouseOverObject.PropertyExists("specialUse")) { string use = ""; if (mouseOverObject.PropertyExists("specialUse")) { use = (string)mouseOverObject.GetProperty("specialUse"); } if (use == "arenaMaster") { if (dist < 6.0) { AtavismEventSystem.DispatchEvent("ARENA_MASTER_CLICK", null); } else #if AT_I2LOC_PRESET { ClientAPI.Write(I2.Loc.LocalizationManager.GetTranslation("That object is too far away (") + dist + " " + I2.Loc.LocalizationManager.GetTranslation("meters)")); } #else { ClientAPI.Write("That object is too far away (" + dist + " meters)"); } #endif } else if (use == "Intro") { if (dist < 6.0) { AtavismEventSystem.DispatchEvent("SHOW_INTRO", null); } } } else if (mouseOverObject.PropertyExists("arena_portal")) { if (dist < 6.0) { //ClientAPI.Write ("Retrieving available arenas..."); long playerOid = ClientAPI.GetPlayerObject().Oid; Dictionary <string, object> props = new Dictionary <string, object>(); props.Add("playerOid", playerOid); props.Add("type", (int)mouseOverObject.GetProperty("arena_portal")); NetworkAPI.SendExtensionMessage(0, false, "arena.getTypes", props); } else { #if AT_I2LOC_PRESET ClientAPI.Write(I2.Loc.LocalizationManager.GetTranslation("That object is too far away (") + dist + " " + I2.Loc.LocalizationManager.GetTranslation("meters)")); #else ClientAPI.Write("You need to be closer to the portal to activate it"); #endif } } else if (mouseOverObject.PropertyExists("arena_flag")) { if (dist < 6.0) { long playerOid = ClientAPI.GetPlayerObject().Oid; Dictionary <string, object> props = new Dictionary <string, object>(); props.Add("playerOid", playerOid); props.Add("team", mouseOverObject.GetProperty("arena_flag")); NetworkAPI.SendExtensionMessage(0, false, "arena.pickupFlag", props); } else { #if AT_I2LOC_PRESET ClientAPI.Write(I2.Loc.LocalizationManager.GetTranslation("That object is too far away (") + dist + " " + I2.Loc.LocalizationManager.GetTranslation("meters)")); #else ClientAPI.Write("That object is too far away (" + dist + " meters)"); #endif } } else if (mouseOverObject.CheckBooleanProperty("Usable")) { if (dist < 6.0) { long playerOid = ClientAPI.GetPlayerObject().Oid; Dictionary <string, object> props = new Dictionary <string, object>(); props.Add("object", mouseOverObject.Oid); NetworkAPI.SendExtensionMessage(playerOid, false, "ao.OBJECT_ACTIVATED", props); } } else if (mouseOverObject.CheckBooleanProperty("itemavailable")) { if (dist < 6.0) { NetworkAPI.SendTargetedCommand(mouseOverObject.Oid, "/openMob"); } } else if (mouseOverObject.PropertyExists("skinnableLevel")) { if (dist < 6.0) { int id = (int)mouseOverObject.Oid * -1; Crafting.Instance.HarvestResource(id); } } }
public void OnRightClick(bool down, AtavismNode mouseOverObject) { // Handle the right click event (perhaps over an object). // For now, we can just always reset the cursor on a right click. // At some point, perhaps picking up an item or ability and right clicking // on an object in the world will do something, but it doesn't now. // Make right mouse up reset the cursor if (!down && !AtavismUiSystem.IsMouseOverFrame ()) ResetCursor (); if (down) { // ClientAPI.Write("Mouse down object = " + str(objNode)) // store the mouse down object _mouseDownObject2 = mouseOverObject; return; } if (mouseOverObject == null) return; if (mouseOverObject != _mouseDownObject2) return; if (mouseOverObject.PropertyExists ("targetable")) { if ((bool)mouseOverObject.GetProperty ("targetable") == true) { ClientAPI.SetTarget (mouseOverObject.Oid); bool dead = false; if (mouseOverObject.PropertyExists ("deadstate")) { dead = (bool)mouseOverObject.GetProperty("deadstate"); } MobSoundSet soundSet = mouseOverObject.gameObject.GetComponent<MobSoundSet>(); if (!dead && soundSet != null && ClientAPI.GetTargetOid() != ClientAPI.GetPlayerOid()) { soundSet.PlaySoundEvent(MobSoundEvent.Response); } } } else { ClientAPI.SetTarget (mouseOverObject.Oid); bool dead = false; if (mouseOverObject.PropertyExists ("deadstate")) { dead = (bool)mouseOverObject.GetProperty("deadstate"); } MobSoundSet soundSet = mouseOverObject.gameObject.GetComponent<MobSoundSet>(); if (!dead && soundSet != null && ClientAPI.GetTargetOid() != ClientAPI.GetPlayerOid()) { soundSet.PlaySoundEvent(MobSoundEvent.Response); } } float dist = (mouseOverObject.Position - ClientAPI.GetPlayerObject ().Position).magnitude; // On a right click, do the context sensitive action if (mouseOverObject.PropertyExists ("click_handler")) { ClientAPI.Write ("Invoking custom click handler for object"); //mouseOverObject.GetProperty ("click_handler") (mouseOverObject, None); } else if (mouseOverObject.CheckBooleanProperty ("lootable")) { if (dist < 4.0) NetworkAPI.SendTargetedCommand (mouseOverObject.Oid, "/getLootList"); else ClientAPI.Write ("That object is too far away (" + dist + " meters)"); } else if (mouseOverObject.CheckBooleanProperty ("questconcludable")) { AtavismLogger.LogDebugMessage ("questconcludable"); //NetworkAPI.SendQuestConcludeRequestMessage (mouseOverObject.Oid); if (dist < 6.0) ClientAPI.ScriptObject.GetComponent<NpcInteraction> ().GetInteractionOptionsForNpc (mouseOverObject.Oid); else ClientAPI.Write ("That object is too far away (" + dist + " meters)"); } else if (mouseOverObject.CheckBooleanProperty ("questavailable")) { AtavismLogger.LogDebugMessage ("questavailable"); // NetworkAPI.SendQuestInfoRequestMessage (mouseOverObject.Oid); if (dist < 6.0) ClientAPI.ScriptObject.GetComponent<NpcInteraction> ().GetInteractionOptionsForNpc (mouseOverObject.Oid); else ClientAPI.Write ("That object is too far away (" + dist + " meters)"); } else if (mouseOverObject.CheckBooleanProperty ("questinprogress")) { AtavismLogger.LogDebugMessage ("questinprogress"); // NetworkAPI.SendQuestInfoRequestMessage (mouseOverObject.Oid); if (dist < 6.0) ClientAPI.ScriptObject.GetComponent<NpcInteraction> ().GetInteractionOptionsForNpc (mouseOverObject.Oid); else ClientAPI.Write ("That object is too far away (" + dist + " meters)"); } else if (mouseOverObject.CheckBooleanProperty ("itemstosell")) { if (dist < 6.0) ClientAPI.ScriptObject.GetComponent<NpcInteraction> ().GetInteractionOptionsForNpc (mouseOverObject.Oid); else ClientAPI.Write ("That object is too far away (" + dist + " meters)"); } else if (mouseOverObject.PropertyExists ("dialogue_available")) { int dialogueID = (int)mouseOverObject.GetProperty ("dialogue_available"); if (dialogueID > 0) { if (dist < 6.0) { ClientAPI.ScriptObject.GetComponent<NpcInteraction> ().GetInteractionOptionsForNpc (mouseOverObject.Oid); } } } else if (mouseOverObject.CheckBooleanProperty ("attackable")) { int targetType = (int)mouseOverObject.GetProperty("targetType"); if (!mouseOverObject.IsPlayer () && targetType < 1) { if (dist < 8.0) { // should be 4? NetworkAPI.SendAttackMessage (mouseOverObject.Oid, "strike", true); ClientAPI.Write ("Sent 'strike' attack for " + mouseOverObject.Oid); } else { ClientAPI.Write ("That object is too far away (" + dist + " meters)"); } } } else if (mouseOverObject.PropertyExists ("specialUse")) { string use = (string)mouseOverObject.GetProperty ("specialUse"); if (use == "arenaMaster") { if (dist < 6.0) AtavismEventSystem.DispatchEvent ("ARENA_MASTER_CLICK", null); else ClientAPI.Write ("That object is too far away (" + dist + " meters)"); } else if (use == "Intro") { if (dist < 6.0) AtavismEventSystem.DispatchEvent ("SHOW_INTRO", null); } } else if (mouseOverObject.PropertyExists ("arena_portal")) { if (dist < 6.0) { ClientAPI.Write ("Retrieving available arenas..."); long playerOid = ClientAPI.GetPlayerObject ().Oid; Dictionary<string, object> props = new Dictionary<string, object> (); props.Add ("playerOid", playerOid); props.Add ("type", (int)mouseOverObject.GetProperty ("arena_portal")); NetworkAPI.SendExtensionMessage (0, false, "arena.getTypes", props); } else { ClientAPI.Write ("You need to be closer to the portal to activate it"); } } else if (mouseOverObject.PropertyExists ("arena_flag")) { if (dist < 6.0) { long playerOid = ClientAPI.GetPlayerObject ().Oid; Dictionary<string, object> props = new Dictionary<string, object> (); props.Add ("playerOid", playerOid); props.Add ("team", mouseOverObject.GetProperty ("arena_flag")); NetworkAPI.SendExtensionMessage (0, false, "arena.pickupFlag", props); } else { ClientAPI.Write ("That object is too far away (" + dist + " meters)"); } } else if (mouseOverObject.CheckBooleanProperty ("Usable")) { if (dist < 6.0) { long playerOid = ClientAPI.GetPlayerObject ().Oid; Dictionary<string, object> props = new Dictionary<string, object> (); props.Add ("object", mouseOverObject.Oid); NetworkAPI.SendExtensionMessage (playerOid, false, "ao.OBJECT_ACTIVATED", props); } } else if (mouseOverObject.CheckBooleanProperty ("itemavailable")) { if (dist < 6.0) { NetworkAPI.SendTargetedCommand (mouseOverObject.Oid, "/openMob"); } } else if (mouseOverObject.PropertyExists ("harvestType")) { if (mouseOverObject.CheckBooleanProperty("active") && dist < 6.0) { mouseOverObject.gameObject.GetComponent<ResourceNode>().HarvestResource(); } } }