75 lines
2.7 KiB
C#
75 lines
2.7 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
namespace Beyond
|
|
{
|
|
public class UseGemstoneStep : MonoBehaviour
|
|
{
|
|
private const int shadowSlayerItemID = 3;
|
|
public BaseStepController baseStepController;
|
|
public MenuScroll menuScroll;
|
|
private bool usedGemstone = false;
|
|
public bEquipArea weaponsArea;
|
|
public PanelSwitcher weaponsPanelSwitcher;
|
|
public bItemWindow resourcesWindow;
|
|
public GameObject middleArrow, bottomArrow;
|
|
|
|
private void Start()
|
|
{
|
|
// equipSlots = equipArea.equipSlots;
|
|
baseStepController.OnStarted += () => { ShowCorrectPointingArrow(); Player.Instance.ItemManager.onUseItem.AddListener(TryToMarkAsSwordPowered); };
|
|
baseStepController.ConditionsAreMet += () => usedGemstone;
|
|
baseStepController.OnCompleted += () => { CloseMenu(); Player.Instance.ItemManager.onUseItem.RemoveListener(TryToMarkAsSwordPowered); TryToSelectShadowSlayer(); };
|
|
}
|
|
|
|
private void ShowCorrectPointingArrow()
|
|
{
|
|
if (resourcesWindow.slots.Count > 2)
|
|
{
|
|
middleArrow.SetActive(false);
|
|
bottomArrow.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
middleArrow.SetActive(true);
|
|
bottomArrow.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void CloseMenu()
|
|
{
|
|
menuScroll.CloseScroll();
|
|
}
|
|
|
|
public void TryToSelectShadowSlayer()
|
|
{
|
|
bEquipSlot slot = weaponsArea.equipSlots.Find(slot => slot.item && slot.item.id == shadowSlayerItemID);
|
|
if (!slot) //
|
|
{
|
|
bItem item = Player.Instance.ItemManager.items.Find(item => item.id == shadowSlayerItemID);
|
|
if (!item) //if for some reason cant find the sword in inventory, should not be possible to happen, but in case...
|
|
{
|
|
return;
|
|
}
|
|
weaponsArea.AddItemToEquipSlot(weaponsArea.currentSelectedSlot, item);
|
|
}
|
|
else if (weaponsArea.currentEquippedSlot.item.id != shadowSlayerItemID)
|
|
{
|
|
int slayerAreaIndex = weaponsArea.equipSlots.FindIndex(wSlot => wSlot.item.id == shadowSlayerItemID);
|
|
weaponsPanelSwitcher.SetPanelToIndex(slayerAreaIndex);
|
|
}
|
|
}
|
|
|
|
public void TryToMarkAsSwordPowered(bItem itemUsed)
|
|
{
|
|
if (itemUsed.type == bItemType.Gemstones)
|
|
{
|
|
usedGemstone = true;
|
|
}
|
|
|
|
Player.Instance.ItemManager.onUseItem.RemoveListener(TryToMarkAsSwordPowered);
|
|
}
|
|
}
|
|
} |