Ejemplo n.º 1
0
    void opponentAttack(float damage)
    {
        AttackBall opponentAttackBall = Instantiate(opponentAttackBallPrefab, opponentAttackBallSpawnPosition, Quaternion.identity).GetComponent <AttackBall> ();

        opponentAttackBall.transform.Rotate(new Vector3(0f, 180f));
        opponentAttackBall.setDamage(damage);
        opponentAttackBall.setOwn(false);
        opponentCharacterAnimator.SetTrigger(AnimationCommand.ATTACK);
    }
Ejemplo n.º 2
0
    public void judgeAnswer()
    {
        if (int.Parse(answerText.text) == problemSet.Value)
        {
            generateNewProblem();

            ownCharacterAnimator.SetTrigger(AnimationCommand.ATTACK);

            // Play sound effects
            tappingSound.PlayOneShot(GameSFX.ANSWER_CORRECT);

            // Add combo
            ++combo;
            comboText.text = "" + combo;
            comboTimer     = ownCharacter.getComboTimer();

            // Increase own special gauge
            ownSpecialGauge += ownCharacter.getSpecialBarIncrease() [difficulty];
            if (ownSpecialGauge >= 1)
            {
                ownSpecialGauge = 1;
                if (!specialButton.activeSelf)
                {
                    sound.PlayOneShot(GameSFX.SPECIAL_FULL);
                }
                specialButton.SetActive(true);
            }

            float      damage        = ownCharacter.getDamage() [difficulty] * (1 + combo * COMBO_MULTIPLIER);
            AttackBall ownAttackBall = Instantiate(ownAttackBallPrefab, opponentAttackBallSpawnPosition, Quaternion.identity).GetComponent <AttackBall> ();
            ownAttackBall.setDamage(damage);
            ownAttackBall.setOwn(true);

            // Call RPC
            this.photonView.RPC("opponentAttack", PhotonTargets.Others, damage);
            this.photonView.RPC("modifyOpponentSpecialGauge", PhotonTargets.Others, ownSpecialGauge);
        }
        else
        {
            resetCombo();

            // Play sound effects
            tappingSound.PlayOneShot(GameSFX.ANSWER_FALSE);
        }
        deleteAnswer();
    }
Ejemplo n.º 3
0
    void Update()
    {
        #region balldrop count && timer
        //Set Ball TxT in game to Ball : then -> + ballcount from 100....
        ballTxT.text = "Balls: " + ballCount.ToString();
        // Once ballcount has reach 0 and timer is is bigger then 0
        if (ballCount <= 0 && timer >= 0.0f)
        {
            //Start ball count from 10 - 0 seconds
            timer -= Time.deltaTime;
            //Display Time
            timerTxT.text = "" + timer.ToString("Time to Collect! 0");
        }
        //if the time has reached 0 then.....
        if (timer <= 0)
        {
            // This is where you decide who wins
            int        minScore = int.MinValue;
            AttackBall winner   = null;
            for (int i = 0; i < playerScores.Length; i++)
            {
                AttackBall player = playerScores[i];
                if (player.score >= minScore)
                {
                    minScore = player.score;
                    winner   = player;
                }
                //print(player.hitColor + ": " + player.count);
            }

            TausFails.SetActive(true);

            //If the algorithm found a winner
            if (winner != null)
            {
                // Enable Winner Canvas Panels
                // Set text of 'winner color' to winner.hitColor
                playerWin.text = "Player " + winner.hitColor + " wins!";
                // Set text of 'winner score' to winner.score
                playerNumScore.text = "Points: " + winner.score;
                Time.timeScale      = 0.0f;
            }
        }
        #endregion
    }
Ejemplo n.º 4
0
    void npcAttack()
    {
        opponentCharacterAnimator.SetTrigger(AnimationCommand.ATTACK);
        ++npcComboCount;

        int npcDifficulty = Random.Range(0, 3);

        //Set npc attack time
        switch (npcDifficulty)
        {
        case 0:
            npcAttackTime = Random.Range(1, 4);
            break;

        case 1:
            npcAttackTime = Random.Range(2, opponentCharacter.getComboTimer() + 1);
            break;

        case 2:
            npcAttackTime = Random.Range(3, opponentCharacter.getComboTimer() + 2);
            break;
        }
        ;

        npcComboTimer = opponentCharacter.getComboTimer();

        // Increase opponent's special gauge
        opponentSpecialGauge += opponentCharacter.getSpecialBarIncrease() [npcDifficulty];
        if (opponentSpecialGauge >= 1)
        {
            opponentSpecialGauge = 1;
        }

        float      damage             = opponentCharacter.getDamage() [npcDifficulty] * (1 + npcComboCount * COMBO_MULTIPLIER);
        AttackBall opponentAttackBall = Instantiate(opponentAttackBallPrefab, opponentAttackBallSpawnPosition, Quaternion.identity).GetComponent <AttackBall> ();

        opponentAttackBall.transform.Rotate(new Vector3(0f, 180f));
        opponentAttackBall.setDamage(damage);
        opponentAttackBall.setOwn(false);
    }