|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
|
|
public class FlakePosition : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
public static FlakePosition Instance;
|
|
|
|
|
|
|
|
|
|
|
|
[AutoUI] public bool View;
|
|
|
|
|
|
[AutoUI] public Vector2 Position1;
|
|
|
|
|
|
[AutoUI] public Vector2 Position2;
|
|
|
|
|
|
[AutoUI] public Vector2 Position3;
|
|
|
|
|
|
[AutoUI] public Vector2 Position4;
|
|
|
|
|
|
[AutoUI] public Vector2 Position5;
|
|
|
|
|
|
[AutoUI] public Vector2 Position6;
|
|
|
|
|
|
|
|
|
|
|
|
private RawImage[] imgs;
|
|
|
|
|
|
[SerializeField] private List<int> PositionSeed = new List<int>();
|
|
|
|
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
|
void Awake()
|
|
|
|
|
|
{
|
|
|
|
|
|
Instance = this;
|
|
|
|
|
|
imgs = GetComponentsInChildren<RawImage>();
|
|
|
|
|
|
for (int seed = 1;seed <= 6; seed++)
|
|
|
|
|
|
PositionSeed.Add(seed);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
if((Time.frameCount & 0x19) == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetImgEnable(View);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetImgEnable(bool view)
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0;i<imgs.Length;i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
imgs[i].enabled = view;
|
|
|
|
|
|
imgs[i].rectTransform.anchoredPosition = GetPos(i + 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int Take(out Vector2 pos)
|
|
|
|
|
|
{
|
|
|
|
|
|
var random = Random.Range(0, PositionSeed.Count);
|
|
|
|
|
|
var seed = PositionSeed[random];
|
|
|
|
|
|
Debug.Log(seed);
|
|
|
|
|
|
pos = GetPos(seed);
|
|
|
|
|
|
PositionSeed.RemoveAt(random);
|
|
|
|
|
|
return seed;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Put(int seed)
|
|
|
|
|
|
{
|
|
|
|
|
|
PositionSeed.Add(seed);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Vector2 GetPos(int seed)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch(seed)
|
|
|
|
|
|
{
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
return Position1;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
return Position2;
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
return Position3;
|
|
|
|
|
|
case 4:
|
|
|
|
|
|
return Position4;
|
|
|
|
|
|
case 5:
|
|
|
|
|
|
return Position5;
|
|
|
|
|
|
case 6:
|
|
|
|
|
|
return Position6;
|
|
|
|
|
|
}
|
|
|
|
|
|
return Vector2.zero;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|