//Inits and start the game void Start() { playerScript = GameObject.Find("Player").GetComponent <Player>(); state = GlobalTurnState.Reset; turn = 0; AdvanceInTurn(); }
IEnumerator GazAnimation() { yield return(new WaitForSeconds(1.0f)); state = GlobalTurnState.Move; canAdvance = true; }
//Execute the next phase of the turn void AdvanceInTurn() { canAdvance = false; switch (state) { //Reset game case GlobalTurnState.Reset: //Re-inits GazedZones = new List <GameObject>(); playerScript.PlayerPosInZone = DiceRoll(2, 6); turn = 0; //Create some PNJs pnjListScritps = new List <PNJ>(); CreateSomePNJs(Random.Range(3, 5)); state = GlobalTurnState.Action; canAdvance = true; break; //Phase 1 : Action state case GlobalTurnState.Action: turn++; //Player choose his action playerScript.Playerstate = PlayerActionState.ChooseAction; //Execute action AI of all pnjs for (int i = 0; i < pnjListScritps.Count; i++) { pnjListScritps[i].PNJState = PlayerActionState.ChooseAction; } state = GlobalTurnState.Gaz; break; //Phase 2 : Gaz state case GlobalTurnState.Gaz: //Set gaz on a random zone bool isSelected = false; int r = 0; while (!isSelected) { r = Random.Range(0, 11); if (!GazedZones.Contains(Zones[r])) { GazedZones.Add(Zones[r]); Zones[r].GetComponent <Renderer>().material = mat_GazedGreen; isSelected = true; } } StartCoroutine(GazAnimation()); break; //Phase 3 : Moving state case GlobalTurnState.Move: //Player can move playerScript.Playerstate = PlayerActionState.ChooseMove; //Execute move AI of all pnjs for (int i = 0; i < pnjListScritps.Count; i++) { pnjListScritps[i].PNJState = PlayerActionState.ChooseMove; } state = GlobalTurnState.Action; break; } }