// ---------------------------------------------------------------- // Wrap Types // ---------------------------------------------------------------- static public int WrapTypeToInt(WrapTypes wt) { switch (wt) { case WrapTypes.None: return(0); case WrapTypes.Parallel: return(1); case WrapTypes.Flip: return(2); case WrapTypes.CW: return(3); default: return(-1); // Hmm. } }
public static WrapTypeAttribute FromElement(XmlElement elem) { WrapTypes wt = (WrapTypes)Enum.Parse(typeof(WrapTypes), elem.InnerText, true); return(new WrapTypeAttribute(wt)); }
public WrapTypeAttribute(WrapTypes type) { this.WrapType = type; }
// ---------------------------------------------------------------- // Initialize // ---------------------------------------------------------------- public BoardData(LevelDataXML ldxml) { wrapH = BoardUtils.IntToWrapType(ldxml.wrapH); wrapV = BoardUtils.IntToWrapType(ldxml.wrapV); // Layout! string[] levelStringArray = GetLevelStringArrayFromLayoutString(ldxml.layout); if (levelStringArray.Length == 0) { levelStringArray = new string[] { "." }; } // Safety catch. int numLayoutLayers = 1; // will increment for every "", we find. for (int i = 0; i < levelStringArray.Length; i++) { if (levelStringArray[i].Length == 0) // We found a break that denotes another layer of layout! { numLayoutLayers++; } } // Set numCols and numRows! if (levelStringArray.Length == 0) { Debug.LogError("Uhh! levelStringArray is empty!"); } numCols = levelStringArray[0].Length; numRows = (int)((levelStringArray.Length - numLayoutLayers + 1) / numLayoutLayers); // Add all gameplay objects! MakeEmptyBoardSpaces(); MakeEmptyLists(); objectsInBoard = new BoardObjectData[numCols, numRows]; for (int layer = 0; layer < numLayoutLayers; layer++) { for (int i = 0; i < numCols; i++) { for (int j = 0; j < numRows; j++) { int stringArrayIndex = j + layer * (numRows + 1); if (stringArrayIndex >= levelStringArray.Length || i >= levelStringArray[stringArrayIndex].Length) { Debug.LogError("Whoops! Mismatch in layout in a board layout XML. " + stringArrayIndex + ", " + i); continue; } char spaceChar = (char)levelStringArray[stringArrayIndex][i]; int col = i; int row = numRows - 1 - j; switch (spaceChar) { // BoardSpace properties! case '~': GetSpaceData(col, row).isPlayable = false; break; // ExitSpot! case '$': AddExitSpotData(col, row); break; // Player! case '@': AddPlayerData(col, row); break; // Void! case 'V': AddVoydData(col, row, false); break; case 'v': AddVoydData(col, row, true); break; // Beams! case 't': AddBeamGoalData(col, row, Sides.T, 0); break; case 'y': AddBeamGoalData(col, row, Sides.R, 0); break; case 'h': AddBeamGoalData(col, row, Sides.B, 0); break; case 'g': AddBeamGoalData(col, row, Sides.L, 0); break; case 'T': AddBeamSourceData(col, row, Sides.T, 0); break; case 'Y': AddBeamSourceData(col, row, Sides.R, 0); break; case 'H': AddBeamSourceData(col, row, Sides.B, 0); break; case 'G': AddBeamSourceData(col, row, Sides.L, 0); break; case 'u': AddBeamGoalData(col, row, Sides.T, 1); break; case 'i': AddBeamGoalData(col, row, Sides.R, 1); break; case 'k': AddBeamGoalData(col, row, Sides.B, 1); break; case 'j': AddBeamGoalData(col, row, Sides.L, 1); break; case 'U': AddBeamSourceData(col, row, Sides.T, 1); break; case 'I': AddBeamSourceData(col, row, Sides.R, 1); break; case 'K': AddBeamSourceData(col, row, Sides.B, 1); break; case 'J': AddBeamSourceData(col, row, Sides.L, 1); break; // Crates! case 'q': AddCrateGoalData(col, row, Corners.TL, false); break; case 'w': AddCrateGoalData(col, row, Corners.TR, false); break; case 's': AddCrateGoalData(col, row, Corners.BR, false); break; case 'a': AddCrateGoalData(col, row, Corners.BL, false); break; case 'e': AddCrateGoalData(col, row, Corners.TL, true); break; case 'r': AddCrateGoalData(col, row, Corners.TR, true); break; case 'f': AddCrateGoalData(col, row, Corners.BR, true); break; case 'd': AddCrateGoalData(col, row, Corners.BL, true); break; case 'Q': AddCrateData(col, row, Corners.TL, false); break; case 'W': AddCrateData(col, row, Corners.TR, false); break; case 'S': AddCrateData(col, row, Corners.BR, false); break; case 'A': AddCrateData(col, row, Corners.BL, false); break; case 'E': AddCrateData(col, row, Corners.TL, true); break; case 'R': AddCrateData(col, row, Corners.TR, true); break; case 'F': AddCrateData(col, row, Corners.BR, true); break; case 'D': AddCrateData(col, row, Corners.BL, true); break; //case 'O': AddCrateData (col,row, true); break; //case '#': AddCrateData (col,row, false); break; // Walls! case '_': SetIsWallT(col, row - 1); break; // note: because the underscore looks lower, consider it in the next row (so layout text file looks more intuitive). case '|': SetIsWallL(col, row); break; // MODIFYING properties... case 'Z': FlipChirH(col, row); break; case 'X': FlipChirV(col, row); break; case 'm': SetNotMovable(col, row); break; } } } } // Safety check. if (playerDatas.Count == 0) { AddPlayerData(0, 0); } // We can empty out those lists now. objectsInBoard = null; }
/// <summary> /// Denotes whether this type definition has the specified wrap type. This is it has the <see cref="WrapTypeAttribute"/> /// defined with the specified value. /// </summary> /// <param name="wrapType">the expected wrap type</param> public virtual bool HasWrapType(WrapTypes wrapType) { return(HasAttribute <WrapTypeAttribute>() && GetAttribute <WrapTypeAttribute>().WrapType == wrapType); }
public WrapTypeAttribute(WrapTypes type) { WrapType = type; }