public static void GenerateEvent(Transform eventType, FieldEventType eventFlag, int numOfEvent) { for (int i = 0; i < numOfEvent; i++) { Vector2 eventCoordination = GetEventCoordination(i, eventType); if (eventCoordination == new Vector2(-1, -1)) { continue; } if (fieldEventFlag[(int)eventCoordination.x, (int)eventCoordination.y] == 0 & eventCoordination != new Vector2(PlayerPrefs.GetInt(PrefsEntity.CurrentX), PlayerPrefs.GetInt(PrefsEntity.CurrentY))) { Vector3 eventPosition = new Vector3( -2.5f + (int)eventCoordination.x * (5 / (mapSize.x - 1)) + (-(int)eventCoordination.x + mapSize.x / 2) * -(mapSize.x - 6) / 15, 0.15f, -2.5f + (int)eventCoordination.y * (5 / (mapSize.y - 1)) + (-(int)eventCoordination.y + mapSize.y / 2) * -(mapSize.y - 6) / 15 ); Quaternion eventRotation = Quaternion.Euler(new Vector3(0, 0, 0)); /* Object Offset * Box : 0.07 */ /* Object Angle * Box : -45 */ switch (eventFlag) { case FieldEventType.Box: eventPosition.y = 0.07f; eventRotation = Quaternion.Euler(new Vector3(0, -45, 0)); break; case FieldEventType.Trap: eventPosition.y = 0.07f; eventRotation = Quaternion.Euler(new Vector3(0, -45, 0)); break; case FieldEventType.Enemy: eventPosition.y = -0.7f; break; default: break; } Transform newTile = Instantiate(eventType, eventPosition, eventRotation) as Transform; //newTile.localScale = Vector3.one * 0.3f; //TODO : Set Rotation v fieldEventContainer[(int)eventCoordination.x, (int)eventCoordination.y] = newTile; fieldEventFlag[(int)eventCoordination.x, (int)eventCoordination.y] = eventFlag; PlayerPrefsX.SetVector2(eventType.name + i.ToString(), eventCoordination); //Debug.Log(eventCoordination.ToString()); PlayerPrefs.SetString(eventCoordination.ToString(), eventType.name + i.ToString()); } else { i--; } } }
private void OccurTrap(ref FieldEventType eventFlag, ref Transform eventObject) { Debug.Log("Trap"); Vector2 eventCoordination = new Vector2(currentX, currentY); PlayerPrefsX.SetVector2(PlayerPrefs.GetString(eventCoordination.ToString()), new Vector2(-1, -1)); DestroyImmediate(eventObject.gameObject); switch (currentLevel) { case 0: TrapNormal(); break; case 1: TrapHard(); break; case 2: TrapHell(); break; } Utility.ObjectVisibility(controlBlocker, true); Utility.ObjectVisibility(trapPanel, true); eventFlag = FieldEventType.Nothing; }
private void OccurBox(ref FieldEventType eventFlag, ref Transform eventObject) { Debug.Log("Box"); Vector2 eventCoordination = new Vector2(currentX, currentY); PlayerPrefsX.SetVector2(PlayerPrefs.GetString(eventCoordination.ToString()), new Vector2(-1, -1)); DestroyImmediate(eventObject.gameObject); Utility.ObjectVisibility(controlBlocker, true); Utility.ObjectVisibility(boxPanel, true); eventFlag = FieldEventType.Nothing; }
private void OccurExit(ref FieldEventType eventFlag, ref Transform eventObject) { //Debug.Log("Exit"); Utility.ObjectVisibility(controlBlocker, true); Utility.ObjectVisibility(requestNextFloorPanel, true); //eventObject.gameObject.SetActive(false); //PlayerPrefs.SetInt("Current Floor", --currentFloor); //Scene scene = SceneManager.GetActiveScene(); //SceneManager.LoadScene(scene.name); //DestroyImmediate(eventObject.gameObject); //eventFlag = 0; }
// 0 = No event, 1 = Entrance, 2 = Exit, 3 = Enemy, 4 = Trap, 5 = Event, 6 = Box private void OccurEnemy(ref FieldEventType eventFlag, ref Transform eventObject) { Debug.Log("Enemy"); Vector2 eventCoordination = new Vector2(currentX, currentY); PlayerPrefsX.SetVector2(PlayerPrefs.GetString(eventCoordination.ToString()), new Vector2(-1, -1)); //Debug.Log(PlayerPrefs.GetString(eventCoordination.ToString())); //Debug.Log(fieldEventContainer[currentX, currentY].name); DestroyImmediate(eventObject.gameObject); eventFlag = FieldEventType.Nothing; //Debug.Log("St X : " + PlayerPrefs.GetInt(PrefsEntity.StartX) + " St Y : " + PlayerPrefs.GetInt(PrefsEntity.StartY)); LoadingManager.LoadSceneFieldToBattle(); }
private void OccurJail(ref FieldEventType eventFlag, ref Transform eventObject) { Debug.Log("Jail"); Vector2 eventCoordination = new Vector2(currentX, currentY); PlayerPrefsX.SetVector2(PlayerPrefs.GetString(eventCoordination.ToString()), new Vector2(-1, -1)); DestroyImmediate(eventObject.gameObject); switch (currentLevel) { case 0: EventNormal(); break; case 1: EventHard(); break; case 2: EventHell(); break; } eventFlag = FieldEventType.Nothing; }