// Setting up references
 void Awake()
 {
     obstacleSpawner = GameObject.FindGameObjectWithTag("ObstacleSpawner").GetComponent<ObstacleSpawner>();
     pickupSpawner = GameObject.FindGameObjectWithTag("PickupSpawner").GetComponent<PickupSpawner>();
     soundManager = GameObject.FindGameObjectWithTag("SoundManagerGO").GetComponent<SoundManager>();
     playerControls = player.GetComponent<CharacterUserControls>();
 }
Esempio n. 2
0
 // Use this for initialization
 void Start()
 {
     startingX       = (int)transform.position.x;
     scoreText       = GameObject.Find("Score").guiText;
     lifeText        = GameObject.Find("Life").guiText;
     obstacleSpawner = GameObject.Find("ChunkManager").GetComponent <ObstacleSpawner>();
 }
Esempio n. 3
0
 private void Awake()
 {
     if (!instance)
     {
         instance = this;
     }
 }
Esempio n. 4
0
 void CreateInstance()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Esempio n. 5
0
    void Start()
    {
        var spawnerObject = GameObject.FindWithTag("GameController");

        spawner = spawnerObject.GetComponent <ObstacleSpawner>();
        GetComponent <Rigidbody2D>().velocity = velocity;
    }
Esempio n. 6
0
        public IEnumerator spawns_objects_at_spawn_rate()
        {
            // Arrange
            GameObject   spawnManagerObject = new GameObject("SpawnManager");
            SpawnManager spawnManager       =
                spawnManagerObject.AddComponent <SpawnManager>();
            ObstacleSpawner obstacleSpawner =
                spawnManagerObject.AddComponent <ObstacleSpawner>();

            spawnManager.ObstacleSpawner           = obstacleSpawner;
            spawnManager.ObstacleSpawner.SpawnRate = 0.30f;
            spawnManager.ObstacleSpawner.SpawnData.SpawnStartTime = 0.0f;
            spawnManager.ObstacleSpawner.SpawnData.PoolSize       = 5;

            spawnManager.ObstacleSpawner.SpawnData.Prefabs    = new GameObject[1];
            spawnManager.ObstacleSpawner.SpawnData.Prefabs[0] =
                CreateObstacle(Vector3.zero);

            // Act
            yield return(new WaitForSeconds(1.0f));

            // Assert
            Assert.AreEqual(4, spawnManager.ObstacleSpawner.NumberSpawned);

            // Clean
            spawnManagerObject.SetActive(false);
        }
Esempio n. 7
0
        public IEnumerator creates_three_obstacle_pools_when_given_three_prefabs()
        {
            // Arrange
            GameObject   spawnManagerObject = new GameObject("Spawn Manager");
            SpawnManager spawnManager       =
                spawnManagerObject.AddComponent <SpawnManager>();
            ObstacleSpawner obstacleSpawner =
                spawnManagerObject.AddComponent <ObstacleSpawner>();

            spawnManager.ObstacleSpawner = obstacleSpawner;
            spawnManager.ObstacleSpawner.SpawnData.Prefabs = new GameObject[3];

            spawnManager.ObstacleSpawner.SpawnData.Prefabs[0] =
                CreateObstacle(Vector3.zero);
            spawnManager.ObstacleSpawner.SpawnData.Prefabs[1] =
                CreatePole(Vector3.zero);
            spawnManager.ObstacleSpawner.SpawnData.Prefabs[2] =
                CreateWaste(Vector3.zero);

            // Act
            yield return(new WaitForSeconds(0.3f));

            // Assert
            Assert.IsTrue(spawnManager.ObstacleSpawner.Pools[0] != null);
            Assert.IsTrue(spawnManager.ObstacleSpawner.Pools[1] != null);
            Assert.IsTrue(spawnManager.ObstacleSpawner.Pools[2] != null);

            // Clean
            spawnManagerObject.SetActive(false);
        }
Esempio n. 8
0
    void Start()
    {
        cart = GameObject.Find("Cart");

        setCube();
        spawner = GameObject.Find("Obstacle Spawner").GetComponent<ObstacleSpawner>();
    }
Esempio n. 9
0
        public IEnumerator instantiates_30_pool_objects_when_given_three_prefabs_and_10_prefab_pool_size()
        {
            // Arrange
            GameObject   spawnManagerObject = new GameObject("Spawn Manager");
            SpawnManager spawnManager       =
                spawnManagerObject.AddComponent <SpawnManager>();
            ObstacleSpawner obstacleSpawner =
                spawnManagerObject.AddComponent <ObstacleSpawner>();

            spawnManager.ObstacleSpawner = obstacleSpawner;
            spawnManager.ObstacleSpawner.SpawnData.Prefabs  = new GameObject[3];
            spawnManager.ObstacleSpawner.SpawnData.PoolSize = 10;

            spawnManager.ObstacleSpawner.SpawnData.Prefabs[0] =
                CreateObstacle(Vector3.zero);
            spawnManager.ObstacleSpawner.SpawnData.Prefabs[1] =
                CreatePole(Vector3.zero);
            spawnManager.ObstacleSpawner.SpawnData.Prefabs[2] =
                CreateWaste(Vector3.zero);

            // Act
            yield return(new WaitForSeconds(0.3f));

            // Assert
            Assert.AreEqual(30, spawnManager.transform.childCount);

            // Clean
            spawnManagerObject.SetActive(false);
        }
Esempio n. 10
0
 void Start()
 {
     this.rigidbody.velocity = new Vector3(60, 0, 0);
     spawner  = GameObject.Find("Obstacle Spawner").GetComponent <ObstacleSpawner>();
     niceShot = GameObject.Find("Nice_Shot_Popup").GetComponent <ParticleSystem>();
     increase = GameObject.Find("Increase_Score").GetComponent <ParticleSystem>();
 }
Esempio n. 11
0
    public void Init()
    {
        ObstacleCreateDelay = Random.Range(3.0f, 5.0f);
        ObstacleCreateTimer = ObstacleCreateDelay;

        leftObstacleDelay  = Random.Range(3.0f, 10.0f);
        rightObstacleDelay = Random.Range(3.0f, 10.0f);

        leftObstacleTimer  = leftObstacleDelay;
        rightObstacleTimer = rightObstacleDelay;
        instance           = this;
        for (int i = 0; i < obstacles.Length; i++)
        {
            for (int j = 0; j < obstacles[i].obstacle.Count; j++)
            {
                obstacles[i].obstacle[j].GetComponent <ObstacleScript>().SetIndex(i, j);
                if (!obstacles[i].obstacle[j].activeInHierarchy)
                {
                    InactiveObstacles[i].obstacle.Add(obstacles[i].obstacle[j]);
                }
            }
        }

        for (int i = 0; i < leftObstacle.Length; i++)
        {
            leftObstacle[i].SetActive(false);
            leftInactiveObstacle.Add(leftObstacle[i]);
        }
        for (int i = 0; i < rightObstacle.Length; i++)
        {
            rightObstacle[i].SetActive(false);
            rightInactiveObstacle.Add(rightObstacle[i]);
        }
    }
Esempio n. 12
0
        public IEnumerator spawned_obstacle_is_passed_to_dog_focus_queue()
        {
            // Arrange
            GameObject   spawnManagerObject = new GameObject("Spawn Manager");
            SpawnManager spawnManager       =
                spawnManagerObject.AddComponent <SpawnManager>();
            ObstacleSpawner obstacleSpawner =
                spawnManagerObject.AddComponent <ObstacleSpawner>();

            spawnManager.ObstacleSpawner = obstacleSpawner;
            spawnManager.ObstacleSpawner.SpawnData.PoolSize   = 3;
            spawnManager.ObstacleSpawner.SpawnData.Prefabs    = new GameObject[1];
            spawnManager.ObstacleSpawner.SpawnData.Prefabs[0] =
                CreateObstacle(Vector3.zero);

            GameObject dogGameObject = new GameObject("Dog");

            dogGameObject.transform.position = Vector3.zero;
            DogCharacter dog = dogGameObject.AddComponent <DogCharacter>();

            spawnManager.ObstacleSpawner.Dog = dog;

            // Act
            yield return(new WaitForSeconds(0.3f));

            spawnManager.ObstacleSpawner.RandomObstacleSpawn();

            // Assert
            Assert.AreEqual("Obstacle", dog.CurrentObject.transform.tag);

            // Clean
            spawnManagerObject.SetActive(false);
            dogGameObject.SetActive(false);
        }
    // Start is called before the first frame update
    void Start()
    {
        elapsedSeconds = 0;//set the elapsed seconds to 0 at the start of the level

        playerMovement  = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerMovement>();
        obstacleSpawner = GameObject.Find("obstacles").GetComponent <ObstacleSpawner>();
    }
Esempio n. 14
0
    public void Respawn(Vector2 position, Vector2 size, Vector2 speed, float rotationSpeed, Color colour, uint score, int ID, ObstacleSpawner spawner, bool harmfull = true)
    {
        passed = false;

        rigidbody.velocity        = Vector2.zero;
        rigidbody.angularVelocity = 0;

        transform.position = position;
        transform.rotation = Quaternion.identity;
        start = position;

        this.speed         = speed;
        this.speed.x      *= (Random.Range(0, 2) * 2 - 1);
        this.speed.y      *= (Random.Range(0, 2) * 2 - 1);
        this.rotationSpeed = rotationSpeed * (Random.Range(0, 2) * 2 - 1);

        this.ID = ID;

        SetSize(size);
        SetColour(colour);

        this.score    = score;
        this.harmfull = harmfull;

        this.spawner = spawner;
    }
    public void Init(int i, ref Vector3 _pos, ref Vector3 _rota)
    {
        obstacleSpawner = this.gameObject.GetComponent <ObstacleSpawner>();
        obstacleSpawner.Init();

        Spawn(i, ref _pos, ref _rota);
    }
Esempio n. 16
0
 void Start()
 {
     this.rigidbody.velocity = new Vector3(60, 0, 0);
     spawner = GameObject.Find("Obstacle Spawner").GetComponent<ObstacleSpawner>();
     niceShot = GameObject.Find("Nice_Shot_Popup").GetComponent<ParticleSystem>();
     increase = GameObject.Find("Increase_Score").GetComponent<ParticleSystem>();
 }
 public void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Esempio n. 18
0
    // Use this for initialization
    void Start()
    {
		startingX = (int) transform.position.x;
		scoreText = GameObject.Find("Score").guiText;
		lifeText = GameObject.Find("Life").guiText;
		obstacleSpawner = GameObject.Find("ChunkManager").GetComponent<ObstacleSpawner>();
    }
Esempio n. 19
0
 void Start()
 {
     obstacleSpawner = GetComponent <ObstacleSpawner>();
     spawnData       = GetComponent <SpawnData>();
     // player = GetComponent<GameObject>();
     SetupNextStage();
 }
Esempio n. 20
0
    // Use this for initialization
    void Start()
    {
        adManager = FindObjectOfType <AdManager>();

        GetScore();
        Debug.Log("playCount: " + playCount);
        Time.timeScale = 0;
        if (playCount > 3)
        {
            int randomChance = Random.Range(0, 2);
            Debug.Log(randomChance);
            if (randomChance == 1)
            {
                adManager.ShowStandardVideoAd();
                playCount = 0;
            }
        }
        Time.timeScale = 1;

        flappy           = GameObject.Find("Flappy");
        flappyController = flappy.GetComponent <FlappyController>();
        flappyRB         = flappy.GetComponent <Rigidbody2D>();
        startCanvas      = GameObject.Find("StartCanvas");
        gameOverCanvas   = GameObject.Find("GameOverCanvas");
        gameOverCanvas.SetActive(false);
        obstacleSpawner = GameObject.Find("ObstacleSpawner");
        os = obstacleSpawner.GetComponent <ObstacleSpawner>();
        sc = gameOverCanvas.GetComponent <ScoreCounter>();

        score = 0;
        UpdateScore();
    }
Esempio n. 21
0
    public static void AddScore(int amount)
    {
        score += amount;
        float playerForwardVelocity = PlayerController.GetForwardVelocity();

        if (playerForwardVelocity < 70f)
        {
            PlayerController.SetForwardVelocity(playerForwardVelocity * 1.25f * totalMult);
        }

        PlayerController.SetAngularVelocity(PlayerController.GetAngularVelocity() * 1.01f * totalMult);

        float spawnInterval = ObstacleSpawner.GetSpawnInterval();

        if (spawnInterval > 10f)
        {
            ObstacleSpawner.SetSpawnInterval(spawnInterval - 0.1f * totalMult);
        }

        float holeRatioMin = ObstacleSpawner.GetHoleMin();
        float holeRatioMax = ObstacleSpawner.GetHoleMax();

        if (holeRatioMin > 0.2f)
        {
            ObstacleSpawner.SetHoleMin(holeRatioMin - 0.05f);
            ObstacleSpawner.SetHoleMax(holeRatioMax - 0.05f);
        }
        float rotationMultiplier = ObstacleBehaviour.GetRotationMultiplier();

        if (rotationMultiplier < 50.0f)
        {
            ObstacleBehaviour.SetRotationMultiplier(rotationMultiplier + 0.05f * totalMult);
        }
    }
Esempio n. 22
0
 void Start()
 {
     os = FindObjectOfType <ObstacleSpawner>();
     dc = FindObjectOfType <DudeController>();
     a  = GetComponent <Animator>();
     sc = FindObjectOfType <SpeedControl>();
 }
Esempio n. 23
0
    void Start()
    {
        cart = GameObject.Find("Cart");

        setCube();
        spawner = GameObject.Find("Obstacle Spawner").GetComponent <ObstacleSpawner>();
    }
Esempio n. 24
0
    void Start()
    {
        //get the width of the scrollable object
        SpriteRenderer[] srs = this.gameObject.GetComponentsInChildren <SpriteRenderer>();
        bounds = new Bounds(this.transform.position, Vector3.zero);

        foreach (SpriteRenderer renderer in srs)
        {
            bounds.Encapsulate(renderer.bounds);
        }


        tileSizeX = bounds.size.x - screenWidth;
        //get the startposition
        Transform startTransform = GetComponent <Transform>();

        startPosition.x = startTransform.position.x;
        startPosition.y = startTransform.position.y;
        //objCreationControl = true;
        isObjCreated       = false;
        bgSpawner          = FindObjectOfType <BGSpawner>();
        obstacleSpawner    = FindObjectOfType <ObstacleSpawner>();
        coinSpawner        = FindObjectOfType <CoinSpawner>();
        gameEngine         = FindObjectOfType <GameEngine>();
        currentSpeedFactor = gameEngine.speedFactor;
    }
Esempio n. 25
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Esempio n. 26
0
    private void Start()
    {
        os    = FindObjectOfType <ObstacleSpawner>();
        speed = os.obstacleSpeed;

        sr = GetComponent <SpriteRenderer>();
    }
Esempio n. 27
0
    void Start()
    {
        spinSpeed = Random.Range(-15, 15);
        var spawnerObject = GameObject.FindWithTag("GameController");

        spawner = spawnerObject.GetComponent <ObstacleSpawner>();
        GetComponent <Rigidbody2D>().velocity = velocity;
    }
Esempio n. 28
0
 void Start()
 {
     //link scripts
     ui        = Camera.main.GetComponent <GameUI> ();
     spawner   = Camera.main.GetComponent <ObstacleSpawner> ();
     player    = GameObject.FindGameObjectWithTag("Player");
     rocketMan = player.GetComponent <RocketMan> ();
 }
Esempio n. 29
0
 private void Start()
 {
     eventSystem     = GameObject.Find("EventSystem").GetComponent <EventSystem>();
     playerSpawner   = GetComponent <PlayerSpawner>();
     obstacleSpawner = GameObject.Find("ObstacleSpawner").GetComponent <ObstacleSpawner>();
     obstacleSpawner.gameObject.SetActive(false);
     SetState(State.MainMenu);
 }
Esempio n. 30
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     initObstacles();
 }
Esempio n. 31
0
    void Start()
    {
        player = GameObject.Find("Player");

        campSpawnerScript     = GameObject.Find("CampSpawner").GetComponent <CampSpawner>();
        obstacleSpawnerScript = GameObject.Find("ObstacleSpawner").GetComponent <ObstacleSpawner>();
        //fuelSpawnerScript = GameObject.Find("FuelSpawner").GetComponent<FuelSpawner>();
        //cogSpawnerScript = GameObject.Find("CogSpawner").GetComponent<CogSpawner>();
    }
Esempio n. 32
0
 // Start is called before the first frame update
 void Start()
 {
     StartCoroutine("Shooting");
     StartValues();
     audioSource = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <AudioSource>();
     player      = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerController>();
     spawner     = GameObject.FindGameObjectWithTag("GameManager").GetComponent <ObstacleSpawner>();
     manager     = GameObject.FindGameObjectWithTag("GameManager").GetComponent <GameManager>();
 }
Esempio n. 33
0
        public void UpdateTest()
        {
            ArenaFacade.Instance.UpdateDimensions(new Vector2(0, 0), new Vector2(0, 0), new Vector2(0, 0), 10f);
            ArenaObjectSpawner spawner = new ObstacleSpawner(GameData.ObstacleSpawnerParams, new AbstractArenaObjectFactory[] { new NonPassableArenaObjectFactory() });

            GameManager.Instance.SetTimeSinceLastFrame(0.69f);
            spawner.Update();
            Assert.IsTrue(spawner.Time.Equals(0.69f));
        }
Esempio n. 34
0
        public void SpawnTest()
        {
            ArenaObjectSpawner spawner = new ObstacleSpawner(GameData.ObstacleSpawnerParams, new AbstractArenaObjectFactory[] { new NonPassableArenaObjectFactory() });

            // a long time ensures spawning
            GameManager.Instance.SetTimeSinceLastFrame(100f);
            spawner.Update();
            Assert.IsTrue(ArenaFacade.Instance.ArenaObjects.Count > 0);
        }
Esempio n. 35
0
    void Start()
    {
        spawner = GameObject.FindGameObjectWithTag("ObstacleSpawner").GetComponent<ObstacleSpawner>();
        player = GameObject.FindGameObjectWithTag("Player").transform;
        thisTransform = transform;
        startPosition = thisTransform.position;

        if(SpawnOnStart)
        {
            spawner.SpawnNew(thisTransform.position.x);
        }
    }
Esempio n. 36
0
    // Use this for initialization
    void Start()
    {
        //Initialize
        shipInfo = ScriptableObject.CreateInstance<ShipData>();
        defaultDrag = rigidbody.drag;
        lightSpeedEffect = transform.Find("Light Speed Effect").particleSystem;
        engine = GetComponent<Engine>() as Engine;
        lineRendererToLauncher = gameObject.AddComponent<LineRenderer>();
        asteroidSpawner = GetComponent<ObstacleSpawner>();

        //Set default stuff
        SetToDefaultState();
    }
	public static ObstacleSpawner instance; //Instance

	void Awake(){
		instance = this;
	}
	void Awake(){
		Instance = this;
	}
Esempio n. 39
0
    // Initialization event
    void Start()
    {
        //Initialize
        shipInfo = ScriptableObject.CreateInstance<ShipData>();
        defaultDrag = rigidbody.drag;
        engine = GetComponent<Engine>() as Engine;
        engine.enabled = false;
        asteroidSpawner = GetComponent<ObstacleSpawner>();
        lootCollector = GetComponent<Looter>();
        lootCollector.enabled = false;
        if(gravityComponent != null)
            gravityComponent.SetActive(false);

        //Set default stuff
        state = new StateMachine<ShipState>(new Orbit(this));
    }
Esempio n. 40
0
 public Transit( Ship self, float ftlCounterForce = 0, float timeOfLaunch = 0 )
     : base(self)
 {
     asteroidSpawner = self.asteroidSpawner;
     gravityComponent = self.gravityComponent;
     this.ftlCounterForce = ftlCounterForce;
     this.timeOfLaunch = timeOfLaunch;
     this.lootCollector = self.lootCollector;
 }
Esempio n. 41
0
	void Start()
	{
		question = GameObject.Find("Question").GetComponent<Text>();
		obstacleSpawner = GameObject.Find("ObstacleSpawner").GetComponent<ObstacleSpawner>();
	}