/// <summary> /// The update function that will move the update through the two stages, before and after they press the roll key /// </summary> /// <returns>Returns true when the update is finished</returns> public bool OnUpdateFunction() { //Iterating through the states of the RollMananger switch (m_CurrentRollState) { //If the button has been pressed, which is caught in a different function, use one frame to setup the display of the dice, had errors when it was on the previous frame case RollManangerState.ButtonPress: { m_Panel.transform.FindChild("NumberDisplay").FindChild("DiceRoll").GetComponent <TextMeshProUGUI>().text = m_Player.m_LastRoll.ToString(); m_CurrentRollState = RollManangerState.NumberReveal; break; } //How long we want the player to look at the roll number case RollManangerState.NumberReveal: { m_DeltaTime += Time.deltaTime; if (m_DeltaTime >= c_REVEAL_TIME) { GameObject.Destroy(m_Panel); GameWorldMananger.ReturnInstance().AddToAnimationQueue(new PlayerMovement(m_Player, m_Player.m_LastRoll)); return(true); } break; } } return(false); }
/// <summary> /// Called by the Unity Button class /// </summary> public void ButtonPressed() { //Generates the roll results, 1 - 12 for 2 dices m_Player.m_LastRoll = Random.RandomRange(1, 12); m_Panel.transform.FindChild("RollButton").gameObject.SetActive(false); m_Panel.transform.FindChild("NumberDisplay").gameObject.SetActive(true); m_CurrentRollState = RollManangerState.ButtonPress; GameWorldMananger.ReturnInstance().WriteToLog("Player: " + m_Player.name + " Rolled: " + m_Player.m_LastRoll); }
/// <summary> /// Creates all the windows and allocates them /// Would be better to just turn off and on but being strapped for time, this is safer in creating less bugs /// </summary> /// <returns></returns> public bool OnStartFunction() { m_DeltaTime = 0.0f; m_CurrentRollState = RollManangerState.NULL; //Instiates the window m_Panel = Canvas.Instantiate(Resources.Load("RollSreen", typeof(GameObject)) as GameObject); m_Panel.transform.parent = GameWorldMananger.ReturnInstance().m_Canvas.transform; m_Panel.transform.localPosition = Vector3.zero; m_Panel.transform.localRotation = Quaternion.identity; //Sets up the players name being displayed m_Panel.transform.FindChild("Name").GetComponent <TextMeshProUGUI>().text = m_Player.name + "'s Turn!"; m_Panel.transform.FindChild("RollButton").GetComponent <Button>().onClick.AddListener(ButtonPressed); return(true); }