Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        //means is hiding.
        if (_rectTransform.position.x < -80000)
        {
            return;
        }

        _rectTransform.position = Hoverable.MousePositionTowardsScreenCenter();

        //after 3 seconds of being show
        //if key = "" is a simple msg with out key
        if (Time.time > showedAt + .7 && !string.IsNullOrEmpty(_key))
        {
            SpawnMedHover();
        }
    }
Ejemplo n.º 2
0
    private static void UpdateCursorHover()
    {
        SetInteractionCursor(false);
        ClearHoverText();

        Collider2D hitColl = Physics2D.OverlapPoint(Camera.main.ScreenToWorldPoint(Input.mousePosition));
        Hoverable  hitItem = null;

        if (hitColl != null)
        {
            hitItem = hitColl.GetComponent <GameItem>();
        }

        if (hitItem != null)
        {
            hitItem.OnHoverEnter();
        }
    }
Ejemplo n.º 3
0
    // Token: 0x06000500 RID: 1280 RVA: 0x00029D94 File Offset: 0x00027F94
    private void UpdateCrosshair(Player player, float bowDrawPercentage)
    {
        GameObject hoverObject = player.GetHoverObject();
        Hoverable  hoverable   = hoverObject ? hoverObject.GetComponentInParent <Hoverable>() : null;

        if (hoverable != null && !TextViewer.instance.IsVisible())
        {
            this.m_hoverName.text  = hoverable.GetHoverText();
            this.m_crosshair.color = ((this.m_hoverName.text.Length > 0) ? Color.yellow : new Color(1f, 1f, 1f, 0.5f));
        }
        else
        {
            this.m_crosshair.color = new Color(1f, 1f, 1f, 0.5f);
            this.m_hoverName.text  = "";
        }
        Piece hoveringPiece = player.GetHoveringPiece();

        if (hoveringPiece)
        {
            WearNTear component = hoveringPiece.GetComponent <WearNTear>();
            if (component)
            {
                this.m_pieceHealthRoot.gameObject.SetActive(true);
                this.m_pieceHealthBar.SetValue(component.GetHealthPercentage());
            }
            else
            {
                this.m_pieceHealthRoot.gameObject.SetActive(false);
            }
        }
        else
        {
            this.m_pieceHealthRoot.gameObject.SetActive(false);
        }
        if (bowDrawPercentage > 0f)
        {
            float num = Mathf.Lerp(1f, 0.15f, bowDrawPercentage);
            this.m_crosshairBow.gameObject.SetActive(true);
            this.m_crosshairBow.transform.localScale = new Vector3(num, num, num);
            this.m_crosshairBow.color = Color.Lerp(new Color(1f, 1f, 1f, 0f), Color.yellow, bowDrawPercentage);
            return;
        }
        this.m_crosshairBow.gameObject.SetActive(false);
    }
Ejemplo n.º 4
0
        public static bool Prefix(Humanoid __instance, Inventory inventory, ItemDrop.ItemData item, bool fromInventoryGui)
        {
            GameObject hoverObject = __instance.GetHoverObject();
            Hoverable  hoverable   = (hoverObject ? hoverObject.GetComponentInParent <Hoverable>() : null);

            if (hoverable == null || fromInventoryGui || !PlayerUpdate.isAltHold)
            {
                return(true);
            }
            var signComponentInParent = hoverObject.GetComponentInParent <Sign>();

            if (signComponentInParent == null)
            {
                return(true);
            }

            Log.LogInfo("Alternative Use Item");
            signComponentInParent.UseItem(__instance, item);
            return(false);
        }
        public static void setCrosshairValues(Player player)
        {
            GameObject hoverObject = player.GetHoverObject();
            Hoverable  hoverable   = hoverObject ? hoverObject.GetComponentInParent <Hoverable>() : null;

            if (hoverable != null && !TextViewer.instance.IsVisible())
            {
                isLookingAtActivatable = true;
            }
            else
            {
                isLookingAtActivatable = false;
            }

            if (displayCrosshairAlways.Value)
            {
                targetCrosshairAlpha = crosshairColor.Value.a;
            }
            else if (displayCrosshairWhenBuilding.Value && player.InPlaceMode())
            {
                targetCrosshairAlpha = crosshairColor.Value.a;
            }
            else if (displayCrosshairOnActivation.Value && isLookingAtActivatable)
            {
                targetCrosshairAlpha = crosshairColor.Value.a;
            }
            else if (displayCrosshairOnEquipped.Value && characterEquippedItem)
            {
                targetCrosshairAlpha = crosshairColor.Value.a;
            }
            else if (displayCrosshairOnBowEquipped.Value && characterEquippedBow)
            {
                targetCrosshairAlpha = crosshairColor.Value.a;
            }
            else
            {
                targetCrosshairAlpha = 0;
            }
        }
 public bool IsEntityOrParentCompliant(Hoverable component)
 {
     return
         (component.GetComponentInParent <School>() != null || component.GetComponent <School>() != null);
 }
 public void OnBlur(Hoverable hoverable)
 {
     hoverable
     .GetComponent <Renderer>()
     .material.SetColor("_EmissionColor", Color.black);
 }
Ejemplo n.º 8
0
 public bool IsCompliant(Hoverable hoverable)
 {
     return(hoverable.GetComponent <House>() != null);
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Called when the supplied hoverable gets hovered over
 /// </summary>
 protected virtual void OnItemHovered(Hoverable hovered)
 {
 }
Ejemplo n.º 10
0
 void IPointerEnterHandler.OnPointerEnter(PointerEventData eventData)
 {
     current = this;
     ExecuteEvents.ExecuteHierarchy <IHasChanged>(gameObject, null, (x, y) => x.HasChanged());
 }
Ejemplo n.º 11
0
        private static void Player_Update(Player __instance)
        {
            if (Player.m_localPlayer == __instance)
            {
                if (Settings.PingWhereLooking.Value)
                {
                    if (Enum.TryParse(Settings.PingKey.Value, out KeyCode key))
                    {
                        if (__instance.InvokeMethod <bool>("TakeInput"))
                        {
                            if (Input.GetKeyDown(key))
                            {
                                // TODO: improve object detection range

                                var dir = __instance.GetAimDir(Vector3.zero);
                                var ray = new Ray(GameCamera.instance.transform.position, GameCamera.instance.transform.forward);

                                var mask = Pathfinding.instance.m_layers | Pathfinding.instance.m_waterLayers;

                                Physics.Raycast(ray, out var hit, 500f, mask);

                                string  pingText = "Ping!";
                                Vector3 pos      = hit.point;

                                if (__instance.GetHoverCreature() != null)
                                {
                                    pingText = __instance.GetHoverCreature().GetHoverName();
                                    pos      = __instance.GetHoverCreature().GetCenterPoint();
                                }
                                else if (__instance.GetHoverObject())
                                {
                                    Hoverable hoverable = __instance.GetHoverObject().GetComponentInParent <Hoverable>();
                                    if (hoverable != null)
                                    {
                                        pingText = hoverable.GetHoverText().Split('\n')[0];
                                    }
                                    pos = __instance.GetHoverObject().transform.position;
                                }
                                ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "ChatMessage", new object[]
                                {
                                    pos,
                                    3,
                                    __instance.GetPlayerName(),
                                    $"{pingText} at ({Mathf.FloorToInt(pos.x)}, {Mathf.FloorToInt(pos.z)})"
                                });
                            }
                        }
                    }
                }

                if (Enum.TryParse(Settings.ShareMapKey.Value, out KeyCode mapKey))
                {
                    if (Input.GetKeyDown(mapKey))
                    {
                        Plugin.ShareMap();
                    }
                }


                if (Enum.TryParse(Settings.SharePinsKey.Value, out KeyCode pinKey))
                {
                    if (Input.GetKeyDown(pinKey))
                    {
                        Plugin.SharePins();
                    }
                }
            }
        }
Ejemplo n.º 12
0
        // permament features
        public override void InitializeConsole()
        {
            const int topY = 12;
            const int left = 3;

            base.InitializeConsole();

            // back button
            buttons.Add(new Button(console.getWidth() - 10, 1, 6, 1, "[back]",
                                   elementDark, Constants.COL_BLUE, foregroundColor,
                                   GotoMainMenu));

            // start game button
            buttons.Add(new Button(console.getWidth() - 10, console.getHeight() - 2, 6, 1, "[done]",
                                   elementDark, Constants.COL_BLUE, foregroundColor,
                                   StartGame)); // TODO: change to load level


            // init some temp components to store data in -------------------------------------------------------- Attribute buttons stuff
            attributes = new AttributesComponent();

            // init the stat adjusting buttons for each stat
            attrSelectors = new List <StatSelector>();
            int buttonLine = 0;

            foreach (string attr in attributes.Attributes())
            {
                int       y          = buttonLine + topY;
                const int leftOffset = 14;

                StatSelector statSelector = new StatSelector();
                statSelector.statName = attr;
                statSelector.current  = 0;

                // the decrease button
                statSelector.decrease = new Button(left + leftOffset, y, 1, 1, "-",
                                                   elementDark, Constants.COL_BLUE, foregroundColor,
                                                   DecreaseCurrentStat);
                statSelector.decrease.payload = statSelector;

                // the increase button
                statSelector.increase = new Button(left + leftOffset + 6, y, 1, 1, "+",
                                                   elementDark, Constants.COL_BLUE, foregroundColor,
                                                   IncreaseCurrentStat);
                statSelector.increase.payload = statSelector;

                buttons.Add(statSelector.decrease);
                buttons.Add(statSelector.increase);

                attrSelectors.Add(statSelector);
                buttonLine += 2;
            }

            const string mainTitle = "[CREATE CHARACTER]";

            // draw main title
            DrawText(console.getWidth() / 2 - mainTitle.Length / 2, 1, mainTitle, foregroundColor);
            DrawDividerLine(0, 2, console.getWidth());

            // draw out the attibute names in a list
            DrawText(left, 4, "Character Name:", Constants.COL_ATTENTION);
            DrawText(left, topY - 4, "Character Attrbiutes: ", Constants.COL_ATTENTION);

            // initialize the default skill and item lists ----------------------------------------------------- Item and skill selection stuff
            defaultSkills  = new List <Entity>();
            defaultItems   = new List <Entity>();
            equippedSkills = new List <Entity>();
            equippedItems  = new List <Entity>();

            string[] skillNames = engine.dataTables.GetListValue("startSkills", "CharacterCreation", "set");
            string[] itemNames  = engine.dataTables.GetListValue("startItems", "CharacterCreation", "set");

            // The skill selector area ---------------------------------------------------------
            const int skillLeft  = 30;
            const int tableY     = 4;
            const int tableWidth = 32;

            // define a littel subsection box for the skill select area
            skillSelectSection        = new SubSection();
            skillSelectSection.origin = new Vector2(skillLeft - 1, tableY + 1);
            skillSelectSection.size   = new Vector2(tableWidth, 43);

            skillDropSection        = new SubSection();
            skillDropSection.origin = new Vector2(skillLeft - 1, skillSelectSection.origin.Y + skillSelectSection.size.Y + 3);
            skillDropSection.size   = new Vector2(tableWidth, 7);

            DrawText(skillSelectSection.origin.X, skillSelectSection.origin.Y - 1, "Starting Skills:", Constants.COL_ATTENTION);
            DrawText(skillDropSection.origin.X, skillDropSection.origin.Y - 1, "Equipped Skills:", Constants.COL_ATTENTION);

            int line = 0;

            // for each skill in the list from data, instantiate the skill antity and create a hover target for it
            foreach (string name in skillNames)
            {
                Entity skill = engine.data.InstantiateEntity(name);
                defaultSkills.Add(skill);

                var getName = (EGetScreenName)skill.FireEvent(new EGetScreenName());

                int y = tableY + 2 + line;
                //DrawText(skillLeft, y, "+" + getName.text, foregroundColor);

                // create a hover target for each skill
                Hoverable hoverTarget = new Hoverable();
                hoverTarget.entity  = skill;
                hoverTarget.width   = getName.text.Length + 1;
                hoverTarget.origin  = new Vector2(skillSelectSection.origin.X + 1, y);
                hoverTarget.handler = OpenSkillInspector;

                hoverableItems.Add(hoverTarget);
                line += 1;
            }

            // The item selector area ---------------------------------------------------------
            const int itemLeft = 63;

            itemSelectSection        = new SubSection();
            itemSelectSection.origin = new Vector2(itemLeft - 1, tableY + 1);
            itemSelectSection.size   = new Vector2(tableWidth, 43);

            itemDropSection        = new SubSection();
            itemDropSection.origin = new Vector2(itemLeft - 1, itemSelectSection.origin.Y + itemSelectSection.size.Y + 3);
            itemDropSection.size   = new Vector2(tableWidth, 7);

            DrawText(itemSelectSection.origin.X, itemSelectSection.origin.Y - 1, "Starting Items:", Constants.COL_ATTENTION);
            DrawText(itemDropSection.origin.X, itemDropSection.origin.Y - 1, "Equipped Items:", Constants.COL_ATTENTION);

            line = 0;
            // for each item in the list from data, instantiate the item entity and create a hover target for it
            foreach (string name in itemNames)
            {
                Entity item = engine.data.InstantiateEntity(name);
                defaultItems.Add(item);

                var getName = (EGetScreenName)item.FireEvent(new EGetScreenName());

                int y = tableY + 2 + line;
                //DrawText(itemLeft, y, "+" + getName.text, foregroundColor);

                // create a hover target for each skill
                Hoverable hoverTarget = new Hoverable();
                hoverTarget.entity  = item;
                hoverTarget.width   = getName.text.Length + 1;
                hoverTarget.origin  = new Vector2(itemSelectSection.origin.X + 1, y);
                hoverTarget.handler = OpenItemInspector;

                hoverableItems.Add(hoverTarget);
                line += 1;
            }
        }
Ejemplo n.º 13
0
        public static bool Prefix(Humanoid __instance, [HarmonyArgument(0)] Inventory inventory, [HarmonyArgument(1)] ItemDrop.ItemData item,
                                  [HarmonyArgument(2)] bool fromInventoryGui, Inventory ___m_inventory, ZSyncAnimation ___m_zanim)
        {
            string itemName = item.m_shared.m_name;

            // Only Override function for Trophy Items
            if (itemName.Contains("$item_trophy_"))
            {
                string enemy = itemName.Substring(13);

                Debug.Log($"Use {enemy} trophy!");

                // Skip Boss Trophy if Unconsumable
                if (!UsefulTrophies.CanConsumeBosses && UsefulTrophies.BossEnemies.Contains(enemy))
                {
                    return(true);
                }

                if (inventory == null)
                {
                    inventory = ___m_inventory;
                }
                if (!inventory.ContainsItem(item))
                {
                    return(false);
                }

                // Prioritize Hover Objects (item stands/altars)
                GameObject hoverObject = __instance.GetHoverObject();
                Hoverable  hoverable   = hoverObject ? hoverObject.GetComponentInParent <Hoverable>() : null;
                if (hoverable != null && !fromInventoryGui)
                {
                    Interactable componentInParent = hoverObject.GetComponentInParent <Interactable>();
                    if (componentInParent != null && componentInParent.UseItem(__instance, item))
                    {
                        return(false);
                    }
                }

                Debug.Log($"Consume {enemy} trophy!");

                // Get a Random Skill from the Player's Skill Pool
                List <Skills.Skill> skills      = __instance.GetSkills().GetSkillList();
                Skills.SkillType    randomSkill = skills[UnityEngine.Random.Range(0, skills.Count)].m_info.m_skill;

                float skillFactor = 10f;
                if (UsefulTrophies.TrophyXPDict.TryGetValue(enemy, out float dictSkillFactor))
                {
                    skillFactor = dictSkillFactor;
                }
                else
                {
                    Debug.Log($"Unknown trophy for {enemy}!");
                }

                // Increase Skill by Configured Skill Factor
                __instance.RaiseSkill(randomSkill, skillFactor);
                Debug.Log($"Raised {randomSkill} by {skillFactor}");

                // Consume Item
                inventory.RemoveOneItem(item);
                __instance.m_consumeItemEffects.Create(Player.m_localPlayer.transform.position, Quaternion.identity, null, 1f, -1);
                ___m_zanim.SetTrigger("eat");

                // Notify Player of the Stat Increase
                __instance.Message(MessageHud.MessageType.Center, $"You feel better at {randomSkill}", 0, null);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 14
0
    // Update is called once per frame
    void Update()
    {
        // Mouse controll
        RaycastHit hit;
        Ray ray = Camera.main.ScreenPointToRay (Input.mousePosition);
        if (Physics.Raycast (ray, out hit)) {
            var floor = hit.collider.gameObject;

        //			Debug.DrawRay (Camera.main.transform.position, hit.point, Color.red);
        //			Debug.Log (Camera.main.transform.position +" "+ray.direction+" "+Color.red);
        //			Debug.Log(string.Format("Mouse is over {0}", hit.collider.name));
            var hoveredNow = hit.collider.gameObject.GetComponent<Hoverable>();
        //			Debug.Log(string.Format("GameObject: {0}", hit.collider.gameObject.name));
            if(hoveredNow!=null){
                if(lastHovered != hoveredNow){
                    if(lastHovered!=null){
                        lastHovered.Unhover();
                    }
                    lastHovered = hoveredNow;
                    lastHovered.Hover();

                } else {
                    // still hovering the same object
                }
            } else {
                if(lastHovered!=null){
                    lastHovered.Unhover();
                    lastHovered = null;
                }
            }
        }

        if (Input.GetButton ("Fire1") && lastHovered!=null) {
            if(lastHovered is Clickable){
                var clickedObject = (Clickable) lastHovered;
                clickedObject.Click();
            }
            if(lastHovered is FloorController && lastSelected is MuslimController){
                var floorController = (FloorController) lastHovered;
                var muslim = (MuslimController) lastSelected;
        //				if(floorController.Floor.
                muslim.moveTo(hit.point);
        //				Debug.Log(Camera.main.transform.position +" "+ ( floor.transform.position));

            }
            if(lastHovered is Selectable){
                var selectedObject = (Selectable) lastHovered;
                lastSelected = selectedObject;
                selectedObject.Select();
            }
        }

        // Camera controll
        float h = Input.GetAxisRaw ("Horizontal");
        float v = Input.GetAxisRaw ("Vertical");

        movement = movement.normalized * speed * Time.deltaTime;
        movement.Set (h, 0f, v);

        transform.position = transform.position + movement;
    }
Ejemplo n.º 15
0
    void onHover(Ray ray, RaycastHit2D hit)
    {
        hit = Physics2D.Raycast(ray.origin, ray.direction, Mathf.Infinity);
        if (hit.collider != null)
        {
            if (hit.collider.GetComponent <Hoverable>())
            {
                Hoverable entity = hit.collider.GetComponent <Hoverable>();
                entity.hovering = true;
                if (prevEntity && entity.id != prevEntity.id)
                {
                    prevEntity.hovering = false;
                }
                if (entity.GetComponent <Tile>())
                {
                    Tile tile = entity.GetComponent <Tile>();
                    player.hoveringTile = tile;
                    if (Input.GetMouseButtonDown(0))
                    {
                        if (!inventoryOpen)
                        {
                            if (player.selectedItem == "empty")
                            {
                                player.mineTile(tile);
                            }
                            else
                            {
                                player.placeItem(tile);
                            }
                        }
                    }
                    else if (Input.GetMouseButtonDown(1))
                    {
                        player.breakMachine(tile);
                    }
                    else if (Input.GetKeyDown(KeyCode.R))
                    {
                        player.rotateTile(tile);
                    }
                }
                else
                {
                    if (Input.GetMouseButtonDown(0))
                    {
                        if (entity.GetComponent <Slot>())
                        {
                            Slot slot = entity.GetComponent <Slot>();
                            player.setSelectedItem(slot.item);
                        }
                    }
                }

                if (entity.GetComponent <Recipe>())
                {
                    Recipe recipe = entity.GetComponent <Recipe>();
                    crafting.updateText(recipe);
                    if (prevEntity && entity.id != prevEntity.id)
                    {
                        crafting.updateColors(recipe);
                    }
                    if (Input.GetMouseButtonDown(0))
                    {
                        crafting.craft(recipe);
                    }
                }
                else
                {
                    crafting.resetText();
                }

                if (entity.GetComponent <GroundItem>())
                {
                    if (Input.GetMouseButtonDown(0))
                    {
                        SpriteRenderer renderer = entity.GetComponent <SpriteRenderer>();
                        inventoryService.addItem(renderer.sprite.name, 1);
                        Destroy(entity.gameObject);
                    }
                }
                prevEntity = entity;
            }
        }
    }