Example #1
0
        public void AddTileNonMatchingTile_WhenOpen_ExceptionThrown()
        {
            var engine = new DominoTileEntity(12, 12, true);
            var game   = new GameEntity(
                Guid.NewGuid(),
                Enumerable.Empty <PlayerEntity>(),
                MexicanTrain.Create(),
                engine,
                new Stack <DominoTileEntity>());

            Games.Add(game.Id, game);

            var playerId  = Guid.NewGuid();
            var sut       = new PlayerTrain(engine, playerId);
            var tileOne   = new DominoTileEntity(12, 11);
            var tileTwo   = new DominoTileEntity(11, 10);
            var tileThree = new DominoTileEntity(11, 3);

            sut.AddTile(tileOne, playerId);
            sut.Open();
            sut.AddTile(tileTwo, playerId);
            Action addTile = () => sut.AddTile(tileThree, playerId);

            Assert.ThrowsAny <Exception>(addTile);
        }
        private static void TestOpenCloseIsOpen()
        {
            Console.WriteLine("Testing Open(), Close(), IsOpen");
            Console.WriteLine();

            Random      rndGen = new Random();
            int         engVal = rndGen.Next(1, 7);
            PlayerTrain test   = new PlayerTrain(new Hand(), engVal);

            Console.WriteLine("Expect: IsOpen = False");
            Console.WriteLine("Result: IsOpen = " + test.IsOpen.ToString());
            Console.WriteLine();

            Console.WriteLine("Calling Open()");
            Console.WriteLine();

            test.Open();

            Console.WriteLine("Expect: IsOpen = True");
            Console.WriteLine("Result: IsOpen = " + test.IsOpen.ToString());
            Console.WriteLine();

            Console.WriteLine("Calling Close()");
            Console.WriteLine();

            test.Close();

            Console.WriteLine("Expect: IsOpen = False");
            Console.WriteLine("Result: IsOpen = " + test.IsOpen.ToString());
            Console.WriteLine();
        }
Example #3
0
        public void AddTile_ThreeTiles_FourTilesIncludingEngineExists()
        {
            var engine = new DominoTileEntity(12, 12, true);
            var game   = new GameEntity(
                Guid.NewGuid(),
                Enumerable.Empty <PlayerEntity>(),
                MexicanTrain.Create(),
                engine,
                new Stack <DominoTileEntity>());

            Games.Add(game.Id, game);

            var playerId  = Guid.NewGuid();
            var sut       = new PlayerTrain(engine, playerId);
            var tileOne   = new DominoTileEntity(12, 11);
            var tileTwo   = new DominoTileEntity(11, 10);
            var tileThree = new DominoTileEntity(10, 9);

            sut.Open();
            sut.AddTile(tileOne, playerId);
            sut.AddTile(tileTwo, playerId);
            sut.AddTile(tileThree, playerId);

            Assert.Equal(tileThree, sut.GetTiles().First());
            Assert.True(sut.GetTiles().First().IsLinked(tileTwo));
            Assert.True(sut.GetTiles().Skip(1).First().IsLinked(tileOne));
            Assert.True(sut.GetTiles().Skip(2).First().IsLinked(engine));
            Assert.Equal(4, sut.GetTiles().Count());
        }
Example #4
0
    public void FinishGhostMove()
    {
        PlayerTrain playerTrain = PlayerTrain.reference;

        speedPenalty += ghostStrength;
        playerTrain.speedDebuffPercent += ghostStrength;
    }
Example #5
0
        public void GetTiles_ThreeTilesInTrain_CorrectTilesReceived()
        {
            var engine = new DominoTileEntity(12, 12, true);
            var game   = new GameEntity(
                Guid.NewGuid(),
                Enumerable.Empty <PlayerEntity>(),
                MexicanTrain.Create(),
                engine,
                new Stack <DominoTileEntity>());

            Games.Add(game.Id, game);

            var playerId = Guid.NewGuid();
            var sut      = new PlayerTrain(engine, playerId);
            var tileOne  = new DominoTileEntity(12, 11);
            var tileTwo  = new DominoTileEntity(11, 10);

            sut.Open();
            sut.AddTile(tileOne, playerId);
            sut.AddTile(tileTwo, playerId);

            var result = sut.GetTiles();

            Assert.Equal(tileTwo, result.First());
            Assert.Equal(tileOne, result.Skip(1).First());
            Assert.Equal(engine, result.Skip(2).First());
        }
Example #6
0
        public void ToString_ThreeTilesAddes_AlignedTiles()
        {
            var engine = new DominoTileEntity(12, 12, true);
            var game   = new GameEntity(
                Guid.NewGuid(),
                Enumerable.Empty <PlayerEntity>(),
                MexicanTrain.Create(),
                engine,
                new Stack <DominoTileEntity>());

            Games.Add(game.Id, game);

            var playerId = Guid.NewGuid();
            var sut      = new PlayerTrain(engine, playerId);
            var tileOne  = new DominoTileEntity(11, 12);
            var tileTwo  = new DominoTileEntity(10, 11);

            sut.Open();
            sut.AddTile(tileOne, playerId);
            sut.AddTile(tileTwo, playerId);

            var result = sut.ToString();

            Assert.Equal("[12|12], [12|11], [11|10]", result);
        }
 public void SetUpAllTests()
 {
     playerOne      = new Hand();
     playerOneTrain = new PlayerTrain(playerOne, 12);
     mexiTrain      = new MexicanTrain(12);
     mustFlip       = false;
 }
Example #8
0
 public void SetUpAllTests()
 {
     def                = new PlayerTrain();
     defBoneYard        = new BoneYard();
     overloadedBoneYard = new BoneYard(13);
     defHand            = new Hand();
 }
Example #9
0
	void OnDisable()
	{
		reference = null;
		for(int wagonIndex = 0; wagonIndex < InventorySystem.reference.wagonUIs.Count; wagonIndex++)
		{
			InventorySystem.reference.wagonUIs[wagonIndex].wagonGameObject = null;
		}
	}
Example #10
0
 public void Repair()
 {
     if (PlayerTrain.CurrentHP < PlayerTrain.BaseHP)
     {
         PlayerStats.SpendMoney(repairPrice);
         PlayerTrain.RepairTrain(baseRepairPoints);
     }
 }
Example #11
0
 public void SetUpTest()
 {
     d       = new Domino(1, 2);
     dDouble = new Domino(12, 12);
     by      = new BoneYard(12);
     h       = new Hand(by, 2);
     pT      = new PlayerTrain(h);
 }
Example #12
0
 bool PassCheck(PlayerTrain player)
 {
     if (difficulty > player.speed * PlayerSaveData.reference.trainData.currentWeight)
     {
         return(false);
     }
     return(true);
 }
Example #13
0
 void OnDisable()
 {
     reference = null;
     for (int wagonIndex = 0; wagonIndex < InventorySystem.reference.wagonUIs.Count; wagonIndex++)
     {
         InventorySystem.reference.wagonUIs[wagonIndex].wagonGameObject = null;
     }
 }
Example #14
0
        public void TestConstructor()
        {
            Assert.AreEqual(6, p1Train.EngineValue);
            Assert.AreEqual(6, p2Train.EngineValue);
            PlayerTrain newPtrain = new PlayerTrain(h1, 2);

            Assert.AreEqual(2, newPtrain.EngineValue);
        }
Example #15
0
        public void TestOpen()
        {
            PlayerTrain newTrain = new PlayerTrain(h1, 2);

            Assert.False(newTrain.IsOpen);
            p1Train.Open();
            Assert.True(p1Train.IsOpen);
        }
Example #16
0
        public void TestEngineValue()
        {
            MexicanTrain a = new MexicanTrain(6);
            PlayerTrain  b = new PlayerTrain(hand1, 5);

            Assert.True(a.EngineValue == 6);
            Assert.True(b.EngineValue == 5);
        }
Example #17
0
 void OnEnable()
 {
     reference = this;
     for (int wagonIndex = 0; wagonIndex < InventorySystem.reference.wagonUIs.Count; wagonIndex++)
     {
         InventorySystem.reference.wagonUIs[wagonIndex].wagonGameObject = transform.GetChild(wagonIndex + 1);
         InventorySystem.reference.wagonUIs[wagonIndex].CheckSigns();
     }
 }
Example #18
0
 public void SetUpAllTests()
 {
     hand1              = new Hand();
     hand2              = new Hand();
     aMexicanTrain      = new MexicanTrain();
     aPlayerTrain       = new PlayerTrain(hand1);
     anotherPlayerTrain = new PlayerTrain(hand2);
     reallyBigHand      = new BoneYard(6);
 }
Example #19
0
 public void SetUpAllTests()
 {
     h1      = new Hand();
     h2      = new Hand();
     d00     = new Domino();
     d27     = new Domino(2, 7);
     p1Train = new PlayerTrain(h1, 6);
     p2Train = new PlayerTrain(h2, 6);
 }
Example #20
0
 public void SetUpAllTests()
 {
     pT  = new PlayerTrain(h, 12);
     pT1 = new PlayerTrain(h);
     d   = new Domino(10, 10);
     d1  = new Domino(5, 5);
     d3  = new Domino(12, 12);
     d4  = new Domino(12, 0);
 }
Example #21
0
	void OnEnable()
	{
		reference = this;
		for(int wagonIndex = 0; wagonIndex < InventorySystem.reference.wagonUIs.Count; wagonIndex++)
		{
			InventorySystem.reference.wagonUIs[wagonIndex].wagonGameObject = transform.GetChild(wagonIndex+1);
			InventorySystem.reference.wagonUIs[wagonIndex].CheckSigns();
		}
	}
Example #22
0
 void OnTriggerEnter2D(Collider2D collider)
 {
     if (collider.CompareTag("Train"))
     {
         Destroy(Instantiate(impactEffect, transform.position, Quaternion.identity), 3f);
         Destroy(gameObject);
         PlayerTrain.DamageTrain(damage);
     }
 }
Example #23
0
        public void TestClose()
        {
            PlayerTrain newTrain = new PlayerTrain(h1, 7);

            Assert.False(newTrain.IsOpen);
            newTrain.Open();
            Assert.True(newTrain.IsOpen);
            newTrain.Close();
            Assert.False(newTrain.IsOpen);
        }
Example #24
0
        public void ConstructorTest()
        {
            // Tests the PlayerTrain Constructor
            PlayerTrain p = new PlayerTrain(h, 3);

            //The engine value should be three, there should not
            // be three dominos in the train
            Assert.AreEqual(3, p.EngineValue);
            Assert.AreNotEqual(3, p.Count);
        }
Example #25
0
	public override IEnumerator Cast(PlayerTrain playerTrain)
	{
		if (roadFeature != null)
			roadFeature.stopFeature = true;
		foreach (GameObject pile in playerTrain.GetPilesNear()) {
			pile.GetComponent<RoadPile>().hitPoints -= 1;
		}
		playerTrain.ClearPilesNear ();
		yield return null;
	}
Example #26
0
        public void SetUpAllTests()
        {
            ptEmpty = new PlayerTrain(h, 0);
            pt      = new PlayerTrain(h, 0);
            h       = new Hand();
            d01     = new Domino(0, 1);
            d11     = new Domino(1, 1);

            pt.Add(d01);
            h.Add(d11);
        }
Example #27
0
    void SpawnGhost(PlayerTrain playerTrain, Vector3 side)
    {
        GhostInfo  info     = new GhostInfo();
        GameObject newGhost = Instantiate(ghostPrefab) as GameObject;

        newGhost.GetComponent <GhostController> ().feature = this;
        info.obj = newGhost;
        int wagonsCount = 0;

        for (int childIndex = 0; childIndex < playerTrain.transform.childCount; childIndex++)
        {
            if (playerTrain.transform.GetChild(childIndex).GetComponent <WagonScript>() != null)
            {
                wagonsCount += 1;
            }
        }

        WagonScript wagon      = null;
        Transform   spawnPoint = null;

        for (int wagonIndex = 0; wagonIndex < wagonsCount; wagonIndex++)
        {
            // try to get random wagon point
            wagon      = playerTrain.GetWagon(Random.Range(0, wagonsCount));
            spawnPoint = wagon.GetGhostPoint();
            if (spawnPoint != null)
            {
                info.wagonIndex = wagon.GetIndex();
                break;
            }


            wagon      = playerTrain.GetWagon(wagonIndex);
            spawnPoint = wagon.GetGhostPoint();
            if (spawnPoint != null)
            {
                info.wagonIndex = wagon.GetIndex();
                break;
            }
        }
        //GameObject wagon = playerTrain.GetWagon (Random.Range(0,wagonsCount)).gameObject;
        if (spawnPoint == null)
        {
            return;
        }

        newGhost.transform.parent           = spawnPoint;
        newGhost.transform.localPosition    = new Vector3(0, 0, 0);
        newGhost.transform.localScale       = new Vector3(1, 1, 1);
        newGhost.transform.localEulerAngles = side;
        newGhost.GetComponent <Animator>().Play("move");

        spawnedGhosts.Add(info);
    }
Example #28
0
 void Restart()
 {
     gameIsOver = false;
     PlayerStats.ResetStats();
     PlayerTrain.ResetTrain();
     foreach (Turret turret in FindObjectsOfType <Turret>())
     {
         Destroy(turret.gameObject);
     }
     gameOverScreen.SetActive(false);
 }
Example #29
0
	public override IEnumerator Cast(PlayerTrain playerTrain)
	{

		if (roadFeature != null)
			roadFeature.stopFeature = true;

		PlayerSaveData.reference.trainData.conditions.Shield = true;
		InventorySystem.reference.RepairWholeInventory (repairValue, true);
		yield return new WaitForSeconds (duration);
		PlayerSaveData.reference.trainData.conditions.Shield = false;

	}
Example #30
0
    public override IEnumerator Cast(PlayerTrain playerTrain)
    {
        if (roadFeature != null)
        {
            roadFeature.stopFeature = true;
        }

        PlayerSaveData.reference.trainData.conditions.Shield = true;
        InventorySystem.reference.RepairWholeInventory(repairValue, true);
        yield return(new WaitForSeconds(duration));

        PlayerSaveData.reference.trainData.conditions.Shield = false;
    }
Example #31
0
 public override IEnumerator Cast(PlayerTrain playerTrain)
 {
     if (roadFeature != null)
     {
         roadFeature.stopFeature = true;
     }
     foreach (GameObject pile in playerTrain.GetPilesNear())
     {
         pile.GetComponent <RoadPile>().hitPoints -= 1;
     }
     playerTrain.ClearPilesNear();
     yield return(null);
 }
 public void SetUpAllTests()
 {
     hand = new Hand();
     d11  = new Domino(1, 1);
     d12  = new Domino(1, 2);
     d23  = new Domino(2, 3);
     d31  = new Domino(3, 1);
     hand.Add(d12);
     hand.Add(d23);
     hand.Add(d31);
     playerTrain = new PlayerTrain(hand);
     playerTrain.Add(d11);
 }
        private static void TestPTIsPlayable()
        {
            Console.WriteLine("Test PlayerTrain IsPlayable");
            Console.WriteLine();

            const int MAXDOTS = 6;
            BoneYard  b       = new BoneYard(MAXDOTS);

            b.Shuffle();

            Random      rndGen = new Random();
            int         engVal = rndGen.Next(1, 7);
            PlayerTrain test   = new PlayerTrain(new Hand(), engVal);

            const int LOOPS = 10;

            Console.WriteLine("Engine value = " + engVal);
            Console.WriteLine("Playable value = " + test.PlayableValue);
            Console.WriteLine();

            Domino d;

            for (int i = 0; i < LOOPS; i++)
            {
                d = b.Draw();
                Console.WriteLine(d.ToString());

                if (rndGen.Next(1, 3) % 2 == 0)
                {
                    test.Open();
                    Console.WriteLine("The player's hand is open");
                }
                else
                {
                    test.Close();
                    Console.WriteLine("The player's hand is closed");
                }
                Console.WriteLine();

                bool checkPlay = test.IsOpen && (d.Side1 == test.PlayableValue || d.Side2 == test.PlayableValue);
                bool checkFlip = checkPlay ? d.Side1 != test.PlayableValue : false;  // Good form?

                Console.WriteLine("Test IsPlayable");
                Console.WriteLine("Expect: " + checkPlay.ToString());
                Console.WriteLine("Result: " + test.IsPlayable(new Hand(), d, out bool mustFlip).ToString());
                Console.WriteLine("Test mustFlip");
                Console.WriteLine("Expect: " + checkFlip.ToString());
                Console.WriteLine("Result: " + mustFlip.ToString());
                Console.WriteLine();
            }
        }
Example #34
0
        public void SetUpAllTests()
        {
            h  = new Hand();
            h2 = new Hand();

            p12 = new PlayerTrain(h, 12);
            p04 = new PlayerTrain(h, 0);

            d12_4 = new Domino(12, 4);
            d04   = new Domino(0, 4);


            p04.Add(d04);
            p04.Open();
        }
Example #35
0
	void SpawnGhost(PlayerTrain playerTrain, Vector3 side)
	{
		GhostInfo info = new GhostInfo ();
		GameObject newGhost = Instantiate (ghostPrefab) as GameObject;
		newGhost.GetComponent<GhostController> ().feature = this;
		info.obj = newGhost;
		int wagonsCount = 0;
		for(int childIndex = 0; childIndex < playerTrain.transform.childCount; childIndex++)
		{
			if (playerTrain.transform.GetChild(childIndex).GetComponent<WagonScript>() != null)
			{
				wagonsCount += 1;
			}
		}

		WagonScript wagon = null;
		Transform spawnPoint = null;
		for (int wagonIndex = 0; wagonIndex < wagonsCount; wagonIndex++) {
			// try to get random wagon point
			wagon = playerTrain.GetWagon (Random.Range(0,wagonsCount));
			spawnPoint = wagon.GetGhostPoint ();
			if (spawnPoint != null) {
				info.wagonIndex = wagon.GetIndex ();
				break;
			}


			wagon = playerTrain.GetWagon (wagonIndex);
			spawnPoint = wagon.GetGhostPoint ();
			if (spawnPoint != null) {
				info.wagonIndex = wagon.GetIndex ();
				break;
			}

		}
		//GameObject wagon = playerTrain.GetWagon (Random.Range(0,wagonsCount)).gameObject;
		if (spawnPoint == null)
			return;

		newGhost.transform.parent = spawnPoint;
		newGhost.transform.localPosition = new Vector3(0,0,0);
		newGhost.transform.localScale = new Vector3(1,1,1);
		newGhost.transform.localEulerAngles = side;
		newGhost.GetComponent<Animator>().Play("move");

		spawnedGhosts.Add (info);

	}
Example #36
0
	public virtual IEnumerator Cast(PlayerTrain playerTrain)
	{
		yield return null;
	}
Example #37
0
	public override IEnumerator Cast(PlayerTrain playerTrain)
	{
		canCast = false;
		while (true)
		{
			if (!turnedOn) {
				yield return null;
				continue;
			}
			if (stopFeature)
			{
				stopFeature = false;
				tickTimer = Random.Range(tickTimeMin, tickTimeMax);
				RemoveGhosts();
				playerTrain.speedDebuffPercent -= speedPenalty;
				speedPenalty = 0;

			}
			if (tickTimer <= 0)
			{
				tickTimer = Random.Range(tickTimeMin, tickTimeMax);
				for(int ghostIndex = 0; ghostIndex < spawnedGhosts.Count; ghostIndex++)
					InventoryItemsBreakSystem.reference.BreakWagon (spawnedGhosts[ghostIndex].wagonIndex, ghostBreakingStrength, true);
				if (spawnedGhosts.Count < maxGhostCount)
				{
					SpawnGhost(playerTrain, new Vector3(0,0,Random.Range(0.0f, 360.0f)));

				}
			}
			if (packTickTimer <= 0) {
				packTickTimer = Random.Range(packTickTimeMin, packTickTimeMax);
				Vector3 side = new Vector3(0,0,Random.Range(0.0f, 360.0f));
				for (int ghostIndex = 0; ghostIndex < ghostsInPack; ghostIndex++) {
					if (spawnedGhosts.Count < maxGhostCount)
					{
						SpawnGhost(playerTrain, side);

					}
				}
					
			}
			tickTimer -= Time.deltaTime;
			packTickTimer -= Time.deltaTime;
			yield return null;
		}
	}
	bool PassCheck(PlayerTrain player)
	{
		if (difficulty > player.speed * PlayerSaveData.reference.trainData.currentWeight)
			return false;
		return true;
	}