// Use this for initialization void Start() { lanes = this.GetComponentInParent <Lanes>(); currentLane = this.GetComponent <HasLane>(); moduleGrid = this.GetComponent <ModuleGrid>(); Reposition(); }
// Update is called once per frame void Update() { if (Time.time >= nextSpawnTime) { UpdateSpawnTime(); HasLane spawnedMonster = Instantiate(monster, transform.position, transform.rotation, lanes.transform); spawnedMonster.Lane = lanes.RandomLane(); float yPosition = lanes.CenterOfLane(spawnedMonster.Lane) + Random.Range(-lanePositionJitter, lanePositionJitter) * lanes.LaneHeight; spawnedMonster.transform.position += new Vector3(0, yPosition, 0); } }
protected void Start() { this.grid = new Module[maxDepth, height]; lanes = GetComponentInParent <Lanes>(); lane = GetComponent <HasLane>(); BoxCollider2D collider = GetComponent <BoxCollider2D>(); collider.size = new Vector2(lanes.LaneHeight, lanes.LaneHeight * Height); Debug.Log(collider.size); Debug.Log(lanes.LaneHeight); collider.offset = new Vector2(0, collider.size.y / 2f - lanes.LaneHeight / 2f); }
private void Start() { this.sideConfig = new Dictionary <Side, SideConfig>(); this.sideConfig[Side.Left] = this.leftSide; this.sideConfig[Side.Right] = this.rightSide; this.sideConfig[Side.Top] = this.topSide; this.sideConfig[Side.Bottom] = this.bottomSide; lanes = GetComponentInParent <Lanes>(); castleGrid = FindObjectOfType <ModuleGrid>(); // TODO don't use FindObjectOfType, generally lane = GetComponent <HasLane>(); BoxCollider2D collider = GetComponent <BoxCollider2D>(); collider.size = new Vector2(lanes.LaneHeight, lanes.LaneHeight); }