예제 #1
0
    private void Start()
    {
        model = this.transform.GetChild(0).gameObject;
        if (model == null)
        {
            Debug.LogWarning("Model není správně nastaven");
        }
        animator = GetComponentInChildren <Animator>();
        if (animator == null)
        {
            Debug.LogWarning("Animator není správně nastaven");
        }
        orderMachine = GetComponentInParent <Order_machine>();
        if (orderMachine == null)
        {
            Debug.LogWarning("OrderMachine není správně nastaven");
        }
        HardBoundaries hb = GameObject.Find("#Units").GetComponent <HardBoundaries>();

        if (hb == null)
        {
            Debug.LogWarning("Jednotka nemá určené hard boundaries");
        }
        else
        {
            hb.AddManualy(this.transform);
        }
    }
예제 #2
0
    private void Start()
    {
        Joystick = GameObject.Find("#Joystick").GetComponent <bl_Joystick>();
        if (Joystick == null)
        {
            Debug.LogWarning("Joystick není správně nastaven");
        }
        model = this.transform.GetChild(0).gameObject;
        if (model == null)
        {
            Debug.LogWarning("Model není správně nastaven");
        }
        animator = GetComponentInChildren <Animator>();
        if (animator == null)
        {
            Debug.LogWarning("Animator není správně nastaven");
        }
        rb = this.GetComponent <Rigidbody2D>();
        if (rb == null)
        {
            Debug.LogWarning("Rigidbody není správně nastaven");
        }
        HardBoundaries hb = GameObject.Find("#Units").GetComponent <HardBoundaries>();

        if (hb == null)
        {
            Debug.LogWarning("Jednotka nemá určené hard boundaries");
        }
        else
        {
            hb.AddManualy(this.transform);
        }
    }
예제 #3
0
    private void Start()
    {
        //UNIT INICIALIZATION
        Joystick = GameObject.Find("#Joystick").GetComponent <bl_Joystick>();
        if (Joystick == null)
        {
            Debug.LogWarning("Joystick není správně nastaven");
        }
        model = this.transform.GetChild(0).gameObject;
        if (model == null)
        {
            Debug.LogWarning("Model není správně nastaven");
        }
        animator = GetComponentInChildren <Animator>();
        if (animator == null)
        {
            Debug.LogWarning("Animator není správně nastaven");
        }
        rb = this.GetComponent <Rigidbody2D>();
        if (rb == null)
        {
            Debug.LogWarning("Rigidbody není správně nastaven");
        }
        HardBoundaries hb = GameObject.Find("#Units").GetComponent <HardBoundaries>();

        if (hb == null)
        {
            Debug.LogWarning("Jednotka nemá určené hard boundaries");
        }
        else
        {
            hb.AddManualy(this.transform);
        }



        //BOIDS INICIALIZATION
        this.gameObject.name = Random.Range(0, 10000000) + " " + this.gameObject.name;        //unique name for diferentiation from self

        float xv = Random.Range(-boundaries.x, boundaries.x);
        float yv = Random.Range(-boundaries.y, boundaries.y);

        velocity = new Vector2(xv, yv).normalized;
        //this.name = "Boid" + Random.Range(0, 1000000);                //units has their own naming convention
        //float x = Random.Range(-boundaries.x, boundaries.x);          //unit is given fixed initial position
        //float y = Random.Range(-boundaries.y, boundaries.y);          //unit is given fixed initial position
        //this.transform.position = new Vector2(x, y);
    }