public void LevelHandler(object sender, PropertyChangeEventArgs args) { if (node != null) { if (level == 0) { level = (int)node.GetProperty("level"); } if (level != (int)node.GetProperty("level")) { if (level != 0 && timeDelay < Time.time) { if (AtavismSettings.Instance.LevelUpPrefab != null) { go = (GameObject)Instantiate(AtavismSettings.Instance.LevelUpPrefab, transform.position, transform.rotation, transform); } } level = (int)node.GetProperty("level"); timeDelay = Time.time + 1f; } } if (go != null) { Destroy(go, AtavismSettings.Instance.LevelUpPrefabDuration); } }
void Start() { node = GetComponent <AtavismNode>(); if (node != null) { if (node.PropertyExists("level")) { level = (int)node.GetProperty("level"); } node.RegisterObjectPropertyChangeHandler("level", LevelHandler); } }
/// <summary> /// Loads the portrait for a player/mob in-game. /// </summary> /// <returns>The portrait.</returns> /// <param name="node">Node.</param> public Sprite LoadPortrait(AtavismNode node) { if (node == null) { return(null); } if (portraitType == PortraitType.Class && node.PropertyExists("portrait")) { // Class portraits will currently be saved on the player string portraitName = (string)node.GetProperty("portrait"); Sprite portraitSprite = Resources.Load <Sprite>("Portraits/" + portraitName); return(portraitSprite); } else if (portraitType == PortraitType.Prefab || portraitType == PortraitType.Class) { // If the target doesn't have a portrait property, fall back to prefab if (node.GameObject != null && node.GameObject.GetComponent <AtavismMobAppearance>() != null) { return(node.GameObject.GetComponent <AtavismMobAppearance>().portraitIcon); } } else if (portraitType == PortraitType.Custom) { // TODO: Add your code here? if (node.PropertyExists("portrait")) { string portraitName = (string)node.GetProperty("portrait"); Sprite portraitSprite = Resources.Load <Sprite>("Portraits/" + portraitName); return(portraitSprite); } if (node.GameObject != null && node.GameObject.GetComponent <AtavismMobAppearance>() != null) { return(node.GameObject.GetComponent <AtavismMobAppearance>().portraitIcon); } } return(null); }
public void HandleDeadState(object sender, PropertyChangeEventArgs args) { death = (bool)node.GetProperty("deadstate"); UpdateNameDisplay(true); }
public void OnLeftClick(bool down, AtavismNode mouseOverObject) { // Item delete check first if (mouseOverObject == null && _mouseDownObject1 == null) { if (_cursorItem != null && !down && !AtavismUiSystem.IsMouseOverFrame()) { StartItemThrowaway(); } return; } if (down) { // ClientAPI.Write("Mouse down object = " + str(worldObj)) // store the mouse down object _mouseDownObject1 = mouseOverObject; return; } else { if (mouseOverObject != _mouseDownObject1) { return; } _mouseDownObject1 = null; } if (ClientAPI.GetPlayerObject() == null) { return; } // mouse up over the same object as the mouse down // that means this is a 'click' on the object float dist = (mouseOverObject.Position - ClientAPI.GetPlayerObject().Position).magnitude; // First check if this is an arena object if (mouseOverObject.PropertyExists("arena_portal")) { if (dist < 6.0) { #if AT_I2LOC_PRESET ClientAPI.Write(I2.Loc.LocalizationManager.GetTranslation("Retrieving available arenas...")); #else ClientAPI.Write("Retrieving available arenas..."); #endif 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("That object is too far away (" + dist + " meters)"); #endif } } else if (mouseOverObject.PropertyExists("itemstosell")) { /*if (dist < 6.0) * MarsContainer.GetMerchantTable ((mouseOverObject.GetProperty ("itemstosell"))); * else * ClientAPI.Write ("That object is too far away (" + dist + " meters)");*/ } 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.PropertyExists("specialUse")) { string use = (string)mouseOverObject.GetProperty("specialUse"); if (use == "Intro") { if (dist < 6.0) { AtavismEventSystem.DispatchEvent("SHOW_INTRO", null); } } } else if (mouseOverObject.PropertyExists("DomeWarden")) { // int dome = (int)mouseOverObject.GetProperty ("DomeWarden"); if (dist < 6.0) { long playerOid = ClientAPI.GetPlayerObject().Oid; Dictionary <string, object> props = new Dictionary <string, object>(); props.Add("domeID", mouseOverObject.GetProperty("DomeWarden")); NetworkAPI.SendExtensionMessage(playerOid, false, "ao.DOME_ENQUIRY", props); } } 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); } } if (mouseOverObject.PropertyExists("targetable")) { if ((bool)mouseOverObject.GetProperty("targetable") == false || (string)mouseOverObject.GetProperty("targetable") == "False") { return; } } if (mouseOverObject.Oid != ClientAPI.GetTargetOid()) { ClientAPI.SetTarget(mouseOverObject.Oid); MobSoundSet soundSet = mouseOverObject.gameObject.GetComponent <MobSoundSet>(); if (soundSet != null && ClientAPI.GetTargetOid() != ClientAPI.GetPlayerOid()) { soundSet.PlaySoundEvent(MobSoundEvent.Response); } } //MarsTarget.TargetByOID (mouseOverObject.OID); }
/// <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); } } }
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); } } }
/// <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) { // 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(); } } }
public void OnLeftClick(bool down, AtavismNode mouseOverObject) { if (down) { // ClientAPI.Write("Mouse down object = " + str(worldObj)) // store the mouse down object _mouseDownObject1 = mouseOverObject; return; } if (mouseOverObject == null) { if (_cursorItem != null && !down && !AtavismUiSystem.IsMouseOverFrame ()) { StartItemThrowaway(); } return; } // ClientAPI.Write("Mouse up object = " + str(worldObj)) if (mouseOverObject != _mouseDownObject1) return; // mouse up over the same object as the mouse down // that means this is a 'click' on the object float dist = (mouseOverObject.Position - ClientAPI.GetPlayerObject ().Position).magnitude; // First check if this is an arena object 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 ("That object is too far away (" + dist + " meters)"); } } else if (mouseOverObject.PropertyExists ("itemstosell")) { /*if (dist < 6.0) MarsContainer.GetMerchantTable ((mouseOverObject.GetProperty ("itemstosell"))); else ClientAPI.Write ("That object is too far away (" + dist + " meters)");*/ } 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.PropertyExists ("specialUse")) { string use = (string)mouseOverObject.GetProperty ("specialUse"); if (use == "Intro") { if (dist < 6.0) AtavismEventSystem.DispatchEvent ("SHOW_INTRO", null); } } else if (mouseOverObject.PropertyExists ("DomeWarden")) { int dome = (int)mouseOverObject.GetProperty ("DomeWarden"); if (dist < 6.0) { long playerOid = ClientAPI.GetPlayerObject ().Oid; Dictionary<string, object> props = new Dictionary<string, object> (); props.Add ("domeID", mouseOverObject.GetProperty ("DomeWarden")); NetworkAPI.SendExtensionMessage (playerOid, false, "ao.DOME_ENQUIRY", props); } } 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); } } if (mouseOverObject.PropertyExists ("targetable")) { if ((bool)mouseOverObject.GetProperty ("targetable") == false || (string)mouseOverObject.GetProperty ("targetable") == "False") return; } if (mouseOverObject.Oid != ClientAPI.GetTargetOid()) { ClientAPI.SetTarget (mouseOverObject.Oid); MobSoundSet soundSet = mouseOverObject.gameObject.GetComponent<MobSoundSet>(); if (soundSet != null && ClientAPI.GetTargetOid() != ClientAPI.GetPlayerOid()) { soundSet.PlaySoundEvent(MobSoundEvent.Response); } } //MarsTarget.TargetByOID (mouseOverObject.OID); }