Пример #1
0
 public void SetToDestroy()
 {
     m_Decal.SetToDestroy();
     GameScoreManager.Get().DecrementLiveCracks();
     //SetEnableAllActorTriggerBase(false);
     m_DefenderCollider.enabled = false;
 }
Пример #2
0
 public void UpdateAttackedState(State currState, float deltaTime)
 {
     if (m_Animation.IsPlaying("HitReaction") == false)
     {
         //Debug.Log("Animation finished..");
         m_PlayerStateMachine.CanChangeState = true;
         if (GameScoreManager.Get().PlayerHealth == 0.0f)
         {
             m_BufferedInput.AddInput("Death", 0.1f);
         }
     }
 }
Пример #3
0
 void Awake()
 {
     _instance = this;
     //#if UNITY_ANDROID
     //        print("UNITY_ANDROID测试");
     path = Application.persistentDataPath + "/StreamingAssets";
     print("UNITY_ANDROID::path = " + path);
     //#elif UNITY_EDITOR
     //        print("UNITY_EDITOR测试");
     //path = Application.dataPath + "/StreamingAssets";
     //print("UNITY_EDITOR::path=" + path);
     //#endif
     //Debug.Log(path);
 }
Пример #4
0
        public void GameEngine_PlayerBIsNull_ThrowException()
        {
            var    playerA = new Player("ROGER");
            Player playerB = null;
            var    randomPointResultEngine = new RandomPointResultEngine();
            var    gameScoreManager        = new GameScoreManager();
            var    consoleUserInterface    = new ConsoleUserInterface();

            var gameEngine = new GameEngine(randomPointResultEngine,
                                            gameScoreManager,
                                            consoleUserInterface,
                                            playerA,
                                            playerB);
        }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        if (!m_GameOver)
        {
            m_Text.text = "" + (GameScoreManager.Get() != null ? GameScoreManager.Get().PatchedCount : 0);
            float healthBarWIdth = GameScoreManager.Get().PlayerHealth *m_HealthBarMaxWidth;
            m_HealthBar.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, healthBarWIdth);

            float damageBarWidthPercent = (float)GameScoreManager.Get().NumLiveCracks / GameScoreManager.Get().MaxNumLiveCracks;
            if (damageBarWidthPercent >= 1.0f)
            {
                damageBarWidthPercent = 1.0f;
                m_GameOver            = true;
                m_MessageGenerator.gameObject.SetActive(false);
            }
            if (GameScoreManager.Get().PlayerHealth <= 0.0f)
            {
                m_GameOver = true;
                m_MessageGenerator.gameObject.SetActive(false);
            }

            m_DamagehBar.rectTransform.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, damageBarWidthPercent * m_DamageBarMaxWidth);
        }
        else
        {
            if (m_Player.DeathStateCompleted && !m_GameOverScreenShown)
            {
                m_GameOverScreenShown = true;
                m_HealthCanvas.gameObject.SetActive(false);
                m_ScoreCanvas.gameObject.SetActive(false);
                m_DamageCanvas.gameObject.SetActive(false);
                m_GameOverCanvas.gameObject.SetActive(true);
                m_GameOverTimer = 2.0f;
            }
            if (m_GameOverScreenShown)
            {
                m_GameOverTimer -= Time.deltaTime;
                if (m_GameOverTimer <= 0.0f)
                {
                    if (Input.anyKey)
                    {
                        SceneManager.LoadScene(SceneManager.GetActiveScene().name);
                    }
                }
            }
        }
    }
Пример #6
0
 // Called when any types weapon collides with this, returns true if it is successful attack
 // returns false if attack is blocked
 public override bool Attacked(Actor attacker, GameObject bodyPartGotHit, float damage)
 {
     if (attacker.GetType().IsSubclassOf(typeof(Patch)) || attacker.GetType() == typeof(Patch))
     {
         Patch patch = (Patch)attacker;
         if (patch != null)
         {
             if (GameScoreManager.Get() != null)
             {
                 GameScoreManager.Get().IncrementPatchCount();
             }
             //patch.SetToDestroy();
             SetToDestroy();
         }
     }
     return(true);
 }
Пример #7
0
        public void PlayGame_PlayerAAlwaysWinThePoint_PlayerAWinsTheGame()
        {
            var playerA = new Player("ROGER");
            var playerB = new Player("RAFA");
            var randomPointResultEngine = new Fake_PlayerAAlwaysWinResultEngine();
            var gameScoreManager        = new GameScoreManager();
            var consoleUserInterface    = new Fake_UserInterface();

            var gameEngine = new GameEngine(randomPointResultEngine,
                                            gameScoreManager,
                                            consoleUserInterface,
                                            playerA,
                                            playerB);

            var winner = gameEngine.PlayGame();

            Assert.AreEqual(playerA.Name, winner);
        }
Пример #8
0
 // Called when any types weapon collides with this, returns true if it is successful attack
 // returns false if attack is blocked
 public override bool Attacked(Actor attacker, GameObject bodyPartGotHit, float damage)
 {
     if (attacker.GetType().IsSubclassOf(typeof(Projectile)))
     {
         Projectile proj = (Projectile)attacker;
         if (proj != null)
         {
             proj.DestroyWithoutDecals();
         }
         if (m_PlayerStateMachine.CurrentState != (int)PlayerStates.ePS_Dead)
         {
             m_PlayerHealth -= damage;
             GameScoreManager.Get().PlayerHealth = Mathf.Clamp(m_PlayerHealth / m_PlayerMaxHealth, 0.0f, 1.0f);
             m_BufferedInput.AddInput("Attacked", 0.05f);
             m_PlayerStateMachine.CanChangeState = true;
         }
     }
     return(true);
 }
Пример #9
0
        public void UpdateScore_PlayerMakesPoint_PlayerScoreIncrease()
        {
            var playerA      = new Player("ROGER");
            var playerB      = new Player("RAFA");
            var scoreManager = new GameScoreManager();

            scoreManager.UpdateScore(playerA, playerB, playerA.Name);
            Assert.AreEqual(Points.Fifteen, playerA.Score);

            scoreManager.UpdateScore(playerA, playerB, playerA.Name);
            Assert.AreEqual(Points.Thirty, playerA.Score);

            scoreManager.UpdateScore(playerA, playerB, playerA.Name);
            Assert.AreEqual(Points.Forty, playerA.Score);

            scoreManager.UpdateScore(playerA, playerB, playerB.Name);
            Assert.AreEqual(Points.Fifteen, playerB.Score);

            scoreManager.UpdateScore(playerA, playerB, playerB.Name);
            Assert.AreEqual(Points.Forty, playerA.Score);

            scoreManager.UpdateScore(playerA, playerB, playerB.Name);
            Assert.AreEqual(Points.Forty, playerB.Score);

            scoreManager.UpdateScore(playerA, playerB, playerA.Name);
            Assert.AreEqual(Points.Forty, playerB.Score);

            scoreManager.UpdateScore(playerA, playerB, playerB.Name);
            Assert.AreEqual(Points.Forty, playerB.Score);

            scoreManager.UpdateScore(playerA, playerB, playerB.Name);
            Assert.AreEqual(Points.Advantage, playerB.Score);

            scoreManager.UpdateScore(playerA, playerB, playerB.Name);
            Assert.AreEqual(Points.Game, playerB.Score);

            playerB.Score = Points.Forty;
            playerA.Score = Points.Advantage;
            scoreManager.UpdateScore(playerA, playerB, playerA.Name);
            Assert.AreEqual(Points.Game, playerA.Score);
        }
Пример #10
0
        static void Main(string[] args)
        {
            try
            {
                var playerA = new Player("ROGER");
                var playerB = new Player("RAFA");
                var randomPointResultEngine = new RandomPointResultEngine();
                var gameScoreManager        = new GameScoreManager();
                var consoleUserInterface    = new ConsoleUserInterface();

                var gameEngine = new GameEngine(randomPointResultEngine,
                                                gameScoreManager,
                                                consoleUserInterface,
                                                playerA,
                                                playerB);
                gameEngine.PlayGame();
            }
            catch (System.Exception ex)
            {
                System.Console.WriteLine(ex);
            }
        }
Пример #11
0
	// Use this for initialization
	void Awake () {
		Instance = this;
	}
Пример #12
0
        public void CheckGameWinner_PlayerMakesPoint_PlayersWinsTheGame()
        {
            var playerA      = new Player("ROGER");
            var playerB      = new Player("RAFA");
            var scoreManager = new GameScoreManager();

            playerA.Score = Points.Fifteen;
            playerB.Score = Points.Love;
            var winner = scoreManager.GetGameWinnerName(playerA, playerB);

            Assert.AreEqual("", winner);

            playerA.Score = Points.Thirty;
            playerB.Score = Points.Love;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual("", winner);

            playerA.Score = Points.Forty;
            playerB.Score = Points.Love;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual("", winner);

            playerA.Score = Points.Love;
            playerB.Score = Points.Fifteen;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual("", winner);

            playerA.Score = Points.Love;
            playerB.Score = Points.Thirty;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual("", winner);

            playerA.Score = Points.Love;
            playerB.Score = Points.Forty;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual("", winner);

            playerA.Score = Points.Love;
            playerB.Score = Points.Love;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual("", winner);

            playerA.Score = Points.Fifteen;
            playerB.Score = Points.Fifteen;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual("", winner);

            playerA.Score = Points.Thirty;
            playerB.Score = Points.Thirty;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual("", winner);

            playerA.Score = Points.Forty;
            playerB.Score = Points.Forty;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual("", winner);

            playerA.Score = Points.Advantage;
            playerB.Score = Points.Forty;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual("", winner);

            playerA.Score = Points.Forty;
            playerB.Score = Points.Advantage;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual("", winner);

            playerA.Score = Points.Game;
            playerB.Score = Points.Love;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual(playerA.Name, winner);

            playerA.Score = Points.Game;
            playerB.Score = Points.Fifteen;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual(playerA.Name, winner);

            playerA.Score = Points.Game;
            playerB.Score = Points.Thirty;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual(playerA.Name, winner);

            playerA.Score = Points.Game;
            playerB.Score = Points.Forty;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual(playerA.Name, winner);

            playerA.Score = Points.Love;
            playerB.Score = Points.Game;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual(playerB.Name, winner);

            playerA.Score = Points.Fifteen;
            playerB.Score = Points.Game;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual(playerB.Name, winner);

            playerA.Score = Points.Thirty;
            playerB.Score = Points.Game;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual(playerB.Name, winner);

            playerA.Score = Points.Forty;
            playerB.Score = Points.Game;
            winner        = scoreManager.GetGameWinnerName(playerA, playerB);
            Assert.AreEqual(playerB.Name, winner);
        }
Пример #13
0
 // Use this for initialization
 protected void Awake()
 {
     m_Decal           = GetComponent <Decal>();
     m_NoOfPointsAdded = 0;
     GameScoreManager.Get().IncrementLiveCracks();
 }
Пример #14
0
    //private PulledObject pulled_object;

    private void Awake()
    {
        scoreManager = GameObject.FindGameObjectWithTag("GM").GetComponent <GameScoreManager>();
        //pulled_object = gameObject.GetComponent<PulledObject>();
    }