59 lines
1.1 KiB
C#
59 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class MateriSelector : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
protected MateriList materiList;
|
|
|
|
protected int currentIndex = 0;
|
|
public int CurrentIndex => currentIndex;
|
|
|
|
public void ClampIndex()
|
|
{
|
|
if(materiList.totalMateri == 0)
|
|
{
|
|
Debug.LogWarning(" Mission Selector is empty kocak !");
|
|
return;
|
|
}
|
|
|
|
if(currentIndex >= materiList.totalMateri)
|
|
{
|
|
currentIndex = 0;
|
|
}
|
|
|
|
if(currentIndex < 0)
|
|
{
|
|
currentIndex = materiList.totalMateri - 1;
|
|
}
|
|
}
|
|
|
|
public void SetIndex (int index)
|
|
{
|
|
currentIndex = index;
|
|
ClampIndex();
|
|
}
|
|
|
|
public void IncrementIndex()
|
|
{
|
|
SetIndex(currentIndex+1);
|
|
}
|
|
|
|
public void DecrementIndex()
|
|
{
|
|
SetIndex(currentIndex-1);
|
|
}
|
|
|
|
public MateriSpec GetMission(int index)
|
|
{
|
|
return materiList.GetMateri(index);
|
|
}
|
|
|
|
public MateriSpec GetCurrentMission()
|
|
{
|
|
return materiList.GetMateri(currentIndex);
|
|
}
|
|
|
|
}
|