// Use this for initialization void Start() { player = FindObjectOfType <PlayerBehaviour>(); paused = false; Time.timeScale = 1f; pauseMenu.SetActive(false); endTime.SetActive(false); delaycpy = delay; if (delaycpy % 60 > 0) { m = (int)delaycpy / 60; delaycpy -= m * 60; s = (int)delaycpy; } //Debug.Log(m + " - " + s); current = imgs[player.index]; index = player.index; current.color = new Color(1, 0, 0); iMenu.SetActive(false); Goal.GetComponent <Text>().text = score + " / " + maxScore; Won.SetActive(false); deltaT = Time.deltaTime; }
private void M_ShotResponseRecieved(object sender, EventArgs e) { if (myTurn) { WeaponResponseComm c = (WeaponResponseComm)sender; short field = 0; if (c.result == null) { if (c.response == FireResponse.hit) { //myTurn = true; field = 3; } else { field = 2; //myTurn = false; } } else if (c.result == FireResult.sunk) { //myTurn = true; field = 4; } else //implement o win { Won.Invoke(me, EventArgs.Empty); } myTurn = false; opponent.Battlefield.field[getIntFromLetter(c.x), c.y] = field; } }
public static void WriteJson(this Won value, JsonWriter writer, JsonSerializer serializer) { switch (value) { case Won.False: serializer.Serialize(writer, "false"); break; case Won.True: serializer.Serialize(writer, "true"); break; } }
/// <summary> /// Returns hash code of the stage object. /// </summary> public override int GetHashCode() { var hashCode = -1406906831; hashCode = hashCode * -1521134295 + StageIndex.GetHashCode(); hashCode = hashCode * -1521134295 + Started.GetHashCode(); hashCode = hashCode * -1521134295 + Won.GetHashCode(); hashCode = hashCode * -1521134295 + AlmostWon.GetHashCode(); return(hashCode); }
public void AddPoints() { СountPoints += 200 + _coefficientOfPoints; ChangeColor(); if (СountPoints >= _level.WinCountPoints) { _isOpacity = true; Won?.Invoke(); } }
public void OnEnemyKilled() { if (_activeDeathRequiredAmount) { _currentEnemyDeath++; if (_currentEnemyDeath >= _deathRequiredAmount) { Won?.Invoke(_missionName); ChangeLevelStatus(); } } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); Fonts.LoadFonts(Content); Sprites.LoadSprites(Content); Tiles.LoadTiles(Content); map = Map.Parse("maps/demo.txt"); welcome = new Welcome(); won = new Won(); lost = new Lost(); fight = new Fight(); currentScreen = welcome; }
public override string ToString() { var final = new StringBuilder(); final.Append($"{Name.PadRight(30)} | "); final.Append($"{Played.ToString().PadLeft(2)} | "); final.Append($"{Won.ToString().PadLeft(2)} | "); final.Append($"{Drawn.ToString().PadLeft(2)} | "); final.Append($"{Lost.ToString().PadLeft(2)} | "); final.Append($"{Point.ToString().PadLeft(2)}"); return(final.ToString()); }
public string[] getinfo() { string[] info = new string[9]; info[0] = TeamName; info[1] = Played.ToString(); info[2] = Won.ToString(); info[3] = Drawn.ToString(); info[4] = Lost.ToString(); info[5] = GF.ToString(); info[6] = GA.ToString(); info[7] = GD.ToString(); info[8] = Points.ToString(); return(info); }
public void GameDone(GameResult gameResult) { UpdateGameScore(gameResult); OnPropertyChanged("GameResultStr"); Won.RaiseCanExecuteChanged(); Drew.RaiseCanExecuteChanged(); Lost.RaiseCanExecuteChanged(); var @event = OnGameDone; if (@event != null) { @event(this, new EventArgs()); } }
public void OnPlayerReceivedDamage(bool receivedDamage) { if (_activeUntouchable) { if (receivedDamage == false) { Won?.Invoke(_missionName); ChangeLevelStatus(); } else { MissionFailed?.Invoke(_missionName); } } }
public void OnTimeIsOver(float timeValue) { if (_activeTimeToHoldOut) { if (timeValue == 0) { Won?.Invoke(_missionName); ChangeLevelStatus(); } else { MissionFailed?.Invoke(_missionName); } } }
static void Main(string[] args) { Won won = new Won(1000); Dollar dollar = new Dollar(1); Yen yen = new Yen(100); Won won1 = yen; Won won2 = (Won)yen; Won won3 = (Won)dollar; Console.WriteLine(won1); Console.WriteLine(won2); Console.WriteLine(won3); //won = yen; // yen과 won의 타입이 다르기 때문에 컴파일 시에 오류 발생 }
static void Main(string[] args) { Won won = new Won(1000); Dollar dollar = new Dollar(1); Yen yen = new Yen(100); //won = dollar; // 부모, 자식 관계가 아닌 클래스끼리는 형변환이 불가능하다. dollar = yen; // 형변환 연산자를 implicit으로 오버로딩 했으므로 묵시적 형변환이 발생한다. dollar = (Dollar)yen; // 명시적으로 해도 상관없다. //yen = won; // 형변환 연산자를 explicit으로 오버로딩 했으므로 명시적 형변환을 해야한다. yen = (Yen)won; Console.WriteLine(won); Console.WriteLine(dollar); Console.WriteLine(yen); }
public void Sunk(BattleshipShip ship) { player1.sunk.Add(ship); for (int i = 0; i < ship.size; i++) { rightBoard.cells[ship.positions[i][0] - 1, ship.positions[i][1] - 1].BackgroundImage = ship.components[i]; } if (player1.sunk.Count == player1.myShips.Count) { finished = true; //rightBoard.ImgClick -= Guess1; Won?.Invoke(this, new OnWin { player = player1 }); } }
private void OnWon() { Won?.Invoke(this, new GameControllerEventArgs(this)); }
// Update is called once per frame void Update() { Debug.Log(deltaT); if (Input.GetKeyDown(KeyCode.Escape)) { isPaused(); deltaT = 0; } else { deltaT = Time.deltaTime; } //Counter if (m >= 0) { s -= deltaT; if (s <= 0) { m--; s = 60; } } else if (m <= 0) { Time.timeScale = 0f; timer.SetActive(false); endTime.SetActive(true); } //Power Up time. if (player.isPwrdUp) { powerUp.SetActive(true); powerUp.GetComponent <Text>().text = "Ends in... " + (int)player.pwrDelay; } else { powerUp.SetActive(false); } if (player.isHit) { damaged.SetActive(true); damaged.GetComponent <Text>().text = "Pain ends in..." + (int)player.hitDelay; } else { damaged.SetActive(false); } //State system if (index != player.index) { for (int i = 0; i < imgs.Length; i++) { imgs[i].color = Color.white; } index = player.index; } else { current = imgs[player.index]; current.color = new Color(0.8f, 0.4f, 0.2f); } //imgs timer.GetComponent <Text>().text = "Time: " + (int)m + ": " + (int)s; Goal.GetComponent <Text>().text = score + " / " + maxScore; if (score == maxScore) { Time.timeScale = 0f; Won.SetActive(true); } }
static void Main(string[] args) { //GAME STARTS HERE Console.SetWindowSize(110, 25); StishBoard.Instance.Player1 = Player.PlayerFactory(Player.PlayerNumber.Player1, Player.PlayerType.Human, StishBoard.Instance);; StishBoard.Instance.Player2 = Player.PlayerFactory(Player.PlayerNumber.Player2, Player.PlayerType.Computer, StishBoard.Instance);; Console.Clear(); StishBoard.Instance.Render(); //game loop takes place here bool GameEnd = false; Won won = 0; Turn turn = Turn.Player1; while (GameEnd == false) { //checks if a base has been destroyed. if one has then the other player has won. //if not then alternate player turns Coordinate P1Base = new Coordinate(StishBoard.Instance.Player1.BaseX, StishBoard.Instance.Player1.BaseY); Coordinate P2Base = new Coordinate(StishBoard.Instance.Player2.BaseX, StishBoard.Instance.Player2.BaseY); if (StishBoard.Instance.getSquare(P2Base).Dep.Health < 1) { //Player1 has won GameEnd = true; won = Won.Player1; } else if (StishBoard.Instance.getSquare(P1Base).Dep.Health < 1) { //Player2 has won GameEnd = true; won = Won.Player2; } else { //Game Continues if (turn == Turn.Player1) { Cursor.Instance.FindX = StishBoard.Instance.Player1.CursorX; Cursor.Instance.FindY = StishBoard.Instance.Player1.CursorY; StishBoard.Instance.Player1.TurnBalance(StishBoard.Instance); StishBoard.Instance.Player1.MaxMP(StishBoard.Instance); Analytics.Cardinal(StishBoard.Instance.Player1, Cursor.Instance.Where); StishBoard.Instance.Player1.MakeMove(); turn++; } else if (turn == Turn.Player2) { Cursor.Instance.FindX = StishBoard.Instance.Player2.CursorX; Cursor.Instance.FindY = StishBoard.Instance.Player2.CursorY; StishBoard.Instance.Player2.TurnBalance(StishBoard.Instance); StishBoard.Instance.Player2.MaxMP(StishBoard.Instance); Analytics.Cardinal(StishBoard.Instance.Player2, Cursor.Instance.Where); StishBoard.Instance.Player2.MakeMove(); turn--; } } } Console.WriteLine("{0} HAS WON THE GAME \nPRESS <ENTER> TO KILL THE PROGRAM", won.ToString()); Console.ReadLine(); }
private void OnWon(WonArgs e) { Won?.Invoke(this, e); }
private void Guess1(object sender, BattleshipBoard.ImgClickEventArgs e) { int x = e.coordinates[0] - 1, y = e.coordinates[1] - 1; if (!finished) { Guess(); } void Guess() { if (player1.guesses[x, y] == 0) { bool hit = false; foreach (BattleshipShip ship in bot.myShips) { if (!hit) { int i = 0; while (i < ship.size && !(ship.positions[i][0] == x + 1 && ship.positions[i][1] == y + 1)) { i++; } if (i < ship.size) { hit = true; player1.guesses[x, y] = 2; Hit(new int[] { x, y }, rightBoard); ship.hp -= 1; if (ship.hp == 0) { Sunk(ship); } } } } if (!hit) { player1.guesses[x, y] = 1; Miss(new int[] { x, y }, rightBoard); } //BOT GUESS if (!finished) { hit = false; int[] botGuess = bot.Guesser(); foreach (BattleshipShip ship in player1.myShips) { if (!hit) { int i = 0, xBot = botGuess[0] + 1, yBot = botGuess[1] + 1; while (i < ship.size && !(ship.positions[i][0] == xBot && ship.positions[i][1] == yBot)) { i++; } if (i < ship.size) { hit = true; bot.guesses[x, y] = 2; bot.Hit(); Hit(botGuess, leftBoard); ship.hp -= 1; if (ship.hp == 0) { bot.sunk.Add(ship); if (bot.sunk.Count == bot.myShips.Count) { finished = true; Won?.Invoke(this, new OnWin { player = bot }); } } } } } if (!hit) { bot.guesses[x, y] = 1; Miss(botGuess, leftBoard); } } } } }