Example #1
0
    void OnGameEndEvent(GameEndEvent e)
    {
        AkSoundEngine.PostEvent("play_music_menu", gameObject);
        gameActive = false;

        /*for (int i = 0; i < 2; i++)
         * {
         *  PhaseZones[i].gameObject.SetActive(false);
         * }*/

        currentOverlay.SetActive(false);

        if (e.Victorious)
        {
            VictoryOverlay.SetActive(true);

            var score = VictoryOverlay.transform.Find("ScoreLine/ScoreCount").GetComponent <TextMeshProUGUI>();
            score.text = GameScore.Score.ToString();

            var rank = VictoryOverlay.transform.Find("RankLine/RankCount").GetComponent <TextMeshProUGUI>();
            rank.text = Leaderboard.GetRankByScore(GameScore.Score).ToString();

            currentOverlay = VictoryOverlay;
        }
        else
        {
            GameOverOverlay.SetActive(true);

            var score = GameOverOverlay.transform.Find("Score").GetComponent <TextMeshProUGUI>();
            score.text = FillScoreWithZeros(GameScore.Score.ToString());

            currentOverlay = GameOverOverlay;
        }
    }
Example #2
0
        public static void Main(string[] args)
        {
            string       whatarewe = Assembly.GetEntryAssembly().Location; //get the location of the .exe
            string       dir       = Path.GetDirectoryName(whatarewe);     //get the directory it's in
            PluginLoader loader    = new PluginLoader($"{dir}/Plugins");   //the Plugins folder will be in our directory -> Plugins. It will be created on first run if it doesnt exist

            Events.SetMaster();                                            //Make it so that only this application can lock or unlock events
            XanaAwakenEvent.Lock();                                        //locking an event
            //note: since this application is different from LyokoForDummies_Extending for example, it will not be able to call this event either, which is not what we want in this case.
            //You'll probably want to use Events.LockAll() in most cases though

            Console.WriteLine("Welcome to fake Lyoko, press enter to start a Game");
            Console.ReadKey();
            Console.WriteLine("Testing Extending");

            GameStartEvent.Call(); //game isn't in story mode, so we dont need to provide a boolean
            ExtendingTest.Test();
            GameEndEvent.Call(false);

            Console.WriteLine("Tested. Press enter to test Reconstructing");
            GameStartEvent.Call(); //game isn't in story mode, so we dont need to provide a boolean
            GameEndEvent.Call(false);
            ReconstructingTest.Test();

            Console.WriteLine("Tested, press enter to quit");
            Console.ReadKey();
        }
Example #3
0
 public void OnGameEnd(GameEndEvent e)
 {
     endGame = true;
     if (e.winner != null)
     {
         float pitch = e.winner.playerNum == 0 ? 0.8f : 2f;
         Services.AudioManager.CreateTrackAndPlay(Clips.WIN, pitch);
         _turnIndicatorIcon.sprite = e.winner.PlayerIcon;
         _turnIndicatorIcon.color  = e.winner.playerColor[0];
         _turnIndicator.color      = e.winner.playerColor[0];
         _turnIndicator.text       = "    WINS";
         WinnerConfetti winnerConfetti = Instantiate(Services.Prefabs.WinnerConfetti);
         winnerConfetti.Init(e.winner);
         Task fadeGradient = new LERPColor(_gradient, _transparent, e.winner.playerColor[0], 0.75f);
         _tm.Do(fadeGradient);
     }
     else
     {
         Services.AudioManager.CreateTrackAndPlay(Clips.TIE);
         _turnIndicatorIcon.color = new Color(0, 0, 0, 0);
         _turnIndicator.color     = new Color(127 / 256f, 127 / 256f, 127 / 256f);
         _turnIndicator.text      = "TIE GAME";
         Task fadeGradient = new LERPColor(_gradient, _transparent, _iconGray, 0.75f);
         _tm.Do(fadeGradient);
     }
 }
Example #4
0
        public Game(ChoiceHandler[] playerChoiceHandlers, string cardInfoJson, GameState.GameStateType startState = GameState.GameStateType.JurySelection)
        {
            StartState = startState;

            Board = new Board(this);

            CardTemplateGenerator tempGenerator = new CardTemplateGenerator(cardInfoJson);

            List <Card> cards = new List <Card>();

            tempGenerator.GetAllCardTemplates().ForEach(c => cards.Add(new Card(c)));
            Deck = new DeckHolder(cards);

            Discards = new DiscardHolder();

            int idx = 0;

            foreach (Player.PlayerSide side in new Player.PlayerSide[] { Player.PlayerSide.Prosecution, Player.PlayerSide.Defense })
            {
                players.Add(side, new Player(side, playerChoiceHandlers[idx], this));
                idx += 1;
            }

            NotifyStateStart += logStartOfState;
            NotifyGameEnd    += logEndOfGame;

            initStates();
        }
Example #5
0
 void OnGameEndEvent(GameEndEvent e)
 {
     if (e.Victorious)
     {
         //TeamNameInput.GetComponent<InputField>().Initialize();
         //LeaderboardMenuSelector.enabled = false;
     }
 }
Example #6
0
 private void OffRemotePlayerSurrend(GameEndEvent e)
 {
     foreach (Player p in remotePlayers.Values)
     {
         if (p.Stat == PlayerStat.Spectator)
         {
             p.Stat = PlayerStat.Player;
         }
     }
 }
Example #7
0
    private void EndGameSystem(GameEndEvent e)
    {
        GameManager.instance.GameStat = GameStat.Wait;
        GameRoomSceneManager.instance.UpdateUI();

        end         = true;
        player.Stat = PlayerStat.Player;
        audioSource.Stop();

        spawnPoint = Vector2.zero;
    }
Example #8
0
    void Handle(GameEndEvent e)
    {
        if (e.playerID == 1)
        {
            SceneManager.LoadScene("Player1Win");
        }

        if (e.playerID == 2)
        {
            SceneManager.LoadScene("Player2Win");
        }
    }
Example #9
0
        private void CurrentGame_OnGameEnd(object sender, GameEndEvent e)
        {
            switch (e.GameEndReason)
            {
            case GameEndReason.GameOver:
                this.currentState = GameState.GameOver;
                break;

            case GameEndReason.AllBricksBroken:
                this.currentState = Level + 1 > MaxLevel ? GameState.GameComplete : GameState.LevelCompleted;
                if (currentState == GameState.LevelCompleted)
                {
                    Score += 100;
                }
                break;
            }
        }
Example #10
0
        private IEnumerator UpdateGameState()
        {
            if (this.isGameActive)
            {
                yield break;
            }
            this.isGameActive = true;
            GameStartEvent?.Invoke(this, null);

            this.remainingTime = this.maxTime;
            while (this.remainingTime > 0)
            {
                this.remainingTime -= Time.deltaTime;
                yield return(null);
            }

            this.remainingTime = 0;
            this.isGameActive  = false;
            GameEndEvent?.Invoke(this, null);
        }
 public void OnGameEnd(GameEndEvent e)
 {
     endGame = true;
     if (e.winner != null)
     {
         _turnIndicatorIcon.sprite = e.winner.PlayerIcon;
         _turnIndicatorIcon.color  = e.winner.playerColor[0];
         _turnIndicator.color      = e.winner.playerColor[0];
         _turnIndicator.text       = "    WINS";
         WinnerConfetti winnerConfetti = Instantiate(Services.Prefabs.WinnerConfetti);
         winnerConfetti.Init(e.winner);
         Task fadeGradient = new LERPColor(_gradient, _transparent, e.winner.playerColor[0], 0.75f);
         _tm.Do(fadeGradient);
     }
     else
     {
         _turnIndicatorIcon.color = new Color(0, 0, 0, 0);
         _turnIndicator.color     = new Color(127 / 256f, 127 / 256f, 127 / 256f);
         _turnIndicator.text      = "TIE GAME";
         Task fadeGradient = new LERPColor(_gradient, _transparent, _iconGray, 0.75f);
         _tm.Do(fadeGradient);
     }
 }
Example #12
0
 public void OnGameEnd()
 {
     IsWorking = false;
     GameEndEvent?.Invoke();
 }
 /// <summary>
 // This method is executed when using this.Publish(new GameEndEvent())
 /// </summary>
 public override void GameEndEventHandler(GameEndEvent data)
 {
     base.GameEndEventHandler(data);
     // Process the commands information.  Also, you can publish new events by using the line below.
     // this.Publish(new AnotherEvent())
 }
Example #14
0
 private void OnGameEnd(GameEndEvent gameEnd)
 {
     _gameIsOver = true;
 }
Example #15
0
 public override void GameEndEventHandler(GameEndEvent data)
 {
     base.GameEndEventHandler(data);
 }
Example #16
0
 void OnGameEndEvent(GameEndEvent e)
 {
     roundNumber = 0;
     players.Clear();
 }
Example #17
0
 /// <summary>
 /// 结束
 /// </summary>
 public void End()
 {
     _state = 0;
     GameEndEvent.Invoke(this, new GameEndEventArgs(this.ScoreSystem.Score));
     Console.Out.Write("end");
 }
Example #18
0
        private void ParseMessage(byte[] buf)
        {
            switch (buf[1])
            {
            case (byte)MessageType.Time:
            {
                var time = ParseTime(buf, 2);
                //Debug.WriteLine("Received time: {0}:{1}:{2}.{3}.", time.Hours, time.Minutes, time.Seconds, time.Milliseconds);

                lock (currentTimeLock)
                {
                    currentTime = time;
                }
            }
            break;

            case (byte)MessageType.Event:
            {
                var eventType = buf[2];
                var time      = ParseTime(buf, 3);

                switch (eventType)
                {
                case (byte)EventType.GameEnd:
                {
                    var ev = new GameEndEvent()
                    {
                        Time = time
                    };
                    lock (eventsLock)
                    {
                        events.Add(ev);
                    }
                    Debug.WriteLine("Received a game end event: {0}:{1}:{2}.{3}.", time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
                }
                break;

                case (byte)EventType.MapChange:
                {
                    var    len = BitConverter.ToInt32(buf, 11);
                    string map = System.Text.Encoding.ASCII.GetString(buf, 15, len);

                    var ev = new MapChangeEvent {
                        Time = time, Map = map
                    };
                    lock (eventsLock)
                    {
                        events.Add(ev);
                    }
                    Debug.WriteLine("Received a map change event: {0}:{1}:{2}.{3}; {4}.", time.Hours, time.Minutes, time.Seconds, time.Milliseconds, map);
                }
                break;

                case (byte)EventType.TimerReset:
                {
                    var ev = new TimerResetEvent()
                    {
                        Time = time
                    };
                    lock (eventsLock)
                    {
                        events.Add(ev);
                    }
                    Debug.WriteLine("Received a timer reset event: {0}:{1}:{2}.{3}.", time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
                }
                break;

                case (byte)EventType.TimerStart:
                {
                    var ev = new TimerStartEvent()
                    {
                        Time = time
                    };
                    lock (eventsLock)
                    {
                        events.Add(ev);
                    }
                    Debug.WriteLine("Received a timer start event: {0}:{1}:{2}.{3}.", time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
                }
                break;

                case (byte)EventType.BS_ALeapOfFaith:
                {
                    var ev = new BS_ALeapOfFaithEvent()
                    {
                        Time = time
                    };
                    lock (eventsLock)
                    {
                        events.Add(ev);
                    }
                    Debug.WriteLine("Received a BS A Leap of Faith event: {0}:{1}:{2}.{3}.", time.Hours, time.Minutes, time.Seconds, time.Milliseconds);
                }
                break;

                default:
                    Debug.WriteLine("Received an unknown event type: " + buf[2]);
                    break;
                }
            }
            break;

            default:
                Debug.WriteLine("Received an unknown message type: " + buf[1]);
                break;
            }
        }
Example #19
0
 public virtual void OnEvent(GameEndEvent eventData) => StopCoroutine(appleSpawnCoroutine);
 public void OnGameEnd(GameEndEvent e)
 {
     Services.EventManager.Unregister <TouchDown>(OnTouchDown);
     Services.EventManager.Unregister <MouseDown>(OnMouseDown);
 }
 void OnGameEndEvent(GameEndEvent e)
 {
     gameActive = false;
 }
 /// <summary>
 // This method is executed when using this.Publish(new GameEndEvent())
 /// </summary>
 public override void GameEndEventHandler(GameEndEvent data)
 {
     base.GameEndEventHandler(data);
     // Process the commands information.  Also, you can publish new events by using the line below.
     // this.Publish(new AnotherEvent())
 }
Example #23
0
 void OnGameEndEvent(GameEndEvent e)
 {
     ActivateSpaceships(false);
 }
Example #24
0
 public void GameRestart(int sceneIndex)
 {
     GameEndEvent?.Invoke();
     SaveGame();
     SceneManager.LoadScene(sceneIndex);
 }
Example #25
0
        /// <summary>
        /// Handles the click of the Period Start/End button
        /// </summary>
        /// <param name="sender">Should just be the periodStartButton</param>
        /// <param name="e">Some arguments that we may or may not user</param>
        private void periodChange_Click(object sender, EventArgs e)
        {
            // create a generic event. We may have either a period start or period end event
            Button button = (Button)sender;
            // Check if its a period or an overtime
            string perOrOver = pac.Period > 2 ? "Overtime" : "Period";
            Event ev = null;

            // if the button had "Start" in it
            if (button.Text.Contains("Start"))
            {
                ev = new PeriodStartEvent(pac);
                pac.post(ev);
                perOrOver += " End";
                return;
            }// end if
            //PERIOD END
            else
            {
                ev = new PeriodEndEvent(pac);
                bool sameScore = confirmScore(false);
                if (pac.Period >= 2)
                {
                    // going into overtime
                    if (sameScore)
                    {
                        pac.post(ev);
                        perOrOver = "Overtime";
                    }
                    //we are trying to end the game
                    else
                    {
                        pac.post(ev);
                        //the score is different, we are ending NOW

                        if (!confirmScore(true))
                        {
                            ev = new GameEndEvent(pac);
                            pac.post(ev);
                        }
                        // the user changed the score so we are going into another overtime
                        else
                        {
                            perOrOver = "Overtime";
                        }
                    }
                }
                else
                {
                    pac.post(ev);
                }
                perOrOver += " Start";
            }// end else
            button.Text = perOrOver;
        }
Example #26
0
        public List<Event> getEvents(Alpaca pac)
        {
            List<Event> events = new List<Event>();
            if (gameEvents == null)
                return events;

            foreach(Dictionary<string, object> dict in gameEvents)
            {
                Event e = null;
                string eventType = dict["eventType"].ToString().Split(new char[] { '/' })[1];
                Console.WriteLine("Found eventType: " + eventType);
                Context context = JsonConvert.DeserializeObject<Context>(dict["context"].ToString());
                if (eventType.Equals("gameEnd"))
                {
                    e = new GameEndEvent(pac);
                }
                else if (eventType.Equals("periodStart"))
                {
                    Console.WriteLine("Found a periodStart event");
                    e = new PeriodStartEvent(pac);
                }
                else if (eventType.Equals("periodEnd"))
                {
                    e = new PeriodEndEvent(pac);
                }
                else if (eventType.Equals("madeShot"))
                {

                    string shooter = dict["shooter"].ToString();
                    object assisted;
                    dict.TryGetValue("assistedBy", out assisted);

                    string assistedBy = null;
                    if (assisted != null)
                        assistedBy = assisted.ToString();
                    string shotType = dict["shotType"].ToString();
                    int pointsScored = int.Parse(dict["pointsScored"].ToString());
                    bool fastBreak = bool.Parse(dict["fastBreakOpportunity"].ToString());
                    bool goaltending = bool.Parse(dict["goaltending"].ToString());
                    int[] location = JsonConvert.DeserializeObject<int[]>(dict["location"].ToString());
                    Point locPt = new Point(location[0], location[1]);

                    Console.WriteLine("made shot");
                    Console.WriteLine(shooter);
                    Console.WriteLine(location[0] + " " + location[1]);

                    e = new MadeShotEvent(pac, shooter, pac.getPlayer(shooter).TeamId, assistedBy, shotType, pointsScored, fastBreak,
                        goaltending, locPt);
                }
                else if (eventType.Equals("missedShot"))
                {
                    string shooter = dict["shooter"].ToString();
                    object blocked;
                    dict.TryGetValue("blockedBy", out blocked);

                    string blockedBy = null;
                    if (blocked != null)
                        blockedBy = blocked.ToString();

                    string shotType = dict["shotType"].ToString();
                    int pointsAttempted = int.Parse(dict["pointsAttempted"].ToString());
                    bool fastBreak = bool.Parse(dict["fastBreakOpportunity"].ToString());
                    int[] location = JsonConvert.DeserializeObject<int[]>(dict["location"].ToString());
                    Point locPt = new Point(location[0], location[1]);

                    e = new MissedShotEvent(pac, shooter, pac.getPlayer(shooter).TeamId, blockedBy, shotType, pointsAttempted, fastBreak, locPt);

                }
                else if (eventType.Equals("jumpBall"))
                {
                    string homePlayer = dict["homePlayer"].ToString();
                    string awayPlayer = dict["awayPlayer"].ToString();
                    string winner = dict["winner"].ToString();
                    int[] location = JsonConvert.DeserializeObject<int[]>(dict["location"].ToString());
                    Point locPt = new Point(location[0], location[1]);

                    e = new JumpballEvent(pac, homePlayer, awayPlayer, winner, locPt);

                }
                else if (eventType.Equals("rebound"))
                {
                    object rebound;
                    dict.TryGetValue("rebounder", out rebound);

                    string rebounder = null;
                    if (rebound != null)
                    {
                        rebounder = rebound.ToString();
                    }

                    string reboundType = dict["reboundType"].ToString();

                    int[] location = JsonConvert.DeserializeObject<int[]>(dict["location"].ToString());
                    Point locPt = new Point(location[0], location[1]);

                    e = new ReboundEvent(pac, rebounder, reboundType, locPt);

                }
                else if (eventType.Equals("substitution"))
                {
                    string exitingPlayer = dict["exitingPlayer"].ToString();
                    string enteringPlayer = dict["enteringPlayer"].ToString();

                    e = new SubstitutionEvent(pac, enteringPlayer, exitingPlayer, pac.getPlayer(enteringPlayer).TeamId);
                }
                else if (eventType.Equals("turnover"))
                {
                    string committedBy = dict["committedBy"].ToString();
                    object forced;
                    dict.TryGetValue("forcedBy", out forced);

                    string forcedBy = null;
                    if (forced != null)
                    {
                        forcedBy = forced.ToString();
                    }

                    string turnoverType = dict["turnoverType"].ToString();
                    int[] location = JsonConvert.DeserializeObject<int[]>(dict["location"].ToString());
                    Point locPt = new Point(location[0], location[1]);

                    e = new TurnoverEvent(pac, committedBy, forcedBy, turnoverType, locPt);
                }
                else if (eventType.Equals("timeout"))
                {
                    object team;

                    dict.TryGetValue("timeoutTeam", out team);

                    string timeoutTeam = null;
                    if (team != null)
                    {
                        timeoutTeam = team.ToString();
                    }

                    string timeoutType = dict["timeoutType"].ToString();

                    e = new TimeoutEvent(pac, timeoutTeam, timeoutType);

                }
                else if (eventType.Equals("foul"))
                {
                    string committedBy = dict["committedBy"].ToString();

                    object drew;
                    dict.TryGetValue("drewBy", out drew);

                    string drewBy = null;
                    if (drew != null)
                    {
                        drewBy = drew.ToString();
                    }

                    string foulType = dict["foulType"].ToString();
                    bool ejected = bool.Parse(dict["ejected"].ToString());
                    int[] location = JsonConvert.DeserializeObject<int[]>(dict["location"].ToString());
                    Point locPt = new Point(location[0], location[1]);

                    e = new FoulEvent(pac, pac.getPlayer(committedBy).TeamId, committedBy, drewBy, foulType, ejected, locPt);

                }

                if (e != null)
                {
                    e.EventId = dict["eventId"].ToString();
                    e.setContext(context);
                    e.resolve();
                    events.Add(e);
                }
            }
            return events;
        }
Example #27
0
 /// <summary>
 // This method is executed when using this.Publish(new GameEndEvent())
 /// </summary>
 public virtual void GameEndEventHandler(GameEndEvent data)
 {
     // Process the commands information.  Also, you can publish new events by using the line below.
     // this.Publish(new AnotherEvent())
 }
Example #28
0
 void OnGameEndEvent(GameEndEvent e)
 {
     names.Clear();
     scores.Clear();
 }
 /// <summary>
 // This method is executed when using this.Publish(new GameEndEvent())
 /// </summary>
 public virtual void GameEndEventHandler(GameEndEvent data)
 {
     // Process the commands information.  Also, you can publish new events by using the line below.
     // this.Publish(new AnotherEvent())
 }
Example #30
0
 void OnGameEndEvent(GameEndEvent e)
 {
     gameActive = false;
     PhasingVFX.SetActive(false);
     PhasingExplosionVFX.SetActive(false);
 }