/// <summary> /// Constructor for testing purposes /// </summary> /// <param name="game"></param> /// <param name="testConstructor"></param> public LevelManager(Game game, bool testConstructor) : base(game) { //updateCam = false; //curLevelInfo = 0; //levels = new List<LevelInfo>(); //currentLevel = new Level(); ////levels.Add(new LevelInfo("", 3, 72, 8, 1, 200, 0, 25, Constants.RED_PLATFORM)); ////generator = new LevelGenerator(currentLevel, levels, 42, new ChunkType[,] { {ChunkType.FLOOR}, {ChunkType.STAIRS}, {ChunkType.FLOATING_PLATFORMS_SAFE}, //// {ChunkType.FLOATING_PLATFORMS_NOT_SAFE}, {ChunkType.MOUNTAIN_LEFT}, {ChunkType.MOUNTAIN_RIGHT}, {ChunkType.JAGGIES_LEFT}, {ChunkType.JAGGIES_RIGHT}, //// {ChunkType.TALL_GROUND}}); //levels.Add(new LevelInfo("", 3, 8, 8, 0, 200, 0, 0, Constants.RED_PLATFORM)); //generator = new LevelGenerator(currentLevel, levels, 42, new ChunkType[,] { {ChunkType.TALL_GROUND}}); //currentLevel = generator.GenerateNewLevel(0, 1); //this.SetUpCameraDefault(); //this.projectiles = new List<Projectile>(); //this.expOrbs = new List<ExperienceOrb>(); updateCam = false; curLevelInfo = 0; setUpLevels(); currentLevel = new Level(levels[curLevelInfo].width, levels[curLevelInfo].height, 1); generator = new LevelGenerator(currentLevel, levels, new Random().Next()); currentLevel = generator.GenerateNewLevel(curLevelInfo, 1); this.SetUpCameraDefault(); this.projectiles = new List<Projectile>(); this.expOrbs = new List<ExperienceOrb>(); }
void Start() { _level_generator = (LevelGenerator) this.GetComponent("LevelGenerator"); // Launch the generator. Runs at load time in Unity CalculateQuantities (); GenerateEnemies (); }
public static void NewGame() { auto = false; data = new GameData(); enemyController = new EnemyController(); ILevelBuilder generator = new LevelGenerator(); data.level = generator.Generate(); for (int i = 0; i < data.level.doors.Count; i++) { data.level.doors[i].Init(); } data.SpawnPlayer(); //DEBUG STUFF //data.inventory.Add(ItemLibrary.Get().items[5], 1); foreach (IGameDataChangeListener listener in GAMEDATA_CHANGE_LISTENERS) { listener.OnGameDataChange(data); } //ConsolePseudoRaycast.CastRay(new Vector2(14, 1), new Vector2(16, 3)); //Console.ReadKey(); }
/** * */ public void SetObstacleJumpInfo(LevelGenerator.JumpInfo jumpInfo) { #if UNITY_EDITOR if (mObstacleJumpInfo != null && jumpInfo != null) Debug.LogWarning("Already assigned"); #endif mObstacleJumpInfo = jumpInfo; }
void Start () { // beatObserver = GetComponent<BeatObserver>(); syncronizer = GameObject.Find("AudioManager").GetComponent<BeatSynchronizer>(); syncAudioSrc = GameObject.Find("AudioManager").GetComponent<AudioSource>(); // counter = GameObject.Find("AudioManager").GetComponent<BeatCounter>(); levelGenerator = GameObject.Find("LevelGenerator").GetComponent<LevelGenerator>(); }
//methods // Use this for initialization void Start() { GameObject temp = GameObject.FindGameObjectWithTag ("LevelControl");//finds levelGenerator level = temp.GetComponent<LevelGenerator> ();// saved the script in level bombsPlaced = 0; //maxBomb maxBombs = 1; explodeRange = 1; }
/// <summary> /// Initializes a new instance of the <see cref="SectionBuilder"/> class. /// </summary> /// <param name="mainGenerator">The <see cref="LevelGenerator"/> using this SectionBuilder. </param> /// <param name="sbParams">The various parameters characterizing this <see cref="SectionBuilder"/></param> public SectionBuilder(LevelGenerator mainGenerator, SBParams sectionParams) { sbParams = sectionParams; generator = mainGenerator; numberBlocksX = ConvertToBlocksX(sbParams.size.x); numberBlocksY = ConvertToBlocksY(sbParams.size.y); section = new int[numberBlocksX,numberBlocksY]; groundHeight = sbParams.entrancePositions.westEntrance.location - 1; blocksSinceLastChange = 0; finalEntrancePositions = new EntrancePositions(sbParams.entrancePositions); pits = new List<int>(); }
public LevelManager(Game game, int numPlayers) : base(game) { updateCam = true; curLevelInfo = 0; setUpLevels(); currentLevel = new Level(levels[curLevelInfo].width, levels[curLevelInfo].height, numPlayers); generator = new LevelGenerator(currentLevel, levels, new Random().Next()); currentLevel = generator.GenerateNewLevel(curLevelInfo, numPlayers); this.SetUpCameraDefault(); this.projectiles = new List<Projectile>(); this.expOrbs = new List<ExperienceOrb>(); }
private bool doingSetup = true; //Boolean to check if we're setting up board, prevent Player from moving during setup. //Awake is always called before any Start functions void Awake() { //Check if instance already exists if (instance == null) instance = this; else if (instance != this) Destroy(gameObject); DontDestroyOnLoad(gameObject); //Assign enemies to a new List of Enemy objects. // enemies = new List<Enemy>(); //Get a component reference to the attached BoardManager script boardScript = GetComponent<LevelGenerator>(); InitGame(); }
void OnTriggerEnter(Collider whichDoor) { levelMap = GameObject.FindGameObjectWithTag("LevelGenerator").GetComponent<LevelGenerator>(); levelMap.currentRoom = levelMap.currentRoom.getNextRoom(this.tag); //Josh Added GameObject[] LevelRef = GameObject.FindGameObjectsWithTag("LevelGenerator"); LevelGenerator Rooming = LevelRef[0].gameObject.GetComponent<LevelGenerator>(); Rooming.RoomChange = true; StartCoroutine("RoomChangeCounter"); //Debug.Log("Room Change " + Rooming.RoomChange); }
public override void OnInspectorGUI() { DrawDefaultInspector(); LevelGenerator LG = (LevelGenerator)target; EditorGUILayout.Space(); GUILayout.Label("PSD size: 13 - 12 pixels.\n" + "Use the pencil tool, size 1px.\n" + "Save as PSD en set in Unity filter mode to Point\n" + "and compression to none and in advanced Read/Write enabled"); if (GUILayout.Button("Build Levels", GUILayout.Height(50))) { Debug.Log("Build done"); LG.RemoveLevel(); LG.BuildLevel(); } }
void Awake() { Debug.Log("Level Generator AWAKEN"); //Ensure that there is only one object pool if (Current == this) { return; } if (Current == null) { Current = this; } else { Debug.LogError("Attempting to spawn a second LevelGenerator!", this); Destroy(gameObject); } }
private void Start() { if (levelCamera == null) { levelCamera = GameObject.FindObjectOfType <MultiPlayerCamera>(); } if (levelGenerator == null) { levelGenerator = GameObject.FindObjectOfType <LevelGenerator>(); } if (charater == null) { charater = gameObject.GetComponentInParent <MainCharacter>(); } SetCameraConstrains(); levelCamera.AttachPlayer(charater.transform); }
/// <summary> /// Sets up object references and the GameManager. /// </summary> void Awake() { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } DontDestroyOnLoad(gameObject); levelGen = GetComponent <LevelGenerator>(); // Inits references infoText = GameObject.Find("InfoText").GetComponent <Text>(); menuBackdrop = GameObject.Find("MenuBackdrop"); }
public NoveltySearchGA(bool minimalCriteria, bool deathPenalty, int populationSize, int genomeLength, float mutationRate, bool elitism, CrossoverType crossoverType, int tournamentSize, float evaluationTime, bool testing, int testRuns, int maxGeneration, LevelGenerator levelGenerator) { this.populationSize = populationSize; this.genomeLength = genomeLength; this.levelGenerator = levelGenerator; this.tournamentSize = tournamentSize; this.testing = testing; this.testRuns = testRuns; this.maxGeneration = maxGeneration; this.elitism = elitism; this.crossoverType = crossoverType; this.mutationRate = mutationRate; this.evaluationTime = evaluationTime; this.minimalCriteria = minimalCriteria; this.deathPenalty = deathPenalty; Initialise(); }
// Start is called before the first frame update void Awake() { leveler = this; rightWall.position = Camera.main.ViewportToWorldPoint(new Vector3(1, 0.5f, 0)); leftWall.position = Camera.main.ViewportToWorldPoint(new Vector3(0, 0.5f, 0)); random = new float[4]; sign [0] = false; sign[1] = false; sign[2] = true; sign[3] = true; done = false; weight[0] = 30; weight[1] = 45; weight[2] = 15; weight[3] = 5; generating = false; counter = 0; }
void Start() { ScoreTimer = 1.5f; Bonus = FindObjectOfType <Bonus>(); ScoreDisplayCanvas = GameObject.Find("ScoreTextCanvas"); RespawnCanvas = GameObject.Find("RespawnCanvas"); RespawnCanvas.gameObject.SetActive(false); CameraMovement = FindObjectOfType <CameraMovement>(); LevelGenerator = FindObjectOfType <LevelGenerator>(); Player = FindObjectOfType <PlayerBehaviour>(); Audio = FindObjectOfType <AudioController>(); CameraStartPoint = Camera.main.transform.position; LevelStartPoint = GameObject.Find("StartPoint"); Audio.PlayMusic(); PlayerAlive = true; StartCoroutine("ScoreCount"); }
public override void Apply(Generator gen, LevelGenerator levelGen, Level level) { for (var i = 0; i < 50; i++) { var houseX = gen.Random.Next(0, gen.Size); var houseY = gen.Random.Next(0, gen.Size); var houseWidth = gen.Random.Next(MinSize.X, MaxSize.X + 1); var houseHeight = gen.Random.Next(MinSize.Y, MaxSize.Y + 1); if (level.IsValid(houseX, houseY, houseWidth, houseHeight, true, CanBePlacedOn)) { level.FillRectangle(houseX, houseY, houseWidth, houseHeight, Floor); level.Rectangle(houseX, houseY, houseWidth, houseHeight, Wall); } _progress = i / 50f; } }
// Use this for initialization void Start () { score = Camera.transform.FindChild("Hud").FindChild("Score").GetComponent<Text>(); levelGen = Ground.GetComponent<LevelGenerator>(); baseDistance = levelGen.baseDistance; numH = levelGen.numH; numV = levelGen.numV; numCoins = (numH-2) * (numV-2) - 4; baseVecH = baseDistance*Ground.transform.right; baseVecV = baseDistance*Ground.transform.forward; vecH0V0 = baseVecH*(1-numH)/2f + baseVecV*(1-numV)/2f; spawnCoins(); spawnBall(0, 0); spawnEnemy(numH-1,numV-1); }
void Start() { this.player = GameObject.FindGameObjectWithTag("Player"); this.treadmillBehaviour = (TreadmillBehaviour)GameObject.Find ("Treadmill").GetComponent("TreadmillBehaviour"); this.levelGenerator = new LevelGenerator( this.treadmillBehaviour ); this.gameRunning = true; // Score TextMesh GameObject scoreText = GameObject.Find("ScoreText"); this.scoreText = scoreText.GetComponent(typeof(TextMesh)) as TextMesh; // Listen for coin collection event this.playerBehaviour = this.player.GetComponent("PlayerBehaviour") as PlayerBehaviour; this.playerBehaviour.coinCollected += new PlayerBehaviour.CoinCollectedHandler( HandleCoinsCollected ); this.playerBehaviour.SetTreadmill(this.treadmillBehaviour); }
// public override void OnInspectorGUI(){ // // // // // // } public override void OnInspectorGUI() { lg = (LevelGenerator)target; // if(!lg.sequences){ // lg.sequences = new LevelSequence[1]; // } int numOfSequences = 2; //lg.sequences.Length; numOfSequences = EditorGUILayout.IntField("Number of Sequences", numOfSequences); if(numOfSequences != lg.sequences.Length){ } }
public override List <PathfindingNode> FindPath(LevelGenerator tempLevelNodes, PathfindingNode tempStartNode, PathfindingNode tempTargetNode) { StartPathfindingSteps(tempLevelNodes, tempStartNode, tempTargetNode); while (openSet.Count > 0) { PathfindingNode node = openSet[0]; for (int i = 1; i < openSet.Count; i++) { float distNode = GetDistance(node, targetNode); float newDist = GetDistance(openSet[i], targetNode); if (newDist <= distNode) { // favor y movement (down movement) if (openSet[i].gridY < node.gridY) { node = openSet[i]; } } } openSet.Remove(node); closedSet.Add(node); if (node == targetNode) { return(RetracePath(startNode, targetNode)); } foreach (PathfindingNode neighbour in GetNeighbours(node)) { if (!neighbour.walkable || closedSet.Contains(neighbour)) { continue; } if (!openSet.Contains(neighbour)) { neighbour.parent = node; if (!openSet.Contains(neighbour)) { openSet.Add(neighbour); } } } } return(null); }
private void LoadLevelMap() { ; int maxJumpDist = (int)GetCurrenMoveXSpeed() - 2; List <int> heightMaps = LevelGenerator.RandomZoneMap(5, 5, 5, maxJumpDist); m_workingLevelDTO.SetHeightMap(heightMaps); int maxGround = heightMaps.Count; int startGround = 0; while (startGround < maxGround) { int lineHeight = heightMaps[startGround]; int endGround = startGround + 1; while (endGround < heightMaps.Count && heightMaps[startGround] == heightMaps[endGround]) { endGround++; } int numSpace = (endGround - startGround); if (lineHeight < 0) //need jump { //To force player do jump over [numSpace] unit, We just need set 1 SquareObstacle at middle has enough tall. for (int i = 0; i < numSpace; i++) { int mid = (numSpace - 1) / 2; if (i == (int)mid) { PlacementObjectDTO groundInfo = new PlacementObjectDTO(); groundInfo.ObjectType = ObjectType.SquareObstacle; //groundInfo.SizeX = numSpace; groundInfo.SizeX = 1; groundInfo.SizeY = 0.8f + 0.3f * (mid * mid - (mid - i) * (mid - i)); groundInfo.MapX = startGround + i; groundInfo.MapY = 0; m_workingLevelDTO.PlacementObjects.Add(groundInfo); } } } startGround = endGround; } }
void NewGame() { bricks = new List <GameObject>(); LevelGenerator.StartLevel(ref bricks); GameObject playerGameObject = GameObject.FindWithTag("Player"); player = playerGameObject.GetComponent <Player>() as Player; UpdateLivesText(); gameStateText.enabled = false; Player.PlayerLostABall += UpdateLivesText; Player.PlayerLostAllBalls += GameOver; Brick.BrickDestroyed += checkForVictory; GoldenBar.GoldenBarDestroyed += checkForVictory; gameState = GameState.NewGame; }
private void Restart() { if (routine != null) { behaviour.StopCoroutine(routine); } Rotation[] rotations = Array.Empty <Rotation>(); while (IsSameAsLevel(rotations)) { rotations = LevelGenerator.Create().GetRandomRotations(GameStore.instance.weight); } GameStore.instance.SetTriangles(GenerateTriangles(rotations)); routine = WatchForWin(); behaviour.StartCoroutine(routine); LogUtils.LogState(GetType().Name); }
// Use this for initialization void Start() { l = GameObject.Find("LevelGenerator").GetComponent <LevelGenerator> (); cameraPositions = new float[l.levelLength]; lookAts = new float[l.levelLength]; cameraPositionRoute = new float[l.levelLength]; cameraHeight = l.GetLevelAreaHeights(); //Set array with x values for the camera LerpCameraPostionsArray(); LerpCameraHeightsArray(); LerpCameraLooksAtsArray(); //Set initial position, height and rotation SetLookAtsArray(); SetCameraPositionsArray(); UpdateCameraHeight(); }
public void ImportGameKataExample1() { String level = "4 4\n" + "*...\n" + "....\n" + ".*..\n" + "....\n"; LevelGenerator levelGenerator = new LevelGenerator();; bool result = levelGenerator.ImportLevel(level); Assert.True(result); string mineMap = levelGenerator.Level; string expectedMap = "*100" + "2210" + "1*10" + "1110"; Assert.AreEqual(expectedMap, mineMap); }
// void start() // original name void Start() { // finds the collision manager in the scene. if (colManager == null) { colManager = FindObjectOfType <CollisionManager>(); } // if the game state loader has not been set, it searches for one. if (gsLoader == null) { gsLoader = FindObjectOfType <GameStateLoader>(); } if (levelGenerator == null) { levelGenerator = FindObjectOfType <LevelGenerator>(); } }
private void Start() { // Size of dungeon. int sizeX = 20; int sizeY = 8; // Rather than hardcode the resolution of a tile, use the size of the first sprite. var tileSheet = m_tileMap.TileSheet; var spriteSize = tileSheet.Get(0).rect; // Define and apply the settings for the tilemap. var settings = new TileMeshSettings(sizeX, sizeY, (int)spriteSize.width); m_tileMap.MeshSettings = settings; // The level generator uses an enum to define each type of tile. // UnityTileMap doesn't (and shouldn't) know about the enum, // so we need a way to translate each enum value (type of tile) to a sprite. var tileTypes = new Dictionary <LevelGenerator.TileType, int>(); tileTypes[LevelGenerator.TileType.Wall] = tileSheet.Lookup("Green"); tileTypes[LevelGenerator.TileType.Floor] = tileSheet.Lookup("Blue"); // Generate the level. var level = LevelGenerator.Generate(sizeX, sizeY); // Loop through the level and set each tile. // This might look very different depending on how the generator/loader returns the level. foreach (KeyValuePair <Vector2, LevelGenerator.TileType> pair in level) { var x = (int)pair.Key.x; var y = (int)pair.Key.y; var tile = pair.Value; // Use our cached lookup, which sprite represents this type of tile? var spriteId = tileTypes[tile]; // Set one tile. m_tileMap[x, y] = spriteId; } // Done! }
public static bool CanMoveRight(int[] coordinates) //gets game object, returns true if object can move right one cell on the grid { int[] leftCoordinates = new int[] { coordinates[0], coordinates[1] + 1 }; if (leftCoordinates[1] >= LevelGenerator.GetCols()) { return(false); } if (MapUtility.GetMapCell(leftCoordinates) == 1) { return(false); } else { return(true); } }
public override void OnInspectorGUI() { LevelGenerator levelGen = (LevelGenerator)target; if (DrawDefaultInspector()) { levelGen.generate(); } if (GUILayout.Button("Generate")) { levelGen.generate(); } if (GUILayout.Button("Destroy")) { levelGen.Destroy(); } }
private void RepopulateTileMap() { Tuple <int, int> startCoords = ConvertCoordinates(startPipeX, startPipeY, -9, -5, false); Tuple <int, int> endCoords = ConvertCoordinates(endPipeX, endPipeY, -9, -5, false); LevelGenerator levelGenerator = new LevelGenerator(); Tuple <TileType, int>[,] newLevel = levelGenerator.GenerateNewLevel(19, 11, startCoords.Item1, startCoords.Item2, endCoords.Item1, endCoords.Item2); for (int x = 0; x < newLevel.GetLength(0); x++) { for (int y = 0; y < newLevel.GetLength(1); y++) { Tuple <int, int> convertedCoords = ConvertCoordinates(x, y, -9, -5, true); bool highlight = levelGenerator.IsBorderTile(x, y); calculator.PaintTile(convertedCoords.Item1, convertedCoords.Item2, newLevel[x, y].Item1, newLevel[x, y].Item2, highlight); } } }
public override void Spawn(List <Vector2Int> region, LevelGenerator levelGenerator) { int maxTries = 50; while (maxTries > 0) { Vector2Int pos = region.Sample(); maxTries--; if (levelGenerator.collisionMap.SpaceMarking(pos.x, pos.y) == 0) { // Placed successfully maxTries = 0; GameObject trapObj = levelGenerator.PlaceMapPrefab("FireStaffTrap", pos.x, pos.y); Game.instance.levelGenerator.collisionMap.MarkSpace(pos.x, pos.y, 6); } } }
private void OnTriggerEnter2D(Collider2D col) { if (col.tag == "ColorChanger") { LevelGenerator lvlGenerator = FindObjectOfType <LevelGenerator>(); lvlGenerator.LevelGeneratorMethod(rb); SetRandomColor(); Destroy(col.gameObject); return; } if (col.tag != currentColor) { Dead(); } }
public void Initialize(LevelGenerator generator, object[] generationData) { DungeonMetadata metadata = null; GenerationSettings settings = null; for (int i = 0; i < generationData.Length; i++) { if (generationData[i] is DungeonMetadata) { metadata = generationData[i] as DungeonMetadata; } if (generationData[i] is GenerationSettings) { settings = generationData[i] as GenerationSettings; } } metadata.LayoutData = new Layout(settings.Size); }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.R) && !generating) { generating = true; //Borramos todos los elementos del mapa anterior foreach (Transform child in mapParent.transform) { Destroy(child.gameObject); } //Generamos un mapa nuevo lg = new LevelGenerator(); //cm.SetupMap(lg.GenerateMap(mapSize, roomNumber, minRoomSize, maxRoomSize)); generating = false; } }
IEnumerator LevelStart() { int a = count; while (GameManager.Instance().gaming&& a > 0) { a--; float generatePosX = Random.Range(shootingStarCenterPoint.x - shootingStarSize.x / 2, shootingStarCenterPoint.x + shootingStarSize.x / 2); float generatePosY = Random.Range(shootingStarCenterPoint.y - shootingStarSize.y / 2, shootingStarCenterPoint.y + shootingStarSize.y / 2); LevelGenerator.Instance().InstantiateObject("Star", new Vector2(generatePosX, generatePosY), shootingStarDirection, torque); yield return(new WaitForSeconds(interval)); } LevelFinish(); }
public override void OnInspectorGUI() { DrawDefaultInspector(); LevelGenerator levelGenerator = (LevelGenerator)target; if (GUILayout.Button("Generate Level")) { levelGenerator.GenerateLevel(); } if (GUILayout.Button("Clear Level")) { //levelGenerator.ClearLevel(); } EditorUtility.SetDirty(levelGenerator); }
private (IList <Platform> platforms, MovementFunc guidePath) ConstructLevel(LevelGeneratorParams levelGenParams) { LevelGenerator levelGen = new LevelGenerator(); // Generate platforms IList <PlatformInfo> platformInfos = levelGen.GeneratePlatforms(new System.Random(), PlatformInfo.FromLength(Vector2.zero, startPlatformLength), levelGenParams); IList <Platform> platforms = new List <Platform>(platformInfos.Count); PlacePlatforms(platforms, platformInfos); // Generate guide path float jumpDuration = platformInfos.Sum(p => p.GetJumpFunction().duration); float runDuration = levelGenParams.levelDuration - jumpDuration; float runDistance = platformInfos.Sum(p => Vector3.Distance(p.GetLandPoint(), p.GetJumpPoint())); float guideRunSpeed = runDistance / runDuration; MovementFunc guidePath = levelGen.GenerateGuidePath(platformInfos, guideRunSpeed); return(platforms, guidePath); }
private void Awake() { instance = this; difficulty = GameManager.instance.difficulty; if (difficulty == 1) { noOfBombs = Random.Range(7, 9); xMax = 3.22f; xMin = -2.78f; yMax = 2.09f; yMin = -3.91f; increment = 2; noOfBlocksAcross = ((xMax - xMin) / increment) + 1; noOfBlocksDownward = ((yMax - yMin) / increment) + 1; easyPlatform.SetActive(true); } if (difficulty == 2) { noOfBombs = Random.Range(10, 15); xMax = 3.73f; xMin = -3.77f; yMax = 2.54f; yMin = -3.46f; increment = 1.5f; noOfBlocksAcross = ((xMax - xMin) / increment) + 1; noOfBlocksDownward = ((yMax - yMin) / increment) + 1; mediumPlatform.SetActive(true); } if (difficulty == 3) { noOfBombs = Random.Range(20, 33); xMax = 4.54f; xMin = -4.46f; yMax = 3; yMin = -3; increment = 1; noOfBlocksAcross = ((xMax - xMin) / increment) + 1; noOfBlocksDownward = ((yMax - yMin) / increment) + 1; hardPlatform.SetActive(true); } }
void Start() { roomGen = transform.parent.GetComponent <RoomGenerator>(); GameObject gO = GameObject.Find("Level Generator"); enMan = gO.GetComponent <EnemyManager>(); levGen = gO.GetComponent <LevelGenerator>(); levMan = gO.GetComponent <LevelManager>(); cam = GameObject.FindWithTag("MainCamera").GetComponent <CameraFollow>(); gO = GameObject.FindWithTag("Player"); shootingScript = gO.GetComponent <MouseShooting>(); moveScript = gO.GetComponent <CharacterNavMeshMovement>(); pointsPerRoom = enMan.levelDifficulty; if (DebugHandler.debugEnabled) { roomMask.GetComponent <MeshRenderer>().enabled = DebugHandler.roomMasksEnabled; } }
void Awake() { if (LG == null) { LG = this; } platforms = GameObject.Find("Platforms"); if (platforms == null) { Debug.LogError("Platforms GameObject Not Found!"); return; } System.Diagnostics.Stopwatch st = new System.Diagnostics.Stopwatch(); st.Start(); SpawnPlatforms(); st.Stop(); loadingTime = (float)(st.ElapsedMilliseconds) / 1000f; }
public static bool CanMoveDown(int[] coordinates) //gets coordinates, returns true if object can move down one cell on the grid { int[] downCoordinates = new int[] { coordinates[0] + 1, coordinates[1] }; if (downCoordinates[0] >= LevelGenerator.GetRows()) { return(false); } if (MapUtility.GetMapCell(downCoordinates) == 1) { return(false); } else { return(true); } }
// Use this for initialization void Start() { if( null == m_GUIAnimationTexture ) { GameObject obj = GameObject.Find( m_GUIAnimationObjectName ) ; if( null == obj ) { Debug.Log( "AnimationPlayer::Start() null == obj" ) ; } m_GUIAnimationTexture = obj.GetComponent<GUITexture>() ; m_GUIAnimationTexture.pixelInset = new Rect( 0 , (Camera.main.pixelHeight - Camera.main.pixelWidth * m_PictureScale) / 2 , Camera.main.pixelWidth , Camera.main.pixelWidth * m_PictureScale ) ; } if( null == m_LevelGeneratorPtr ) { GameObject obj = GameObject.Find( "GlobalSingleton" ) ; m_LevelGeneratorPtr = obj.GetComponent<LevelGenerator>() ; } }
//This function is called at the start of the game void Start() { //Calibrates the myInstance static variable instances++; if (instances > 1) Debug.Log("Warning: There are more than one Level Generator at the level"); else myInstance = this; //Sets the starting values defaultScroll = scrollSpeed; scrollBackg = scrollSpeed * 12.5f; scrollMiddle = scrollBackg * 3; scrollForg = scrollBackg * 8; //Generate a seconds and third layer in the middle GenerateSecondLayer(1); GenerateThirdLayer(1); }
// Use this for initialization void Start () { // Instantiate internal managers gui = gameObject.AddComponent<GUIManager>(); musicManager = (GameObject) Instantiate(Resources.Load(ResourcePaths.musicManager), Vector3.zero, Quaternion.identity); musicManager.transform.SetParent(transform); soundManager = (GameObject) Instantiate(Resources.Load(ResourcePaths.soundManager), Vector3.zero, Quaternion.identity); soundManager.transform.SetParent(transform); music = musicManager.GetComponent<MusicManager>(); sound = soundManager.GetComponent<SoundManager>(); objects = gameObject.AddComponent<ObjectManager>(); levels = gameObject.AddComponent<LevelGenerator>(); art = gameObject.GetComponent<LayerManager>(); reactionTable = new ReactionTable(); if(layerTracks.Length > 0) { music.clips = layerTracks; } //Find camera if not explicitly done in the Editor (this is a failsafe.. shouldn't rely on this) if (!mainCamera) { mainCamera = GameObject.Find("Main Camera"); } // Start first level state = GameState.loading; PopulateReactionTable(); //This is just so the old "Gameplay" scene doesn't break #pragma warning disable 0618 // Type or member is obsolete if(Application.loadedLevelName == "Gameplay") { worldProperties = gameObject.AddComponent<WorldProperties>(); levels.CreateSampleLevel(); // Set the camera to follow the game's player mainCamera.GetComponent<CameraFollow>().SetPlayer(ref worldProperties.player); } #pragma warning restore 0618 // Type or member is obsolete }
private void InitGame() { startScreen = GameObject.Find("StartScreen"); pausedScreen = GameObject.Find("PauseScreen"); GameObject.Find("Title").GetComponent<Text>().enabled = false; GameObject.Find("Instructions").GetComponent<Text>().enabled = false; gameOverText = GameObject.Find("GameOverText").GetComponent<Text>(); pausedText = GameObject.Find("PausedText").GetComponent<Text>(); startScreen.SetActive(false); pausedScreen.SetActive(false); levelUp = false; enemies.Clear(); currentLevel = levelGenerators[Random.Range(0, levelGenerators.Length)]; currentLevel.CreateLevel(50, 50, 60, player); state.StartGame(); }
void Start() { instance = this; foreach (Transform child in transform) { if (child.gameObject.activeInHierarchy) { pieceLibrary.Add(child.gameObject); } } GenerateBoard(); }
void Start () { levelScript = GameObject.FindGameObjectWithTag("GameController").GetComponent<LevelGenerator> (); tileRecords = levelScript.goodTileRecords; InvokeRepeating ("ShiftPosition", 0, camJumpTime); }
void Start() { _GameManager = GetComponent<GameManager>(); _LevelGenerator = GetComponent<LevelGenerator>(); iniLevels(); }
///My Change // public void BonusAndGooglePlayCreate() // { // if (TimeNow > PlayerPrefs.GetInt ("SavedBonusTime2") && PlayerPrefs.GetInt("SessionNumber") == 2) { // // //print (TimeNow + " " + PlayerPrefs.GetInt ("SavedBonusTime2") + "TIMETIMETIMETIMETIMETIMETIMETIMETIMETIME"); // BonusScreen.SetActive (true); // // } else { // // PlayerPrefs.SetInt("SessionNumber" , 2); // // #if (UNITY_ANDROID) // // AppManager.instance.ConnectToGooglePlay(); // // #endif // // #if UNITY_IPHONE // // myGameCenterScript.ConnectToGameCenter(); // #endif // // } // // } void Awake() { int test = PlayerPrefs.GetInt ("gameLevel"); if (test < 4) { FacebookButton.enabled = false; exclamation.enabled = false; } else { FacebookButton.enabled = true; exclamation.enabled = true; } //MyChange TimeNow = System.DateTime.Now.DayOfYear; // AppManager.instance.ConnectToGooglePlay(); // BonusAndGooglePlayCreate (); mInstance = this; mPlatforms.Add(FirstPlatform); mTransform = gameObject.transform; mCamera = Camera.main; mUIRoot = GameObject.Find("UI Root").GetComponent<UIRoot>(); mUICamera = GameObject.Find("UI Root/Camera").GetComponent<Camera>(); mCameraTransform = mCamera.transform; //GameEndScreen.SetActive(false); AppManager.instance.challengeActivated += OnChallengeActivated; // Get player GameObject playerGO = GameObject.FindGameObjectWithTag("Player"); mPlayerController = playerGO.GetComponent<PlayerController>(); // Initialization MaxPlatformOffsetY = InitialMaxPlatformOffsetY; MinPlatformOffsetY = InitialMinPlatformOffsetY; // Get coin width Sprite sprite = Multires.GetSprite("coin0"); mCoinWidth = sprite.bounds.size.x;; mCoinHWidth = mCoinWidth * 0.5f; // // Records initial state //----------------------- // Player mIniPlayerPosition = playerGO.transform.localPosition; // Platform GameObject platform = GameObject.FindGameObjectWithTag("platform"); mIniPlatformPosition = platform.transform.localPosition; mIniPlatformSize = platform.GetComponent<BoxCollider2D>().size; // Level controller mIniGeneratorPosition = mTransform.localPosition; //------------------------ // Get player size Vector2 playerSize = playerGO.GetComponent<BoxCollider2D>().size; CharacterHalfWidth = playerSize.x * 0.5f; CharacterHalfHeight = playerSize.y + 0.3f; DontDestroyOnLoad(this); }
/** * */ void Awake() { mTransform = gameObject.transform; mLevelGenerator = LevelGenerator.instance; mPlayer = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerController>(); mAnimator = GetComponent<Animator>(); mRigidBody = GetComponent<Rigidbody2D>(); mCurPlatform = mLevelGenerator.FirstPlatform; mGroundY = mCurPlatform.transform.localPosition.y + GetComponent<SpriteRenderer>().bounds.extents.y ; }
// Use this for initialization void Start() { _LevelGenerator = GetComponent<LevelGenerator>(); //GameState = 1; }
// Use this for initialization void Start() { CountBreakable(); timesHit = 0; levelManager = GameObject.FindObjectOfType<LevelManager>(); levelGenerator = GameObject.FindObjectOfType<LevelGenerator>(); textControl = GameObject.FindObjectOfType<TextController>(); }
void Start() { if (levelHelpers == null) { levelHelpers = GameObject.Find ("Level Helpers"); } if (leftBorder == null) { leftBorder = levelHelpers.transform.Find ("Left Border").gameObject; } if (rightBorder == null) { rightBorder = levelHelpers.transform.Find ("Right Border").gameObject; } if (spawnZone == null) { spawnZone = levelHelpers.transform.Find ("Spawn Zone").gameObject; } if (levelGenerator == null) { levelGenerator = GetComponent<LevelGenerator> (); } if (statistics == null) { statistics = GetComponent<Statistics> (); } if (playerController == null) { playerController = GameObject.Find ("Player Container").GetComponent<PlayerController_old> (); } if (guiManager == null) { guiManager = GameObject.Find ("GUI").GetComponent<GUIManager_old> (); } if (equipmentCellMap == null) { equipmentCellMap = guiManager.transform.Find ("GUI Camera").transform.Find ("Equipment").GetComponent<EquipmentCellMap> (); } }
public void setGenerator(LevelGenerator gen) { _generator = gen; }
// Use this for initialization void Start() { if( null == m_GUIAnimationTexture ) { GameObject obj = GameObject.Find( m_GUIAnimationObjectName ) ; if( null == obj ) { Debug.Log( "AnimationPlayer::Start() null == obj" ) ; } m_GUIAnimationTexture = obj.GetComponent<GUITexture>() ; m_GUIAnimationTexture.texture = null ; } if( null == m_GUIQuestionZoneAnswer ) { m_GUIQuestionZoneAnswer = GameObject.Find( m_GUIQuestionZoneAnswerName ) ; if( null == m_GUIQuestionZoneAnswer ) { Debug.Log( "AnimationPlayer::Start() null == m_GUIQuestionZoneAnswer" ) ; } m_GUIQuestionZoneAnswer.GetComponent<GUITexture>().texture = null ; m_GUIQuestionZoneAnswer.GetComponent<GUITexture>().pixelInset = new Rect( 0 , (Camera.main.pixelHeight - Camera.main.pixelWidth * m_PictureScale) / 2 , Camera.main.pixelWidth , Camera.main.pixelWidth * m_PictureScale ) ; ShowGUITexture.Show( m_GUIQuestionZoneAnswer , false , true , true ) ; } if( null == m_LevelGeneratorPtr ) { GameObject obj = GameObject.Find( "GlobalSingleton" ) ; m_LevelGeneratorPtr = obj.GetComponent<LevelGenerator>(); } if( null == m_AnimationPlayer ) { GameObject obj = GameObject.Find( "GlobalSingleton" ) ; m_AnimationPlayer = obj.GetComponent<AnimationPlayer>() ; } if( null == m_GUIReady ) { GameObject obj = GameObject.Find( "GUI_Ready" ) ; m_GUIReady = obj.GetComponent<GUIText>() ; } if( null == m_GUIBack ) { m_GUIBack = GameObject.Find( m_GUIBackName ) ; } if( null == m_GUIInstruction ) { m_GUIInstruction = GameObject.Find( "GUI_Instruction" ) ; } if( null == m_GUICorrect ) { m_GUICorrect = GameObject.Find( "GUI_CorrectSymbol" ) ; ShowGUITexture.Show( m_GUICorrect , false , true , true ) ; } if( null == m_GUIWrong ) { m_GUIWrong = GameObject.Find( "GUI_WrongSymbol" ) ; ShowGUITexture.Show( m_GUIWrong , false , true , true ) ; } if( null == m_GUIAgain ) { m_GUIAgain = GameObject.Find( "GUI_Again" ) ; ShowGUITexture.Show( m_GUIAgain , false , true , true ) ; } m_QuestionString = StaticData.QuestionString ; Debug.Log( "m_QuestionString=" + m_QuestionString ) ; SetupForAnswerZone() ; }
void Start(){ levelGenerator = GameObject.Find("LevelGenerator").GetComponent<LevelGenerator>(); playerAnimator = GetComponentInChildren<Animator>(); syncAudioSrc = GameObject.Find("AudioManager").GetComponent<AudioSource>(); playerAnimator.SetTrigger("Idle"); }