public static void SetTutorialTiles() { if (Input.GetKeyDown(KeyCode.Mouse0) /*&& Events.GetComponent<Pause>().paused == false*/) { Ray ray; RaycastHit hit; ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { string[] index; if ((hit.transform.tag == "I" && instance.toSpawnUnit == 0) || (hit.transform.tag == "CV" && instance.toSpawnUnit == 1) || (hit.transform.tag == "CN" && instance.toSpawnUnit == 2)) //toSpawnUnit is the same unit as the required unit of the hexcell they clicked on { index = hit.transform.gameObject.name.Split('_'); HexCell h = MapMaster.Map[int.Parse(index[0]), int.Parse(index[1])]; int tSU = instance.toSpawnUnit; instance.unitsUsed[tSU]--; instance.uoList.Add(new UnitOrder(h.r, h.q, tSU, (GameObject)GameObject.Instantiate(Resources.Load("prefabs/UnitImagePlane"), MapMaster.Map[h.R, h.Q].spawnPoint.transform.position + new Vector3(0.0f, 0.05f, 0.0f), Quaternion.Euler(0.0f, 180.0f * PlayerMaster.CurrentTurn, 0.0f)))); SoundMaster.Deploy(); MapMaster.Map[h.R, h.Q].Passable = false; instance.uoList[instance.uoList.Count - 1].icon.GetComponent <ImagePlaneTest>().SetUnitPicture(((UnitTypes)tSU).ToString(), PlayerMaster.CurrentTurn); UIMaster.UpdateDeployAmount(); GameObject.Destroy(hit.transform.parent.gameObject); } } } }
public static void SetTiles() { if (Input.GetKeyDown(KeyCode.Mouse0) /*&& Events.GetComponent<Pause>().paused == false*/) { Ray ray; RaycastHit hit; ray = Camera.main.ScreenPointToRay(Input.mousePosition); if (Physics.Raycast(ray, out hit)) { if (hit.transform.tag == "HexCell") { HexCell h = hit.transform.gameObject.GetComponent <HexCell>(); if (PlayerMaster.CurrentPlayer.backLine.Contains(h)) { int tSU = instance.toSpawnUnit; if (MapMaster.Map[h.R, h.Q].Passable && tSU != -1) { if (instance.unitsUsed[tSU] > 0) { instance.unitsUsed[tSU]--; instance.uoList.Add(new UnitOrder(h.r, h.q, tSU, (GameObject)GameObject.Instantiate(Resources.Load("prefabs/UnitImagePlane"), MapMaster.Map[h.R, h.Q].spawnPoint.transform.position + new Vector3(0.0f, 0.05f, 0.0f), Quaternion.Euler(0.0f, 180.0f * PlayerMaster.CurrentTurn, 0.0f)))); //aud.GetComponent<Audiomanager>().soundeffectplay(5); SoundMaster.Deploy(); MapMaster.Map[h.R, h.Q].Passable = false; instance.uoList[instance.uoList.Count - 1].icon.GetComponent <ImagePlaneTest>().SetUnitPicture(((UnitTypes)tSU).ToString(), PlayerMaster.CurrentTurn); } } else if (!(MapMaster.Map[h.R, h.Q].Passable) && tSU == -1) { UnitOrder uO; for (int i = 0; i < instance.uoList.Count; i++) { uO = instance.uoList[i]; if (h.r == uO.R && h.q == uO.Q) { GameObject.Destroy(uO.icon); instance.unitsUsed[uO.unitType]++; h.Passable = true; instance.uoList.RemoveAt(i); break; } } } UIMaster.UpdateDeployAmount(); } } } } }
//Alters aspects of the game state (such as highlights or unit numbers) based on phase and other information private static IEnumerator AlterState() { switch (gP) { case (GamePhase.Deploy): if (DeployMaster.instance.uoList.Count != 0) { yield return(DeployMaster.DeployUnitsCoroutine()); yield return(new WaitForSeconds(1.5f)); } UIMaster.UpdateDeployAmount(); break; case (GamePhase.Cannon): // CheckSkip(); /* if (PlayerMaster.CurrentTurn == 0) * { * CheckSkip(); * } */ CannonMaster.ExitCannon(); HighlightMaster.UnhighlightCannons(PlayerMaster.CurrentPlayer); DeactivateCannonByCannon(PlayerMaster.OtherPlayer); if (PlayerMaster.CurrentTurn == 0) { //DeactivateCannonByMove(PlayerMaster.OtherPlayer); HighlightMaster.HighlightActiveCannons(PlayerMaster.OtherPlayer); } break; case (GamePhase.Move): if (MoveMaster.UnitsToMove != 0) { HighlightMaster.UnhighlightMovable(PlayerMaster.CurrentPlayer); MoveMaster.ClearMoveVariables(); } AttackMaster.BuildCombatAreas(); ActivateCannonByMove(PlayerMaster.CurrentPlayer); DeactivateCannonByMove(PlayerMaster.CurrentPlayer); if (AttackMaster.CombatCount == 0) { CannonMaster.CheckCannonCapture(); yield return(WinByMove()); if (PlayerMaster.CurrentTurn == 0) { MoveMaster.PrimeMoveVariables(PlayerMaster.OtherPlayer); HighlightMaster.HighlightMovable(PlayerMaster.OtherPlayer); } } else if (AttackMaster.CombatCount != 0) { // AttackMaster.BuildCombatAreas(); //gP = GamePhase.Attack; UIMaster.SetActionPanel(false); //Deactivates off action panel UIMaster.FadePhanel((int)UIPannels.Action); acceptInput = false; instance.StartCoroutine(Fight()); //yield return Fight(); } break; case (GamePhase.Attack): break; default: yield return(null); break; } }