// Game public void PlayGame(uint gameID) { Logger.Log($"Starting app {gameID}..."); var playGames = new ClientMsgProtobuf <CMsgClientGamesPlayed>(EMsg.ClientGamesPlayed); playGames.Body.games_played.Add(new CMsgClientGamesPlayed.GamePlayed { game_id = gameID, steam_id_gs = 0, game_ip_address = 0, game_port = 0, is_secure = false, game_extra_info = "", process_id = Utils.RandomPID(), streaming_provider_id = 0, game_flags = 3, owner_id = Client.SteamID.AccountID, launch_option_type = 0, launch_source = 100, }); playGames.Body.client_os_type = (uint)EOSType.Windows10; Client.Send(playGames); Task.Delay(2000).ContinueWith(x => { Logger.Log($"Sending matchmaking hello..."); LastActionTime = DateTime.Now; var clientHello = new ClientGCMsgProtobuf <CMsgClientHello>( (uint)EGCBaseClientMsg.k_EMsgGCClientHello ); GameCoordinator.Send(clientHello, 730); }); }
/// <summary> /// Finishes the current game by updating the game results, depending on the win/lost state of the game /// </summary> /// <param name="coordinator"></param> private void FinishGame(GameCoordinator coordinator) { GameViewModel model = coordinator.ViewModel; // Get current player record so we can update the statistics var user = users.GetById(model.Id); if (model.GameStatus == GameStatus.Win) { model.ImageUrl = UtilityConstants.WinImageUrl; model.WordInProgress.Clear(); model.WordInProgress.Add(model.FullWord); // Update statistics user.GamesWon += 1; if (model.GuessedChars == 0) { user.FullWordGuesses += 1; } } else if (model.GameStatus == GameStatus.Lose) { model.ImageUrl = UtilityConstants.LoseImageUrl; // Update statistics user.GamesLost += 1; } // Update the completed games and number of guesses made user.GamesPlayed += 1; user.Guesses = model.GuessedChars + model.MistakenChars; users.Save(); }
/// <summary> /// Called from ActionButton /// </summary> /// <param name="itemClicked"></param> public void ShopLevelClicked(GameObject itemClicked) { var clickedItemLevel = itemClicked.GetComponent <UI_WeaponShop_ItemLevel>(); SetActivePreview(clickedItemLevel.level); // note: we want to include the shop potential sales in the price. int previousItemValue = weaponShop.GetItemValue(weaponShop.equippedWeapon); int newItemCost = weaponShop.GetItemValue(clickedItemLevel.item, clickedItemLevel.level); if (previousItemValue + GameCoordinator.instance.currencyValue < newItemCost) { GameCoordinator.PlayOneShot(GameCoordinator.instance.data.errorSound); } else { GameCoordinator.instance.currencyValue += previousItemValue - newItemCost; level = clickedItemLevel.level; weaponShop.EquipdWeapon(this); GameCoordinator.instance.data.equippedPrimaryWeaponPrefab = primaryWeapon; GameCoordinator.instance.data.primaryWeaponLevel = level; foreach (var itemLevel in itemLevels) { if (itemLevel.level <= clickedItemLevel.level) { itemLevel.SetUIActive(); } else { itemLevel.SetUIDisabled(); } } } }
private void Start() { gameCoordinator = GameCoordinator.Coordinator; if (gameCoordinator == null) { Debug.LogError(gameObject.name + ": couldn't get GameCoordinator reference.", gameObject); } }
public Board(GameCoordinator coordinator) { this.coordinator = coordinator; random = new System.Random(); TileMap = new Dictionary <HexCoords, TileTypes>(); Units = new Dictionary <HexCorner, Unit>(); Roads = new Dictionary <HexEdge, Road>(); CornerGraph = new HexCornerGraph(this); }
public void init(Player owner, GameCoordinator game, MapCoordinator map) { Owner = owner; Owner.Team.Add(this); Health = Traits[Trait.Health]; _Targeter = new TargetingHandler(this, game); _Targeter.Priority = TargetPriority; _Game = game; _Map = map; }
private void OnClientWelcome(IPacketGCMsg obj) { Logger.Log("Received client welcome!"); LastActionTime = DateTime.Now; var request = new ClientGCMsgProtobuf <CMsgGCCStrike15_v2_MatchmakingClient2GCHello>( (uint)ECsgoGCMsg.k_EMsgGCCStrike15_v2_MatchmakingClient2GCHello ); GameCoordinator.Send(request, 730); }
private void Awake() { if (Instance == null) { Instance = this; } foreach (Transform t in EnemyList.transform) { enemies.Add(t.GetComponent <Oink>()); } }
// Use this for initialization void Start() { buttonRef = GetComponent <Button>(); buttonRef.onClick.AddListener(ApplySpeedPolicy); OGNormalColor = buttonRef.colors.normalColor; OGHighlighted = buttonRef.colors.highlightedColor; if (GameCoordinator.getInstance().getCurrentSpeedPolicy() == speedPolicyToApply) { changeColorToActive(); } }
private void Start() { var provider = ViewProvider.Instance; provider.Preloader = _preloader; provider.MainScreen = _mainScreen; provider.Gameplay = _gameplay; var gameCoordinator = new GameCoordinator(); gameCoordinator.Present(null); }
public static void Construct() { if (initialized) { return; } if (instance == null) { instance = new GameObject("GameCoordinator").AddComponent <GameCoordinator>(); } instance.Init(); }
// Start is called before the first frame update void Awake() { if (Instance == null) { Instance = this; } else { Destroy(this.gameObject); return; } DontDestroyOnLoad(this.gameObject); }
private float GetFuelPolicyConsumption() { switch (GameCoordinator.getInstance().getCurrentSpeedPolicy()) { case shipSpeed.HighSpeed: return(HighSpeedFuelConsumptionFactor); case shipSpeed.NormalSpeed: return(NormalSpeedFuelConsumptionFactor); default: return(LowSpeedFuelConsumptionFactor); } }
private void Awake() { _cachedInstance = this; GameTime = new NetworkedTime() { Rate = 1 }; TimeLeft = new NetworkedTime() { Rate = -1 }; }
/// <summary> /// Processes a letter guess /// </summary> /// <param name="guess">A single letter, which has been chosen by the user</param> /// <returns></returns> public ActionResult WordGuess(string guess) { GameCoordinator gameCoordinator = new GameCoordinator(); GameViewModel model = gameCoordinator.ViewModel; gameCoordinator.ProcessGuess(guess); if (model.GameStatus == GameStatus.Win || model.GameStatus == GameStatus.Lose) { FinishGame(gameCoordinator); } return(View("Game", model)); }
public static void Main(string[] args) { var consoleWrapper = new ConsoleWrapper(); var outputHandler = new OutputHandler(consoleWrapper); var inputHandler = new InputHandler(outputHandler, consoleWrapper); var gameRunner = new GameRunner(outputHandler); var coordinator = new GameCoordinator(gameRunner, inputHandler); outputHandler.Welcome(); coordinator.Play(); }
/// <summary> /// Gathers the game results for the current user and sends them to the view /// </summary> /// <returns></returns> public ActionResult ShowResults() { GameCoordinator gameCoordinator = new GameCoordinator(); ApplicationUser currentUser = users.GetById(this.User.Identity.GetUserId()); gameCoordinator.ResultsViewModel.UserName = currentUser.UserName; gameCoordinator.ResultsViewModel.FullWordGuesses = currentUser.FullWordGuesses; gameCoordinator.ResultsViewModel.GamesWon = currentUser.GamesWon; gameCoordinator.ResultsViewModel.GamesLost = currentUser.GamesLost; gameCoordinator.ResultsViewModel.GamesPlayed = currentUser.GamesPlayed; gameCoordinator.ResultsViewModel.Guesses = currentUser.Guesses; return(View("../Game/Results", gameCoordinator.ResultsViewModel)); }
private void Awake() { if (Instance != null) { _level = Instance._level; _health = Instance._health; Destroy(Instance.gameObject); Instance = null; } DontDestroyOnLoad(this.gameObject); Instance = this; }
// Start is called before the first frame update void Start() { Instance = this; for (int i = 2; i >= 1; i--) { for (int j = 1; j <= nc; j++) { var newPiece = Instantiate(PiecePrefab, PlacementBoard.transform.position + new Vector3(squareWidth * (j - 3.5f), squareWidth * (i - 1.5f), -1), Quaternion.identity); newPiece.GetComponent <SpriteRenderer>().sprite = pieceSprites[0]; newPiece.GetComponent <SpriteRenderer>().material.color = selfUnrevealedPieceColor; placementTable[i, j] = newPiece; } } }
private void Start() { if (obstacleTemplatesGameObject == null) { Debug.LogError(gameObject.name + ": obstacles templates object not stated.", gameObject); } gameCoordinator = GameCoordinator.Coordinator; if (gameCoordinator == null) { Debug.LogError(gameObject.name + ": couldn't get GameCoordinator reference.", gameObject); } InitializeObstacleTemplatesList(); startDelayed = true; paused = false; lastSpawnTime = 0f; timeTillNextObstacle = 0f; StartCoroutine(DelayedStart(startDelay)); }
private void Awake() { if ((_instance != null) && (_instance.GetInstanceID() != this.GetInstanceID())) { Debug.LogWarning($"Second GameCoordinator instance detected. Original: '{_instance.gameObject.name}', new: '{this.gameObject.name}'", this); _level = _instance._level; _health = _instance._health; _ammo = _instance._ammo; Destroy(_instance.gameObject); _instance = null; } DontDestroyOnLoad(this.gameObject); _instance = this; }
//Hunt down some relevant gameobjects to keep track of public void OnEnable() { GameObject debug = GameObject.FindGameObjectWithTag("DatabaseDebug"); if (debug != null) { UnityEngine.UI.Text t = debug.GetComponent <UnityEngine.UI.Text>(); if (t != null) { debugText = t; //Debug.Log("Succesfully set debug text"); } else { Debug.Log("Couldn't find text component"); } } else { Debug.Log("Couldn't find debug text."); } GameObject foundGameCoord = GameObject.FindGameObjectWithTag("NetworkArchitecture"); if (foundGameCoord != null) { GameCoordinator g = foundGameCoord.GetComponent <GameCoordinator>(); if (g != null) { game = g; //Debug.Log("Successfully found game coordinator"); } else { Debug.Log("Couldn't find GameCoordinator component"); } } else { Debug.Log("Couldn't find network architecture."); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); PersistenceGateway storeGateway = new RolePlayFileStorage(); IntervalRandomGenerator intervalRandomGenerator = new VisualStudioRandomGenerator(); Dice[] dices = { new DiceFudge(intervalRandomGenerator), new Dice3(intervalRandomGenerator), new Dice6(intervalRandomGenerator) }; RolePlayGameGUIPresenter rolePlayGameGUIPresenter = new RolePlayGameGUIPresenter(); RolePlayGame rolePlayGame = new RolePlayGameCoordinator(storeGateway, dices, rolePlayGameGUIPresenter); GameCoordinator gameCoord = new GameCoordinator(rolePlayGame); rolePlayGameGUIPresenter.connectToBoard(gameCoord); gameCoord.stratNewPlayRoleBoardGame(); }
void Awake() { //Check if instance already exists if (_instance == null) { //if not, set instance to this _instance = this; } //If instance already exists and it's not this: else if (_instance != this) { //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. Destroy(gameObject); } //Sets this to not be destroyed when reloading scene DontDestroyOnLoad(gameObject); }
static void Main(string[] args) { Debug.Log("Initializing the database adapter."); //This is a vital thing in order to proceed the queries Adapter.Initialize("localhost", 3306, "root", "", "newgame"); Debug.Log("Starting our realtime server."); NetworkServer server = new NetworkServer("127.0.0.1", 3000); //Coordinators initialization //@todo Make them different threads not only instances LoginCoordinator loginServer = new LoginCoordinator(server); StoreCoordinator storeServer = new StoreCoordinator(server); GameCoordinator gameServer = new GameCoordinator(server); //Show repo information DisplayRepoInformation(); //Display Build Version DisplayBuildVersion(); //Server must start after all sub-servers being initialized server.Start(); }
private void Start() { if (pauseDialog == null) { Debug.LogError(gameObject.name + ": pause dialog not assigned.", gameObject); } if (gameoverDialog == null) { Debug.LogError(gameObject.name + ": gameover dialog not assigned.", gameObject); } if (gameoverDialogScoreText == null) { Debug.LogError(gameObject.name + ": gameover dialog score text not assigned.", gameObject); } if (scoreText == null) { Debug.LogError(gameObject.name + ": score text not assigned.", gameObject); } gameCoordinator = GameCoordinator.Coordinator; if (gameCoordinator == null) { Debug.LogError(gameObject.name + ": couldn't get GameCoordinator reference.", gameObject); } }
/// <summary> /// This method is reponsible for starting the game /// </summary> /// <param name="selValue">Value, indicating the selected word category in the dropdown list on the main screen</param> /// <returns></returns> public ActionResult StartGame(string selValue) { GameCoordinator gameCoordinator = new GameCoordinator(); Word wordQuery; if (selValue != null) { // Get random word from the provided Category wordQuery = words.All().Where(x => x.Category.Name == selValue).OrderBy(x => Guid.NewGuid()).First(); } else { // Get the first category from the database and get random word from this category selValue = categories.All().Select(x => x.Name).ToList().First(); wordQuery = words.All().Where(x => x.Category.Name == selValue) .OrderBy(x => Guid.NewGuid()).First(); } gameCoordinator.StartGame(this.User.Identity.GetUserId(), wordQuery.Value, wordQuery.Clue, categories.All().Select(x => x.Name).ToList(), selValue); return(View("../Game/Game", gameCoordinator.ViewModel)); }
public TargetingHandler(Character parent, GameCoordinator game) { _parent = parent; Priority = TargetingPriorities.Random; _game = game; }
private void Awake() { Coordinator = this; }
public float CalculateHappyLevelInSector() { HappyLevel = (calculateSardineLevel() + SectorManager.getInstance().calculateDeathImpact() + SectorManager.getInstance().getFoodPolicyHappyImpact(currentFoodPolicy) + getSectorMilitarization() + GameCoordinator.getInstance().getTimeAwayFromPlanet()) / 5; return(HappyLevel); }