public void Initialize() { moneyString = "Money: " + GameAuth.GetCurrentGame().Money; moneyPosition = new Vector2(30, screenHeight - 60); bagString = "Items in bag: " + GetItemsCount(GameAuth.GetCurrentGame()); bagPosition = new Vector2(300, screenHeight - 60); closeString = "Close"; closePosition = new Vector2(screenWidth - 100, screenHeight - 60); close = new Button(closeString, closePosition); items = new List <ShopItem>(); List <Item> shopItems = GetAllShopItems(); for (int i = 0, col = 0, row = 0; i < shopItems.Count; col++, i++) { if (col == 4) { row++; col = 0; } Vector2 position = new Vector2(30 + col * 200, 20 + row * 200); items.Add(new ShopItem(shopItems[i], position)); } foreach (ShopItem si in items) { si.Initialize(); } }
public void Initialize() { var charactersList = GetAllGameCharacters(GameAuth.GetCurrentGame()); characters = new List <CharacterBlock>(); for (int i = 0; i < charactersList.Count; i++) { characters.Add(new CharacterBlock(charactersList[i], new Vector2(15, 15 + i * 150))); } foreach (CharacterBlock cb in characters) { cb.Initialize(); } bgPosition = Vector2.Zero; shopPosition = new Vector2(screenWidth / 3, screenHeight - 60); backPosition = new Vector2(shopPosition.X + screenWidth / 3, screenHeight - 60); shopString = "Shop"; backString = "Back"; shop = new Button(shopString, shopPosition); back = new Button(backString, backPosition); buttons = new List <Button>(); buttons.Add(shop); buttons.Add(back); shopScreen.Initialize(); }
private void NewGame() { Models.Game currentGame = CreateNewGame(); AddCharactersToGame(currentGame); GameAuth.SetCurrentGame(currentGame); StaticBooleans.SetHasNewGame(true); StaticBooleans.SetIsGameMenuInitializedBool(false); }
public void Update() { moneyString = "Money: " + GetAmountOfMoney(GameAuth.GetCurrentGame()); bagString = "Items in bag: " + GetItemsCount(GameAuth.GetCurrentGame()); foreach (ShopItem si in items) { si.Update(); } close.Update(); }
public void Initialize() { moneyWon = didWin ? "300" : "100"; fightResult = didWin ? "YOU WIN" : "YOU LOSE"; color = didWin ? Color.Black : Color.White; fightResultPos = didWin ? new Vector2(500, 50) : new Vector2(100, 220); moneyWonPos = didWin ? new Vector2(500, 100) : new Vector2(100, 270); highscoreMadePos = didWin ? new Vector2(500, 130) : new Vector2(100, 290); levelValue = GetTotalHighscore(GameAuth.GetCurrentGame(), fighter); levelUpString = "You leveled up - Level: " + levelValue; levelUpStringPos = didWin ? new Vector2(500, 150) : new Vector2(100, 310); escape = "Press Escape For Menu"; escapePos = didWin ? new Vector2(500, 170) : new Vector2(100, 330); }
/// <summary> /// Main /// </summary> /// <param name="args">[0] = Admin key</param> public static void Main(string[] args) { if (args.Length > 0) { GameAuth.ChangeAdminKey(args[0]); } PrintVersion(); ReadConfig(); PrintInfo(); InitLogic(); InitMods(); StartAPI(args); }
public void Update(ContentManager Content, GameTime gameTime) { if (!StaticBooleans.IsShopOpen) { foreach (Button button in buttons) { button.Update(); } } if (StaticBooleans.IsLoadGamesOn && StaticBooleans.HasNewGame) { loadGameScreen.Initialize(); loadGameScreen.LoadContent(Content); StaticBooleans.SetHasNewGame(false); } if (StaticBooleans.IsLoadGamesOn && !StaticBooleans.IsShopOpen) { loadGameScreen.Update(); } if (StaticBooleans.IsStatGamesOn) { loadStatGameScreen.Initialize(); loadStatGameScreen.LoadContent(Content); StaticBooleans.SetHasNewGame(false); } if (StaticBooleans.IsStatGamesOn && !StaticBooleans.IsShopOpen) { loadStatGameScreen.Update(); } if (GameAuth.HasStartedGame() && !StaticBooleans.IsGameMenuInitialized) { gameMenu.Initialize(); gameMenu.LoadContent(Content); StaticBooleans.SetIsGameMenuInitializedBool(true); } if (GameAuth.HasStartedGame()) { gameMenu.Update(Content, gameTime); } }
private void GameExit_Tick(object sender, EventArgs e) { if (IsGameRunning()) { if (ExitLevel == 0) { this.Hide(); } ExitLevel = 1; BlockUnauthorizedPrograms(true); } else if (ExitLevel > 0) { ExitLevel = 0; GameAuth.Stop(); try { string sampchatlogpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "GTA San Andreas User Files", "SAMP"); string larpchatlogfile = Path.Combine(Program.Path_ChatLog, "ChatLog" + DateTime.Now.ToString("-yyMMdd-HHmmss") + ".txt"); if (!Directory.Exists(Program.Path_ChatLog)) { Directory.CreateDirectory(Program.Path_ChatLog); } File.Copy(Path.Combine(sampchatlogpath, "chatlog.txt"), larpchatlogfile, true); PercentageLabel.Text = "챗로그가 자동 백업되었습니다."; } catch { PercentageLabel.Text = "챗로그 백업에 실패했습니다."; } // 하단 버튼 설정 Button_2_1.Text = "열기"; Button_2_2.Text = "종료"; SetButtonEvent(Button_2_1, ButtonEvent_OpenChatLog); SetButtonEvent(Button_2_2, ButtonEvent_Exit); ShowButtons(2); this.Show(); this.TopMost = true; this.TopMost = false; } }
public void Draw(SpriteBatch spriteBatch, ContentManager Content) { //spriteBatch.Begin(); if (GameAuth.HasStartedGame()) { gameMenu.Draw(spriteBatch, Content); } else if (StaticBooleans.IsLoadGamesOn) { loadGameScreen.Draw(spriteBatch); } else if (StaticBooleans.IsStatGamesOn) { loadStatGameScreen.Draw(spriteBatch); } else { LoadMainMenu(spriteBatch); } //spriteBatch.End(); }
public void Update() { prevMouseState = MouseState; MouseState = Mouse.GetState(); if (MouseState.X < pos.X || MouseState.Y < pos.Y || MouseState.X > pos.X + font.MeasureString(name).X || MouseState.Y > pos.Y + font.MeasureString(name).Y) { //The mouse is not hovering over the button color = new Color(255, 255, 255); if (StaticBooleans.IsShopOpen) { if (item != null && this.item.Price > GameAuth.GetCurrentGame().Money) { color = new Color(161, 161, 161); } else if (item != null && BagOver4(GameAuth.GetCurrentGame())) { color = new Color(161, 161, 161); } } } else { color = new Color(161, 161, 161); if (MouseState.LeftButton == ButtonState.Pressed && prevMouseState.LeftButton == ButtonState.Released) { switch (name) { case "New Game": NewGame(); break; case "Load Game": StaticBooleans.SetLoadGamesBool(true); break; case "Statistics": StaticBooleans.SetStatBool(true); break; case "Fight": StartFight(this.character, GameAuth.GetCurrentGame()); break; case "Shop": StaticBooleans.SetOpenShopBool(true); break; case "Buy": BuyIfPossible(this.item, GameAuth.GetCurrentGame()); break; case "Close": StaticBooleans.SetOpenShopBool(false); break; case "Back": if (!StaticBooleans.IsShopOpen) { GameAuth.EndGame(); StaticBooleans.SetLoadGamesBool(false); StaticBooleans.SetStatBool(false); } break; default: LoadGame(this.game); break; } } } }
private void LoadGame(Models.Game game) { Models.Game currentGame = game; GameAuth.SetCurrentGame(currentGame); StaticBooleans.SetIsGameMenuInitializedBool(false); }
public void Initialize() { fight = FightAuth.GetCurrentFight(); character = new Character(); character = GetCharacterFromFight(fight); map.Initialize(); fighter = new Fighter(character); fighter.Initialize(); enemy = new Enemy(); enemy.Initialize(); drawNames = new DrawNames(fighter.Character, enemy.Character); drawNames.Initialize(); itemsInBag = new List <Item>(); itemsInBag = GetGameItems(GameAuth.GetCurrentGame()); gameItems = new List <GameItem>(); int offset = 0; foreach (Item i in itemsInBag) { gameItems.Add(new GameItem(i, new Vector2(210 + offset, screenHeight - 80))); offset += 110; } foreach (GameItem gi in gameItems) { gi.Initialize(); } control = new Control(fight, fighter, enemy, gameItems); control.Initialize(); InitializeBars(); attacks = new List <Components.Attack>(); basicAttack = new Components.Attack("Basic", new Vector2(340, 90), fighter.Character, fighter.BasicAttack, control); specialAttack = new Components.Attack("Special", new Vector2(410, 90), fighter.Character, fighter.SpecialAttack, control); attacks.Add(basicAttack); attacks.Add(specialAttack); //test playerHealth = control.PlayerHealth.ToString(); playerHealthPos = new Vector2(20, 25); playerMana = control.PlayerMana.ToString(); playerManaPos = new Vector2(20, 55); playerAtk = control.PlayerAtk.ToString(); playerAtkPos = new Vector2(20, 140); playerSpAtk = control.PlayerSpAtk.ToString(); playerSpAtkPos = new Vector2(20, 160); enemyHealth = control.EnemyHealth.ToString(); enemyHealthPos = new Vector2(420, 25); enemyMana = control.EnemyMana.ToString(); enemyManaPos = new Vector2(420, 55); enemyAtk = control.EnemyAtk.ToString(); enemyAtkPos = new Vector2(700, 140); enemySpAtk = control.EnemySpAtk.ToString(); enemySpAtkPos = new Vector2(700, 160); //test numberOne = "1"; numberTwo = "2"; numberThree = "3"; numberFour = "4"; positionOne = new Vector2(230, screenHeight - 30); positionTwo = new Vector2(340, screenHeight - 30); positionThree = new Vector2(450, screenHeight - 30); positionFour = new Vector2(560, screenHeight - 30); }
private void GameStart_Tick(object sender, EventArgs e) { GameStart.Stop(); KillGameProcess(); Debug.Print("InitLevel - " + InitLevel + " - "); switch (InitLevel) { case 1: // 서버 연결 확인 HttpWebRequest request; HttpWebResponse response; HttpStatusCode[] statuscode = new HttpStatusCode[2]; try { request = (HttpWebRequest)WebRequest.Create(new Uri(Program.InfowebURL)); request.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore); response = (HttpWebResponse)request.GetResponse(); statuscode[0] = response.StatusCode; response.Close(); request = (HttpWebRequest)WebRequest.Create(new Uri(Program.LauncherURL)); request.CachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore); response = (HttpWebResponse)request.GetResponse(); statuscode[1] = response.StatusCode; response.Close(); } catch { statuscode[0] = statuscode[1] = HttpStatusCode.NotFound; } if (statuscode[0] != HttpStatusCode.OK && statuscode[1] != HttpStatusCode.OK) { PercentageLabel.Text = "서버에 연결할 수 없습니다."; Button_2_1.Text = "인포웹"; Button_2_2.Text = "종료"; SetButtonEvent(Button_2_1, ButtonEvent_OpenInfoweb); SetButtonEvent(Button_2_2, ButtonEvent_Exit); ShowButtons(2); this.TopMost = true; this.TopMost = false; } else { GameStart.Start(); } break; case 2: // 런처 업데이트 StartUpdate(); break; case 3: // 게임 구성 파일 변조 검사 및 패치 // 비인가 프로그램 차단 (파일 변조 검사 제외) ResetAuthorizedFiles(); LoadAuthorizedFilesFromServer(Program.LauncherURL + "/getfilelist.do?type=allowedfiles"); LoadAuthorizedFilesFromServer(Program.LauncherURL + "/getfilelist.do?type=patch"); LoadAuthorizedFilesFromServer(Program.LauncherURL + "/getfilelist.do?type=launcher"); if (BlockUnauthorizedPrograms()) { return; } // 검사 및 패치 if (!CompareMD5OfGameFile(Program.LauncherURL + "/getfilelist.do?type=patch")) { StartPatch(Program.LauncherURL + "/patch", GetDissimilarFiles()); } else { // 게임 실행 단계 진행 GameStart.Start(); } break; case 4: // 게임 실행 // 비인가 프로그램 차단 (파일 변조 검사 포함) if (BlockUnauthorizedPrograms()) { return; } // 닉네임 레지스트리 동기화 SaveUsernameToRegistry(); if (GetNewLauncherPath() != String.Empty) { // URL Scheme CreateUrlSchemeRegistry(); // 최신 런처 실행 RunNewLauncher(); } else if (string.Compare(GetUsername(), "NULL") == 0) { Button_2_1.Text = "인포웹"; Button_2_2.Text = "종료"; SetButtonEvent(Button_2_1, ButtonEvent_OpenInfoweb); SetButtonEvent(Button_2_2, ButtonEvent_Exit); ShowButtons(2); alert("설치 완료", false); } else if (!GenerateToken(ref CToken, Program.LauncherURL + "/auth.do", "conn")) { Button_1_1.Text = "종료"; SetButtonEvent(Button_1_1, ButtonEvent_Exit); ShowButtons(1); alert("접속 인증 실패", false); } else { PercentageLabel.Text = "게임에 접속중입니다."; // IP 등록 RegisterIP(); // SAMP 실행 StartedGamePath = GetGamePath(); Process.Start(Path.Combine(StartedGamePath, "samp.exe"), "server.la-rp.co.kr"); GameExit.Start(); GameAuth.Start(); } break; } InitLevel++; }
public void Update(GameTime gameTime, ContentManager Content) { if (hasFightEnded) { if (!hasEndBeenInitialized) { endFightScreen = new EndFightScreen(didWin, highscoreMade.ToString(), fighter); endFightScreen.Initialize(); endFightScreen.LoadContent(Content); hasEndBeenInitialized = true; } endFightScreen.Update(); } else { if (!endFight) { if (!changeTurn) { if (this.Turn == 0) { prevKeyState = keyState; keyState = Keyboard.GetState(); if (keyState.IsKeyDown(Keys.D1) && prevKeyState.IsKeyUp(Keys.D1)) { UseItem(gameItems[0]); gameItems[0].IsUsed = true; } if (keyState.IsKeyDown(Keys.D2) && prevKeyState.IsKeyUp(Keys.D2)) { UseItem(gameItems[1]); gameItems[1].IsUsed = true; } if (keyState.IsKeyDown(Keys.D3) && prevKeyState.IsKeyUp(Keys.D3)) { UseItem(gameItems[2]); gameItems[2].IsUsed = true; } if (keyState.IsKeyDown(Keys.D4) && prevKeyState.IsKeyUp(Keys.D4)) { UseItem(gameItems[3]); gameItems[3].IsUsed = true; } if (fighter.BasicAttack.Active) { FighterBasicAttack(gameTime); changeTurn = true; } else if (fighter.SpecialAttack.Active) { FighterSpecialAttack(gameTime); changeTurn = true; } } else { if (enemyMana >= enemySpAtk) { EnemySpecialAttack(gameTime); } else { EnemyBasicAttack(gameTime); } changeTurn = true; } } if (changeTurn) { Wait(gameTime); } } else { EndFightPause(gameTime); if (waitingDone) { SaveBagToDatabase(GameAuth.GetCurrentGame(), gameItems); if (didWin) { YouWin(gameTime); } else { YouLose(gameTime); } } } } }