using UnityEngine;
using System.Collections;
public class miner : MonoBehaviour
{
public enum State
{
EnterMineAndDigForNuggets,
EnterBankAndDepositGold
}
public State state;
public void Awake()
{
state = State.EnterMineAndDigForNuggets;
// Start the Finite State Machine
StartCoroutine(FSM());
}
IEnumerator FSM()
{
// Execute the current coroutine (state)
while (true)
{
yield return StartCoroutine(state.ToString());
}
}
IEnumerator EnterMineAndDigForNuggets()
{
/* This part works as the Enter function
of the previous post (it's optional) */
print("Entering the mine...");
yield return null;
/* Now we enter in the Execute part of a state
which will be usually inside a while - yield block */
bool dig = true;
int digged = 0;
while (dig)
{
print("Digging... " + (digged++) + " " + Time.time);
if (digged == 2) dig = false;
yield return new WaitForSeconds(1);
}
/* And finally do something before leaving
the state (optional too) and starting a new one */
print("Exiting the mine...");
state = State.EnterBankAndDepositGold;
}
IEnumerator EnterBankAndDepositGold()
{
//Enter
print("Entering the bank...");
yield return null;
//Execute
bool queing = true;
float t = Time.time;
while (queing)
{
print("waiting...");
if (Time.time - t > 5) queing = false;
yield return new WaitForSeconds(1);
}
//Exit
print("Leaving the bank a little bit richer...");
state = State.EnterMineAndDigForNuggets;
}
}
2019년 6월 6일 목요일
피드 구독하기:
댓글 (Atom)
git rejected error(feat. cherry-pick)
문제 아무 생각 없이 pull을 받지않고 로컬에서 작업! 커밋, 푸시 진행을 해버렷다. push에선 remote와 다르니 당연히 pull을 진행해라고 하지만 로컬에서 작업한 내용을 백업하지 않고 진행하기에는 부담스럽다(로컬작업 유실 가능성) 해결하려...
-
public class Test : MonoBehaviour { //매출 데이터를 읽어 들이고 Sales 객체 리스트를 반환한다. List<string> list = new List<string> { ...
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 ...
-
아마 포함 디렉터리에 맞지 않는 버전(2019 or 2018 의 fbx sdk) 본인은 2019만 추가 되어 있어서 2017도 추가 했더니 해당 Error 가 사라짐 이렇게 해주면 일단 해당 Error는 사라짐
댓글 없음:
댓글 쓰기