public ObstacleTilemap SpawnObstacle() { ObstacleTilemap obst = obstSpawn.SpawnNext(); obst.Setup(); obstSpawn.PositionObstacle(obst, currentPosition + obst.GetExtent()); return(obst); }
private void OnTriggerExit2D(Collider2D collision) { GameObject obj = collision.gameObject; if (obj.CompareTag(Meta_Tags.floor)) { Platform platform = obj.GetComponent <Platform>(); platform.Setdown(); } else if (obj.CompareTag(Meta_Tags.obstacle)) { ObstacleTilemap obst = obj.GetComponent <ObstacleTilemap>(); obst.Setdown(); } }
/// <summary> /// Spawn the next obstacle /// </summary> /// <param name="pos"></param> /// <returns></returns> public ObstacleTilemap SpawnNext() { ObstacleTilemap obstacle = Spawn(this.nextObst); //Modify the weight so it does not occor too many times in a row. pool[this.nextObst].ApplyWeightMod(); if (weightQueue.Count >= currentLevel.data.obstacles.Count) { pool[weightQueue[qIndex]].ResetWeight(); weightQueue.RemoveAt(qIndex); qIndex++; if (qIndex >= currentLevel.data.obstacles.Count) { qIndex = 0; } } CalculateTotalWeight(); weightQueue.Add(this.nextObst); this.nextObst = Roll(); return(obstacle); }
/// <summary> /// Spawn a specific obstacle /// </summary> /// <param name="data"></param> /// <param name="pos"></param> /// <returns></returns> public ObstacleTilemap Spawn(ObstacleData obData) { ObstacleTilemap obstacle = GetPool(obData); return(obstacle); }
/// <summary> /// Position the obstacle according to it's data. /// </summary> /// <param name="obData"></param> /// <param name="obstacle"></param> public void PositionObstacle(ObstacleTilemap obstacle, float pos) { //Adjust position by obstacle center pos -= obstacle.GetCenter(); obstacle.transform.position = new Vector3(pos, (float)(platformData.GroundLevel + 1.5), 0); }