Exemplo n.º 1
0
    private void Awake()
    {
        _rigidbody2D      = GetComponent <Rigidbody2D>();
        _enemy            = GetComponent <Enemy>();
        _screenBoundaries = GetComponent <ScreenBoundaries>();

        Assert.IsNotNull(_rigidbody2D);
        Assert.IsNotNull(_enemy);
        Assert.IsNotNull(_screenBoundaries);
    }
Exemplo n.º 2
0
    void Awake()
    {
        box2D = GetComponent <BoxCollider2D>();

        bottomCorner = ScreenBoundaries.CalcBottomCorner(transform.position);
        topCorner    = ScreenBoundaries.CalcTopCorner(transform.position);

        float addition = box2D.size.x * transform.localScale.x / 2;

        minX = bottomCorner.x + addition;
        maxX = topCorner.x - addition;
    }
Exemplo n.º 3
0
 // Start is called before the first frame update
 void Start()
 {
     boundaries = GetComponent <ScreenBoundaries>();
     mesh       = GetComponent <MeshRenderer>();
     if (target == null)
     {
         if (GameObject.FindWithTag("Player") != null)
         {
             target = GameObject.FindWithTag("Player").GetComponent <Transform>();
         }
     }
     StartCoroutine("FlyerActions");
 }
Exemplo n.º 4
0
    private static ScreenBoundaries CreateScreenBoundaries()
    {
        GameObject SB = new GameObject();

        SB.name = "ScreenBoundaries";
        SB.transform.position   = Vector3.zero;
        SB.transform.localScale = Vector3.one;
        BoxCollider2D boxCollider2D = SB.AddComponent <BoxCollider2D>();

        boxCollider2D.isTrigger = true;
        ScreenBoundaries screenBoundaries = SB.AddComponent <ScreenBoundaries>();

        return(screenBoundaries);
    }
Exemplo n.º 5
0
 // Start is called before the first frame update
 void Start()
 {
     boundaries = GetComponent <ScreenBoundaries>();
     SpawnEnemies();
 }