public static RoundDatas GetRoundDatas() { RoundDatas r = Array.Find(_RoundDatas, e => e.codeMap == MAP_GamePlay.CodeMapcurent); if (r != null) { return(ScriptableObject.Instantiate(r)); } return(null); }
private void SetUpRounds() { // SetUpInfo Vector2Int positionCurrent = PositionPlayerStart; rounds = DataMap.GetRoundDatas(); Direct lasDir = Direct.Down; for (int i = 0; i < rounds.NumberRound - 1; i++) { RoundData roundCurrent = rounds.GetRound(i); roundCurrent.position = positionCurrent; List <Direct> drs = new List <Direct>(); drs.Add(Direct.Left); drs.Add(Direct.Right); drs.Add(Direct.Up); if (lasDir == Direct.Right) { roundCurrent.AddDirect(Direct.Left); drs.Remove(Direct.Left); } if (lasDir == Direct.Left) { roundCurrent.AddDirect(Direct.Right); drs.Remove(Direct.Right); } if (lasDir == Direct.Up) { roundCurrent.AddDirect(Direct.Down); } int a = Random.Range(0, drs.Count); lasDir = drs[a]; roundCurrent.AddDirect(lasDir); positionCurrent = GetNewPosition(positionCurrent, lasDir); } RoundData bossRound = rounds.GetRound(rounds.NumberRound - 1); bossRound.position = positionCurrent; if (lasDir == Direct.Right) { bossRound.AddDirect(Direct.Left); } if (lasDir == Direct.Left) { bossRound.AddDirect(Direct.Right); } if (lasDir == Direct.Up) { bossRound.AddDirect(Direct.Down); } for (int i = 0; i < rounds.NumberRound; i++) { RoundData r = rounds.GetRound(i); SetRoundData(r); DrawMap.Draw(r.textMap, (Vector3Int)r.position); } for (int i = 0; i < rounds.NumberRound - 1; i++) { RoundData r1 = rounds.GetRound(i); RoundData r2 = rounds.GetRound(i + 1); Vector2Int p1 = r1.position; Vector2Int p2 = r2.position; if (p1.x == p2.x) { DrawMap.DrawConnect((Vector3Int)r1.GetPositionOutSide(Direct.Up), (Vector3Int)r2.GetPositionOutSide(Direct.Down)); } else if (p1.y == p2.y) { if (p1.x < p2.x) { DrawMap.DrawConnect((Vector3Int)r1.GetPositionOutSide(Direct.Right), (Vector3Int)r2.GetPositionOutSide(Direct.Left)); } else { DrawMap.DrawConnect((Vector3Int)r2.GetPositionOutSide(Direct.Right), (Vector3Int)r1.GetPositionOutSide(Direct.Left)); } } } }