//Awake is called before Start.
 private void Awake()
 {
     groundOfOne = this;
     //Get and store a reference to the collider2D attached to Ground.
     groundCollider = GetComponent <BoxCollider2D> ();
     //Store the size of the collider along the x axis (its length in units).
     groundHorizontalLength = groundCollider.size.x;
 }
    /// <summary>
    /// Check if the bat has passed the current cave screen
    /// </summary>
    /// <param name="positionX"> The x position of the bat</param>
    /// <returns></returns>
    public bool DidBatPassCave(float positionX)
    {
        RepeatingBackground currentBackground = caveScreens[caveScreenIndex];

        if (positionX > currentBackground.transform.position.x + currentBackground.CaveLength)
        {
            return(true);
        }

        return(false);
    }
示例#3
0
 // Use this for initialization
 void Start()
 {
     RepeatingBackground.setOffsetMultiplier(numSlabs);
     BuildingSlabs        = new List <GameObject> ();
     CurrentSpawnLocation = Vector3.zero;
     for (int i = 0; i < numSlabs; i++)
     {
         GameObject CurrentBlock = Instantiate(BuildingSlab, CurrentSpawnLocation, Quaternion.identity, this.transform) as GameObject;
         CurrentBlock.AddComponent <ScrollingObject> ();
         Vector3 nextSpawnLocation = CurrentBlock.transform.position + offset;
         CurrentSpawnLocation = new Vector3(nextSpawnLocation.x, nextSpawnLocation.y, nextSpawnLocation.z);
         BuildingSlabs.Add(CurrentBlock);
     }
 }
    private void Awake()
    {
        _                      = this;
        backgrounds            = new GameObject[2];
        backgrounds[0]         = transform.GetChild(0).gameObject;
        backgrounds[1]         = transform.GetChild(1).gameObject;
        backgroundsTransforms  = new Transform[backgrounds.Length];
        backgroundsRigidbodies = new Rigidbody2D[backgrounds.Length];
        for (int i = 0; i < backgrounds.Length; i++)
        {
            backgroundsTransforms[i]  = backgrounds[i].GetComponent <Transform>();
            backgroundsRigidbodies[i] = backgrounds[i].GetComponent <Rigidbody2D>();
        }

        BoxCollider2D groundCollider = backgrounds[0].GetComponent <BoxCollider2D> ();

        groundHorizontalLength = groundCollider.size.x;
    }
示例#5
0
 // Use this for initialization
 void Start()
 {
     repeatingBackground = GameObject.FindObjectOfType <RepeatingBackground>();
 }