Ejemplo n.º 1
0
    void Start()
    {
        //robotController = FindObjectOfType(typeof(RobotController)) as RobotController;

        sceneScript     = FindObjectOfType(typeof(SceneScript)) as SceneScript;
        robotController = FindObjectOfType(typeof(RobotController)) as RobotController;
        robotSpawner    = FindObjectOfType(typeof(RobotSpawner)) as RobotSpawner;
        timed           = false;
    }
Ejemplo n.º 2
0
    private void Awake()
    {
        // singleton
        if (Instance == null)
        {
            Instance = this;
        }
        else
        {
            Debug.LogError("More than one RobotSpawner found in scene");
        }

        // spawn each player in a random spawn point at the start of the game
        GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
        for (int i = 0; i < players.Length; i++)
        {
            RespawnAtSpawnPoint(players[i].transform, i);
        }
    }
    public void RunGame()
    {
        switch (currentRoundtype)
        {
        case Verbs.Catch:
            ObjectSpawner catchSpawner = GameObject.Find("Object Spawner").GetComponent <ObjectSpawner>();
            int           index        = UnityEngine.Random.Range(0, catchSpawnObjects.Count);
            GameObject    spawnObject  = catchSpawnObjects[index];
            catchSpawner.SetSpawnerValues(delayBetweenSpawn, catchSpawnObjects[index]);
            catchSpawner.StartSpawning();
            collectiblesCaught = 0;
            foreach (PlayerControl player in players)
            {
                player.OnCaughtObject += PlayerCaughtObject;
                player.active          = true;
            }
            StartCoroutine(TimerCountDown(baseWaitTime - waitTimeOffset));
            break;

        case Verbs.Dodge:
            float offset = 0;
            index = UnityEngine.Random.Range(0, dodgeSpawnObjects.Count);
            GameObject enemyObject = dodgeSpawnObjects[index];
            foreach (EnemySpawner dodgeSpawner in FindObjectsOfType <EnemySpawner>())
            {
                offset += delayBetweenEnemySpawn * 0.25f;
                dodgeSpawner.SetVariables(delayBetweenEnemySpawn, offset, enemyObject, enemyMovementSpeed);
                dodgeSpawner.StartSpawning();
            }
            foreach (PlayerControl player in players)
            {
                player.OnPlayerKilled += PlayerDied;
                player.active          = true;
            }
            StartCoroutine(TimerCountDown(baseWaitTime + waitTimeOffset));
            break;

        case Verbs.Collect:
            //Level layout needs to spawn before player does so so takes place in level loaded function
            collectiblesCaught = 0;
            foreach (PlayerControl player in players)
            {
                player.OnCaughtObject += PlayerCaughtObject;
                player.active          = true;
            }
            StartCoroutine(TimerCountDown(baseWaitTime - waitTimeOffset));
            break;

        case Verbs.Shoot:
            //Level layout needs to spawn before player does so so takes place in level loaded function
            targetsShot = 0;
            foreach (PlayerControl player in players)
            {
                player.active = true;
            }
            StartCoroutine(TimerCountDown(baseWaitTime - waitTimeOffset));
            break;

        case Verbs.Jump:
            offset = 0;
            for (int i = 0; i < FindObjectsOfType <RobotSpawner>().Length; i++)
            {
                if (i < numberOfJumpSpawners)
                {
                    RobotSpawner robotSpawner = FindObjectsOfType <RobotSpawner>()[i];
                    offset += delayBetweenRobotSpawn * 0.5f;
                    robotSpawner.SetVariables(delayBetweenRobotSpawn, offset, robotMovementSpeed);
                    robotSpawner.StartSpawning();
                }
            }
            foreach (PlayerControl player in players)
            {
                player.OnPlayerKilled += PlayerDied;
                player.active          = true;
            }
            StartCoroutine(TimerCountDown(baseWaitTime + waitTimeOffset));
            break;

        case Verbs.Default:
            break;

        default:
            break;
        }
    }
 public ActivateSpawnerAction(EndeavourFactory factory, RobotController controller, List<Goal> goals, Dictionary<TagEnum, Tag> tagMap)
     : base(factory, controller, goals, tagMap)
 {
     name = "ActivateSpawner";
     spawner = getTagOfType<Tag>(TagEnum.Spawner).getLabelHandle().label.GetComponentInChildren<RobotSpawner>();
 }