Exemple #1
0
 public void LoadBlueprintsRows(List <List <InventorySquareCrafting> > rows, WIBlueprint blueprint, InventorySquareCraftingResult resultSquare)
 {
     LoadBlueprintRow(rows [0], blueprint.Row1, blueprint.Strictness);
     LoadBlueprintRow(rows [1], blueprint.Row2, blueprint.Strictness);
     LoadBlueprintRow(rows [2], blueprint.Row3, blueprint.Strictness);
     resultSquare.RequirementsMet = false;
 }
Exemple #2
0
        public override bool DoesContextAllowForUse(IItemOfInterest targetObject)
        {
            WIBlueprint blueprint = null;

            if (Blueprints.Get.BlueprintExistsForItem(targetObject.worlditem, out blueprint) && !blueprint.Revealed)
            {
                return(true);
            }
            return(false);
        }
Exemple #3
0
        protected override void OnUseFinish()
        {
            //get the blueprint for the item if one exists
            //if it exists reveal it
            //TODO make this a timed skill
            WIBlueprint blueprint = null;

            if (Blueprints.Get.BlueprintExistsForItem(LastSkillTarget.worlditem, out blueprint))
            {
                Blueprints.Get.Reveal(blueprint.Name, BlueprintRevealMethod.ReverseEngineer, DisplayName);
            }
        }
        public void CraftBlueprint(string blueprintName)
        {
            if (IsCrafting)
            {
                return;
            }

            WIBlueprint blueprint = null;

            if (Blueprints.Get.Blueprint(blueprintName, out blueprint))
            {
                CraftingInterface.OnSelectBlueprint(blueprint);
                InventoryTabs.Show();
                InventoryTabs.SetSelection("Crafting");
                //let the interface take care of whether we have a crafting item
            }
        }
Exemple #5
0
 public bool CheckRequirements(WIBlueprint blueprint, List <List <InventorySquareCrafting> > rows, InventorySquareCraftingResult resultSquare, ref int numCraftableItems)
 {
     numCraftableItems = Globals.NumItemsPerStack;
     if (CheckRequirementsRow(blueprint, rows [0], ref numCraftableItems) &&
         CheckRequirementsRow(blueprint, rows [1], ref numCraftableItems) &&
         CheckRequirementsRow(blueprint, rows [2], ref numCraftableItems))
     {
         resultSquare.RequirementsMet = true;
     }
     else
     {
         numCraftableItems            = 0;
         resultSquare.RequirementsMet = false;
     }
     resultSquare.NumItemsPossible = numCraftableItems;
     return(resultSquare.RequirementsMet);
 }
Exemple #6
0
 protected bool CheckRequirementsRow(WIBlueprint blueprint, List <InventorySquareCrafting> row, ref int numCraftableItems)
 {
     for (int i = 0; i < row.Count; i++)
     {
         InventorySquareCrafting square = row [i];
         if (square.EnabledForBlueprint)
         {
             if (square.AreRequirementsMet == false)
             {
                 return(false);
             }
             else if (square.NumCraftableItems < numCraftableItems)
             {
                 numCraftableItems = square.NumCraftableItems;
             }
         }
     }
     return(true);
 }
        public void OnSelectBlueprint(WIBlueprint blueprint)
        {
            if (ResultSquare.NumItemsCrafted > 0)
            {
                GUIManager.PostWarning("You have to remove your crafted items first");
                return;
            }

            Blueprint = blueprint;

            mRequiredSkill.LoadBlueprintsRows(Rows, Blueprint, ResultSquare);

            SetCraftOneButton(false);
            SetCraftAllButton(false);

            if (Tabs.SelectedTab != "Craft")
            {
                Tabs.SetSelection("Craft");
            }
            RefreshRequest();
        }
        public void OnSelectBlueprint(System.Object result)
        {
            UsingMenu = false;

            WIListResult dialogResult = result as WIListResult;

            switch (dialogResult.Result)
            {
            case "Craft":
                //we want to select a new blueprint
                WIBlueprint blueprint = null;
                if (Blueprints.Get.Blueprint(RequirementBlueprint, out blueprint))
                {
                    GUIInventoryInterface.Get.CraftingInterface.OnSelectBlueprint(blueprint);
                }
                break;

            default:
                break;
            }
        }
        public void OnBlueprintPotentiallyChanged( )
        {
            Debug.Log("Blueprint potentially changed");
            //set blueprint to null in case we don't find a new one
            Blueprint = null;
            //generate a pattern based on the arrangement of items
            //use that pattern to look up potential matches
            //use the blueprints skill to find a real match
            int pattern = 0;

            for (int i = 0; i < mPatternSquares.Count; i++)
            {
                if (mPatternSquares[i].Stack.HasTopItem)
                {
                    pattern |= 1 << i;
                }
            }
            mPotentialMatches.Clear();
            int numCraftableItems = 0;

            if (Blueprints.Get.BlueprintsByPattern(pattern, mPotentialMatches))
            {
                Blueprint = null;
                //we've found some potential matches
                //see if any actually match
                for (int i = 0; i < mPotentialMatches.Count; i++)
                {
                    WIBlueprint potentialMatch = mPotentialMatches[i];
                    bool        matches        = true;
                    Debug.Log("Checking potential match " + potentialMatch.Name);
                    //check each square
                    for (int s = 0; s < mPatternSquares.Count; s++)
                    {
                        //we only have to check squares that aren't null
                        //if they're null the pattern has ruled them out already
                        if (mPatternSquares[s].HasStack && mPatternSquares[s].Stack.HasTopItem)
                        {
                            //here we perform an actual strictness check
                            //if we blow it, it doesn't match
                            //just pass '1' to the requirements
                            if (!CraftSkill.AreRequirementsMet(
                                    mPatternSquares[s].Stack.TopItem,
                                    potentialMatch.Rows[s],
                                    potentialMatch.Strictness,
                                    mPatternSquares[s].Stack.NumItems,
                                    out numCraftableItems))
                            {
                                matches = false;
                                break;
                            }
                        }
                    }

                    if (matches)
                    {
                        Debug.Log("MATCH! setting blueprint to " + potentialMatch.Name);
                        //hooray, we're done
                        OnSelectBlueprint(potentialMatch);
                        break;
                    }
                }
            }
            else
            {
                //if we didn't find ANY blueprints that match
                //just clear the blueprint
                RefreshRequest();
            }
        }
Exemple #10
0
        public IEnumerator CraftItems(
            WIBlueprint blueprint,
            CraftingItem craftingItem,
            int totalItems,
            List <List <InventorySquareCrafting> > rows,
            InventorySquareCraftingResult resultSquare)
        {
            int    currentItem          = 0;
            double startTime            = 0f;
            double endTime              = 0f;
            double timeOffset           = 0f;
            double timeMultiplier       = 1f;
            double craftTime            = 0f;
            double craftSkillUsageValue = 0f;

            mProgressValue = 0f;

            UseStart(true);

            //here we go with the crafting...
            while (currentItem < totalItems && !mCancelled)
            {
                craftTime            = blueprint.BaseCraftTime * EffectTime;
                craftSkillUsageValue = 1.0f;                //TODO apply modifiers

                startTime = WorldClock.RealTime;
                endTime   = startTime + craftTime;

                if (totalItems > 1)
                {
                    timeOffset     = (float)(currentItem - 1) / (float)totalItems;
                    timeMultiplier = 1.0f / totalItems;
                    //crafting time is reduced in proportion to the number of items you're crafting at once
                }
                //ok, if we can consume the requirements, we're good to go

                if (!ConsumeRequirements(rows))
                {
                    //Debug.Log ("Couldn't consume requirements");
                    break;
                }
                else
                {
                    while (WorldClock.RealTime < endTime && !ProgressCanceled)
                    {
                        double normalizedProgress = (WorldClock.RealTime - startTime) / (endTime - startTime);
                        mProgressValue = (float)((normalizedProgress * timeMultiplier) + timeOffset);                        //make sure it doesn't accidentally stop
                        mProgressValue = Mathf.Clamp(mProgressValue, 0.001f, 0.999f);
                        yield return(null);
                    }

                    if (!ProgressCanceled)
                    {
                        resultSquare.NumItemsCrafted++;
                        currentItem++;
                    }
                }
                yield return(null);
            }
            //just in case
            mProgressValue = 1.0f;

            UseFinish();
            yield break;
        }
Exemple #11
0
        public new void Update()
        {
            base.Update();

                                                #if UNITY_EDITOR
            if (VRManager.VRMode | VRManager.VRTestingMode)
            {
                                                #else
            if (VRManager.VRMode)
            {
                                                #endif
                transform.localPosition = VROffset;
            }
            else
            {
                transform.localPosition = DefaultOffset;
            }

            BackgroundSprite.transform.localScale = Vector3.Lerp(BackgroundSprite.transform.localScale, ScaleTarget, 0.25f);
            BorderSprite.transform.localScale     = BackgroundSprite.transform.localScale;

            ClipPanel.transform.localPosition = Vector3.Lerp(ClipPanel.transform.localPosition, PositionTarget, 0.25f);
            ClipPanel.clipRange = Vector4.Lerp(ClipPanel.clipRange, ClipTarget, 0.25f);

            GainedSomethingIconPanel.clipRange = Vector4.Lerp(GainedSomethingIconPanel.clipRange, GainedSomethingIconPanelTarget, 0.25f);

            if (!HasMessages)
            {
                GainedSomethingIconPanelTarget = GainedSomethingIconInvisible;
                return;
            }

            if (mDelayForFirstMessage > WorldClock.RealTime)
            {
                return;
            }

            if (mCurrentMessageEndTime < WorldClock.RealTime)
            {
                MessageLabel.text  = string.Empty;
                MessageLabel.alpha = 1.0f;
                mCurrentMessage    = mQueuedMessages.Dequeue();
                if (!string.IsNullOrEmpty(mCurrentMessage.MissionToActivate))
                {
                    Missions.Get.ActivateMission(mCurrentMessage.MissionToActivate, MissionOriginType.Introspection, string.Empty);
                }
                mCurrentMessageStartTime = WorldClock.RealTime;
                mDelayForFirstMessage    = 0.0;

                if (mCurrentMessage.GainedSomething)
                {
                    MessageLabel.pivot     = UIWidget.Pivot.Left;
                    MessageLabel.lineWidth = ShortFormLineWidth;
                    MessageLabel.transform.localPosition = ShortFormLabelPositionWithIcon;
                    GainedSomethingIconPanelTarget       = GainedSomethingIconPanelVisible;

                    if (!mCurrentMessage.UpdatedIcon)
                    {
                        //if we haven't updated the icon we haven't parsed scripts either
                        mCurrentMessage.Message = Data.GameData.InterpretScripts(mCurrentMessage.Message, Profile.Get.CurrentGame.Character, null);

                        //first update the prompt under the icon
                        if (mCurrentMessage.Control != InControl.InputControlType.None)
                        {
                            if (!Profile.Get.CurrentPreferences.Controls.ShowControllerPrompts)
                            {
                                //key takes priority over mouse
                                if (mCurrentMessage.Key != KeyCode.None)
                                {
                                    MiniAction.SetKey(mCurrentMessage.Key, mCurrentMessage.ActionDescription);
                                }
                                else
                                {
                                    //mouse
                                    MiniAction.SetMouse(mCurrentMessage.Mouse, mCurrentMessage.ActionDescription);
                                }
                            }
                            else
                            {
                                MiniAction.SetControl(mCurrentMessage.Control, mCurrentMessage.ActionDescription, InterfaceActionManager.ActionSpriteSuffix);
                            }
                        }
                        else
                        {
                            //if there is no prompt, reset the prompt
                            MiniAction.Reset();
                        }


                        //UUUUGH this is f*****g disgusting
                        switch (mCurrentMessage.Type)
                        {
                        case GainedSomethingType.Currency:
                            IconSprite.atlas      = Mats.Get.IconsAtlas;
                            IconSprite.color      = Colors.Get.MessageInfoColor;
                            IconBackground.color  = Colors.Get.SuccessHighlightColor;
                            IconSprite.spriteName = "SkillIconGuildSellMap";
                            break;

                        case GainedSomethingType.MissionItem:
                            IconSprite.atlas      = Mats.Get.IconsAtlas;
                            IconSprite.color      = Colors.Get.MessageSuccessColor;
                            IconBackground.color  = Colors.Get.SuccessHighlightColor;
                            IconSprite.spriteName = "MiscIconMissionItem";
                            break;

                        case GainedSomethingType.Mission:
                            IconSprite.atlas = Mats.Get.IconsAtlas;
                            MissionState missionState = null;
                            if (Missions.Get.MissionStateByName(mCurrentMessage.GainedSomethingName, out missionState) && missionState.ObjectivesCompleted)
                            {
                                IconSprite.color     = Colors.Get.MessageSuccessColor;
                                IconBackground.color = Colors.Get.SuccessHighlightColor;
                            }
                            else
                            {
                                IconSprite.color     = Colors.Get.MessageInfoColor;
                                IconBackground.color = Colors.Get.SuccessHighlightColor;
                            }
                            IconSprite.spriteName = missionState.IconName;
                            break;

                        case GainedSomethingType.Book:
                            IconSprite.atlas      = Mats.Get.IconsAtlas;
                            IconSprite.color      = Colors.Get.MessageInfoColor;
                            IconBackground.color  = Colors.Get.SuccessHighlightColor;
                            IconSprite.spriteName = "SkillIconGuildLibrary";
                            break;

                        case GainedSomethingType.Skill:
                            IconSprite.atlas = Mats.Get.IconsAtlas;
                            Skill skill = null;
                            if (Skills.Get.SkillByName(mCurrentMessage.GainedSomethingName, out skill))
                            {
                                IconSprite.color     = skill.SkillIconColor;
                                IconBackground.color = skill.SkillBorderColor;
                            }
                            IconSprite.spriteName = skill.Info.IconName;
                            break;

                        case GainedSomethingType.Structure:
                            IconSprite.atlas      = Mats.Get.MapIconsAtlas;
                            IconSprite.color      = Colors.Get.MessageSuccessColor;
                            IconBackground.color  = Colors.Get.SuccessHighlightColor;
                            IconSprite.spriteName = "MapIconStructure";
                            break;

                        case GainedSomethingType.Blueprint:
                            IconSprite.atlas = Mats.Get.IconsAtlas;
                            WIBlueprint bp = null;
                            if (Blueprints.Get.Blueprint(mCurrentMessage.GainedSomethingName, out bp))
                            {
                                Skill bpSkill = null;
                                if (Skills.Get.SkillByName(bp.RequiredSkill, out bpSkill))
                                {
                                    IconSprite.spriteName = bpSkill.Info.IconName;
                                    IconSprite.color      = bpSkill.SkillIconColor;
                                    IconBackground.color  = bpSkill.SkillBorderColor;
                                }
                            }
                            IconSprite.spriteName = "SkillIconCraftCreateBlueprint";
                            break;

                        default:
                            break;
                        }

                        mCurrentMessage.UpdatedIcon = true;
                    }
                }
                else
                {
                    //update the visibility of the mini thing

                    GainedSomethingIconPanelTarget = GainedSomethingIconInvisible;
                    if (mCurrentMessage.CenterText)
                    {
                        if (mCurrentMessage.LongForm)
                        {
                            MessageLabel.pivot     = UIWidget.Pivot.Center;
                            MessageLabel.lineWidth = LongFormLineWidth;
                            MessageLabel.transform.localPosition = LongFormLabelPositionCenter;
                        }
                        else
                        {
                            MessageLabel.pivot     = UIWidget.Pivot.Top;
                            MessageLabel.lineWidth = ShortFormLineWidth;
                            MessageLabel.transform.localPosition = ShortFormLabelPositionCenter;
                        }
                    }
                    else
                    {
                        MessageLabel.pivot = UIWidget.Pivot.Left;
                        if (mCurrentMessage.LongForm)
                        {
                            MessageLabel.lineWidth = LongFormLineWidth;
                            MessageLabel.transform.localPosition = LongFormLabelPositionLeft;
                        }
                        else
                        {
                            MessageLabel.lineWidth = ShortFormLineWidth;
                            MessageLabel.transform.localPosition = ShortFormLabelPositionLeft;
                        }
                    }
                }
                return;
            }

            if (mCurrentMessage.SkipOnLoseFocus)
            {
                if (mCurrentMessage.FocusItem == null)
                {
                    mCurrentMessage.Skip = true;
                }
                else
                {
                    if (Player.Local.Surroundings.IsWorldItemInPlayerFocus)
                    {
                        if (Player.Local.Surroundings.WorldItemFocus != mCurrentMessage.FocusItem)
                        {
                            mCurrentMessage.Skip = true;
                        }
                    }
                    else
                    {
                        mCurrentMessage.Skip = true;
                    }
                }
            }

            MessageLabel.text = mCurrentMessage.Message;

            /*if (mCurrentMessageFullDisplayTime < Frontiers.WorldClock.RealTime) {
             *              MessageLabel.text = mCurrentMessage.Message.Trim();
             * } else {
             *              double normalizedDisplayAmount = 1.0 - ((Frontiers.WorldClock.RealTime - mCurrentMessageFullDisplayTime) / (mCurrentMessageStartTime - mCurrentMessageFullDisplayTime));
             *              int stringDisplayLength = Mathf.FloorToInt((float)(mCurrentMessage.Message.Length * normalizedDisplayAmount));
             *              string subMessageFront = mCurrentMessage.Message.Substring(0, stringDisplayLength).Trim();
             *              MessageLabel.text = subMessageFront;
             *              return;
             * }*/

            if (mCurrentMessageStartFadeTime < Frontiers.WorldClock.RealTime)
            {
                MessageLabel.alpha = (float)(1.0 - ((Frontiers.WorldClock.RealTime - mCurrentMessageStartFadeTime) / (mCurrentMessageEndTime - mCurrentMessageStartFadeTime)));
                return;
            }
            else
            {
                MessageLabel.alpha = 1.0f;
            }
            MiniAction.SetAlpha(MessageLabel.alpha);
        }