Ejemplo n.º 1
0
        bool UpdateTarget(RaycastHit hit)
        {
            // Double check there is no obstacles in the way
            RaycastHit lineHit;
            float      skipZone = (cam.position - player.transform.position).magnitude;

            if (Physics.Linecast(cam.position + cam.forward * skipZone, hit.point, out lineHit, mask))
            {
                if (lineHit.collider != hit.collider)
                {
                    return(false);
                }
            }

            //Debug.Log (hit.collider.name);

            //	float aimTargetDist = hit.distance + 0.05f;
            //crosshair.transform.position = hit.point;

            var AN = hit.transform.gameObject.GetComponent <AtavismNode>();
            AtavismObjectNode worldObj = null;
            AtavismMobNode    mobObj   = null;

            if (AN != null)
            {
                worldObj = ClientAPI.WorldManager.GetObjectNode(AN.Oid);
            }

            if (worldObj != null)
            {
                mobObj = worldObj as AtavismMobNode;
            }
            if (mobObj != null && mobObj.PropertyExists("health"))
            {
                var health = (int)mobObj.GetProperty("health");
                if (health > 0)
                {
                    if (mobObj.Oid != lastTarget)
                    {
                        MobSoundSet soundSet = mobObj.GameObject.GetComponent <MobSoundSet>();
                        if (soundSet != null)
                        {
                            soundSet.PlaySoundEvent(MobSoundEvent.Response);
                        }
                        lastTarget = mobObj.Oid;
                        AtavismClient.Instance.WorldManager.TargetId = mobObj.Oid;
                    }
                }
            }
            else
            {
                if (LoseLock)
                {
                    AtavismClient.Instance.WorldManager.TargetId = -1;
                    lastTarget = -1;
                }
            }
            return(true);
        }
Ejemplo n.º 2
0
        public void PlaySoundEvent(MobSoundEvent soundEvent)
        {
            MobSoundSet mss = transform.parent.GetComponent <MobSoundSet>();

            if (mss != null)
            {
                mss.PlaySoundEvent(soundEvent);
            }
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
                }
            }
        }