public void CopyVariables(NWObject oSource, NWObject oCopy) { int variableCount = _nwnxObject.GetLocalVariableCount(oSource); for (int variableIndex = 0; variableIndex < variableCount - 1; variableIndex++) { LocalVariable stCurVar = _nwnxObject.GetLocalVariable(oSource, variableIndex); switch (stCurVar.Type) { case LocalVariableType.Int: oCopy.SetLocalInt(stCurVar.Key, oSource.GetLocalInt(stCurVar.Key)); break; case LocalVariableType.Float: oCopy.SetLocalFloat(stCurVar.Key, oSource.GetLocalFloat(stCurVar.Key)); break; case LocalVariableType.String: oCopy.SetLocalString(stCurVar.Key, oSource.GetLocalString(stCurVar.Key)); break; case LocalVariableType.Object: oCopy.SetLocalObject(stCurVar.Key, oSource.GetLocalObject(stCurVar.Key)); break; case LocalVariableType.Location: oCopy.SetLocalLocation(stCurVar.Key, oSource.GetLocalLocation(stCurVar.Key)); break; } } }
private void LoadMainPage() { NWObject table = _.OBJECT_SELF; NWPlayer pc = GetPC(); game = PazaakService.GetCurrentGame(table); if (game == null && table.GetLocalInt("IN_GAME") == 2) { // Belt and bracers clean up code. table.DeleteLocalInt("IN_GAME"); } // Check whether we have a game, or whether we should create one. if (table.GetLocalInt("IN_GAME") == 2) { CheckEndRound(table); if (game.nextTurn == pc) { // Our turn. BuildTurnOptions(pc); } else if (game.player2.IsNPC) { // NPC turn. Handle some DoNPCTurn(game); CheckEndRound(table); if (game.nextTurn == game.player2) { DoNPCTurn(game); } BuildTurnOptions(pc); } else { // Other player turn. SetPageHeader("MainPage", "It is not currently your turn."); ClearPageResponses("MainPage"); } } // Table is open for a second player. else if (table.GetLocalInt("IN_GAME") == 1) { NWObject collection = pc.GetLocalObject("ACTIVE_COLLECTION"); if (GetName(table.GetLocalObject("PLAYER_1")) == pc.Name) { SetPageHeader("MainPage", "You are waiting for an opponent here. Or play against the host."); ClearPageResponses("MainPage"); AddResponseToPage("MainPage", "Table host (NPC)"); } // Check that the player has an active Pazaak deck. else if (collection.IsValid) { SetPageHeader("MainPage", GetName(table.GetLocalObject("PLAYER_1")) + " is waiting for an opponent. Join game?"); ClearPageResponses("MainPage"); AddResponseToPage("MainPage", "Join game"); } else { SetPageHeader("MainPage", "Use your Pazaak Collection on this table to join the game."); ClearPageResponses("MainPage"); } } // Create a game. Offer the PC a choice of vs NPC or vs Player. else { NWObject collection = pc.GetLocalObject("ACTIVE_COLLECTION"); // Check that the player has an active Pazaak deck. if (collection.IsValid) { table.SetLocalInt("IN_GAME", 1); table.SetLocalObject("PLAYER_1", pc); table.DeleteLocalObject("PLAYER_2"); SetPageHeader("MainPage", "Game created. Will this be against another player, or the table owner?"); ClearPageResponses("MainPage"); AddResponseToPage("MainPage", "A player"); AddResponseToPage("MainPage", "Table host (NPC)"); } else { SetPageHeader("MainPage", "Use your Pazaak Collection on this table to join the game."); ClearPageResponses("MainPage"); } } }