示例#1
0
 private void exitGame()
 {
     if (InvalidMove != null)
     {
         EndOfGame.Invoke(getOppositionPlayer(), EventArgs.Empty);
     }
 }
示例#2
0
 private void FireGameOverIfNeeded()
 {
     if (NumberOfSticks == 0)
     {
         gameStage = GameStage.GameOver;
         EndOfGame.Invoke(WhoseTurn);
     }
 }
示例#3
0
 public void Win()
 {
     WinText.SetActive(true);
     IsWaitng = true;
     if (state == EndOfGame.Invalid)
     {
         state = EndOfGame.WinState;
     }
 }
示例#4
0
 public void Lose()
 {
     LoseText.SetActive(true);
     IsWaitng = true;
     if (state == EndOfGame.Invalid)
     {
         state = EndOfGame.LoseState;
     }
 }
示例#5
0
 EndOfGame()
 {
     //save time instead of searching for the game controller
     //check if the instance is not null, we are creating more than one instance, warn us
     if (instance != null)
     {
         Debug.LogError("There's an instance already created, click on the next error to check it", gameObject);
         Debug.LogError("Original EndOfGame instance is", instance.gameObject);
         return;
     }
     instance = this;
 }
示例#6
0
 public void Run(TextReader reader, TextWriter writer)
 {
     using (new TextConsole(this.bus, reader, writer))
         using (new SentenceParser(this.bus, this.words))
             using (EndOfGame endOfGame = new EndOfGame(this.bus))
                 using (InputLoop loop = new InputLoop(this.bus, ">"))
                     using (new Inventory(this.bus))
                         using (this.InitializeMap())
                         {
                             loop.Run(endOfGame.Token);
                         }
 }
示例#7
0
        public void SendAfterDisposeDoesNothing()
        {
            MessageBus bus        = new MessageBus();
            string     lastOutput = null;

            bus.Subscribe <OutputMessage>(m => lastOutput = "[" + m.Text + "]");
            EndOfGame end = new EndOfGame(bus);

            end.Dispose();
            bus.Send(new EndOfGameMessage("It's not over."));

            lastOutput.Should().BeNull();
        }
示例#8
0
 //default constructor
 private Player()
 {
     Name            = "Ash";
     Level           = 1;
     EXP             = 0;
     ATK             = DEF = 5;        // ATK = 5; DEF = 5;
     MaxHP           = CurrentHP = 15;
     MaxMP           = CurrentMP = 10; // MP = 10; TP = 10;
     Alive           = true;
     abilityList     = new List <PlayerAbility>();
     InCombat        = false;
     weapon          = null;
     playerInventory = Inventory.haveOne();
     endGame         = EndOfGame.oneEnd();
 }
示例#9
0
        public void EndOfGameNoMessageSendsCancellationNoOutput()
        {
            MessageBus bus        = new MessageBus();
            string     lastOutput = null;

            bus.Subscribe <OutputMessage>(m => lastOutput = "[" + m.Text + "]");
            using (EndOfGame end = new EndOfGame(bus))
            {
                end.Token.IsCancellationRequested.Should().BeFalse();

                bus.Send(new EndOfGameMessage());

                end.Token.IsCancellationRequested.Should().BeTrue();
                lastOutput.Should().BeNull();
            }
        }
        public void Fight(Player player)
        {
            Console.WriteLine(
                $"You see a monster in the room. It's {monsterName}!\n" +
                $"{monsterName} has {monsterDamage} in damage and {monsterHealth} healthpoints.\n" +
                $"You have {player.playerAttackDamage} in damage\n" +
                $"Press any key when you are ready to fight {monsterName}");
            Console.ReadKey(true);
            Console.Clear();
            bool turn = true; // true = player turn, false = monster turn

            do
            {
                if (turn == true)
                {
                    Console.WriteLine($"You hit the {monsterName} for {player.playerAttackDamage} ");
                    monsterHealth = monsterHealth - player.playerAttackDamage;
                    Console.WriteLine($"{monsterName} have {monsterHealth} left");
                    Thread.Sleep(1000);
                    turn = false;
                }
                else if (turn == false)
                {
                    Console.WriteLine($"{monsterName} hit you for {monsterDamage}");
                    player.playerHealthPoints = player.playerHealthPoints - monsterDamage;
                    Console.WriteLine("You have " + player.playerHealthPoints + " left");
                    Thread.Sleep(1000);
                    turn = true;
                }
            }while (player.playerHealthPoints > 0 && monsterHealth > 0);
            Thread.Sleep(1000);
            Console.Clear();

            if (monsterHealth > 0)
            {
                Console.WriteLine($"You lost the fight against {monsterName}");
                EndOfGame endOfGame = new EndOfGame();
                endOfGame.EndingGame(player);
            }
            else
            {
                Console.WriteLine($"After a hard fight against {monsterName} you are victorious!");
            }
        }
示例#11
0
    private IEnumerator GameLoop()
    {
        yield return(StartCoroutine(RoundStarting()));

        yield return(StartCoroutine(RoundPlaying()));

        yield return(StartCoroutine(RoundEnding()));

        if (m_GameWinner != null)
        {
            RstButton.SetActive(false);
            EscButton.SetActive(false);
            EndOfGame.SetActive(true);
        }
        else
        {
            StartCoroutine(GameLoop());
        }
    }
示例#12
0
        public bool GameOver()
        {
            bool gameOver = false;

            if (CurrentPlayer.IsLoose() || WaitingPlayer.Tie(CurrentPlayer))
            {
                gameOver = !gameOver;  // true
                CalcFinalScore();
                EndOfGameEventArgs e = new EndOfGameEventArgs();
                EndOfGame.Invoke(this, e);

                if (!e.m_GameOver)
                {
                    PlayerHasScored.Invoke(this, new EventArgs());
                    Checkers.Board.ClearLogicBoard();
                    ResetGame();
                }
            }

            return(gameOver);
        }
示例#13
0
 private void HearthEvent(HearthstoneEvent hearthEvent)
 {
     if (hearthEvent is NewGame)
     {
         var newGameEvent = hearthEvent as NewGame;
         hearthstoneGame = newGameEvent.game;
         SetState(null, typeof(HSStateAcceptingBets));
     }
     else if (hearthEvent is EndOfGame)
     {
         var endGameEvent = hearthEvent as EndOfGame;
         lastGameEnding = endGameEvent;
         SetState(null, typeof(HSStateEndOfGame));
     }
     else if (hearthEvent is DrawCard)
     {
         var drawEvent = hearthEvent as DrawCard;
         if (currentState is HSStatePlaying)
         {
             var playingState = currentState as HSStatePlaying;
             playingState.NextTurn(drawEvent);
         }
     }
 }
示例#14
0
    void Awake()
    {
        PhotonNetwork.isMessageQueueRunning = true;
        mainCamera = Camera.main.transform;

        _as = GetComponent <AudioSource>();

        setCanvas(0);

        gameResult = GameObject.Find("GameResult");
        gr         = gameResult.GetComponent <GameResult>();

        eg = GameObject.Find("EndOfGame").GetComponent <EndOfGame>();
        eg.setActive(false);

        gi = GameObject.Find("GameItems(Clone)").GetComponent <GameItems>();

        gameStarted = false;
        zoomed      = false;
        gameover    = false;
        swapCamPos  = false;

        StartCoroutine(CheckPlayerNumber());
    }
示例#15
0
文件: Chat.cs 项目: micha224/Jan_1GAM
 void Awake()
 {
     _gameSystem = GameObject.Find("_System").GetComponent<GameSystem>();
     _end = GameObject.Find("EndOfGame").GetComponent<EndOfGame>();
     SP = this;
 }
示例#16
0
 private void Awake()
 {
     endGame_ref = GameObject.FindGameObjectWithTag("Canvas").GetComponent <EndOfGame>();
 }