Ejemplo n.º 1
0
    private void SwitchMode()
    {
        string command = RConsole.lastCommands.LastOrDefault();

        string[] comArray = command.Split(' ');

        if (comArray.Length > 1)
        {
            string newMode = comArray[1].ToLower();

            if (newMode == "creative" || newMode == "easy" || newMode == "normal" || newMode == "hardcore")
            {
                ModeCheck(newMode);
            }
            else
            {
                Log("<b><color=#d7575a>GameOptions: That input is invalid. Please choose <color=#ffcf01>Creative</color>, <color=#ffcf01>Easy</color>, <color=#ffcf01>Normal</color> or <color=#ffcf01>Hardcore</color>.</color></b>");
            }

            CraftingMenu cMenu = ComponentManager <CraftingMenu> .Value;

            if (cMenu != null)
            {
                cMenu.creativeModeCategoryButton.SetActive(GameManager.GameMode == GameMode.Creative);
            }
        }
    }
Ejemplo n.º 2
0
 public static void ProcessIngredientMatches(CraftingMenu __instance, Recipe _recipe, IList <List <int> > _compatibleItems, IList <int> _bestIngredientsMatch)
 {
     try
     {
         int m_lastRecipeIndex = (int)AccessTools.Field(typeof(CraftingMenu), "m_lastRecipeIndex").GetValue(__instance);
         //WorkInProgress.Instance.MyLogger.LogDebug($"ProcessIngredientMatches: {_recipe.name}");
         if (RecipesReorder.dctIngr2.ContainsKey(_recipe.name))
         {
             for (int i = 0; i < RecipesReorder.dctIngr2[_recipe.name].Count; i++)
             {
                 if (RecipesReorder.dctIngr2[_recipe.name][i] > -1 &&
                     !_compatibleItems.Any(l => l.Contains(RecipesReorder.dctIngr2[_recipe.name][i])))
                 {
                     //WorkInProgress.Instance.MyLogger.LogDebug($" > Delete save");
                     RecipesReorder.dctIngr2.Remove(_recipe.name);
                     break;
                 }
             }
         }
         //if (RecipesReorder.dctIngr2.ContainsKey(_recipe.name))
         //{
         //    _bestIngredientsMatch = RecipesReorder.dctIngr2[_recipe.name];
         //}
         //foreach (var item in _bestIngredientsMatch)
         //{
         //    WorkInProgress.Instance.MyLogger.LogDebug($" > {item}");
         //}
     }
     catch (Exception ex)
     {
         WorkInProgress.Instance.MyLogger.LogError("ProcessIngredientMatches: " + ex.Message);
     }
 }
Ejemplo n.º 3
0
        static bool CraftingMenu_CraftingDone_Pre(CraftingMenu __instance, ref List <Item> __state)
        {
            List <Item> ingredients = GetDestructibleIngredients(__instance);
            List <Item> results     = GetDestructibleResults(__instance);

            #region quit
            if (!_preserveDurability || ingredients.IsEmpty() || ingredients.IsEmpty())
            {
                return(true);
            }
            #endregion

            float averageRatio = 0;
            foreach (var item in ingredients)
            {
                averageRatio += item.DurabilityRatio;
            }
            averageRatio /= ingredients.Count;

            foreach (var item in results)
            {
                if (item.Stats.TryAssign(out var stats))
                {
                    stats.StartingDurability = (stats.MaxDurability * averageRatio.Lerp(1f, _restoreMissingDurability / 100f)).Round();
                }
            }

            __state = results;
            return(true);
        }
Ejemplo n.º 4
0
        public static void IngredientSelectorHasChanged(CraftingMenu __instance, int _selectorIndex, int _itemID)
        {
            try
            {
                int m_lastRecipeIndex = (int)AccessTools.Field(typeof(CraftingMenu), "m_lastRecipeIndex").GetValue(__instance);
                //WorkInProgress.Instance.MyLogger.LogDebug($"IngredientSelectorHasChanged: {_selectorIndex}={_itemID} ({m_lastRecipeIndex})");
                if (m_lastRecipeIndex != -1)
                {
                    List <KeyValuePair <int, Recipe> > m_complexeRecipes = (List <KeyValuePair <int, Recipe> >)AccessTools.Field(typeof(CraftingMenu), "m_complexeRecipes").GetValue(__instance);
                    Recipe rec = m_complexeRecipes[m_lastRecipeIndex].Value;
                    //WorkInProgress.Instance.MyLogger.LogDebug($" > {rec.name}");

                    List <RecipeDisplay> m_recipeDisplays  = (List <RecipeDisplay>)AccessTools.Field(typeof(CraftingMenu), "m_recipeDisplays").GetValue(__instance);
                    IList <int>          m_bestIngredients = (IList <int>)AccessTools.Field(typeof(RecipeDisplay), "m_bestIngredients").GetValue(m_recipeDisplays[m_lastRecipeIndex]);
                    if (!RecipesReorder.dctIngr2.ContainsKey(rec.name))
                    {
                        RecipesReorder.dctIngr2.Add(rec.name, m_bestIngredients.ToList());
                    }
                    RecipesReorder.dctIngr2[rec.name][_selectorIndex] = _itemID;
                    //WorkInProgress.Instance.MyLogger.LogDebug($" > Ingredient saved!");
                }
            }
            catch (Exception ex)
            {
                WorkInProgress.Instance.MyLogger.LogError("IngredientSelectorHasChanged: " + ex.Message);
            }
        }
Ejemplo n.º 5
0
 public static bool PreOnRecipeSelected(CraftingMenu __instance, int _index) // Called on select recipe or crafted
 {
     try
     {
         if (_index != -1)
         {
             List <KeyValuePair <int, Recipe> > m_complexeRecipes = (List <KeyValuePair <int, Recipe> >)AccessTools.Field(typeof(CraftingMenu), "m_complexeRecipes").GetValue(__instance);
             //WorkInProgress.Instance.MyLogger.LogDebug($"PreOnRecipeSelected: {m_complexeRecipes[_index].Value.name}");
             List <RecipeDisplay> m_recipeDisplays  = (List <RecipeDisplay>)AccessTools.Field(typeof(CraftingMenu), "m_recipeDisplays").GetValue(__instance);
             IList <int>          m_bestIngredients = (IList <int>)AccessTools.Field(typeof(RecipeDisplay), "m_bestIngredients").GetValue(m_recipeDisplays[_index]);
             if (dctIngr2.ContainsKey(m_complexeRecipes[_index].Value.name))
             {
                 //WorkInProgress.Instance.MyLogger.LogDebug($" > Load ingredients");
                 AccessTools.Field(typeof(RecipeDisplay), "m_bestIngredients").SetValue(m_recipeDisplays[_index], dctIngr2[m_complexeRecipes[_index].Value.name]);
             }
             //foreach (var item in m_bestIngredients)
             //{
             //    WorkInProgress.Instance.MyLogger.LogDebug($" > {item}");
             //}
         }
     }
     catch (Exception ex)
     {
         WorkInProgress.Instance.MyLogger.LogError("PreOnRecipeSelected: " + ex.Message);
     }
     return(true);
 }//*/
Ejemplo n.º 6
0
    public static void MenuUpdate()
    {
        CraftingMenu cMenu = ComponentManager <CraftingMenu> .Value;

        cMenu.creativeModeCategoryButton.SetActive(GameManager.GameMode == GameMode.Creative);
        shouldUpdateInventoryMenu = false;
    }
Ejemplo n.º 7
0
    public override void CreateMenu(RectTransform Parent)
    {
        mCraftingMenu = Instantiate(CraftingMenu.DefaultMenu, Parent);

        mTempInventory = new Inventory(RecipeData.MaxIngredients + 1, 1);

        mCraftingMenu.Construct(mTempInventory);
        mTempInventory.mChangeEvent += OnInventoryChange;
    }
Ejemplo n.º 8
0
 static private void SetSingleIngredientCrafting(CraftingMenu __instance, bool enabled = true)
 {
     __instance.m_multipleIngrenentsBrackground.SetAlpha(enabled ? 0f : 1f);
     __instance.m_singleIngredientBackground.SetAlpha(enabled ? 1f : 0f);
     for (int i = 1; i < __instance.m_ingredientSelectors.Length; i++)
     {
         __instance.m_ingredientSelectors[i].GOSetActive(!enabled);
     }
 }
Ejemplo n.º 9
0
 public void Start()
 {
     craftingMenu          = GameObject.Find("Player").GetComponent <CraftingMenu>();
     masterCraftingRecipes = GameObject.Find("SceneManager").GetComponent <MasterCraftList>().MasterCraftRecipies;
     playerInventory       = GameObject.Find("Player").GetComponent <Inventory>();
     if (outputInventory == null)
     {
         outputInventory = GetComponent <Inventory>();
     }
 }
Ejemplo n.º 10
0
        static void CraftingMenu_OnRecipeSelected_Post(CraftingMenu __instance)
        {
            #region quit
            if (!_limitedManualCrafting)
            {
                return;
            }
            #endregion

            SetSingleIngredientCrafting(__instance, __instance.m_lastRecipeIndex == -1);
        }
Ejemplo n.º 11
0
    void Start()
    {
        Instance = this;

        craftingMenu         = GetComponent <Canvas>();
        craftingMenu.enabled = false;

        Inventory.currentlyCrafting.Clear();

        outlines = GameObject.FindGameObjectsWithTag("ButtonOutline");
    }
Ejemplo n.º 12
0
        static void CraftingMenu_GenerateResult_Post(CraftingMenu __instance, ref int __state, ItemReferenceQuantity _result)
        {
            #region quit
            if (_extraResultsMultiplier == 100)
            {
                return;
            }
            #endregion

            _result.Quantity = __state;
        }
Ejemplo n.º 13
0
        static bool CraftingMenu_GenerateResult_Pre(CraftingMenu __instance, ref int __state, ItemReferenceQuantity _result)
        {
            #region quit
            if (_extraResultsMultiplier == 100)
            {
                return(true);
            }
            #endregion

            __state          = _result.Quantity;
            _result.Quantity = GetModifiedResultsAmount(_result);
            return(true);
        }
Ejemplo n.º 14
0
        static bool CraftingMenu_Show_Post(CraftingMenu __instance)
        {
            #region quit
            if (!_limitedManualCrafting ||
                __instance.m_craftingStationType != Recipe.CraftingType.Alchemy ||
                HasLearnedRecipe(__instance.LocalCharacter, _crystalPowderRecipe))
            {
                return(true);
            }
            #endregion

            LearnRecipe(__instance.LocalCharacter, _crystalPowderRecipe);
            return(true);
        }
Ejemplo n.º 15
0
        static void CraftingMenu_IngredientSelectorHasChanged_Post(CraftingMenu __instance, int _selectorIndex, int _itemID)
        {
            #region quit
            if (!_limitedManualCrafting || __instance.m_lastRecipeIndex >= 0)
            {
                return;
            }
            #endregion

            bool isMulti = _limitedManulCraftingExceptions.Value.HasFlag(CraftingExceptions.Lanterns) && _itemID.IsContainedIn(LANTERN_IDS) ||
                           _limitedManulCraftingExceptions.Value.HasFlag(CraftingExceptions.Relics) && _itemID.IsContainedIn(RELIC_IDS) ||
                           _limitedManulCraftingExceptions.Value.HasFlag(CraftingExceptions.HailfrostWeapons) && _itemID.IsContainedIn(HAILFROST_WEAPONS_IDS) ||
                           _limitedManulCraftingExceptions.Value.HasFlag(CraftingExceptions.UniqueWeapons) && _itemID.IsContainedIn(UNIQUE_WEAPONS_IDS);
            SetSingleIngredientCrafting(__instance, !isMulti);
        }
Ejemplo n.º 16
0
        static void CraftingMenu_CraftingDone_Post(CraftingMenu __instance, ref List <Item> __state)
        {
            #region quit
            if (__state == null)
            {
                return;
            }
            #endregion

            foreach (var item in __state)
            {
                if (item.Stats.TryAssign(out var stats))
                {
                    stats.StartingDurability = -1;
                }
            }
        }
Ejemplo n.º 17
0
    private void Start()
    {
        playerCrafter      = GetComponent <Crafter>();
        inventoryDisplayer = GetComponent <InventoryDisplayer>();
        animator           = GetComponent <AnimationManager>();
        inventory          = GetComponent <Inventory>();
        craftingMenu       = GetComponent <CraftingMenu>();

        hud              = GetComponent <PlayerHUD>();
        combat           = GetComponent <Combat>();
        Cursor.visible   = false;
        Cursor.lockState = CursorLockMode.Locked;

        FreeMove   = true;
        FreeLook   = true;
        camControl = playerCamera.GetComponent <CameraControl>();
    }
Ejemplo n.º 18
0
            private static void OnCrafted(object sender, EventArgs e)
            {
                var heldItem = CraftingMenu.GetFieldValue <Object>(CraftingPageHeldItemField);

                if (PreviousCraftedObject == heldItem)
                {
                    return;
                }

                var args = new ObjectEventArgs(heldItem);

                CraftedObjectChanged?.Invoke(args);
                if (heldItem != args.Object)
                {
                    CraftingMenu.SetFieldValue(CraftingPageHeldItemField, PreviousCraftedObject = args.Object);
                }
            }
Ejemplo n.º 19
0
 void Awake()
 {
     Text[] texts = GetComponentsInChildren <Text>();
     if (texts[0].gameObject.name == "Name")
     {
         nameText  = texts[0];
         countText = texts[1];
     }
     else
     {
         nameText  = texts[1];
         countText = texts[0];
     }
     but = GetComponent <Button>();
     but.onClick.AddListener(Clicked);
     menu = GetComponentInParent <CraftingMenu>();
 }
Ejemplo n.º 20
0
            private static void OnCrafted(object sender, EventArgs e)
            {
                var heldItem = CraftingMenu.GetField <Item>("heldItem") as Object;

                if (PreviousCraftedObject == heldItem)
                {
                    return;
                }

                var args = new ObjectEventArgs(heldItem);

                CraftedObjectChanged?.Invoke(args);
                if (heldItem != args.Object)
                {
                    CraftingMenu.SetField <Item>("heldItem", PreviousCraftedObject = args.Object);
                }
            }
Ejemplo n.º 21
0
    void Start()
    {
        Instance = this;

        isOpen = false;
        ToggleMenu();

        if (selectedItem == null)
        {
            var firstItem = GetComponentInChildren <CraftListItem>();
            if (firstItem)
            {
                ListItemSelected(firstItem);
            }
        }

        ToggleMenu();
    }
Ejemplo n.º 22
0
        static private List <Item> GetDestructibleIngredients(CraftingMenu craftingMenu)
        {
            List <Item> destructibleIngredients = new List <Item>();

            foreach (var ingredientSelector in craftingMenu.m_ingredientSelectors)
            {
                if (ingredientSelector.AssignedIngredient.TryAssign(out var ingredient))
                {
                    foreach (var itemAmountByUID in ingredient.GetConsumedItems(false, out _))
                    {
                        if (ItemManager.Instance.GetItem(itemAmountByUID.Key).TryAssign(out var item) &&
                            item.MaxDurability > 0)
                        {
                            destructibleIngredients.TryAddUnique(item);
                        }
                    }
                }
            }
            return(destructibleIngredients);
        }
Ejemplo n.º 23
0
    public static void DeterminePossibleItems(bool craftingMenuOpen)
    {
        //loop thru allItems list, if an item's requiremnts list is the same length and
        //contains the same elements as the currentlyCrafting list add it to possibleItems list

        foreach (Item item in allItemsCopy)
        {
            Debug.Log("currently crafting length: " + Inventory.currentlyCrafting.Count);
            if (Inventory.currentlyCrafting.Count == item.requirements.Count)
            {
                bool noMatch = false;
                foreach (string req in Inventory.currentlyCrafting)
                {
                    Debug.Log("Current Craft: " + req + " present? " + item.requirements.Contains(req));
                    if (!item.requirements.Contains(req))
                    {
                        noMatch = true;
                    }
                }

                if (!noMatch)
                {
                    if (!Crafting.possibleItems.Contains(item))
                    {
                        Crafting.possibleItems.Add(item);
                    }
                }
            }
        }

        Debug.Log("Current Possible Items: " + possibleItems.Count);

        if (!craftingMenuOpen)
        {
            PossibleItemsMenu.ShowItems();
        }
        else
        {
            CraftingMenu.ShowResults();
        }
    }
Ejemplo n.º 24
0
        static private List <Item> GetDestructibleResults(CraftingMenu craftingMenu)
        {
            // Choose recipe index
            int         selectorIndex        = craftingMenu.m_lastRecipeIndex;
            int         recipeIndex          = selectorIndex >= 0 ? craftingMenu.m_complexeRecipes[selectorIndex].Key : craftingMenu.m_lastFreeRecipeIndex;
            List <Item> desctructibleResults = new List <Item>();

            // Execute
            if (recipeIndex >= 0)
            {
                Recipe recipe = craftingMenu.m_allRecipes[recipeIndex];
                foreach (var result in recipe.Results)
                {
                    if (result.RefItem.TryAssign(out var item) &&
                        item.MaxDurability > 0)
                    {
                        desctructibleResults.TryAddUnique(item);
                    }
                }
            }
            return(desctructibleResults);
        }
Ejemplo n.º 25
0
    void Start()
    {
        craftingUiMenu = uiElementFactory.CreateCraftingMenu();

        orderSnippet = GetComponentInChildren <CraftingOrderSnippet>();

        // Not in conversation by default
        craftingConversationBehavior.enabled = false;

        craftingUiMenu.TailoredUiEvent += OnCraftingMenuStatusChange;

        CustomerDialogueTracker.IntroDialogueEnded     += OnCustomerIntroEndMoveToCraftingView;
        CustomerDialogueTracker.OutroDialogueTriggered += OnDialogueOutroExitFocusedView;

        InventoryButton.InventoryButtonPressed += OnInventoryButtonPressed;

        RecipeProgressTracker.onRecipeCompleted.AddListener(OnRecipeCompleted);

        toolkitMenu.ToolRollout += OnToolRollout;
        toolkitMenu.gameObject.SetActive(false);

        uiElementFactory.CreateDefaultCraftingActionWidget(craftingButton, craftingUiMenu.CraftingButtonContainer);
    }
Ejemplo n.º 26
0
 public static bool TryCraft(CraftingMenu __instance)
 {
     try
     {
         int  m_lastRecipeIndex = (int)AccessTools.Field(typeof(CraftingMenu), "m_lastRecipeIndex").GetValue(__instance);
         bool m_canCraft        = (bool)AccessTools.Field(typeof(CraftingMenu), "m_canCraft").GetValue(__instance);
         if (m_lastRecipeIndex == -1 && m_canCraft)
         {
             int num = 0;
             CompatibleIngredient compatibleIngredient  = null;
             IngredientSelector[] m_ingredientSelectors = (IngredientSelector[])AccessTools.Field(typeof(CraftingMenu), "m_ingredientSelectors").GetValue(__instance);
             for (int i = 0; i < m_ingredientSelectors.Length; i++)
             {
                 if (m_ingredientSelectors[i].AssignedIngredient != null && !m_ingredientSelectors[i].IsMissingIngredient)
                 {
                     compatibleIngredient = m_ingredientSelectors[i].AssignedIngredient;
                     num++;
                 }
             }
             if (num == 1 && compatibleIngredient != null)
             {
                 // lasyan3 : rancid water needs other ingredients to be cleaned
                 if (compatibleIngredient.IsWaterItem && compatibleIngredient.WaterType == WaterType.Rancid)
                 {
                     CharacterUI m_characterUI = (CharacterUI)AccessTools.Field(typeof(CraftingMenu), "m_characterUI").GetValue(__instance);
                     m_characterUI.ShowInfoNotificationLoc("Cleaning such water needs one more ingredient...");
                     return(false);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         WorkInProgress.Instance.MyLogger.LogError("TryCraft: " + ex.Message);
     }
     return(true);
 }
Ejemplo n.º 27
0
    void Start()
    {
        _uiCamera      = GetComponentInChildren <Camera>();
        _touchInput    = GetComponent <TouchInput>();
        _nontouchInput = GetComponent <NontouchInput>();
        _craftingMenu  = GetComponent <CraftingMenu>();

#if UNITY_EDITOR || UNITY_STANDALONE || UNITY_WEBPLAYER
        _touchInput.enabled = false;
#elif (UNITY_ANDROID || UNITY_IOS) && !UNITY_EDITOR
        _nontouchInput.enabled = false;
#endif

        _playerHeartBox = GameManager.Player.gameObject.GetComponentInChildren <HeartBox>();
        Transform hurtVignette = (Transform)Instantiate(HurtVignette, HurtVignette.position, HurtVignette.rotation);
        hurtVignette.parent = transform;
        _hurtVignetteAlpha  = hurtVignette.GetComponent <AlphaPulse>();

        Transform chaseVignette = (Transform)Instantiate(ChaseVignette, ChaseVignette.position, ChaseVignette.rotation);
        chaseVignette.parent = transform;
        _chaseVignetteAlpha  = chaseVignette.GetComponent <AlphaPulse>();

        Transform searchVignette = (Transform)Instantiate(SearchVignette, SearchVignette.position, SearchVignette.rotation);
        searchVignette.parent = transform;
        _searchVignetteAlpha  = searchVignette.GetComponent <AlphaPulse>();

        Transform flash = (Transform)Instantiate(LensFlareFlash, LensFlareFlash.position, LensFlareFlash.rotation);
        flash.parent = transform;
        _flashAlpha  = flash.GetComponent <AlphaPulse>();
        _hasFlashed  = false;

        _matteBars        = (Transform)Instantiate(MatteBars, MatteBars.position, MatteBars.rotation);
        _matteBars.parent = transform;
        Transform stealthKillVignette = (Transform)Instantiate(StealthKillVignette, StealthKillVignette.position, StealthKillVignette.rotation);
        stealthKillVignette.parent = transform;
        _stealthKillVignette       = stealthKillVignette.GetComponent <Fader>();
        Color stealthColor = _stealthKillVignette.GetComponent <Renderer>().material.color;
        stealthColor.a = 0;
        _stealthKillVignette.GetComponent <Renderer>().material.color = stealthColor;

        Transform stealthKillVignette1 = (Transform)Instantiate(StealthKillVignette1, StealthKillVignette1.position, StealthKillVignette1.rotation);
        stealthKillVignette1.parent = transform;
        _stealthKillVignette1       = stealthKillVignette1.GetComponent <Fader>();
        _stealthKillVignette1.GetComponent <Renderer>().material.color = stealthColor;

        Transform stealthKillVignette2 = (Transform)Instantiate(StealthKillVignette2, StealthKillVignette2.position, StealthKillVignette2.rotation);
        stealthKillVignette2.parent = transform;
        _stealthKillVignette2       = stealthKillVignette2.GetComponent <Fader>();
        _stealthKillVignette2.GetComponent <Renderer>().material.color = stealthColor;

        _weaponWheelPos = new Vector3(1, 1, 8);
        _weaponWheelPos = _uiCamera.ViewportToWorldPoint(_weaponWheelPos);
        _currentWeapon  = 0;

        // weapon quads at proper positions
        _weaponQuads      = new GameObject[3];
        _weaponCountQuads = new GameObject[3];

        Vector3 quadPos = _weaponWheelPos + Vector3.left * WeaponRadius;
        quadPos.z        = -4.0f;
        _weaponQuads [0] = (GameObject)Instantiate(WeaponQuadPrefab, quadPos, Quaternion.identity);
        _weaponQuads [0].transform.parent = _craftingMenu.WeaponWheel.transform;

        quadPos          = _weaponWheelPos + Vector3.RotateTowards(Vector3.left, Vector3.down, Mathf.PI / 4.0f, 0.0f) * WeaponRadius;
        quadPos.z        = -4.0f;
        _weaponQuads [1] = (GameObject)Instantiate(WeaponQuadPrefab, quadPos, Quaternion.identity);
        _weaponQuads [1].transform.parent = _craftingMenu.WeaponWheel.transform;

        quadPos          = _weaponWheelPos + Vector3.down * WeaponRadius;
        quadPos.z        = -4.0f;
        _weaponQuads [2] = (GameObject)Instantiate(WeaponQuadPrefab, quadPos, Quaternion.identity);
        _weaponQuads [2].transform.parent = _craftingMenu.WeaponWheel.transform;

        quadPos               = _weaponWheelPos + Vector3.left * WeaponCountRadius;
        quadPos.z             = -4.0f;
        _weaponCountQuads [0] = (GameObject)Instantiate(WeaponCountQuadPrefab, quadPos, Quaternion.identity);
        _weaponCountQuads [0].transform.parent = _craftingMenu.WeaponWheel.transform;

        quadPos               = _weaponWheelPos + Vector3.RotateTowards(Vector3.left, Vector3.down, Mathf.PI / 4.0f, 0.0f) * WeaponCountRadius;
        quadPos.z             = -4.0f;
        _weaponCountQuads [1] = (GameObject)Instantiate(WeaponCountQuadPrefab, quadPos, Quaternion.identity);
        _weaponCountQuads [1].transform.parent = _craftingMenu.WeaponWheel.transform;

        quadPos               = _weaponWheelPos + Vector3.down * WeaponCountRadius;
        quadPos.z             = -4.0f;
        _weaponCountQuads [2] = (GameObject)Instantiate(WeaponCountQuadPrefab, quadPos, Quaternion.identity);
        _weaponCountQuads [2].transform.parent = _craftingMenu.WeaponWheel.transform;


        // *** track player objectives ***
        _playerObjectives = GetComponent <ObjectiveTracker>();

        ObjectiveQuadPos   = _uiCamera.ViewportToWorldPoint(ObjectiveQuadPos);
        ObjectiveQuadPos.z = 8.0f;
        _objectiveQuad     = (GameObject)Instantiate(ObjectiveQuadPrefab, ObjectiveQuadPos, Quaternion.identity);
        _objectiveQuad.transform.parent = transform;

        // load map

        /* TODO: GameObject mapQuad = (GameObject)Instantiate (MapQuadPrefab, _uiCamera.ViewportToWorldPoint (new Vector3 (0.5f, 0.5f, 7.0f)), Quaternion.identity);
         * _mapQuad = mapQuad.GetComponent<MapQuad> ();
         * _mapQuad.transform.parent = transform;
         * _mapQuad.gameObject.SetActive (false);*/

        // *** add all game objects to map ***
        // TODO: _mapQuad.renderer.material.mainTexture = Resources.Load<Texture2D> ("Textures/User Interface/Maps/Commercial Zone Map");
        //   _mapQuad.renderer.material.color = new Color (_mapQuad.renderer.material.color.r,
        //                                                 _mapQuad.renderer.material.color.g,
        //                                                 _mapQuad.renderer.material.color.b,
        //                                                 1.0f);

        // *** set up hints ***
        _hintQuad = (GameObject)Instantiate(HintQuadPrefab, _uiCamera.ViewportToWorldPoint(new Vector3(0.20f, 0.80f, 7.0f)), Quaternion.identity);
        _hintQuad.transform.parent = transform;
        _hintQuad.GetComponent <Renderer>().enabled = false;
        _hintDuration = 0.0f;
        _hintElapsed  = 0.0f;


        _isTrackingSwipe = false;
        _swipeID         = -1;
        _swipeStartPos   = Vector3.zero;

        _ready = true;
    }
Ejemplo n.º 28
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatchView   = new SpriteBatch(GraphicsDevice);
            spriteBatchStatic = new SpriteBatch(GraphicsDevice);

            // PREPROCESSING Bounding Sprites
            Texture2D textureBaseShip = Content.Load <Texture2D>("BaseShip");

            LoadDynamicBoundingBoxPerFrame(true, 8, 1, textureBaseShip, "baseShip", 0.6f, 1.0f);
            Texture2D textureBaseSail = Content.Load <Texture2D>("DecomposedBaseSail");

            LoadDynamicBoundingBoxPerFrame(false, 8, 3, textureBaseSail, "baseSail", 0.6f, 1.0f);
            Texture2D textureShortShip = Content.Load <Texture2D>("ShortShipHullRedMark");

            LoadDynamicBoundingBoxPerFrame(true, 8, 1, textureShortShip, "shortShip", 1.1f, 1.0f);
            Texture2D textureShortSail = Content.Load <Texture2D>("ShortSail");

            LoadDynamicBoundingBoxPerFrame(false, 8, 3, textureShortSail, "shortSail", 1.1f, 1.0f);
            Texture2D textureTeePee = Content.Load <Texture2D>("TeePee");

            LoadDynamicBoundingBoxPerFrame(true, 1, 4, textureTeePee, "teePee", 0.5f, 1.0f);
            Texture2D texturePlayerPirate = Content.Load <Texture2D>("Pirate1-combat");

            LoadDynamicBoundingBoxPerFrame(false, 4, 11, texturePlayerPirate, "playerPirate", 1.0f, 1.0f);
            Texture2D textureBaseTribal = Content.Load <Texture2D>("Tribal1");

            LoadDynamicBoundingBoxPerFrame(false, 4, 12, textureBaseTribal, "baseTribal", 1.0f, 1.0f);
            Texture2D textureBaseCat = Content.Load <Texture2D>("Cat1");

            LoadDynamicBoundingBoxPerFrame(false, 4, 12, textureBaseCat, "baseCat", 0.7f, 1.0f);
            Texture2D textureChicken = Content.Load <Texture2D>("Chicken");

            LoadDynamicBoundingBoxPerFrame(false, 4, 10, textureChicken, "chicken", 0.7f, 1.0f);
            Texture2D textureSnake = Content.Load <Texture2D>("Snake1");

            LoadDynamicBoundingBoxPerFrame(false, 5, 9, textureSnake, "snake", 0.7f, 1.0f);
            Texture2D textblueBird = Content.Load <Texture2D>("BlueBird");

            LoadDynamicBoundingBoxPerFrame(false, 5, 4, textblueBird, "blueBird", 0.4f, 1.0f);
            Texture2D textureBaseSword = Content.Load <Texture2D>("BaseSword");

            LoadDynamicBoundingBoxPerFrame(false, 4, 3, textureBaseSword, "baseSword", 1.0f, 1.0f);
            Texture2D texturePistol = Content.Load <Texture2D>("pistol");

            LoadDynamicBoundingBoxPerFrame(false, 4, 3, texturePistol, "pistol", 1.0f, 1.0f);
            Texture2D textureCrossBow = Content.Load <Texture2D>("crossBow");

            LoadDynamicBoundingBoxPerFrame(false, 4, 3, textureCrossBow, "crossBow", 1.0f, 1.0f);
            Texture2D texturePickaxe = Content.Load <Texture2D>("pickaxe");

            LoadDynamicBoundingBoxPerFrame(false, 4, 3, texturePickaxe, "pickaxe", 1.0f, 1.0f);
            Texture2D textureShortSword = Content.Load <Texture2D>("ShortSword");

            LoadDynamicBoundingBoxPerFrame(false, 4, 3, textureShortSword, "shortSword", 1.0f, 1.0f);
            Texture2D textureShovel = Content.Load <Texture2D>("Shovel");

            LoadDynamicBoundingBoxPerFrame(false, 4, 3, textureShovel, "shovel", 1.0f, 1.0f);
            Texture2D textureTower = Content.Load <Texture2D>("tower");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureTower, "tower", 0.5f, 1.0f);

            Texture2D textureCannonBall = Content.Load <Texture2D>("CannonBall");

            LoadDynamicBoundingBoxPerFrame(false, 1, 2, textureCannonBall, "baseCannonBall", 1.0f, 1.0f);
            Texture2D textureCannonBallItem = Content.Load <Texture2D>("CannonBall");

            LoadDynamicBoundingBoxPerFrame(false, 1, 2, textureCannonBallItem, "cannonBallItem", 1.0f, 1.0f);
            Texture2D texturePistolShot = Content.Load <Texture2D>("PistolShot");

            LoadDynamicBoundingBoxPerFrame(false, 1, 2, texturePistolShot, "pistolShot", 1.0f, 1.0f);
            Texture2D texturePistolShotItem = Content.Load <Texture2D>("PistolShot");

            LoadDynamicBoundingBoxPerFrame(false, 1, 2, texturePistolShotItem, "pistolShotItem", 1.0f, 1.0f);
            Texture2D textureArrowItem = Content.Load <Texture2D>("Arrow");

            LoadDynamicBoundingBoxPerFrame(false, 1, 2, textureArrowItem, "arrowItem", 1.0f, 1.0f);
            Texture2D textureArrow = Content.Load <Texture2D>("Arrow");

            LoadDynamicBoundingBoxPerFrame(false, 1, 2, textureArrow, "arrow", 1.0f, 0.5f); // SCALING BOUNDING BOX FOR DIRECTIONAL AMMO
            Texture2D textureRustyHarpoonItem = Content.Load <Texture2D>("RustyHarpoon");

            LoadDynamicBoundingBoxPerFrame(false, 1, 2, textureRustyHarpoonItem, "rustyHarpoonItem", 1.0f, 0.5f);
            Texture2D textureRustyHarpoon = Content.Load <Texture2D>("RustyHarpoon");

            LoadDynamicBoundingBoxPerFrame(false, 1, 2, textureRustyHarpoon, "rustyHarpoon", 1.0f, 0.5f); // SCALING BOUNDING BOX FOR DIRECTIONAL AMMO

            Texture2D textureBaseCannon = Content.Load <Texture2D>("BaseCannon");

            LoadDynamicBoundingBoxPerFrame(false, 1, 4, textureBaseCannon, "baseCannon", 1.0f, 1.0f);
            Texture2D textureBallista = Content.Load <Texture2D>("Ballista");

            LoadDynamicBoundingBoxPerFrame(false, 1, 4, textureBallista, "ballista", 1.0f, 1.0f);
            Texture2D textureLantern = Content.Load <Texture2D>("Lantern");

            LoadDynamicBoundingBoxPerFrame(false, 4, 3, textureLantern, "lantern", 1.0f, 1.0f);
            Texture2D textureBarrel = Content.Load <Texture2D>("Barrel");

            LoadDynamicBoundingBoxPerFrame(false, 2, 3, textureBarrel, "baseBarrel", 0.5f, 1.0f);
            Texture2D textureChest = Content.Load <Texture2D>("Barrel");

            LoadDynamicBoundingBoxPerFrame(false, 2, 3, textureChest, "baseChest", 0.5f, 1.0f);

            Texture2D textureClayFurnace = Content.Load <Texture2D>("Furnace");

            LoadDynamicBoundingBoxPerFrame(false, 1, 6, textureClayFurnace, "clayFurnace", 0.5f, 1.0f);
            Texture2D textureCraftingAnvil = Content.Load <Texture2D>("Anvil");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureCraftingAnvil, "craftingAnvil", 0.5f, 1.0f);
            Texture2D textureCampFire = Content.Load <Texture2D>("CampFire");

            LoadDynamicBoundingBoxPerFrame(false, 1, 6, textureCampFire, "campFire", 0.3f, 1.0f);

            // Tile Pieces, Ground Objects and Invetory Items
            Texture2D textureOcean1 = Content.Load <Texture2D>("Ocean1v3");

            LoadDynamicBoundingBoxPerFrame(false, 4, 1, textureOcean1, "oceanTile", 1.0f, 1.0f);
            Texture2D textureLand1 = Content.Load <Texture2D>("Land1HolesShore");

            LoadDynamicBoundingBoxPerFrame(false, 9, 4, textureLand1, "landTile", 1.0f, 1.0f);
            //Texture2D textureShipDeck1 = Content.Load<Texture2D>("ShipDeck");
            //LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureShipDeck1, "interiorTile", 1.0f, 1.0f);
            //Texture2D textureShipDeck1Wall = Content.Load<Texture2D>("ShipDeckWall");
            //LoadDynamicBoundingBoxPerFrame(false, 1, 4, textureShipDeck1Wall, "interiorTileWall", 1.0f, 1.0f);
            Texture2D textureShipInterior1 = Content.Load <Texture2D>("ShipInterior");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureShipInterior1, "interiorTile", 1.0f, 1.0f);
            Texture2D textureShipInterior1Wall = Content.Load <Texture2D>("ShipInteriorWall");

            LoadDynamicBoundingBoxPerFrame(false, 1, 4, textureShipInterior1Wall, "interiorTileWall", 1.0f, 1.0f);
            Texture2D textureTree1 = Content.Load <Texture2D>("Tree1");

            LoadDynamicBoundingBoxPerFrame(true, 2, 6, textureTree1, "tree1", 0.6f, 1.0f);
            Texture2D textureTree2 = Content.Load <Texture2D>("Tree2");

            LoadDynamicBoundingBoxPerFrame(true, 2, 4, textureTree2, "tree2", 0.6f, 1.0f);
            Texture2D textureTree3 = Content.Load <Texture2D>("Tree3");

            LoadDynamicBoundingBoxPerFrame(true, 2, 4, textureTree3, "tree3", 0.6f, 1.0f);
            Texture2D textureSoftWood = Content.Load <Texture2D>("softwoodpile");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureSoftWood, "softWood", 0.5f, 1.0f);
            Texture2D textureGrass1 = Content.Load <Texture2D>("RevisedGrass1");

            LoadDynamicBoundingBoxPerFrame(false, 1, 2, textureGrass1, "grass1", 0.6f, 1.0f);
            Texture2D textureRock1 = Content.Load <Texture2D>("Rock1");

            LoadDynamicBoundingBoxPerFrame(false, 2, 4, textureRock1, "rock1", 0.3f, 1.0f);
            Texture2D textureIslandGrass = Content.Load <Texture2D>("islandGrass");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureIslandGrass, "islandGrass", 0.5f, 1.0f);
            Texture2D textureChiliFish = Content.Load <Texture2D>("ChiliFish");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureChiliFish, "chiliFish", 0.5f, 1.0f);
            Texture2D textureChiliPepper = Content.Load <Texture2D>("ChiliPepper");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureChiliPepper, "chiliPepper", 0.5f, 1.0f);
            Texture2D textureCookedFish = Content.Load <Texture2D>("CookedFish");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureCookedFish, "cookedFish", 0.5f, 1.0f);
            Texture2D textureCookedMeat = Content.Load <Texture2D>("CookedMeat");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureCookedMeat, "cookedMeat", 0.5f, 1.0f);
            Texture2D textureFeather = Content.Load <Texture2D>("Feather");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureFeather, "feather", 0.5f, 1.0f);
            Texture2D textureFishOil = Content.Load <Texture2D>("FishOil");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureFishOil, "fishOil", 0.5f, 1.0f);
            Texture2D textureGoldCoins = Content.Load <Texture2D>("GoldCoins");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureGoldCoins, "goldCoins", 0.5f, 1.0f);
            Texture2D textureRawFish = Content.Load <Texture2D>("RawFish");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureRawFish, "rawFish", 0.5f, 1.0f);
            Texture2D textureRawMeat = Content.Load <Texture2D>("RawMeat");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureRawMeat, "rawMeat", 0.5f, 1.0f);
            Texture2D textureScales = Content.Load <Texture2D>("Scales");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureScales, "scales", 0.5f, 1.0f);
            Texture2D textureSpoiledFish = Content.Load <Texture2D>("SpoiledFish");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureSpoiledFish, "spoiledFish", 0.5f, 1.0f);
            Texture2D textureSpoiledMeat = Content.Load <Texture2D>("SpoiledMeat");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureSpoiledMeat, "spoiledMeat", 0.5f, 1.0f);
            Texture2D textureCoal = Content.Load <Texture2D>("coal");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureCoal, "coal", 1.0f, 1.0f);
            Texture2D textureNails = Content.Load <Texture2D>("Nails");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureNails, "nails", 0.4f, 1.0f);
            Texture2D textureIronOre = Content.Load <Texture2D>("IronOre");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureIronOre, "ironOre", 1.0f, 1.0f);
            Texture2D textureIronBar = Content.Load <Texture2D>("IronBar");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureIronBar, "ironBar", 1.0f, 1.0f);
            Texture2D textureTribalTokens = Content.Load <Texture2D>("TribalTokens");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureTribalTokens, "tribalTokens", 0.5f, 1.0f);
            Texture2D textureBasePlank = Content.Load <Texture2D>("plank");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureBasePlank, "basePlank", 0.5f, 1.0f);
            Texture2D textureClayFurnaceItem = Content.Load <Texture2D>("Furnace");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureClayFurnaceItem, "clayFurnaceItem", 1.0f, 1.0f);
            Texture2D textureAnvilItem = Content.Load <Texture2D>("Furnace");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureAnvilItem, "anvilItem", 1.0f, 1.0f);
            Texture2D textureBarrelItem = Content.Load <Texture2D>("Barrel");

            LoadDynamicBoundingBoxPerFrame(false, 2, 3, textureBarrelItem, "baseBarrelItem", 1.0f, 1.0f);
            Texture2D textureChestItem = Content.Load <Texture2D>("BaseChest");

            LoadDynamicBoundingBoxPerFrame(false, 2, 3, textureChestItem, "baseChestItem", 1.0f, 1.0f);
            Texture2D textureTreasureMap = Content.Load <Texture2D>("TreasureMap");

            LoadDynamicBoundingBoxPerFrame(false, 1, 1, textureTreasureMap, "treasureMapItem", 0.5f, 1.0f);

            gameState = new GameState(Content, GraphicsDevice);

            // Game Map
            mapData = JObject.Parse(File.ReadAllText(@"C:\Users\GMON\source\repos\GustoGame\GustoGame\Content\gamemap.json"));
            map.SetGameMap(Content, GraphicsDevice, spriteBatchView, mapData);
            BuildRegionTree();

            var screenCenter = new Vector2(GraphicsDevice.Viewport.Bounds.Width / 2, GraphicsDevice.Viewport.Bounds.Height / 2);

            // static load
            anchorIcon    = Content.Load <Texture2D>("anchor-shape");
            repairIcon    = Content.Load <Texture2D>("work-hammer-");
            boardingIcon  = Content.Load <Texture2D>("icons8-sword-52");
            treasureXMark = Content.Load <Texture2D>("XSpot");
            font          = Content.Load <SpriteFont>("helperFont");

            windArrows        = new WindArrows(new Vector2(1740, 50), Content, GraphicsDevice);
            WeatherState.wind = windArrows;

            // static init (MENUS)
            inventoryMenu = new Inventory(screenCenter, Content, GraphicsDevice, gameState.player);
            craftingMenu  = new CraftingMenu(screenCenter, Content, GraphicsDevice, gameState.player);
            startingMenu  = new OpenGameMenu(Content, GraphicsDevice);
        }
Ejemplo n.º 29
0
        public static bool OnIngredientSelectorClicked(CraftingMenu __instance, int _selectorIndex)
        {
            try
            {
                IngredientSelector[] m_ingredientSelectors         = (IngredientSelector[])AccessTools.Field(typeof(CraftingMenu), "m_ingredientSelectors").GetValue(__instance);
                List <int>           ingredientSelectorCachedItems = (List <int>)AccessTools.Field(typeof(CraftingMenu), "ingredientSelectorCachedItems").GetValue(__instance);
                int m_lastRecipeIndex = (int)AccessTools.Field(typeof(CraftingMenu), "m_lastRecipeIndex").GetValue(__instance);
                List <KeyValuePair <int, Recipe> > m_complexeRecipes = (List <KeyValuePair <int, Recipe> >)AccessTools.Field(typeof(CraftingMenu), "m_complexeRecipes").GetValue(__instance);
                List <RecipeDisplay> m_recipeDisplays = (List <RecipeDisplay>)AccessTools.Field(typeof(CraftingMenu), "m_recipeDisplays").GetValue(__instance);
                DictionaryExt <int, CompatibleIngredient> m_availableIngredients = (DictionaryExt <int, CompatibleIngredient>)AccessTools.Field(typeof(CraftingMenu), "m_availableIngredients").GetValue(__instance);
                CharacterUI      m_characterUI        = (CharacterUI)AccessTools.Field(typeof(CraftingMenu), "m_characterUI").GetValue(__instance);
                ItemListSelector m_tempSelectorWindow = (ItemListSelector)AccessTools.Field(typeof(CraftingMenu), "m_tempSelectorWindow").GetValue(__instance);
                Transform        m_selectorWindowPos  = (Transform)AccessTools.Field(typeof(CraftingMenu), "m_selectorWindowPos").GetValue(__instance);
                bool             m_simpleMode         = (bool)AccessTools.Field(typeof(CraftingMenu), "m_simpleMode").GetValue(__instance);

                IngredientSelector ingredientSelector = m_ingredientSelectors[_selectorIndex];
                ingredientSelectorCachedItems.Clear();
                if (m_lastRecipeIndex != -1)
                {
                    if (m_complexeRecipes[m_lastRecipeIndex].Value.Ingredients[_selectorIndex].ActionType == RecipeIngredient.ActionTypes.AddGenericIngredient)
                    {
                        IList <int> stepCompatibleIngredients = m_recipeDisplays[m_lastRecipeIndex].GetStepCompatibleIngredients(_selectorIndex);
                        for (int i = 0; i < stepCompatibleIngredients.Count; i++)
                        {
                            if (m_availableIngredients.TryGetValue(stepCompatibleIngredients[i], out CompatibleIngredient _outValue) && _outValue.AvailableQty > 0)
                            {
                                ingredientSelectorCachedItems.Add(_outValue.ItemID);
                            }
                        }
                    }
                }
                else
                {
                    for (int j = 0; j < m_availableIngredients.Count; j++)
                    {
                        if (m_availableIngredients.Values[j].AvailableQty > 0 || ingredientSelector.AssignedIngredient == m_availableIngredients.Values[j])
                        {
                            // lasyan3 : Disallow cleaning water without cooking pot
                            if (m_availableIngredients.Values[j].IsWaterItem && m_simpleMode)
                            {
                                continue;
                            }
                            // lasyan3 : Disallow use of rancid water
                            //if (m_availableIngredients.Values[j].IsWaterItem && m_availableIngredients.Values[j].ItemPrefab.ItemID == (int)eItemIDs.RancidWater) continue;
                            ingredientSelectorCachedItems.Add(m_availableIngredients.Values[j].ItemID);
                        }
                    }
                }
                if (ingredientSelectorCachedItems.Count > 0)
                {
                    m_tempSelectorWindow = m_characterUI.GetListSelector();
                    if ((bool)m_tempSelectorWindow)
                    {
                        m_tempSelectorWindow.onItemHovered = __instance.RefreshItemDetailDisplay;
                        m_tempSelectorWindow.onItemClicked = delegate(IItemDisplay _display)
                        {
                            __instance.IngredientSelectorHasChanged(_selectorIndex, _display?.RefItem.ItemID ?? (-1));
                            m_tempSelectorWindow.Hide();
                        };
                        m_tempSelectorWindow.Position = (((bool)m_selectorWindowPos) ? m_selectorWindowPos.position : __instance.transform.position);
                        m_tempSelectorWindow.Title    = ingredientSelector.Text;
                        m_tempSelectorWindow.ShowSelector(ingredientSelectorCachedItems, ingredientSelector.gameObject, m_lastRecipeIndex == -1);
                    }
                }
            }
            catch (Exception ex)
            {
                WorkInProgress.Instance.MyLogger.LogError("OnIngredientSelectorClicked: " + ex.Message);
            }
            return(false);
        }