예제 #1
0
        public void ShouldBuildMonster()
        {
            var creator = new CharacterCreator(new MonsterBuilder());

            creator.CreateCharacter();
            var monster = creator.GetCharacter();

            Assert.That(monster.Head == "Monster Head" && monster.Body == "Monster Body" && monster.Leg == "Monster Leg");
        }
예제 #2
0
        public void ShouldBuildHuman()
        {
            var creator = new CharacterCreator(new HumanBuilder());

            creator.CreateCharacter();
            var human = creator.GetCharacter();

            Assert.That(human.Head == "Human Head" && human.Body == "Human Body" && human.Leg == "Human Leg");
        }
예제 #3
0
    private void LateUpdate()
    {
        //input for friendly spawns
        if (Input.GetKeyDown(KeyCode.Alpha1) == true)
        {
            //check to see if player has enough points
            if (player.GetComponent <PlayerController>().specialAmmo >= 3)
            {
                //dec points
                player.GetComponent <PlayerController>().FriendlySpawned(3);

                characterCreator = new FriendlyCharacter();

                currentCharacterSpawn = characterCreator.CreateCharacter("walker");

                //spawn walker
                currentCharacterSpawn = Instantiate(currentCharacterSpawn, player.transform.position, player.transform.rotation);

                //add walker script
                currentCharacterSpawn.AddComponent <FriendlyWalker>();

                //make friendly
                currentCharacterSpawn.GetComponent <Character>().friendly = true;

                //set rotation to zero
                currentCharacterSpawn.transform.rotation = Quaternion.identity;
            }
        }

        if (Input.GetKeyDown(KeyCode.Alpha2) == true)
        {
            //check to see if player has enough points
            if (player.GetComponent <PlayerController>().specialAmmo >= 5)
            {
                //dec points
                player.GetComponent <PlayerController>().FriendlySpawned(5);

                characterCreator = new FriendlyCharacter();

                currentCharacterSpawn = characterCreator.CreateCharacter("runner");

                //spawn runner
                currentCharacterSpawn = Instantiate(currentCharacterSpawn, player.transform.position, player.transform.rotation);

                //add runner script
                currentCharacterSpawn.AddComponent <FriendlyRunner>();

                //make friendly
                currentCharacterSpawn.GetComponent <Character>().friendly = true;

                //set rotation to zero
                currentCharacterSpawn.transform.rotation = Quaternion.identity;
            }
        }
    }
예제 #4
0
    private void SpawnEnemy()
    {
        characterCreator = new EnemyCharacter();

        //get spawn point
        int spawnIndex = Random.Range(0, spawners.Count);

        //get enemy type
        string enemyType = enemyTypeArray[Random.Range(0, enemyTypeArray.Length)];

        //get character
        currentCharacterSpawn = characterCreator.CreateCharacter(enemyType);

        //spawn character
        currentCharacterSpawn = Instantiate(currentCharacterSpawn, spawners[spawnIndex].position, spawners[spawnIndex].rotation);

        //add script
        if (enemyType == "walker")
        {
            //add walker script
            currentCharacterSpawn.AddComponent <EnemyWalker>();
        }
        else
        {
            //add runner script
            currentCharacterSpawn.AddComponent <EnemyRunner>();
        }

        //inc
        currentSpawnCount++;

        //check to see if max spawns has been reached
        if (maxSpawns == currentSpawnCount)
        {
            //stop spawning
            CancelInvoke();

            //start end game
            winState = true;
        }
    }