Example #1
0
        private void Awake()
        {
            dispatcher = Finder.Dispatcher;
            playerDeathEventChannel      = Finder.PlayerDeathEventChannel;
            levelCompletedEventChannel   = Finder.LevelCompletedEventChannel;
            savedDataLoadedEventChannel  = Finder.SavedDataLoadedEventChannel;
            savedSceneLoadedEventChannel = Finder.SavedSceneLoadedEventChannel;
            newGameLoadedEventChannel    = Finder.NewGameLoadedEventChannel;
            saveSystem = Finder.SaveSystem;
            scenes     = GetComponentInChildren <Scenes>();

            currentScene = startingScene;
        }
Example #2
0
        private void QuickMatchCallback()
        {
            string rawResponse = _callbackResponse;

            // Check if request failed
            if (RequestFailed(rawResponse))
            {
                MpResponse.Status statusResponse = JsonUtility.FromJson <MpResponse.Status>(rawResponse);
                InvalidToken(statusResponse);
                if (statusResponse.ErrorLevel == "AlreadyInQueue")
                {
                    Other.Tools.CreatePopup(Other.Tools.Messages.AlreadyInQueue);
                }
            }
            else
            {
                // Handle request
                MpResponse.Player playerResponse = JsonUtility.FromJson <MpResponse.Player>(rawResponse);
                Scenes.SetString("GameMode", "Online");
                Scenes.SetString("OpponentName", playerResponse.PlayerName);
                Scenes.Load("Game");
                Other.Tools.CreatePopup(Other.Tools.Messages.SearchingGames);
            }
        }
Example #3
0
 public static void LoadScene(Game.Scenes scene)
 {
     Application.LoadLevel(scene.ToString().ToLower());
 }
Example #4
0
        // Update is called once per frame
        private void Update()
        {
            switch (State)
            {
            case GameState.Playing:
                break;

            case GameState.StartGame:
                InstantiateSlicingObject();
                Controller.PlayerUIScoreController.Setup();
                Controller.OpponentUIScoreController.Setup();
                State = GameState.Playing;
                break;

            case GameState.EndGame:
                Scenes.Load("Menu");
                break;

            case GameState.WonGame:
                GameObject.Find("Border").SetActive(false);
                GameObject.Find("Background").GetComponent <SpriteRenderer>().color = new Color(0, 0, 0, 0.73f);
                ExplodeSlices();
                State = GameState.ShowRoundResults;
                Other.Tools.CreatePopup(Other.Tools.Messages.WonGame);
                break;

            case GameState.LostGame:
                GameObject.Find("Border").SetActive(false);
                GameObject.Find("Background").GetComponent <SpriteRenderer>().color = new Color(0, 0, 0, 0.73f);
                ExplodeSlices();
                State = GameState.ShowRoundResults;
                Other.Tools.CreatePopup(Other.Tools.Messages.LostGame);
                break;

            case GameState.WonRound:
                Player.Points++;
                UpdateScoreDisplay();
                State = GameState.NextRound;
                if (Player.Points >= PointsForWin)
                {
                    State = GameState.WonGame;
                }
                break;

            case GameState.LostRound:
                Opponent.Points++;
                UpdateScoreDisplay();
                State = GameState.NextRound;
                if (Opponent.Points >= PointsForWin)
                {
                    State = GameState.LostGame;
                }
                break;

            case GameState.NextRound:
                State = GameState.Playing;
                if (TotalMassLeft <= 1)
                {
                    State = GameState.NoMassLeft;
                }
                break;

            case GameState.FinishedMove:
                if (GetMassOnScale() <= 0)
                {
                    State = GameState.Playing;
                    break;
                }
                if (GameMode == GameType.Online)
                {
                    MultiplayerManager.Instance.FinishMove(_lastPlacedMass);
                }
                State = GameState.WaitForOpponent;
                break;

            case GameState.TimeOver:
                State = GameState.FinishedMove;
                break;

            case GameState.NoMassLeft:
                Other.Tools.CreatePopup("Out of mass");
                State = GameState.LostGame;
                break;

            case GameState.WaitForOpponent:
                Canvas.transform.Find("FinishMove").gameObject.SetActive(false);
                Canvas.transform.Find("WaitingForOpponent").gameObject.SetActive(true);
                if (GameMode == GameType.Bot)
                {
                    float botMove = _botOpponent.GetNextMove();
                    State          = _lastPlacedMass > botMove ? GameState.WonRound : GameState.LostRound;
                    TotalMassLeft -= _lastPlacedMass;
                    Player.Moves.Add(_lastPlacedMass);
                    Opponent.Moves.Add(botMove);
                    Canvas.transform.Find("FinishMove").gameObject.SetActive(true);
                    Canvas.transform.Find("WaitingForOpponent").gameObject.SetActive(false);
                }
                break;

            case GameState.ShowRoundResults:
                Canvas.transform.Find("FinishMove").gameObject.SetActive(false);
                Canvas.transform.Find("ExitGame").gameObject.SetActive(true);
                PlayingField.SetActive(false);
                Controller.RoundResultsController.enabled = true;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Example #5
0
 private void Start()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     SlicingObjectName = SecurePlayerPrefs.GetString("SlicingObject");
     GameMode          = (GameType)Enum.Parse(typeof(GameType), Scenes.GetString("GameMode"));
     StartGame(5, GameMode);
     GameObject.Find("OpponentName").GetComponent <Text>().text = "You vs. " + Scenes.GetString("OpponentName");
 }