Beispiel #1
0
    private void OnSentenceEnded()
    {
        List <RecordedNote> recordedNotes  = PlayerNoteRecorder.GetRecordedNotes(CurrentSentence);
        SentenceRating      sentenceRating = PlayerScoreController.CalculateScoreForSentence(CurrentSentence, recordedNotes);

        playerUiController.ShowTotalScore((int)PlayerScoreController.TotalScore);
        if (sentenceRating != null)
        {
            playerUiController.ShowSentenceRating(sentenceRating);

            if (sentenceRating == SentenceRating.Perfect)
            {
                perfectSentenceChain++;
            }
            else
            {
                perfectSentenceChain = 0;
            }

            if (perfectSentenceChain >= 2)
            {
                playerUiController.CreatePerfectSentenceEffect();
            }
        }

        sentenceIndex++;
        UpdateSentences(sentenceIndex);
    }
Beispiel #2
0
    public void Init(SongMeta songMeta, PlayerProfile playerProfile, string voiceIdentifier, MicProfile micProfile)
    {
        this.SongMeta      = songMeta;
        this.PlayerProfile = playerProfile;
        this.MicProfile    = micProfile;

        Voice = LoadVoice(songMeta, voiceIdentifier);
        PlayerScoreController.Init(Voice);
        PlayerNoteRecorder.Init(this, playerProfile, micProfile);
    }
Beispiel #3
0
    // Unity lifecycle method
    void Update()
    {
        // FIXME: move this to a view class
        playerOneScoreView.GetComponent <Text>().text = PlayerScoreController.getScoreForPlayer(0).ToString();
        playerTwoScoreView.GetComponent <Text>().text = PlayerScoreController.getScoreForPlayer(1).ToString();

        // TODO: move this time logic to another class
        currentGameTime += Time.deltaTime;
        elapsedTurnTime -= Time.deltaTime;

        if (undoLastMoveButtonControllerScript.shouldUndoLastMove && undoLastMoveButtonControllerScript.isEnabled)
        {
            revertLastMove();
        }
    }
 public PlayerController(GameObject playerGmj, Message_ServerCommand_CreateGameObject info, UnityPlayerData generalPlayerData, IDeviceInput deviceInput)
 {
     alive = true;
     playerScoreController  = new PlayerScoreController();
     spellCaster            = new SpellCasterController(this);
     playerAnimator         = new PlayerAnimatorController(playerGmj);
     healthController       = new PlayerHealthController(this, generalPlayerData);
     this.playerGmj         = playerGmj;
     this.generalPlayerData = generalPlayerData;
     PlayerControllerGUID   = info.GmjGUID;
     OwnerID = info.OwnerGUID;
     playerGmj.transform.position = new Vector3(info.transform.xPos, StaticVariables.GetYPos(), info.transform.zPos);
     targetPos        = playerGmj.transform.position;
     this.deviceInput = deviceInput;
 }
Beispiel #5
0
    private void OnSentenceEnded()
    {
        PlayerNoteRecorder.OnSentenceEnded();
        List <RecordedNote> recordedNotes  = PlayerNoteRecorder.GetRecordedNotes(CurrentSentence);
        SentenceRating      sentenceRating = PlayerScoreController.CalculateScoreForSentence(CurrentSentence, recordedNotes);

        playerUiController.ShowTotalScore(PlayerScoreController.TotalScore);
        if (sentenceRating != null)
        {
            playerUiController.ShowSentenceRating(sentenceRating);
            sentenceRatingStream.OnNext(sentenceRating);
        }

        sentenceIndex++;
        UpdateSentences(sentenceIndex);
    }
Beispiel #6
0
    // perform system cleanups and updates after a move has been made successfully
    // check for a win and stop the game if one is found.
    private void didExecutePlayerMove(string postName, PlayerMoveModel playerMove)
    {
        FormationModel winningFormation = GameBoardController.findWinningFormation(playerMove);

        if (winningFormation != null)
        {
            inturruptUndoLastMoveCoroutine();
            isComplete = true;
            // show winning formation
            PlayerScoreController.declareWinner(playerMove.player);
            buildWinnerText();

            return;
        }

        undoLastMoveCoroutine = enableUndoLastMove();
        StartCoroutine(undoLastMoveCoroutine);
    }
Beispiel #7
0
    public void Init(PlayerProfile playerProfile, string voiceName, MicProfile micProfile)
    {
        this.PlayerProfile      = playerProfile;
        this.MicProfile         = micProfile;
        this.Voice              = GetVoice(songMeta, voiceName);
        this.playerUiController = Instantiate(playerUiControllerPrefab, playerUiArea.transform);
        this.childrenInjector   = CreateChildrenInjectorWithAdditionalBindings();

        // Inject all
        foreach (INeedInjection childThatNeedsInjection in GetComponentsInChildren <INeedInjection>())
        {
            childrenInjector.Inject(childThatNeedsInjection);
        }
        childrenInjector.Inject(playerUiController);

        // Init instances
        playerUiController.Init(PlayerProfile, MicProfile);
        PlayerScoreController.Init(Voice);
    }
Beispiel #8
0
    /// <summary>
    /// Draws the current state of the game to the screen.
    /// </summary>
    /// <remarks>
    /// What is drawn depends upon the state of the game.
    /// </remarks>
    public static void DrawScreen()
    {
        UtilityFunctions.DrawBackground();

        switch (CurrentState)
        {
        case GameState.ViewingMainMenu:
            MenuController.DrawMainMenu();
            break;

        case GameState.ViewingGameMenu:
            MenuController.DrawGameMenu();
            break;

        case GameState.AlteringSettings:
            MenuController.DrawSettings();
            break;

        case GameState.Deploying:
            DeploymentController.DrawDeployment();
            break;

        case GameState.Discovering:
            DiscoveryController.DrawDiscovery();
            break;

        case GameState.EndingGame:
            EndingGameController.DrawEndOfGame();
            break;

        case GameState.ViewingHighScores:
            HighScoreController.DrawHighScores();
            break;

        case GameState.ViewingPlayerScores:
            PlayerScoreController.DrawHighScores();
            break;
        }

        UtilityFunctions.DrawAnimations();

        SwinGame.RefreshScreen();
    }
Beispiel #9
0
    /// <summary>
    /// Handles the user SwinGame.
    /// </summary>
    /// <remarks>
    /// Reads key and mouse input and converts these into
    /// actions for the game to perform. The actions
    /// performed depend upon the state of the game.
    /// </remarks>
    public static void HandleUserInput()
    {
        //Read incoming input events
        SwinGame.ProcessEvents();

        switch (CurrentState)
        {
        case GameState.ViewingMainMenu:
            MenuController.HandleMainMenuInput();
            break;

        case GameState.ViewingGameMenu:
            MenuController.HandleGameMenuInput();
            break;

        case GameState.AlteringSettings:
            MenuController.HandleSetupMenuInput();
            break;

        case GameState.Deploying:
            DeploymentController.HandleDeploymentInput();
            break;

        case GameState.Discovering:
            DiscoveryController.HandleDiscoveryInput();
            break;

        case GameState.EndingGame:
            EndingGameController.HandleEndOfGameInput();
            break;

        case GameState.ViewingHighScores:
            HighScoreController.HandleHighScoreInput();
            break;

        case GameState.ViewingPlayerScores:
            PlayerScoreController.HandleHighScoreInput();
            break;
        }

        UtilityFunctions.UpdateAnimations();
    }
    public void Awake()
    {
        playerListEntries = new Dictionary <int, PlayerScoreController>();

        foreach (Player p in PhotonNetwork.PlayerList)
        {
            // Check if the Player is Local
            if (p.IsLocal)
            {
                // If it is, update the name
                localPlayerScoreController.SetPlayerScoreName(p.NickName);
            }
            else
            {
                // If it's not, Instantiate new GameObjects of PlayerScore
                PlayerScoreController entry = Instantiate(playerScoreControllerPrefab, playersParent);
                entry.SetPlayerScoreName(p.NickName);
                playerListEntries.Add(p.ActorNumber, entry);
            }
        }
    }
 // Use this for initialization
 void Awake()
 {
     animator                 = gameObject.GetComponent <Animator>();
     audioSource              = gameObject.GetComponent <AudioSource>();
     bodyAnimator             = transform.Find("Body").gameObject.GetComponent <Animator>();
     dashAnimator             = transform.Find("Body/Dash").gameObject.GetComponent <Animator>();
     rigidBody                = gameObject.GetComponent <Rigidbody2D>();
     playerTag                = transform.Find("Body/tag").transform;
     bodyAnimator.logWarnings = false;
     //Get correct score component
     maxScore         = GameController.GetMaxGameScore();
     playerScore      = GameController.GetInitialGameScore();
     playerScoreGroup = transform.parent.FindChild("Canvas/Player Score").gameObject;
     playerScoreBar   = playerScoreGroup.GetComponent <PlayerScoreController>();
     playerNameText   = playerScoreGroup.transform.FindChild("Player Name").gameObject.GetComponent <Text>();
     //Populate Attrs Hashtable
     playerAttrs.Add(Attributes.SPEED, moveSpeed);
     playerAttrs.Add(Attributes.THROWSPEED, throwSpeed);
     playerAttrs.Add(Attributes.PRESENTSPEED, presentSpeed);
     playerAttrs.Add(Attributes.FROZEN, State.DEAD);
     playerAttrs.Add(Attributes.DASHDELAY, dashDelay);
     playerAttrs.Add(Attributes.CONTROLDIRECTION, 1f);
 }
Beispiel #12
0
    private void FinishRecordingSentence(int sentenceIndex)
    {
        PlayerNoteRecorder.OnSentenceEnded();

        Sentence recordingSentence = GetSentence(sentenceIndex);

        if (recordingSentence == null)
        {
            return;
        }

        List <RecordedNote> recordedNotes = PlayerNoteRecorder.GetRecordedNotes(recordingSentence);

        PlayerNoteRecorder.RemoveRecordedNotes(recordingSentence);
        SentenceRating sentenceRating = PlayerScoreController.CalculateScoreForSentence(recordingSentence, recordedNotes);

        playerUiController.ShowTotalScore(PlayerScoreController.TotalScore);
        if (sentenceRating != null)
        {
            playerUiController.ShowSentenceRating(sentenceRating);
            sentenceRatingStream.OnNext(sentenceRating);
        }
    }
    // Use this for initialization
    void Start()
    {
        playerScoreController = GameObject.FindObjectOfType <PlayerScoreController>();
        //Randomize the speed
        speed  = Random.Range(.01f, speed);                //Augment the speed by the factor as they are created
        speed *= DifficultyController.obstacleSpeedFactor; //Adjust speed as difficulty increases

        if (protectionZoneOfInterest == null)
        {
            ProtectionZoneController[] protectionZones = GameObject.FindObjectsOfType <ProtectionZoneController>();
            protectionZoneOfInterest = protectionZones[Random.Range(0, protectionZones.Length - 1)];
        }
        //Set the starting position
        startingPosition = transform.position;

        //Set the tag on all obstacles
        this.gameObject.tag = "Obstacle";

        //Initialize health -- Random between range
        health = Random.Range(healthLower, healthUpper);

        //Ensure there are default sounds;
        if (hitStillHealthSound == null)
        {
            hitStillHealthSound = (AudioClip)Resources.Load("Sounds/hitStillHealth");
        }

        if (hitDeadSound == null)
        {
            hitDeadSound = (AudioClip)Resources.Load("Sounds/hitDeadSound");
        }

        //Set the text component for future reference
        hpText      = GetComponentInChildren <Text>();
        hpText.text = "HP: " + health;
    }
Beispiel #14
0
    public void Init(SongMeta songMeta, PlayerProfile playerProfile, string voiceIdentifier)
    {
        this.SongMeta      = songMeta;
        this.PlayerProfile = playerProfile;

        Voice = LoadVoice(songMeta, voiceIdentifier);

        playerUiArea = FindObjectOfType <PlayerUiArea>();

        PlayerScoreController = GetComponentInChildren <PlayerScoreController>();
        PlayerScoreController.Init(Voice);

        PlayerNoteRecorder = GetComponentInChildren <PlayerNoteRecorder>();
        if (PlayerNoteRecorder == null)
        {
            throw new NullReferenceException("PlayerNoteRecorder is null!");
        }
        PlayerNoteRecorder.Init(this, playerProfile.Difficulty.RoundingDistance);

        CreatePlayerUi();

        sentenceIndex = 0;
        UpdateSentences(sentenceIndex);
    }
Beispiel #15
0
    // Unity lifecycle method
    void Start()
    {
        // reset the PlayerTurnController, this is only helpful when a game gets reset or restarted
        PlayerTurnController.init();
        PlayerScoreController.startNewGame();

        masterGameTimeText                 = GameObject.FindGameObjectWithTag("masterGameTime").gameObject;
        elapsedTurnTimeText                = GameObject.FindGameObjectWithTag("elapsedTurnTime").gameObject;
        winnerBannerText                   = GameObject.FindGameObjectWithTag("winnerBanner").gameObject;
        playerTurnView                     = GameObject.FindGameObjectWithTag("playerTurnView").gameObject;
        undoLastMoveButtonController       = GameObject.FindGameObjectWithTag("undoLastMoveButtonController").gameObject;
        undoLastMoveButtonControllerScript = undoLastMoveButtonController.GetComponent <UndoLastMoveButtonController>();
        playerOneScoreView                 = GameObject.FindGameObjectWithTag("playerOneScoreView").gameObject;
        playerTwoScoreView                 = GameObject.FindGameObjectWithTag("playerTwoScoreView").gameObject;

        // FIXME: move this to a view class
        playerOneScoreView.GetComponent <Text>().text = "0";
        playerTwoScoreView.GetComponent <Text>().text = "0";
        winnerBannerText.GetComponent <Text>().text   = "";
        currentGameTime = 0f;
        didStart        = true;

        resetTurnTime();
    }
 private void Awake()
 {
     playerScoreControllerScript = player.GetComponent <PlayerScoreController>();
     playerPreviousScore         = 0;
 }
 // Use this for initialization
 void Start()
 {
     playerScoreController = GameObject.FindObjectOfType <PlayerScoreController>();
 }
 public void Awake()
 {
     playerScoreControllerScript = player.GetComponent <PlayerScoreController>();
     playerSeedControllerScript  = player.GetComponent <PlayerSeedController>();
     Destroy(ruleText, ruleTextShowDuration);
 }
 private void Start()
 {
     instance = this;
 }