public lk.ac.mrt.cse.pc11.AI.a a(CoinPile A_0) { lk.ac.mrt.cse.pc11.AI.a a; lk.ac.mrt.cse.pc11.AI.a a2; this.g = new lk.ac.mrt.cse.pc11.AI.c(); a2 = this.g.a(this.a(this.h().Index), new lk.ac.mrt.cse.pc11.AI.b(this.c().Position), new lk.ac.mrt.cse.pc11.AI.b(A_0.Position)); Label_0048: return a2; }
public d(CoinPile A_0, Contestant A_1, bool[][] A_2) { this.f = 0; base..ctor(); this.a = A_0; this.b = A_1; this.c = A_2; this.b(); return; }
public lk.ac.mrt.cse.pc11.AI.a b() { lk.ac.mrt.cse.pc11.AI.a a; this.g = new lk.ac.mrt.cse.pc11.AI.c(this.c); this.d = this.g.a(this.a(this.h().Index), new lk.ac.mrt.cse.pc11.AI.b(this.c().Position)); Label_0044: try { this.e = this.d.d(); goto Label_0066; } catch (Exception) { Label_0059: this.e = 100; goto Label_0066; } Label_0066: a = this.d; Label_0070: return a; }
private void createMap() { try { StreamReader sr = new StreamReader(ConfigurationManager.AppSettings.Get("MapPath")); String line; List<String> readInputs = new List<String>(); while ((line = sr.ReadLine()) != null) { readInputs.Add(line); } GameEngine.mapDetails = ""; if (readInputs.Count != 0) { GameEngine.mapSize = int.Parse(readInputs[0]); GameEngine.mapDetails += readInputs[0] + ":" + readInputs[1] + ":" + readInputs[2]; Point tempPoint; string[] tokens = readInputs[1].Split(new char[] { ';' }); for (int i = 0; i < tokens.Length; i++) { tempPoint = new Point(int.Parse(tokens[i].Substring(0, tokens[i].IndexOf(","))), int.Parse(tokens[i].Substring(tokens[i].IndexOf(",") + 1, tokens[i].Length - tokens[i].IndexOf(",") - 1))); GameEngine.brickLocations.Add(tempPoint); } tokens = readInputs[2].Split(new char[] { ';' }); for (int i = 0; i < tokens.Length; i++) { tempPoint = new Point(int.Parse(tokens[i].Substring(0, tokens[i].IndexOf(","))), int.Parse(tokens[i].Substring(tokens[i].IndexOf(",") + 1, tokens[i].Length - tokens[i].IndexOf(",") - 1))); GameEngine.obstacles.Add(tempPoint); } CoinPile tempCoinPile; for (int i = 3; i < readInputs.Count; i++) { tokens = readInputs[i].Split(new char[] { ',', ';' }); tempCoinPile = new CoinPile(int.Parse(tokens[0]), int.Parse(tokens[1])); tempCoinPile.AppearTime = int.Parse(tokens[2]); tempCoinPile.LifeTime = int.Parse(tokens[3]); tempCoinPile.Price = int.Parse(tokens[4]); tempCoinPile.DisappearTime = tempCoinPile.AppearTime + tempCoinPile.LifeTime; GameEngine.coinPileList.Add(tempCoinPile); } } sortCoinPileLists(); } catch (Exception ex1) { try { writeConsoleLines("Generating the map"); GameEngine.mapSize = Constant.MAP_SIZE; consoleLinesDoProgress(); RandomGen r = new RandomGen(); consoleLinesDoProgress(); // GameEngine.mapDetails = mapSize + ":"; consoleLinesDoProgress(); int maxBrick = Constant.MAX_BRICKS; if (maxBrick < 5) { maxBrick = 5; writeConsoleLines("Didn't I tell you to put at least 5? I am taking it as 5"); } consoleLinesDoProgress(); int brickCount = r.randomD(maxBrick / 2, maxBrick); consoleLinesDoProgress(); int lineCount = consoleLines.Count; for (int i = 0; i < brickCount; i++) { int x = r.randomD(mapSize - 1); int y = r.randomDP(mapSize - 1, mapSize, x); Point p = new Point(x, y); if (!brickLocations.Contains(p)) { GameEngine.brickLocations.Add(p); if (i != 0) { GameEngine.mapDetails = GameEngine.mapDetails + ";"; } GameEngine.mapDetails = GameEngine.mapDetails + x + "," + y; writeConsoleLines("Bricks:- " + (i + 1) + "/" + brickCount + " created", lineCount); } else { i--; } } GameEngine.mapDetails = GameEngine.mapDetails + ":"; int maxObs = Constant.MAX_OBSTACLES; int minObs = 8; consoleLinesDoProgress(); if (maxObs < 8) { maxObs = 8; writeConsoleLines("Didn't I tell you to put at least 8? I am taking it as 8"); } if (minObs < brickCount)//More obstacals than bricks needed { minObs = brickCount; } if (minObs > maxObs)//But keep in the possible region { minObs = maxObs; } consoleLinesDoProgress(); int obsCount = r.randomD(minObs, maxObs); lineCount = consoleLines.Count; for (int i = 0; i < obsCount; i++) { int x = r.randomD(mapSize - 1); int y = r.randomDP(mapSize - 1, mapSize, x); Point p = new Point(x, y); if ((!brickLocations.Contains(p)) & (!obstacles.Contains(p))) { GameEngine.obstacles.Add(p); if (i != 0) { GameEngine.mapDetails = GameEngine.mapDetails + ";"; } GameEngine.mapDetails = GameEngine.mapDetails + x + "," + y; writeConsoleLines("Stone :- " + (i + 1) + "/" + obsCount + " created", lineCount); } else { i--; } } GameEngine.mapDetails = GameEngine.mapDetails + ":"; consoleLinesDoProgress(); int waterCount = 10; lineCount = consoleLines.Count; for (int i = 0; i < waterCount; i++) { int x = r.randomD(mapSize - 1); int y = r.randomDP(mapSize - 1, mapSize, x); Point p = new Point(x, y); if ((!brickLocations.Contains(p)) & (!obstacles.Contains(p)) & (!water.Contains(p))) { GameEngine.water.Add(p); if (i != 0) { GameEngine.mapDetails = GameEngine.mapDetails + ";"; } GameEngine.mapDetails = GameEngine.mapDetails + x + "," + y; writeConsoleLines("water:- " + (i + 1) + "/" + waterCount + " created", lineCount); } else { i--; } } //Create brick walls for (int i = 0; i < brickLocations.Count; i++) { brickWalls.Add(new BrickWall(brickLocations[i])); } int tresCount = (Constant.CoinPile_RATE) * (Constant.LIFE_TIME / 60000);// CoinPiles for every 1 min consoleLinesDoProgress(); MapItem tempMapItem; consoleLinesDoProgress(); List<Point> points = CreatePointList(tresCount); lineCount = consoleLines.Count; for (int i = 0; i < Math.Min(tresCount, points.Count); i++) { try { tempMapItem = CreateMapItem(points[i], true); List<MapItem> conflictPoints = new List<MapItem>(); for (int j = 0; j < CoinPileList.Count; j++) { conflictPoints.Add(CoinPileList[j]); } Boolean pass = GetMapItemAcceptance(tempMapItem, conflictPoints); if (pass) { GameEngine.coinPileList.Add((CoinPile)tempMapItem); writeConsoleLines("CoinPiles :- " + (i + 1) + "/" + Math.Min(tresCount, points.Count) + " created", lineCount); } else { i--;//Recalculate } } catch (Exception e) { Console.WriteLine("..............................."); Console.WriteLine(e.StackTrace); Console.WriteLine("..............................."); } } int lifePackCount = (Constant.LIFEPACK_RATE) * (Constant.LIFE_TIME / 60000);// CoinPiles for every 1 min consoleLinesDoProgress(); points = CreatePointList(lifePackCount); lineCount = consoleLines.Count; for (int i = 0; i < Math.Min(lifePackCount, points.Count); i++) { try { tempMapItem = CreateMapItem(points[i], false); List<MapItem> conflictPoints = new List<MapItem>(); for (int j = 0; j < CoinPileList.Count; j++) { conflictPoints.Add(CoinPileList[j]); } for (int j = 0; j < lifePackList.Count; j++) { conflictPoints.Add(lifePackList[j]); } Boolean pass = GetMapItemAcceptance(tempMapItem, conflictPoints); if (pass) { GameEngine.lifePackList.Add((LifePack)tempMapItem); writeConsoleLines("LifePacks :- " + (i + 1) + "/" + Math.Min(lifePackCount, points.Count) + " created", lineCount); } else { i--;//Recalculate } } catch (Exception e) { Console.WriteLine("..............................."); Console.WriteLine(e.StackTrace); Console.WriteLine("..............................."); } } writeConsoleLines("\nMap generation was successful!"); Console.Write("\n"); for (int i = 0; i < mapSize; i++) { for (int j = 0; j < mapSize; j++) { Point p = new Point(j, i); if (brickLocations.Contains(p)) { Console.Write("B"); } else if (obstacles.Contains(p)) { Console.Write("S"); } else if (water.Contains(p)) { Console.Write("W"); } else { Console.Write("N"); } Console.Write(" "); } Console.Write("\n"); } Console.Write("\n"); sortCoinPileLists(); } catch (Exception ex2) { Console.WriteLine("Could not load nor generate Map!!!\n\n"); Console.WriteLine("Error Message: " + ex1.Message + "\n\n"); Console.WriteLine("Error Message: " + ex2.Message + "\n\n"); Console.WriteLine("Server not started! Please restart the server!"); while (true) { Console.ReadLine(); } } } }
private void IssuePlunderCoinPile(Point pos, int value) { string tStatus = "C:" + pos.X + "," + pos.Y + ":" + Constant.PLUNDER_TREASUR_LIFE + ":" + value + Constant.S2C_DEL; DataObject dO = new DataObject(tStatus, GameEngine.playerIPList, GameEngine.playerPort); ThreadPool.QueueUserWorkItem(new WaitCallback(com.BroadCast), (object)dO); Console.WriteLine("NEXT CoinPile IN :" + GameEngine.nextCoinPileSend + " :: T-To-Disclose :" + GameEngine.coinPilesToDisclose); Console.WriteLine(tStatus); CoinPile c = new CoinPile(pos.X, pos.Y); c.Price = value; int waitAmout = 0; for (int i = 0; i < plunderCoinPileList.Count; i++) { waitAmout += plunderCoinPileList[i].DisappearBalance; } c.DisappearBalance = Math.Max(0, (Constant.PLUNDER_TREASUR_LIFE - waitAmout)); plunderCoinPileList.Add(c); gui.AddCoin(pos.X, pos.Y, value, Constant.PLUNDER_TREASUR_LIFE); }
private MapItem CreateMapItem(Point p, Boolean isCoinPile) { RandomGen r = new RandomGen(); MapItem tempMapItem; if (isCoinPile) { tempMapItem = new CoinPile(p.X, p.Y); ((CoinPile)tempMapItem).Price = r.randomD(700, 2000); } else { tempMapItem = new LifePack(p.X, p.Y); } tempMapItem.LifeTime = r.randomD(Convert.ToInt32((Constant.MAP_SIZE / 4) * Constant.PLAYER_DELAY), Constant.LIFE_TIME / 10); tempMapItem.AppearTime = r.randomD(0, (Constant.LIFE_TIME - tempMapItem.LifeTime)); tempMapItem.DisappearTime = tempMapItem.AppearTime + tempMapItem.LifeTime; return tempMapItem; }
internal lk.ac.mrt.cse.pc11.AI.a f() { lk.ac.mrt.cse.pc11.AI.a a; a = this.d; Label_000A: return a; }
/// <summary> /// Initializing the timers /// </summary> private void InitializeTimers() { this.updateCoinPileTimer = new System.Timers.Timer(); this.playerUpdateTimer = new System.Timers.Timer(); this.lifeTimer = new System.Timers.Timer(); this.CoinPileDisappearTimer = new System.Timers.Timer(); this.updateLifePackTimer = new System.Timers.Timer(); this.lifePackDisappearTimer = new System.Timers.Timer(); this.plunderCoinPileDisappearTimer = new System.Timers.Timer(); this.updateCoinPileTimer.Elapsed += new ElapsedEventHandler(updateCoinPileTimer_Elapsed); this.playerUpdateTimer.Elapsed += new ElapsedEventHandler(playerUpdateTimer_Elapsed); this.lifeTimer.Elapsed += new ElapsedEventHandler(lifeTimer_Elapsed); this.CoinPileDisappearTimer.Elapsed += new ElapsedEventHandler(CoinPileDisappearTimer_Elapsed); this.updateLifePackTimer.Elapsed += new ElapsedEventHandler(updateLifePackTimer_Elapsed); this.lifePackDisappearTimer.Elapsed += new ElapsedEventHandler(lifePackDisappearTimer_Elapsed); this.plunderCoinPileDisappearTimer.Elapsed += new ElapsedEventHandler(plunderCoinPileDisappearTimer_Elapsed); this.playerUpdateTimer.Enabled = true; this.lifeTimer.Enabled = true; this.updateCoinPileTimer.Enabled = true; this.CoinPileDisappearTimer.Enabled = true; this.updateLifePackTimer.Enabled = true; this.lifePackDisappearTimer.Enabled = true; this.plunderCoinPileDisappearTimer.Enabled = true; this.playerUpdateTimer.Interval = Constant.UPDATE_PERIOD; this.lifeTimer.Interval = Constant.LIFE_TIME; this.plunderCoinPileDisappearTimer.Interval = 1; if (gameEng.CoinPileList.Count > 0) { gameEng.NextCoinPileSend = gameEng.CoinPileList[gameEng.CoinPilesToDisclose - 1].AppearTime; this.updateCoinPileTimer.Interval = gameEng.NextCoinPileSend; this.CoinPileDisappearTimer.Interval = gameEng.DisappearCoinPileList[0].DisappearTime; this.nextCoinPileToDisappear = gameEng.DisappearCoinPileList[0]; } else { this.CoinPileDisappearTimer.Interval = Constant.LIFE_TIME; this.nextCoinPileToDisappear = new CoinPile(-1, -1); this.nextCoinPileToDisappear.AppearTime = Constant.LIFE_TIME; this.nextCoinPileToDisappear.DisappearTime = Constant.LIFE_TIME; } if (gameEng.LifePackList.Count > 0) { gameEng.NextLifePackSend = gameEng.LifePackList[gameEng.LifePacksToDisclose - 1].AppearTime; this.updateLifePackTimer.Interval = gameEng.NextLifePackSend; this.lifePackDisappearTimer.Interval = gameEng.DisappearLifePackList[0].DisappearTime; this.nextLifePackToDisappear = gameEng.DisappearLifePackList[0]; } else { this.lifePackDisappearTimer.Interval = Constant.LIFE_TIME; this.nextLifePackToDisappear = new LifePack(-1, -1); this.nextLifePackToDisappear.AppearTime = Constant.LIFE_TIME; this.nextLifePackToDisappear.DisappearTime = Constant.LIFE_TIME; } this.updateCoinPileTimer.Stop(); this.CoinPileDisappearTimer.Stop(); this.updateLifePackTimer.Stop(); this.lifePackDisappearTimer.Stop(); this.playerUpdateTimer.Stop(); this.lifeTimer.Stop(); }
/// <summary> /// What needs to be done when a CoinPile disappears /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void CoinPileDisappearTimer_Elapsed(object sender, ElapsedEventArgs e) { if (this.nextCoinPileToDisappear != null) { Monitor.Enter(gameEng.DisappearCoinPileList); Monitor.Enter(gameEng.AvailableCoinPileList); CoinPile CoinPileNextInLine = null; int currentIndex = gameEng.DisappearCoinPileList.IndexOf(this.nextCoinPileToDisappear); if (gameEng.AvailableCoinPileList.Contains(this.nextCoinPileToDisappear)) { Console.WriteLine("CoinPile @ " + this.nextCoinPileToDisappear.Position + " VANISHED"); gui.RemoveMapItem(this.nextCoinPileToDisappear.Position.X, this.nextCoinPileToDisappear.Position.Y); gameEng.AvailableCoinPileList.Remove(this.nextCoinPileToDisappear); } if (currentIndex < gameEng.DisappearCoinPileList.Count - 2) { CoinPileNextInLine = gameEng.DisappearCoinPileList[currentIndex + 1]; int updateTimeSpan = CoinPileNextInLine.DisappearTime - this.nextCoinPileToDisappear.DisappearTime; if (updateTimeSpan > 0) this.CoinPileDisappearTimer.Interval = updateTimeSpan; else this.CoinPileDisappearTimer.Interval = 500; this.nextCoinPileToDisappear = CoinPileNextInLine; } else { int updateTimeSpan = gameEng.DisappearCoinPileList[gameEng.DisappearCoinPileList.Count - 1].DisappearTime - gameEng.DisappearCoinPileList[gameEng.DisappearCoinPileList.Count - 2].DisappearTime; if (updateTimeSpan != 0) this.CoinPileDisappearTimer.Interval = updateTimeSpan; else this.CoinPileDisappearTimer.Interval = 500; this.nextCoinPileToDisappear = null; } Monitor.Exit(gameEng.AvailableCoinPileList); Monitor.Exit(gameEng.DisappearCoinPileList); } else { if (gameEng.AvailableCoinPileList.Contains(gameEng.DisappearCoinPileList[gameEng.DisappearCoinPileList.Count-1])) { Monitor.Enter(gameEng.DisappearCoinPileList); Monitor.Enter(gameEng.AvailableCoinPileList); Console.WriteLine("CoinPile @ " + gameEng.DisappearCoinPileList[gameEng.DisappearCoinPileList.Count - 1].Position + " VANISHED"); gui.RemoveMapItem(gameEng.DisappearCoinPileList[gameEng.DisappearCoinPileList.Count - 1].Position.X, gameEng.DisappearCoinPileList[gameEng.DisappearCoinPileList.Count - 1].Position.Y); gameEng.AvailableCoinPileList.Remove(this.nextCoinPileToDisappear); Monitor.Exit(gameEng.AvailableCoinPileList); Monitor.Exit(gameEng.DisappearCoinPileList); gameFinisherThread.RunWorkerAsync(); } } }