Beispiel #1
0
    void Start()
    {
        is_vibing  = false;
        m_Animator = gameObject.GetComponent <Animator>();

        if (gameObject.GetComponentInChildren <AI_Sensor>())
        {
            ai_sensor       = gameObject.GetComponentInChildren <AI_Sensor>(); //DFS children for the script
            hurtBox         = gameObject.GetComponentInChildren <BoxCollider2D>();
            hurtBox.enabled = false;                                           //turn off the hurt
        }
        else
        {
            Debug.Log("AI not attached to entity: " + this.name);
            Destroy(this.gameObject);
        }
    }
    //basic inherited intitialization that all enemies will use
    protected void Base_Initialize()
    {
        moving_right = false;
        facing_right = false;
        invincible   = false;
        m_Animator   = gameObject.GetComponent <Animator>();

        if (gameObject.GetComponentInChildren <AI_Sensor>())
        {
            ai_sensor = gameObject.GetComponentInChildren <AI_Sensor>();      //DFS children for the script
            hurtBox   = transform.GetChild(1).GetComponent <BoxCollider2D>(); //very hacky dont touch the child order lmao
        }
        else
        {
            Debug.Log("AI not attached to entity: " + this.name);
            GetComponent <SpriteRenderer>().color = Color.red; //sanity check in case ai is bonkered
        }
    }