public void moveLeft(ref piece selectedPiece, ref ConsoleKey currentAltitudeKey, ref game currentGame) { if (selectedPiece != null) { if (selectedPiece.king) { if (currentAltitudeKey == ConsoleKey.UpArrow) { selectedPiece.move(new int[] { -1, -1 }, currentGame.gameMap); } else if (currentAltitudeKey == ConsoleKey.DownArrow) { selectedPiece.move(new int[] { -1, 1 }, currentGame.gameMap); } currentAltitudeKey = new ConsoleKey(); } else { if (selectedPiece.value == map.player1) { selectedPiece.move(new int[] { -1, 1 }, currentGame.gameMap); } else if (selectedPiece.value == map.player2) { selectedPiece.move(new int[] { -1, -1 }, currentGame.gameMap); } } selectedPiece = null; } else { currentGame.gameMap.move(new int[] { -1, 0 }); } }
static void Main(string[] args) { game Game = new game(); Game.PlayGame(); Console.WriteLine("Game Over"); }
//销毁上一个路段的物品 void destroyForward() { game rigidbody = GameObject.Find("GameObject").GetComponent <game>(); Destroy(rigidbody.box1); Destroy(rigidbody.bridge1); Destroy(rigidbody.wood1); Destroy(rigidbody.Pavilion1); Destroy(rigidbody.Pavilion2); Destroy(rigidbody.shield1); Destroy(rigidbody.masonry1); int i = 0; foreach (GameObject road in rigidbody.roadList) { if (i < rigidbody.roadList.Count - 2) { Destroy(road.gameObject); } i++; } rigidbody.roadList.Clear(); foreach (GameObject coin in rigidbody.coins) { Destroy(coin.gameObject); } rigidbody.coins.Clear(); }
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { if (selectedNode != null) { treeViewTools.SelectedNode = selectedNode; game sourceGame = null; rom sourceRom = null; if (selectedNode.Tag is rom) { sourceRom = (rom)selectedNode.Tag; sourceGame = (game)selectedNode.Parent.Tag; } else { sourceGame = (game)selectedNode.Tag; } this.datafileObject = AuditingUtil.DeleteItemFromDatafile(this.datafileObject, sourceGame, sourceRom); this.loadDataFileIntoTree(this.datafileObject); } else { MessageBox.Show(ConfigurationManager.AppSettings["Form_DatafileEditor_ErrorDatafileSelectedNode"], ConfigurationManager.AppSettings["Form_DatafileEditor_ErrorDatafileSelectedNodeTitle"]); } }
public IActionResult Play() { Tamagochi Retrievegochi = HttpContext.Session.GetObjectFromJson <Tamagochi>("tamagachi"); Random rand = new Random(); bool Likes = true; if (rand.Next(0, 4) == 0) { Likes = false; } Retrievegochi.Energy -= 5; if (Likes == true) { Retrievegochi.Happiness += rand.Next(5, 11); } HttpContext.Session.SetObjectAsJson("tamagachi", Retrievegochi); ViewBag.tamagachi = Retrievegochi; if (Retrievegochi.Fullness <= 0 || Retrievegochi.Happiness <= 0 || Retrievegochi.Energy <= 0) { game Retrievegame = HttpContext.Session.GetObjectFromJson <game>("gameover"); Retrievegame.over = true; HttpContext.Session.SetObjectAsJson("gameover", Retrievegame); ViewBag.game = Retrievegame; } if (Retrievegochi.Fullness >= 100 && Retrievegochi.Happiness >= 100 && Retrievegochi.Energy >= 100) { game Retrievegame = HttpContext.Session.GetObjectFromJson <game>("gameover"); Retrievegame.over = true; HttpContext.Session.SetObjectAsJson("gameover", Retrievegame); ViewBag.game = Retrievegame; } return(RedirectToAction("dojodachi")); }
public void addNewClan(Transform clan) { Debug.Log("adding"); if (isGame) { if (isA) { if (totalBoards <= currentClan) { games [currentClan] = new game(); pos += desp; games [currentClan].ori = pos; grid.createGrid(pos + new Vector3(0.5f, 0, 0), 10, 10, colorA, colorB, totalBoards, baseA, baseB); } addPlayer(clan); isA = !isA; } else { clan.name = "clan B_" + currentClan.ToString(); clan.GetComponent <clanController> ().clanName = "clan B_" + currentClan.ToString(); addPlayer(clan); ++currentClan; if (currentClan > totalBoards) { ++totalBoards; Debug.Log(totalBoards + " boards created"); } isA = !isA; } } }
public static void ValidateGameAttributes(game game) { if (String.IsNullOrWhiteSpace(game.name)) { throw GameValidator.GenerateEmptyAttributeException("Game", "name"); } if (String.IsNullOrWhiteSpace(game.id)) { throw GameValidator.GenerateEmptyAttributeException("Game", "id", game.name); } if (String.IsNullOrWhiteSpace(game.gameurl)) { throw GameValidator.GenerateEmptyAttributeException("Game", "gameurl", game.name); } if (String.IsNullOrWhiteSpace(game.version)) { throw GameValidator.GenerateEmptyAttributeException("Game", "version", game.name); } if (String.IsNullOrWhiteSpace(game.iconurl)) { throw GameValidator.GenerateEmptyAttributeException("Game", "iconurl", game.name); } if (game.scriptVersion == "0.0.0.0") { throw GameValidator.GenerateEmptyAttributeException("Game", "scriptVersion", game.name); } }
static void Main(string[] args) { Console.WriteLine("Welcome back"); game mainGame = new game(); mainGame.Start(); }
public static void Set(String gameID) { lock (_lock) { string resultStr; game g = findGame(gameID); g.nextQues(); foreach (AsyncResult clientState in _clientStateList) { if (clientState._context.Session != null) { if (clientState.Player.gameID == g.id) { clientState.Player.Ques = g.getQues(); resultStr = myJavaScriptSerializer.Serialize(clientState.Player); if (clientState._isMobile == false) { clientState._context.Response.Write(resultStr); } else { // string str = clientState._callbackStr + "({ res: '" + message.UserNameMessage_Out() + "'})"; string str = "{ res: '" + gameID + "'}"; clientState._context.Response.Write(str); } clientState.CompleteRequest(); } } } } }
public void TestMethod1() { game g = new game(); g.next_step(); Assert.AreEqual(false, g.x_o); }
public async Task <IHttpActionResult> Putgame(int id, game game) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != game.id) { return(BadRequest()); } db.Entry(game).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!gameExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
// Use this for initialization void Start() { game terrain = GameObject.Find("GameObject").GetComponent <game>(); int pathNum = terrain.pathNum; int pathLength = terrain.pathlength; for (int z = 5; z < 500; z += Random.Range(20, 40)) { tree_l = Instantiate(treeArray[Random.Range(0, 3)], new Vector3(13, 0, pathLength * pathNum + z), Quaternion.identity) as GameObject; tree_r = Instantiate(treeArray[Random.Range(0, 3)], new Vector3(-13, 0, pathLength * pathNum + z), Quaternion.identity) as GameObject; treelist.Add(tree_l); treelist.Add(tree_r); } //生成石头 for (int z = 5; z < 500; z += Random.Range(10, 30)) { stone_l = Instantiate(stoneArray[Random.Range(0, 5)], new Vector3(15, -1, pathLength * pathNum + z), Quaternion.identity) as GameObject; stone_r = Instantiate(stoneArray[Random.Range(0, 5)], new Vector3(-15, -1, pathLength * pathNum + z), Quaternion.identity) as GameObject; stoneList.Add(stone_r); stoneList.Add(stone_l); } terrain.generatRoad(); terrain.generateObstacle(); terrain.pathNum++; }
public static string getJsonStr(game g) { switch (g) { case game.incremental: return(JsonConvert.SerializeObject(Incre)); case game.mastermind: return(JsonConvert.SerializeObject(Sudoku)); case game.seeker: return(JsonConvert.SerializeObject(seekerData)); case game.conquer: return(JsonConvert.SerializeObject(conqueror)); case game.daredevil: return(JsonConvert.SerializeObject(daredevilSave)); case game.sokoban: return(JsonConvert.SerializeObject(sokobanSave)); default: return(""); } }
public void TestMethod3() { game g = new game(); List <int> res = new List <int>(); g.checkresult(res); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,MinimunRequirements,Price,Developer")] game game) { if (id != game.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(game); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!gameExists(game.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(game)); }
static int PlayAGame(game aGame) { int moves = 0; Random rand = new Random(DateTime.Now.Millisecond); System.Collections.Generic.List <MoveTuple> availableMoves = aGame.AvailableMoves; Console.WriteLine(aGame.ToString()); while (availableMoves.Count > 0) { moves++; int choice; if (availableMoves.Count > 1) { choice = rand.Next(0, availableMoves.Count - 1); } else { choice = 0; } MoveTuple mt = aGame.AvailableMoves[choice]; Console.WriteLine("{2} available Moves, Moving peg {0} to {1}", mt.original, mt.destination, availableMoves.Count); aGame.Move(mt.original, mt.destination); availableMoves = aGame.AvailableMoves; } return(moves); }
static void Main() { while (true) { Console.Clear(); Console.Write("Black or White? (b/w): "); string bw = Console.ReadLine(); team playerColour; if (bw == "b") { playerColour = team.black; } else if (bw == "w") { playerColour = team.white; } else { Console.WriteLine("That wasn't an option..."); continue; } game1 = new game(playerColour); engine1 = new movingEngine(game1); Console.Clear(); Console.WriteLine("The Board:"); printBoard(game1); Console.ReadLine(); } }
public SchwarzmarktControl(game Game) { InitializeComponent(); InitilizeWirkungen(); if(Game.GUI.saveAndLoad.LadeSpielstand!= null) { if (Game.GUI.saveAndLoad.LadeSpielstand.Schwarzmarkt) { foreach (Droge d in Game.GUI.saveAndLoad.LadeSpielstand.DrogenImShop) { listBoxDrogen.Items.Add(d); } } else { RandomSchwarzmarkt(); } } else { RandomSchwarzmarkt(); } myGame = Game; labelGeld.Text = myGame.geld.ToString() +"$"; labelWirkung.Text = ""; labelPreis.Text = ""; }
private void game_Click(object sender, EventArgs e) { game set = new game(); set.Show(); this.Visible = false; }
public void ConstructorTest() { game target = new game(); // TODO: Implement code to verify target Assert.Inconclusive("TODO: Implement code to verify target"); }
public ActionResult UpGame(FormCollection fc) { game NewGame = new game(); if (fc["game_name"] == "") { Response.Write("<script>alert('游戏名不能为空')</script>"); } else if (fc["game_intro"] == "") { Response.Write("<script>alert('游戏简介不能为空')</script>"); } else if (fc["game_content"] == "") { Response.Write("<script>alert('游戏内容不能为空')</script>"); } else if (fc["game_pic"] == "") { Response.Write("<script>alert('游戏封面不能为空')</script>"); } else if (fc["game_pic_show"] == "") { Response.Write("<script>alert('游戏图片不能为空')</script>"); } else if (fc["game_link"] == "") { Response.Write("<script>alert('游戏链接不能为空')</script>"); } else if (fc["game_type"] == "") { Response.Write("<script>alert('游戏类型不能为空')</script>"); } else { NewGame.game_name = fc["game_name"]; NewGame.game_pic = "/Images/" + fc["game_pic"].ToString(); NewGame.game_intro = fc["game_intro"]; NewGame.game_content = fc["game_content"]; NewGame.game_pic_show = "/Images/" + fc["game_pic_show"].ToString(); NewGame.game_link = fc["game_link"]; NewGame.game_type = fc["game_type"]; GameWebSiteEntities db = new GameWebSiteEntities(); try { db.game.Add(NewGame); upgame_record ugr = new upgame_record(); ugr.admin_id = Session["admin_id"].ToString(); ugr.date = DateTime.Now; ugr.game_name = NewGame.game_name; db.upgame_record.Add(ugr); db.SaveChanges(); return(RedirectToAction("GameList", "Admin")); } catch (Exception e) { Response.Write("<script>alert('游戏已经存在,不能重复添加')</script>"); } } return(View()); }
public int start() { p1 = new game(); p2 = new game(); p1.bot_init(w1); p2.bot_init(w2); while (!p1.isdead && !p2.isdead) { p1.bot_run(); p2.bot_run(); foreach (int g in p2.attacking) { p1.garbage_queue.Push(g); } foreach (int g in p1.attacking) { p2.garbage_queue.Push(g); } //p1.garbage_queue = p2.attacking; //p2.garbage_queue = p1.attacking; p1.deal_garbage(); p2.deal_garbage(); print(); } if (p1.isdead) { return(2); } else { return(1); } }
public void TestMethod14() { game g = new game(); string winner = "Нолики"; g.congratulate(winner); }
static void Main(string[] args) { parser p = new parser(); game g = p.parse(args[0]); g.socialPlanner(); }
public static void ValidateGameAttributes(game game) { if (String.IsNullOrWhiteSpace(game.name)) { throw GameValidator.GenerateEmptyAttributeException("Game", "name"); } if (String.IsNullOrWhiteSpace(game.id)) { throw GameValidator.GenerateEmptyAttributeException("Game", "id", game.name); } if (String.IsNullOrWhiteSpace(game.gameurl)) { throw GameValidator.GenerateEmptyAttributeException("Game", "gameurl", game.name); } if (String.IsNullOrWhiteSpace(game.version)) { throw GameValidator.GenerateEmptyAttributeException("Game", "version", game.name); } if (String.IsNullOrWhiteSpace(game.iconurl)) { throw GameValidator.GenerateEmptyAttributeException("Game", "iconurl", game.name); } }
public ActionResult EditCoverPicture(newsViewModels itemm, HttpPostedFileBase idFile, HttpPostedFileBase idFilee) { if (ModelState.IsValid) { string uniqueName = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(idFile.FileName); var uploadUrl = Server.MapPath("~/Content/img"); idFile.SaveAs(Path.Combine(uploadUrl, uniqueName)); var imgPath = "~/Content/img" + uniqueName; itemm.link_img = "img\\" + uniqueName; game g = artSer.GetById(itemm.idArticle); g.link_img = itemm.link_img; artSer.Update(g); return(RedirectToAction("Edit", new { id = itemm.idArticle })); } else { return(View()); } }
public IActionResult Sleep() { Tamagochi Retrievegochi = HttpContext.Session.GetObjectFromJson <Tamagochi>("tamagachi"); Retrievegochi.Fullness -= 5; Retrievegochi.Happiness -= 5; Retrievegochi.Energy += 15; HttpContext.Session.SetObjectAsJson("tamagachi", Retrievegochi); ViewBag.tamagachi = Retrievegochi; if (Retrievegochi.Fullness <= 0 || Retrievegochi.Happiness <= 0 || Retrievegochi.Energy <= 0) { game Retrievegame = HttpContext.Session.GetObjectFromJson <game>("gameover"); Retrievegame.over = true; HttpContext.Session.SetObjectAsJson("gameover", Retrievegame); ViewBag.game = Retrievegame; } if (Retrievegochi.Fullness >= 100 && Retrievegochi.Happiness >= 100 && Retrievegochi.Energy >= 100) { game Retrievegame = HttpContext.Session.GetObjectFromJson <game>("gameover"); Retrievegame.over = true; HttpContext.Session.SetObjectAsJson("gameover", Retrievegame); ViewBag.game = Retrievegame; } return(RedirectToAction("dojodachi")); }
public client(TcpClient conClient, string username_param, string password_param, ref game GAME) { tcpClient = conClient; clientStream = tcpClient.GetStream(); username = username_param; password = password_param; clientPlayer = new player(username, password, game.areas); if(clientPlayer.loginOk) { Console.WriteLine(username + "'s login was ok"); send("#login:OK"); GAME.onConnect(this.clientPlayer); send("#health:" + clientPlayer.health.ToString()); send("#area:" + clientPlayer.position.name); listener = new Thread(new ThreadStart(listen)); listener.Priority = ThreadPriority.BelowNormal; listener.Start(); } else { Console.WriteLine(username + "'s login was false"); send("#login:FALSE"); tcpClient.Close(); } }
private void button6_Click(object sender, EventArgs e) { this.Hide(); game f1 = new game(s); f1.Show(); }
public void requestControl(game.Vessel vessel, game.FlightControl control) { if(_settings.control) { _background.wait(); _client.execute(() => Protocol.requestControl(vessel, control, _connection)); } }
private void playBtn_Click(object sender, EventArgs e) { game Game = new game(); Game.Show(); this.Hide(); //Sends user to Game form }
// Use this for initialization void Start() { theGame = this; h = GameObject.Find("Slider").GetComponent <Healthbar>(); m = GameObject.Find("MoneyText").GetComponent <money>(); endText = GameObject.FindGameObjectWithTag("GameOverText").GetComponent <Text>(); endText.enabled = false; }
public void UndoTest() { game target = new game(); target.Undo(); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public ActionResult DeleteConfirmed(int id) { game game = db.game.Find(id); db.game.Remove(game); db.SaveChanges(); return(RedirectToAction("Index")); }
public EndScreenControl(QuizControler qc, game Game) { InitializeComponent(); normalFont = WeiterLabel.Font; quizCtr = qc; myGame = Game; originalGeld = qc.Punkte; }
public static void requestControl(game.Vessel vessel, game.FlightControl c, Connection connection) { connection.stream.write("control"); vessel.serialize(connection.stream); c.serialize(connection.stream); connection.flush(); c.deserialize(connection.stream); }
void Awake() { if (Instance != null) { Debug.LogError("Error, there must be two GameSingletons in the scene!"); return; } Instance = this; }
public Orbit(double trueAnomaly, double eccentricity, double parameter, double inclination, double LAN, double argumentOfPeriapsis, double timeAtPeriapsis, game.CelestialBody mainBody) { this.trueAnomaly = trueAnomaly; this.eccentricity = eccentricity; this.parameter = parameter; this.inclination = inclination; this.LAN = LAN; this.argumentOfPeriapsis = argumentOfPeriapsis; this.timeAtPeriapsis = timeAtPeriapsis; this.mainBody = mainBody; }
void Awake() { DontDestroyOnLoad(this); errorHandler = new ErrorPopup(); gameObject.AddComponent<Dataharvester>(); sServer = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); IPAddress remoteIPAddress = IPAddress.Parse(serverAddress); IPEndPoint remoteEndPoint = new IPEndPoint(remoteIPAddress, serverPort); singleton = this; try { sServer.Connect(remoteEndPoint); } catch (Exception e) { Debug.Log("Connectionerror"); errorHandler.add("Connection Failed", e.ToString()); } }
public static void requestUpdate(game.Universe universe, game.Vessel vessel, Connection connection) { connection.stream.write("update"); universe.serialize(connection.stream); vessel.serialize(connection.stream); connection.flush(); }
public void updateState(game.Universe universe, game.Vessel vessel) { if(_stateUpdateHandler.update() && _settings.updateState) { _background.wait(); _client.execute(() => Protocol.requestUpdate(universe, vessel, _connection)); } }
public Player(game Tg, uint CurrentHealth, uint MaxHealth, double Speed) : base(Tg) { this.CurrentHealth = CurrentHealth; this.MaxHealth = MaxHealth; AttackEvent += AttackEventHandler; }
static void Main(string [] args) { // Variables bool gameOver; string gameMessage = ""; // Debug code bool debug = false; if (args.Length == 1) { if (args [0] == "debug") { debug = true; } } game Game = new game (9,9,10, debug); // Main game loop do { // Variables int x = 0; int y = 0; gameOver = false; Game.displayBoard(); // Display any messages to the user colouredOutput (gameMessage + '\n', ConsoleColor.Red); // Check if user wants to continue playing if (getUserInput (QUIT_OR_CONTINUE_TEXT).ToLower() == "q") { return; } Game.displayBoard(); // Get x and y co-ordinates string xString = getUserInput ("Enter X (0 - " + (Game.getBoardWidth()-1) + "):"); x = getValidNumber (xString, Game.getBoardWidth (), out gameMessage); string yString = getUserInput ("Enter Y (0 - " + (Game.getBoardHeight()-1) + "):"); y = getValidNumber (yString, Game.getBoardHeight (), out gameMessage); if (gameMessage != "") // If there has been an error { continue; } // Makes sure user isn't trying to clear something that's already been cleared if ((Game.getState (x, y) != HIDDEN) && (Game.getState (x, y) != MINED)) { gameMessage = ALREADY_CLEAR_ERROR; continue; } // Check if user thinks there is a mine bool validInput; do { string answer = getUserInput (IS_THERE_A_MINE_TEXT); validInput = false; if (answer.ToLower() == "y") { validInput = true; if (Game.getState (x, y) == MINED) { gameMessage = MINE_DEFUSED_TEXT; Game.defuseMine (x, y); } else { // If the user attempts to diffuse a non-MINED square gameMessage = NO_MINE_TEXT; gameOver = true; } } else if (answer.ToLower() == "n") { Game.clearSquare (x, y); // MINED will become EXPLODED! validInput = true; if (Game.getState (x, y) == EXPLODED) { gameMessage = EXPLODED_TEXT; gameOver = true; } else { gameMessage = SQUARE_CLEARED_TEXT; } } } while (!validInput); // If the user has won if (Game.isComplete ()) { gameMessage = CONGRATS_TEXT; gameOver = true; } // On game end checks if user wants to play again if (gameOver) { Game.displayBoard (); colouredOutput (gameMessage + '\n', ConsoleColor.Red); if (playAgain()) { Game.setupBoard (); gameMessage = NEW_GAME_TEXT; gameOver = false; } } } while (!gameOver); }
public byte[] Serialize(object obj) { if ((obj is Game) == false) throw new InvalidOperationException("obj must be typeof Game"); var game = obj as Game; var rootPath = new DirectoryInfo(game.InstallPath).FullName; var save = new game(); save.id = game.Id.ToString(); save.name = game.Name; save.card = new gameCard(); save.card.back = game.CardSize.Back; save.card.front = game.CardSize.Front; save.card.height = game.CardSize.Height.ToString(); save.card.width = game.CardSize.Width.ToString(); save.card.cornerRadius = game.CardSize.CornerRadius.ToString(); save.version = game.Version.ToString(); save.authors = string.Join(",", game.Authors); save.description = game.Description; save.gameurl = game.GameUrl; save.iconurl = game.IconUrl; save.tags = string.Join(" ", game.Tags); save.octgnVersion = game.OctgnVersion.ToString(); save.markersize = game.MarkerSize; save.usetwosidedtable = game.UseTwoSidedTable ? boolean.True : boolean.False; save.noteBackgroundColor = game.NoteBackgroundColor; save.noteForegroundColor = game.NoteForegroundColor; save.scriptVersion = game.ScriptVersion == null ? null : game.ScriptVersion.ToString(); #region Variables save.variables = (game.Variables ?? new List<Variable>()).Select(x => new gameVariable() { @default = x.Default.ToString(), global = x.Global ? boolean.True : boolean.False, name = x.Name, reset = x.Reset ? boolean.True : boolean.False, }).ToArray(); #endregion #region table save.table = SerializeGroup(game.Table, rootPath); #endregion table #region gameBoards if (game.GameBoards != null) { var boardList = new List<gameBoardDef>(); foreach (var b in game.GameBoards) { var board = new gameBoardDef(); board.name = b.Value.Name; board.x = b.Value.XPos.ToString(); board.y = b.Value.YPos.ToString(); board.width = b.Value.Width.ToString(); board.height = b.Value.Height.ToString(); board.src = (b.Value.Source ?? "").Replace(rootPath, ""); boardList.Add(board); } save.gameboards.gameboard = boardList.ToArray(); } #endregion gameBoards #region shared if (game.GlobalPlayer != null) { var gs = new gameShared(); var clist = new List<counter>(); foreach (var counter in game.GlobalPlayer.Counters) { var c = new counter(); c.name = counter.Name; c.icon = (counter.Icon ?? "").Replace(rootPath, ""); c.reset = counter.Reset ? boolean.True : boolean.False; c.@default = counter.Start.ToString(); clist.Add(c); } var glist = new List<group>(); foreach (var group in game.GlobalPlayer.Groups) { glist.Add(SerializeGroup(group, rootPath)); } gs.group = glist.ToArray(); gs.counter = clist.ToArray(); save.shared = gs; } #endregion shared #region player if (game.Player != null) { var player = new gamePlayer(); var ilist = new List<object>(); foreach (var counter in game.Player.Counters) { var c = new counter(); c.name = counter.Name; c.icon = (counter.Icon ?? "").Replace(rootPath, ""); c.reset = counter.Reset ? boolean.True : boolean.False; c.@default = counter.Start.ToString(); ilist.Add(c); } foreach (var v in game.Player.GlobalVariables) { var gv = new gamePlayerGlobalvariable(); gv.name = v.Name; gv.value = v.Value; ilist.Add(gv); } ilist.Add(SerializeGroup(game.Player.Hand, rootPath)); foreach (var g in game.Player.Groups) { ilist.Add(SerializeGroup(g, rootPath)); } player.Items = ilist.ToArray(); player.summary = game.Player.IndicatorsFormat; save.player = player; } #endregion player #region documents if (game.Documents != null) { var docList = new List<gameDocument>(); foreach (var d in game.Documents) { var doc = new gameDocument(); doc.icon = (d.Icon ?? "").Replace(rootPath, ""); doc.name = d.Name; doc.src = (d.Source ?? "").Replace(rootPath, ""); docList.Add(doc); } save.documents = docList.ToArray(); } #endregion documents #region sounds if (game.Sounds != null) { var soundList = new List<gameSound>(); foreach (var d in game.Sounds) { var doc = new gameSound(); doc.name = d.Value.Name; doc.src = (d.Value.Src ?? "").Replace(rootPath, ""); soundList.Add(doc); } save.sounds = soundList.ToArray(); } #endregion sounds #region deck if (game.DeckSections != null) { var dl = new List<deckSection>(); foreach (var s in game.DeckSections) { var sec = new deckSection(); sec.name = s.Value.Name; sec.group = s.Value.Group; dl.Add(sec); } save.deck = dl.ToArray(); } if (game.SharedDeckSections != null) { var dl = new List<deckSection>(); foreach (var s in game.SharedDeckSections) { var sec = new deckSection(); sec.name = s.Value.Name; sec.group = s.Value.Group; dl.Add(sec); } save.sharedDeck = dl.ToArray(); } #endregion deck #region card if (game.CustomProperties != null) { var pl = new List<propertyDef>(); foreach (var prop in game.CustomProperties) { if (prop.Name == "Name") continue; var pd = new propertyDef(); pd.name = prop.Name; pd.type = (propertyDefType)Enum.Parse(typeof(propertyDefType), prop.Type.ToString()); pd.hidden = prop.Hidden.ToString(); pd.ignoreText = prop.IgnoreText ? boolean.True : boolean.False; switch (prop.TextKind) { case PropertyTextKind.FreeText: pd.textKind = propertyDefTextKind.Free; break; case PropertyTextKind.Enumeration: pd.textKind = propertyDefTextKind.Enum; break; case PropertyTextKind.Tokens: pd.textKind = propertyDefTextKind.Tokens; break; } pl.Add(pd); } save.card.property = pl.ToArray(); } #endregion card #region fonts var flist = new List<gameFont>(); if (game.ChatFont.IsSet()) { var f = new gameFont(); f.src = (game.ChatFont.Src ?? "").Replace(rootPath, ""); f.size = (uint)game.ChatFont.Size; f.target = fonttarget.chat; flist.Add(f); } if (game.ContextFont.IsSet()) { var f = new gameFont(); f.src = (game.ContextFont.Src ?? "").Replace(rootPath, ""); f.size = (uint)game.ContextFont.Size; f.target = fonttarget.context; flist.Add(f); } if (game.NoteFont.IsSet()) { var f = new gameFont(); f.src = (game.NoteFont.Src ?? "").Replace(rootPath, ""); f.size = (uint)game.NoteFont.Size; f.target = fonttarget.notes; flist.Add(f); } if (game.DeckEditorFont.IsSet()) { var f = new gameFont(); f.src = (game.DeckEditorFont.Src ?? "").Replace(rootPath, ""); f.size = (uint)game.DeckEditorFont.Size; f.target = fonttarget.deckeditor; flist.Add(f); } save.fonts = flist.ToArray(); #endregion fonts #region scripts if (game.Scripts != null) { var scriptList = new List<gameScript>(); foreach (var script in game.Scripts) { var f = new gameScript(); f.src = script; scriptList.Add(f); } save.scripts = scriptList.ToArray(); } #endregion scripts #region events if (game.Events != null) { var eventList = new List<gameEvent>(); foreach (var e in game.Events.SelectMany(x => x.Value)) { var eve = new gameEvent(); eve.name = e.Name; eve.action = e.PythonFunction; eventList.Add(eve); } save.events = eventList.ToArray(); } #endregion events #region proxygen save.proxygen = new gameProxygen(); save.proxygen.definitionsrc = game.ProxyGenSource; #endregion proxygen #region globalvariables if (game.GlobalVariables != null) { var gllist = new List<gameGlobalvariable>(); foreach (var gv in game.GlobalVariables) { var v = new gameGlobalvariable(); v.name = gv.Name; v.value = gv.Value; gllist.Add(v); } save.globalvariables = gllist.ToArray(); } #endregion globalvariables #region GameModes if (game.Modes != null) { var list = new List<gameGameMode>(); foreach (var m in game.Modes) { var nm = new gameGameMode(); nm.name = m.Name; nm.image = m.Image = (m.Image ?? "").Replace(rootPath, ""); nm.playerCount = m.PlayerCount; nm.shortDescription = nm.shortDescription; list.Add(nm); } save.gameModes = list.ToArray(); } #endregion GameModes var serializer = new XmlSerializer(typeof(game)); directory = new FileInfo(game.InstallPath).Directory.FullName; using (var fs = File.Open(game.Filename, FileMode.Create, FileAccess.Write, FileShare.None)) { serializer.Serialize(fs, save); } return File.ReadAllBytes(game.Filename); }
public Element(game Tg) : base(Tg) { }
console = new GameConsole( game, "conchars");
public static void Main(string[] args) { if(args.Length == 1) { if(args[0] == "") { gme = new game("test"); } else { gme = new game(args[0]); } } else { gme = new game("test"); } data = new byte[1024]; if(args.Length == 2) { if(args[1] == "") { tcpListener = new TcpListener(localhost, 4); //according to iana port 4 is unassigned } else { tcpListener = new TcpListener(localhost, Convert.ToInt32(args[1])); } } else { tcpListener = new TcpListener(localhost, 4); } connectedClients = new Dictionary<string, client>(); tcpListener.Start(); Console.WriteLine("Server started!"); while(true) { bool loggedIn = false; tcpClient = tcpListener.AcceptTcpClient(); networkStream = tcpClient.GetStream(); Console.WriteLine("Client connected"); data = "WELC".ToByteArray(); networkStream.Write(data, 0, data.Length); Thread.Sleep(20); while (!loggedIn) { data = new byte[1024]; received = networkStream.Read(data, 0, data.Length); if (received == 0) break; string[] login = Encoding.ASCII.GetString(data, 0, received).Split(':'); string username = login[0]; string password = login[1]; loggedIn = true; if(connectedClients.ContainsKey(username)) { if(!(connectedClients[username].tcpClient.Connected)) { connectedClients[username] = new client(tcpClient, username, password, ref gme); } } else { connectedClients.Add(username, new client(tcpClient, username, password, ref gme)); } } } tcpListener.Stop(); }
public SPI(lobbyVals gameParams) { Game = new game(gameParams); }