// Use this for initialization void Start() { theScoreManager = FindObjectOfType <ScoreManager>(); thePlatformGenerator = FindObjectOfType <PlatformGenerator>(); theGameMaster = FindObjectOfType <GameMaster>(); fireArray = FindObjectsOfType <PlatformDestroyer>(); }
private void OnDestroy() { if (Instance == this) { Instance = null; } }
// Start is called before the first frame update void Start() { if (_instance != null && _instance != this) { Destroy(this.gameObject); return; } _instance = this; DontDestroyOnLoad(this.gameObject); // the y position of the camera should not change throughout the game this.cameraY = Camera.main.transform.position.y; // from the docs: height of an orthographic camera is 2f*orthographicSize - here, instead though // we want to add or subtract from the center but not get too high this.cameraHeight = Camera.main.orthographicSize * 0.6f; // load the spritesheet from the Resources folder of the project this.sprites = Resources.LoadAll <Sprite>(""); // make a fake gameobject to know the width and height of one platform sprite (all the same) GameObject fake = new GameObject(); fake.transform.localScale = new Vector3(8, 8, 1); SpriteRenderer fakeRenderer = fake.AddComponent(typeof(SpriteRenderer)) as SpriteRenderer; fakeRenderer.sprite = sprites[LEFT_PLATFORM_SPRITE]; this.oneWidth = fakeRenderer.bounds.size.x; this.height = fakeRenderer.bounds.size.y; Destroy(fake); }
private void Recycle() { Parent = transform.parent.GetComponent <PlatformGenerator>(); particles.Stop(true, ParticleSystemStopBehavior.StopEmittingAndClear); transform.position = Parent.StartLocation; gameObject.SetActive(false); }
void Start() { scoreManager = FindObjectOfType <ScoreManager>(); platformGenerator = FindObjectOfType <PlatformGenerator>(); normalLaundryRate = platformGenerator.laundryPercentChance; }
public void transportPlayerToSpawnLocation() { thePlatformGenerator = FindObjectOfType <PlatformGenerator>(); respawnXLocation = (thePlatformGenerator.transform.position.x - thePlatformGenerator.distanceBetween); respawnYLocation = (thePlatformGenerator.transform.position.y + 1); myRigidbody.transform.position = new Vector3(respawnXLocation, respawnYLocation, 0); }
private void CreateLevel() { var levelGenerator = new PlatformGenerator(3); var crystalGenerator = new CrystalGeneratorRandom(5); level.Generate(levelGenerator, crystalGenerator); }
public static void ShowWindow() { GUIContent newWindowContent = new GUIContent("PlatformGenerator", (Texture)AssetDatabase.LoadAssetAtPath("Assets/Art/PlatformTiles/tile5.png", typeof(Texture)), "Tool to generate new platforms with width and height"); _window = EditorWindow.GetWindow(typeof(PlatformGenerateEditor)); _platformGenerator = new PlatformGenerator(); _window.titleContent = newWindowContent; }
// Use this for initialization void Start() { theScoreManager = FindObjectOfType <ScoreManager> (); thePlatformGenerator = FindObjectOfType <PlatformGenerator> (); theGameManager = FindObjectOfType <GameManager> (); normalPointsPerSecond = theScoreManager.pointsPerSecond; }
void Start() { Debug.Assert(numberPrefab != null); pGenerator = FindObjectOfType <PlatformGenerator>(); for (int i = 0; i < spawnCount; ++i) { GameObject numberGO = Instantiate <GameObject>(numberPrefab); possibleAnswers.Add(numberGO); } //parent each possible answer to a platform for (int i = 0; i < pGenerator.platforms.Count; ++i) { possibleAnswers[i].transform.SetParent(pGenerator.platforms[i].transform); int randomNumber = Random.Range(min, max + 1); possibleAnswers[i].GetComponent <NumberText>().value = randomNumber; possibleAnswers[i].GetComponent <NumberText>().text = randomNumber.ToString(); possibleAnswers[i].GetComponent <BoxCollider2D>().size = possibleAnswers[i].GetComponent <NumberText>().GetPreferredValues(); float halfPlatformHeight = pGenerator.platforms[i].GetComponent <BoxCollider2D>().size.y / 2; float halfPlatformWidth = pGenerator.platforms[i].GetComponent <BoxCollider2D>().size.x / 2; possibleAnswers[i].transform.localPosition = new Vector2(halfPlatformWidth + possibleAnswers[i].GetComponent <BoxCollider2D>().size.x, possibleAnswers[i].GetComponent <BoxCollider2D>().size.y / 2 + halfPlatformHeight); } //StartCoroutine(GenerateAnswers()); //init events WorldEventSystem.OnPreTimerElapsed += ReactivateNumberGOs; WorldEventSystem.OnPreTimerElapsed += ConstructPossibleAnswers; WorldEventSystem.OnPostTimerElapsed += DeactivateNumberGOs; }
// Use this for initialization void Start() { platformGenerator = new PlatformGenerator(ScreenManager.platformRadius[0], ScreenManager.platformRadius[1]); obstacleGenerator = new ObstacleGenerator(ScreenManager.obstacleRadius[0], ScreenManager.obstacleRadius[1]); PlayerCollision.onPlatformHit += newStage; stageLayout(Vector2.zero); }
// Use this for initialization void Start() { scoreManager = FindObjectOfType <ScoreManager>(); platformGenerator = FindObjectOfType <PlatformGenerator>(); normalPointPerSecond = scoreManager.pointPerSecond; normalSpikeRate = platformGenerator.spikeGenerateThreshold; }
void OnEnable() { GameObject newGenerator = Instantiate(platformGeneratorPrefab); newGenerator.transform.SetParent(transform); generator = newGenerator.GetComponent <PlatformGenerator>(); platforms = new List <GameObject>(); }
// Start is called before the first frame update void Start() { coinRange = new Range(3, -2.50f); coinFrequency = 10.0f; lastCoinLoad = Time.time; generator = platformGenerator.GetComponent <PlatformGenerator>(); }
// Start is called before the first frame update void Start() { theScoreManager = GameObject.FindObjectOfType <ScoreManager>(); thePlatformGenerator = GameObject.FindObjectOfType <PlatformGenerator>(); theGameManager = FindObjectOfType <GameManager>(); normalPointsPerSecond = theScoreManager.pointsPerSecond; spikeThreshold = thePlatformGenerator.randomSpikeThreshold; }
// Use this for initialization void Start() { cam = GetComponent <Camera>(); thePlatformGenerator = FindObjectOfType <PlatformGenerator>(); thePlayer = FindObjectOfType <PlayerController>(); lastPlayerPosition = thePlayer.transform.position; lastCameraPosition.y = transform.position.y; }
// Start is called before the first frame update void Start() { platGen = GetComponent <PlatformGenerator>(); player = GameObject.Find("Player"); platParent = GameObject.Find("PlatformContainer"); platformCounter = platGen.getMaxPlatforms(); camera = GameObject.Find("Main Camera"); }
private IEnumerator LevelGenerationLoop() { _platformsGenerator = new PlatformGenerator(_sizeOfThePlatformPartsObjectPool, _sizeOfThePlatformsObjectPool, transform, _platformPartPrefab, _platformPrefab, _firstPlatformLength, _leftBorderX, _leftPlatformEdgeSprite, _platformMiddlePartsSprites, _rightPlatformEdgeSprite, _gridSnapper); _farBackgroundObjectsGenerator.CheckAndTryCreateBatchOfObjects(_leftBorderX, _rightBorderX - _leftBorderX, _maxYDistanceOfBackgroundObjectsFromPlatform, (int)(((_rightBorderX - _leftBorderX) / _backgroundObjectsBatchWidth) * _minAmountOfFarBackgroundObjectsInBatch), (int)(((_rightBorderX - _leftBorderX) / _backgroundObjectsBatchWidth) * _maxAmountOfFarBackgroundObjectsInBatch), _farBackgroundObjectsSprites, _gridSnapper); _midBackgroundObjectsGenerator.CheckAndTryCreateBatchOfObjects(_leftBorderX, _rightBorderX - _leftBorderX, _maxYDistanceOfBackgroundObjectsFromPlatform, (int)(((_rightBorderX - _leftBorderX) / _backgroundObjectsBatchWidth) * _minAmountOfMidBackgroundObjectsInBatch), (int)(((_rightBorderX - _leftBorderX) / _backgroundObjectsBatchWidth) * _maxAmountOfMidBackgroundObjectsInBatch), _midBackgroundObjectsSprites, _gridSnapper); _farBackgroundObjectsGenerator.CheckAndTryCreateBatchOfObjects(_leftBorderX, _rightBorderX - _leftBorderX, _maxYDistanceOfBackgroundObjectsFromPlatform, (int)(((_rightBorderX - _leftBorderX) / _backgroundObjectsBatchWidth) * _minAmountOfNearBackgroundObjectsInBatch), (int)(((_rightBorderX - _leftBorderX) / _backgroundObjectsBatchWidth) * _maxAmountOfNearBackgroundObjectsInBatch), _nearBackgroundObjectsSprites, _gridSnapper); _farBackgroundObjectsGenerator.CheckAndTryCreateBatchOfObjects(_leftBorderX, _rightBorderX - _leftBorderX, _maxYDistanceOfBackgroundObjectsFromPlatform, (int)(((_rightBorderX - _leftBorderX) / _backgroundObjectsBatchWidth) * _minAmountOfForegroundObjectsInBatch), (int)(((_rightBorderX - _leftBorderX) / _backgroundObjectsBatchWidth) * _maxAmountOfForegroundObjectsInBatch), _foregroundObjectsSprites, _gridSnapper); WaitForSeconds delay = new WaitForSeconds(_delayToCheckBuildAndRemoveObjects); while (true) { #region создаём объекты _platformsGenerator.CheckAndTryCreatePlatform(_rightBorderX, _minPlatformLength, _maxPlatformLength, _minXDistanceBetweenPlatforms, _maxXDistanceBetweenPlatforms, _minYDistanceBetweenPlatforms, _maxYDistanceBetweenPlatforms, _leftPlatformEdgeSprite, _platformMiddlePartsSprites, _rightPlatformEdgeSprite, _gridSnapper); _wallsGenerator.CheckAndTryCreateObjectOnPlatform(_rightBorderX, _wallsYDistanceToPlatform, _gridSnapper); _buffsOnPlatformsGenerator.CheckAndTryCreateObjectOnPlatform(_rightBorderX, _buffOnPlatformYDistanceToPlatform, _gridSnapper); _debuffsOnPlatformsGenerator.CheckAndTryCreateObjectOnPlatform(_rightBorderX, _debuffOnPlatformYDistanceToPlatform, _gridSnapper); _buffsInTheAirGenerator.CheckAndTryCreateFloatingObject(_rightBorderX, _minHeightAbovePlatformForBuffsInTheAir, _maxHeightAbovePlatformForBuffsInTheAir, _gridSnapper); _bugsInTheAirGenerator.CheckAndTryCreateFloatingObject(_rightBorderX, _minHeightAbovePlatformForBugsInTheAir, _maxHeightAbovePlatformForBugsInTheAir, _gridSnapper); _farBackgroundObjectsGenerator.CheckAndTryCreateBatchOfObjects(_rightBorderX, _backgroundObjectsBatchWidth, _maxYDistanceOfBackgroundObjectsFromPlatform, _minAmountOfFarBackgroundObjectsInBatch, _maxAmountOfFarBackgroundObjectsInBatch, _farBackgroundObjectsSprites, _gridSnapper); _midBackgroundObjectsGenerator.CheckAndTryCreateBatchOfObjects(_rightBorderX, _backgroundObjectsBatchWidth, _maxYDistanceOfBackgroundObjectsFromPlatform, _minAmountOfMidBackgroundObjectsInBatch, _maxAmountOfMidBackgroundObjectsInBatch, _midBackgroundObjectsSprites, _gridSnapper); _nearBackgroundObjectsGenerator.CheckAndTryCreateBatchOfObjects(_rightBorderX, _backgroundObjectsBatchWidth, _maxYDistanceOfBackgroundObjectsFromPlatform, _minAmountOfNearBackgroundObjectsInBatch, _maxAmountOfNearBackgroundObjectsInBatch, _nearBackgroundObjectsSprites, _gridSnapper); _foregroundObjectsGenerator.CheckAndTryCreateBatchOfObjects(_rightBorderX, _backgroundObjectsBatchWidth, _maxYDistanceOfBackgroundObjectsFromPlatform, _minAmountOfForegroundObjectsInBatch, _maxAmountOfForegroundObjectsInBatch, _foregroundObjectsSprites, _gridSnapper); #endregion #region уничтожаем объекты _platformsGenerator.CheckAndTryRemoveObjects(_leftBorderX); _wallsGenerator.CheckAndTryRemoveObjects(_leftBorderX); _buffsOnPlatformsGenerator.CheckAndTryRemoveObjects(_leftBorderX); _debuffsOnPlatformsGenerator.CheckAndTryRemoveObjects(_leftBorderX); _buffsInTheAirGenerator.CheckAndTryRemoveObjects(_leftBorderX); _bugsInTheAirGenerator.CheckAndTryRemoveObjects(_leftBorderX); _farBackgroundObjectsGenerator.CheckAndTryRemoveObjects(_leftBorderX); _midBackgroundObjectsGenerator.CheckAndTryRemoveObjects(_leftBorderX); _nearBackgroundObjectsGenerator.CheckAndTryRemoveObjects(_leftBorderX); _foregroundObjectsGenerator.CheckAndTryRemoveObjects(_leftBorderX); #endregion yield return(delay); } }
// Use this for initialization void Start() { death = false; DSpawn = true; gameOver = false; camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <PlatformGenerator>(); fishPlayer = GameObject.FindGameObjectWithTag("Fish").GetComponent <PlayerController>(); distance = 0; }
// Use this for initialization void Start() { platformStartPoint = platformGenerator.position; playerStartPoint = thePlayer.transform.position; theScoreManager = FindObjectOfType <ScoreManager>(); normalPoints = theScoreManager.pointPerSecond; spikeThreshold = FindObjectOfType <PlatformGenerator>(); spikeRate = spikeThreshold.randomSpikeThreshold; }
// Update is called once per frame void Update() { paused = player.GetComponent <Move>().isPaused(); //Move the platforms if the game is not paused if (paused == false) { platformCounter = player.GetComponent <Move>().getPlatformCounter(); //Changes the speed of the platforms based on the players score if (platformCounter > 40) { platformSpeed = .15f; } else if (platformCounter > 20 && platformCounter < 40) { platformSpeed = 0.1f; } else if (platformCounter < 1) { platformSpeed = 0.01f; } //Creates a platform if (!platCreated) { floor = GameObject.Find("Floor"); platGen = floor.GetComponent <PlatformGenerator>(); platCreated = platGen.getPlatformsDone(); moveDirection = Random.RandomRange(0, 2); } //when the platform is created it starts moving left or right based in the number assigned to it if (platCreated) { if (moveDirection == 0) { transform.position = new Vector2(transform.position.x - platformSpeed, transform.position.y); if (transform.position.x - transform.localScale.x / 2 < -11) { moveDirection = 1; } } else { transform.position = new Vector2(transform.position.x + platformSpeed, transform.position.y); if (transform.position.x + transform.localScale.x / 2 > 11) { moveDirection = 0; } } } } }
// Use this for initialization void Start() { cameraController = FindObjectOfType <CameraController> (); playerController = FindObjectOfType <PlayerController> (); scoreController = FindObjectOfType <ScoreController> (); platformGenerator = FindObjectOfType <PlatformGenerator> (); distanceController = FindObjectOfType <DistanceController>(); hazardController = FindObjectOfType <HazardController>(); gameOverCanvas.enabled = false; started = false; }
void Start() { //Initialization playerCon = PlayerController.instance; platformGen = PlatformGenerator.instance; UIMan = UIManager.instance; pMan = ParticleManager.instance; SetSpeedMultiplier(speedMultiplier); SpawnPlayer(); }
private void Awake() { if (instance != null) { Debug.LogError("Platform Generator: more than one Platform Generator in the Scene."); } else { instance = this; } }
void Start() { if (instance == null) { instance = this; } for (int i = 0; i < 10; i++) { GeneratePlatform(); } }
void Awake() { if (_instance == null) { //If I am the first instance, make me the Singleton _instance = this; DontDestroyOnLoad(this); } else { //If a Singleton already exists and you find //another reference in scene, destroy it! if (this != _instance) { Destroy(this.gameObject); } } mapTile = new int[, ] { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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GetComponent <Renderer> ().bounds.size.x; tileHeight = tiles[0].transform.GetComponent <Renderer> ().bounds.size.y; GeneratePlat(); }
public override void OnInspectorGUI() { DrawDefaultInspector(); PlatformGenerator myScript = (PlatformGenerator)target; if (GUILayout.Button("Build Platform")) { myScript.buildPlatform(); } }
private void Start() { if (SceneManager.GetActiveScene().name == "Main") { songLength = FindObjectOfType <camAudio>().getAudioLength(); player = GameObject.Find("Player"); generator = GetComponentInChildren <PlatformGenerator>(); timeBetweenPlatforms = tempo / 100f; spawnPlatTime = timeBetweenPlatforms; } }
// Start is called before the first frame update void Start() { if (FindObjectOfType <PlatformGenerator>() != null) { platformGenerator = FindObjectOfType <PlatformGenerator>(); if (FindObjectOfType <PlatformGenerator>() != null) { platformGenerator = FindObjectOfType <PlatformGenerator>(); platformStartPoint = platformGenerator.transform.position; } } }
// Use this for initialization void Start() { end = GameObject.FindGameObjectWithTag("SwordfishDespawn").GetComponent <Despawner>(); Spawn = GameObject.FindGameObjectWithTag("FishSpawn").GetComponent <SwordFishSpawner>(); transform.position = new Vector3(transform.position.x, Random.Range(-4f, 4f), 0); camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <PlatformGenerator>(); Ispawn = true; start = false; track = true; indicatorSound = true; swooshSound = true; }
/*int[,] map = * { * {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1}, * {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0}, * {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0}, * {0, 0, 0, 3, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0}, * {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0}, * {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0}, * {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0}, * {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0}, * {1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1} * }; */ // Use this for initialization void Awake() { //CellularAutomata(); //BuildMap(); PlatformGenerator pg = new PlatformGenerator(); replaceArea(5, 0, pg.CreateIsland(40, 40)); replaceArea(10, 50, pg.CreateIsland(20, 40)); replaceArea(80, 70, pg.CreateIsland(30, 50)); replaceArea(60, 40, pg.CreateIsland(20, 30)); replaceArea(145, 55, pg.CreateIsland(30, 60)); replaceArea(100, 5, pg.CreateIsland(30, 60)); map[0, width / 2] = 2; GameObject clone = new GameObject(); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { switch (map[height - y - 1, x]) { case Tiles.GROUND_TILE: clone = Instantiate(GTile, new Vector3(x, y, 0), Quaternion.identity); break; case Tiles.PLAYER: GameObject temp = Instantiate(Player, new Vector3(x, y, 0), Quaternion.identity); C_PlayerController controller = temp.GetComponent <C_PlayerController> (); controller.spawn = new Vector2(x, y); break; case Tiles.HAZARD: clone = Instantiate(Hazard, new Vector3(x, y, 0), Quaternion.identity); break; case Tiles.RAMP_LEFT: clone = Instantiate(Ramp_Left, new Vector3(x, y, 0), Quaternion.identity); break; case Tiles.RAMP_RIGHT: clone = Instantiate(Ramp_Right, new Vector3(x, y, 0), Quaternion.identity); break; default: break; } // Puts objects under "Level" Hierarchy. clone.transform.parent = GameObject.Find("Level").transform; } } }
void Awake() { if(_instance == null) { //If I am the first instance, make me the Singleton _instance = this; DontDestroyOnLoad(this); } else { //If a Singleton already exists and you find //another reference in scene, destroy it! if(this != _instance) Destroy(this.gameObject); } mapTile = new int[,]{ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0}, { 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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 0, 0, 4, 0, 0, 0}, { 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, }; tileWidth = tiles[0].transform.GetComponent<Renderer> ().bounds.size.x; tileHeight = tiles[0].transform.GetComponent<Renderer> ().bounds.size.y; GeneratePlat (); }
// Use this for initialization void Start () { //getting components if(prev) { prevCaveGenerator = prev.GetComponent<CaveGenerator>(); //prevHillGenerator = prev.GetComponent<HillGenerator>(); prevPlatformGenerator = prev.GetComponent<PlatformGenerator>(); } caveGenerator = terrain.GetComponent<CaveGenerator>(); //hillGenerator = terrain.GetComponent<HillGenerator>(); platformGenerator = terrain.GetComponent<PlatformGenerator>(); nextCaveGenerator = next.GetComponent<CaveGenerator>(); //nextHillGenerator = next.GetComponent<HillGenerator>(); nextPlatformGenerator = next.GetComponent<PlatformGenerator>(); GenerateAll(); }
private void OnGUI() { GUILayout.Label("This will create a new platform with height " + "\n" + "and width in tiles."); _height = EditorGUILayout.IntField("height: ", _height); _width = EditorGUILayout.IntField("width: ", _width); _layer = EditorGUILayout.IntField("Layer: ", _layer); _name = EditorGUILayout.TextField("Name: ", _name); _position = EditorGUILayout.Vector3Field("position: ",_position); if (GUILayout.Button("Generate Platform", GUILayout.Width(250))) { if (_platformGenerator == null) _platformGenerator = new PlatformGenerator(); _platformGenerator.GeneratePlatform(_width, _height, _position, _layer, _name); } }
void CreatePlatform() { PlatformGenerator pg = (PlatformGenerator)Instantiate(platformGeneratorPrefab); pg.platformNumber = platformNumber++; pg.transform.parent = transform; pg.transform.position = new Vector3(lastX,0,0); pg.mLength = Random.Range(20,50); pg.GeneratePlatform(); pg.transform.position = new Vector3(lastX,lastY - pg.StartY(),0); pg.SetForegroundColor(r,g,b); lastX = pg.EndX(); lastY = pg.EndY(); recentPlatformGenerator = pg; Messenger.Invoke(typeof(StageCreatedMessage),new StageCreatedMessage(pg.transform.position.x,pg.EndX(),r,g,b)); }
void CreatePlatform() { PlatformGenerator pg = (PlatformGenerator)Instantiate(platformGeneratorPrefab); pg.transform.parent = transform; pg.transform.localPosition = new Vector3(x,0,0); pg.mLength = Random.Range(20,50); pg.GeneratePlatform(x); float delta = 0; if(recentPlatformGenerator) { delta = recentPlatformGenerator.transform.localPosition.y + lastY-pg.mStartHeight; } pg.transform.localPosition = new Vector3(x,delta,0); x += pg.mLength; lastY = pg.mEndHeight; recentPlatformGenerator = pg; totalLength += pg.mLength; }
void OnTriggerEnter2D(Collider2D col) { if(col.gameObject.CompareTag("Player")) { Debug.Log("Player passed trigger"); if(prev) { Destroy(prev.gameObject); } prev = terrain; terrain = next; transform.position += new Vector3(36f, 0f, 0f); GameObject nextGO = (GameObject)Instantiate(terrainPrefab, transform.position, Quaternion.identity); next = nextGO.transform; nextCaveGenerator = next.GetComponent<CaveGenerator>(); //nextHillGenerator = next.GetComponent<HillGenerator>(); nextPlatformGenerator = next.GetComponent<PlatformGenerator>(); nextCaveGenerator.Generate(); nextPlatformGenerator.Append(); } }
// Use this for initialization void Start() { scoreManager = FindObjectOfType<ScoreManager>(); platformGenerator = FindObjectOfType<PlatformGenerator>(); gameManager = FindObjectOfType<GameController>(); }
public NextPlatformReachedMessage(PlatformGenerator pg) { mPlatformNumber = pg.platformNumber; }
// Use this for initialization void Start() { gameMngr = FindObjectOfType (typeof(PopzGameManager)) as PopzGameManager; // Set up references to object generators and grid grid = GameObject.FindGameObjectWithTag ("Grid").GetComponent<Grid> (); platformGen = GameObject.FindGameObjectWithTag ("PlatformGen").GetComponent<PlatformGenerator> (); collectibleGen = GameObject.FindGameObjectWithTag ("CollectibleGen").GetComponent<CollectibleGenerator> (); groundGen = GameObject.FindGameObjectWithTag ("GroundGen").GetComponent<GroundGenerator> (); nbackGen = FindObjectOfType (typeof(NbackGenerator)) as NbackGenerator; player = GameObject.FindGameObjectWithTag ("Player").GetComponent<Player> (); // Position generator and box collider Vector3 bottomLeft = Camera.main.ScreenToWorldPoint (new Vector3 (0f, 0f, 0f)); Vector3 topRight = Camera.main.ScreenToWorldPoint (new Vector3 (Camera.main.pixelWidth, Camera.main.pixelHeight, 0f)); bottomLeft.y = Camera.main.GetComponent<FixedHeight> ().height - (topRight.y - bottomLeft.y)/2f; BoxCollider2D boxCol = gameObject.GetComponent<BoxCollider2D> (); float boxHeight = topRight.y - bottomLeft.y; float boxWidth = 1f; boxCol.size = new Vector2 (boxWidth, boxHeight); boxCol.offset = new Vector2 (-boxWidth, boxHeight / 2f); transform.position = new Vector3(bottomLeft.x, bottomLeft.y, 0f); BoxCollider2D chunkBoxCol = terrainChunk.GetComponent<BoxCollider2D> (); float chunkBoxWidth = 2f * ((float) grid.numCellsX) * grid.cellSizeX; float chunkBoxHeight = topRight.y - bottomLeft.y; chunkBoxCol.size = new Vector2 (chunkBoxWidth, chunkBoxHeight); chunkBoxCol.offset = new Vector2 (chunkBoxWidth/2f, chunkBoxHeight/2f); chunkBoxCol.isTrigger = true; genPlants = false; genPlatforms = false; GenerateTerrain (transform.position); }
public void Start() { Time.timeScale = 0f; startTime = Time.realtimeSinceStartup; instance = this; }