private void OnCollisionStay(Collision collision) { if (collision.gameObject.tag == "Floor" || collision.gameObject.tag == "Landed") { timer += 1 * Time.deltaTime; } if (timer > 0.5) { spawner = GameObject.Find("Spawner"); tileSpawner = spawner.GetComponent <TileSpawner>(); rgbody.isKinematic = true; gameObject.tag = "Landed"; for (int j = 0; j < blocks.Length; j++) { blocks[j].tag = "Landed"; } tileSpawner.spawnTile = true; for (int i = 0; i < blocks.Length; i++) { if (!blocks[i].gameObject.GetComponent <BoxCollider>().isTrigger) { blocks[i].gameObject.transform.parent = null; } else { Destroy(blocks[i].gameObject); } } lineCheck.GetComponent <LineChecker>().checkline = true; gameObject.GetComponent <AudioSource>().Play(); canHold = true; this.enabled = false; } }
public static void LoadMap(string path) { if (File.Exists(path)) { try { var bf = new BinaryFormatter(); var file = File.Open(path, FileMode.Open); var blocks = (SerBlock[])bf.Deserialize(file); file.Close(); //SceneManager.sceneLoaded += (x, y) => { FinishLoad(x, y, blocks); }; //SceneManager.LoadScene("levelEditor", LoadSceneMode.Single); BlockManipulator.DestroyAll(); for (int i = 0; i < blocks.Length; i++) { TileSpawner.SpawnFull(blocks[i].info, (Vector3)blocks[i].pos, blocks[i].Blendshapes, (Vector3)blocks[i].rot, false); } } catch (System.Exception ex) { Debug.Log("Uh oh error while loading."); Debug.Log(ex.Message); } } }
void Start() { tileSpawner = FindObjectOfType <TileSpawner>(); dimensionScript = FindObjectOfType <DimensionScript>(); rb = GetComponent <Rigidbody>(); startPos = gameObject.transform.position; }
//Moves a given wall spawner to the new position public static void MoveWallSpawner(WallSpawner WallSpawner, TileSpawner ReferenceTileSpawner, Vector2Int Direction, Vector2Int Rotation) { if (CanMoveWallSpawner(ReferenceTileSpawner, Direction, Rotation) && WallSpawner != null) { ReferenceTileSpawner.WallSpawnerDict[Direction] = WallSpawner; //Reference this in the reference tile TileSpawner OppositeTileSpawner = null; //Checks if the tileSpawner on the other side of the wallSpawner is inside the room if (Methods.IsInsideRoom(ReferenceTileSpawner.Structure.Width, ReferenceTileSpawner.Structure.Height, ReferenceTileSpawner.X + Direction.x, ReferenceTileSpawner.Y + Direction.y)) { //Find the tile on the other side of the wallSpawner OppositeTileSpawner = ReferenceTileSpawner.Structure.TileSpawnerArray[ReferenceTileSpawner.X + Direction.x, ReferenceTileSpawner.Y + Direction.y]; OppositeTileSpawner.WallSpawnerDict[Direction * -1] = WallSpawner; //Reference this in the opposite tile } if (Direction == Rotation) { WallSpawner.FrontTileSpawner = OppositeTileSpawner; WallSpawner.BackTileSpawner = ReferenceTileSpawner; } else { WallSpawner.FrontTileSpawner = ReferenceTileSpawner; WallSpawner.BackTileSpawner = OppositeTileSpawner; } WallSpawner.Rotation = Rotation; } }
void Start() { m_OrthographicCamera.gameObject.SetActive(true); m_PerspectiveCamera.gameObject.SetActive(false); tileSpawner = FindObjectOfType <TileSpawner>(); buttonText = gameObject.GetComponent <Button>().GetComponentInChildren <Text>(); }
//Currently only used in Methods.LoadStructure. X and Y are the position of the prefab in the editor(-0.5 see LoadStructure). public WallSpawner(Structure Structure, float X, float Y, Vector2Int Rotation, string Name = "", Sprite WallSpawnerSprite = null) { this.Name = Name; this.WallSpawnerSprite = WallSpawnerSprite; this.Rotation = Rotation; //Positions of FrontTile and BackTile int FrontX = (int)(X + Rotation.x * 0.5); int FrontY = (int)(Y + Rotation.y * 0.5); int BackX = (int)(X - Rotation.x * 0.5); int BackY = (int)(Y - Rotation.y * 0.5); //Checks if FrontTile is inside the room, if not set it to null if (Methods.IsInsideRoom(Structure.Width, Structure.Height, FrontX, FrontY)) { this.FrontTileSpawner = Structure.TileSpawnerArray[FrontX, FrontY]; this.FrontTileSpawner.WallSpawnerDict[Rotation * -1] = this; } else { this.FrontTileSpawner = null; } //Checks if BackTile is inside the room, if not set it to null if (Methods.IsInsideRoom(Structure.Width, Structure.Height, BackX, BackY)) { this.BackTileSpawner = Structure.TileSpawnerArray[BackX, BackY]; this.BackTileSpawner.WallSpawnerDict[Rotation] = this; } else { this.BackTileSpawner = null; } }
void Start() { rb = gameObject.GetComponent <Rigidbody>(); TS = FindObjectOfType <TileSpawner>(); actions.Add("jump", jump); actions.Add("dash", dash); }
// Use this for initialization void Start() { transform.localPosition = new Vector3(280, 240, 0); player = GameObject.Find("Player"); playerctrl = player.GetComponent <PlayerController>(); spawner = GameObject.Find("Spawner"); tileSpawner = spawner.GetComponent <TileSpawner>(); }
public PieceSpawn(StateManager m, Board b, TileSpawner s, PieceVariable c, PieceVariable n, Piece[] ps) { _manager = m; _board = b; _spawner = s; _pieces = ps; _currentPiece = c; _nextPiece = n; }
public void Start() { m_Spawner = GetComponent <TileSpawner>(); m_Spawner.InitSpawner(); float chrono = 0f; DOTween.To(() => chrono, x => chrono = x, 1f, 0.2f) .OnComplete(() => m_Spawner.LaunchSpawn()); }
private void Start() { tileSpawner = FindObjectOfType<TileSpawner>(); player = FindObjectOfType<ShipMovement>(); uIManager = FindObjectOfType<UIManager>(); PlayerEvents.UpPlayerScore += IncreaseScore; PlayerEvents.PlayerDeath += EndGame; }
// Start is called before the first frame update void Start() { // Get components ceilingSpawner = spawners[0].GetComponent <TileSpawner>(); groundSpawner = spawners[1].GetComponent <TileSpawner>(); // Set values difficultyAdderTime = 10.0f; timesDifficultyAdded = 0; difficultyTimer = 0.0f; }
public void SpawnItems() { ClearOldItems(); // SpawnVictoryItems(); SpawnShrooms(ItemType.mushroomGood); SpawnShrooms(ItemType.mushroomBad); SpawnShrooms(ItemType.mushroomLegendary); tileSpawner = gameObject.GetComponent <TileSpawner>(); tileSpawner.SetupTiles(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); TileSpawner tile = (TileSpawner)target; if (GUILayout.Button("Generate Grid")) { tile.overwriteGrid(); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); TileSpawner myScript = (TileSpawner)target; if (GUILayout.Button("SpawnIce")) { myScript.SpawnIce(); } }
private void Start() { myPS.SetActive(false); powerUpSlider = GameObject.Find("POWER-UP_SLIDER"); moved = false; initPos = this.transform.position; timeLeftPowerUp = timePowerUp; scoreText = GameObject.FindGameObjectWithTag("ScoreText"); tileSpawner = GameObject.FindGameObjectWithTag("TileSpawner").GetComponent <TileSpawner>(); //madeiraManager = GameObject.FindGameObjectWithTag("MadeiraManager").GetComponent<MadeiraManager>(); soundManager = GameObject.FindGameObjectWithTag("SoundManager").GetComponent <SoundManager>(); }
public void PlaceSpawner(TileSpawner TileSpawner) { if (TileSpawner != null && TileSpawner.ActorSpawner == null && (TileSpawner.BlockSpawner == null || TileSpawner.BlockSpawner.Solid == false)) { this.TileSpawner = TileSpawner; TileSpawner.ActorSpawner = this; } else { this.TileSpawner = null; } }
private void Awake() { if (transform.GetChild(0).GetComponent <SpriteRenderer>()) { effectSpriteRenderer = transform.GetChild(0).GetComponent <SpriteRenderer>(); } else { Debug.LogError("Sprite Renderer is missing"); } tileSpawner = FindObjectOfType <TileSpawner>(); }
public BlockSpawner(TileSpawner TileSpawner, string Name = "", Sprite Sprite = null, bool Solid = true) { this.Name = Name; this.Sprite = Sprite; if (TileSpawner != null && TileSpawner.BlockSpawner == null && (TileSpawner.ActorSpawner == null || Solid == false)) { this.TileSpawner = TileSpawner; TileSpawner.BlockSpawner = this; } else { TileSpawner = null; } }
public Ship LoadShip(string ship) { TileSpawner = GetComponent <TileSpawner>(); TileObjectSpawner = GetComponent <TileObjectSpawner>(); ShipToLoad = FactoryBlueprint.Instance.ROOKIE; ShipToLoad.Layout = BlueprintReader.Read(ShipToLoad.Tiles, ShipToLoad.TileObjects); TileSpawner.SpawnTiles(ShipToLoad.Layout); TileObjectSpawner.SpawnObjects(ShipToLoad.Layout); return(new Ship(ShipToLoad.Layout)); }
public void ChangeVariation(int shift) { if (selected.transform.childCount == 0) { return; } var infoBlocks = selected.GetComponentsInChildren <InfoOnBlock>(); DestroySelected(); for (int i = 0; i < infoBlocks.Length; i++) { var pos = infoBlocks[i].transform.position; var info = infoBlocks[i].Info; info.Variation += shift; TileSpawner.Spawn(info, pos); } }
void Hold() { spawner = GameObject.Find("Spawner"); tileSpawner = spawner.GetComponent <TileSpawner>(); if (tileSpawner.tileToSpawn != 10) { tileSpawner.tileToSpawn = holdController.GetComponent <NextController>().next; tileSpawner.spawnSpecificTile = true; } else { tileSpawner.spawnTile = true; tileSpawner.tileToSpawn = pieceID; } holdController.GetComponent <NextController>().next = pieceID; canHold = false; Destroy(gameObject); }
void Start() { isPaused = false; if (instance == null) { instance = this; } else if (instance == this) { Destroy(gameObject); } zeroAlpha = new Color(1, 1, 1, 0); startColor = new Color(1, 1, 1, 1); PoolManager.Instance.PoolForObject(ball); spawnPosition = new Vector3(-44, 300, -5); TweenColor.SetColor(warning, zeroAlpha, 0); }
public override void OnInspectorGUI() { DrawDefaultInspector(); script = (TileSpawner)target; if (GUILayout.Button("Apply")) { script.DeleteTiles(); script.CreateTiles(); } if (GUILayout.Button("Remove All")) { script.DeleteTiles(); } if (GUILayout.Button("Create (Without Removing)")) { script.CreateTiles(); } }
//Checks if a wallSpawner can be moved to the given direction public static bool CanMoveWallSpawner(TileSpawner ReferenceTileSpawner, Vector2Int Direction, Vector2Int Rotation) { //Check if everything is set if (ReferenceTileSpawner == null || Direction == null || Rotation == null || ReferenceTileSpawner.WallSpawnerDict == null) { return(false); } //Check if direction is parallel to Rotation if (!(Direction == Rotation || Direction == Rotation * -1)) { return(false); } //Check if structure is set if (ReferenceTileSpawner.Structure == null) { return(false); } //Finally check if the spot is already occupied by another wallSpawner return(ReferenceTileSpawner.WallSpawnerDict[Direction] == null); }
private void Start() { tileSpawner = FindObjectOfType <TileSpawner>(); // 플레이어 배치 TileIndex startIdx = tileSpawner.GetStartIndex(); float tileWidth = tileSpawner.GetTileWidth(); float tileHeight = tileSpawner.GetTileHeight(); // 플레이어 배치 좌표 계산 Vector3 startPos = new Vector3(); startPos.x = startIdx.x * tileWidth; startPos.y = startIdx.y * tileHeight; playerObj = Instantiate(PlayerPrefab, startPos, Quaternion.identity); dunPlayer = playerObj.GetComponent <DungeonPlayer>(); dunPlayer.SetIndex(startIdx); // 카메라에 추적대상 설정 FindObjectOfType <DungeonCamera>().SetTarget(dunPlayer.GetAnchor()); }
public void RevealAroundCoordinate(Vector3Int coordinate) { if (tileSpawner == null) { SetPlayerSightRadius(); tileSpawner = gameObject.GetComponent <TileSpawner>(); } coordinate = new Vector3Int(coordinate.x + playerOffSetX, coordinate.y + playerOffSetY, coordinate.z); int circleRadiusInCells = playerSightRadiusInCells; int r2 = circleRadiusInCells * circleRadiusInCells; float circleRadius = (float)circleRadiusInCells + 0.5f; for (int x = -circleRadiusInCells; x <= circleRadiusInCells; x++) { int y = (int)(Mathf.Sqrt(r2 - x * x) + 0.5); // reveal 1st and 2nd quadrant RevealTile(coordinate.x + x, coordinate.y + y); ClearCircle(x, y, coordinate); // reveal 3rd and 4th quadrant RevealTile(coordinate.x + x, coordinate.y - y); ClearCircle(x, -y, coordinate); } for (int y = -circleRadiusInCells; y <= circleRadiusInCells; y++) { int x = (int)(Mathf.Sqrt(r2 - y * y) + 0.5); // reveal 1st and 4th quadrant RevealTile(coordinate.x + x, coordinate.y + y); ClearCircle(x, y, coordinate, true); // reveal 2nd and 3rd quadrant RevealTile(coordinate.x - x, coordinate.y + y); ClearCircle(-x, y, coordinate, true); } }
private void Start() { rb = GetComponent <Rigidbody>(); cameraFollow = FindObjectOfType <SmoothFollow>(); tileSpawner = FindObjectOfType <TileSpawner>(); }
//Main constructor, Makes a room based on a structure instance public Room(Structure Structure) { this.Height = Structure.Height; this.Width = Structure.Width; this.TileArray = new Tile[Width, Height]; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { //Adds grass tiles with no block or actor. TileArray[x, y] = new GrassTile(this, x, y); } } //Goes through every TileSpawner in the structure for (int x = 0; x < Structure.Width; x++) { for (int y = 0; y < Structure.Height; y++) { TileSpawner TileSpawner = Structure.TileSpawnerArray[x, y]; //TileSpawner at (x,y) Tile NewTile = TileSpawner.SpawnTile(this, x, y, this.TileArray[x, y].WallDict); //Creates a new tile based on TileSpawner //Create a new actor at the tile based on ActorSpawner if (TileSpawner.ActorSpawner != null) { TileSpawner.ActorSpawner.SpawnActor(NewTile); } //Create a new block at the tile based on BlockSpawner if (TileSpawner.BlockSpawner != null) { TileSpawner.BlockSpawner.SpawnBlock(NewTile); } //The WallSpawners to the left and bottom of the tile WallSpawner LeftWallSpawner = TileSpawner.WallSpawnerDict[Vector2Int.left]; WallSpawner DownWallSpawner = TileSpawner.WallSpawnerDict[Vector2Int.down]; //Spawn a wall to the left based on LeftWallSpawner if (LeftWallSpawner != null) { LeftWallSpawner.SpawnWall(NewTile, Vector2Int.left); } //Spawn a wall to the bottom based on DownWallSpawner if (DownWallSpawner != null) { DownWallSpawner.SpawnWall(NewTile, Vector2Int.down); } //Walls on the top and right are only spawned on the border //Otherwise walls would be initialized twice if (x == Structure.Width - 1) { WallSpawner RightWallSpawner = TileSpawner.WallSpawnerDict[Vector2Int.right]; if (RightWallSpawner != null) { RightWallSpawner.SpawnWall(NewTile, Vector2Int.right); } } if (y == Structure.Height - 1) { WallSpawner UpWallSpawner = TileSpawner.WallSpawnerDict[Vector2Int.up]; if (UpWallSpawner != null) { UpWallSpawner.SpawnWall(NewTile, Vector2Int.up); } } } } }
void Start() { tile = startTile; tileSpawner = FindObjectOfType <TileSpawner>(); }