Esempio n. 1
0
    public virtual void OnTriggerEnter(Collider col)
    {
        switch (col.tag)
        {
        case "element":
            //	print("saw element");
            elementaction eleref = col.GetComponent <elementaction>();
            if (eleref.purestate && !eleref.captured)
            {
                print("found one!!!");
                enemycontrolref.newfind = true;
                enemycontrolref.importantobjs.Add(eleref.gameObject);
                //	airef.importanttargets.Add(col.transform);
            }

            break;

        case "corecenter":
            //	print("saw corecenter");
            centralaction cenref = col.GetComponent <centralaction>();
            if (col.GetComponent <centralaction>().fullpower)
            {
                print("found a center");
                enemycontrolref.newfind = true;
                enemycontrolref.importantobjs.Add(cenref.gameObject);

                //	airef.importanttargets.Add(col.transform);
            }
            break;
        }
    }
Esempio n. 2
0
    public virtual void breakapart()
    {
        rbody.constraints = RigidbodyConstraints.None;
        float ranx = Random.Range(-5, 5);
        float rany = Random.Range(-5, 5);
        float ranz = Random.Range(-5, 5);

        rbody.AddForce(ranx, rany, ranz);
        int childs = transform.childCount;

        for (int i = 0; i < childs; i++)
        {
            elementaction ele = transform.GetChild(0).GetComponent <elementaction>();
            transform.GetChild(i).gameObject.SetActive(true);
            ele.breakfromcentral();
        }
        centralstate = 0;
    }
Esempio n. 3
0
    public void elementchange()
    {
        elementaction eleref = importanttargets[0].GetComponent <elementaction>();

        if (eleref.purestate)
        {
            eleref.corruptelement();
            TimePerImportantLocation = 0;
            enemystate = 4;
        }
        else
        {
            enemystate = 0;
            if (areacontrolref.importantobjs.Find(obj => obj.gameObject == importanttargets[0]) != null)
            {
                areacontrolref.importantobjs.Remove(importanttargets[0].gameObject);
            }
            importanttargets.Remove(importanttargets[0]);
            print("already captured");
        }
    }
Esempio n. 4
0
    public void movetoimportantobject()
    {
        float         distance = Vector3.Distance(transform.position, importanttargets[0].position);
        elementaction eleref   = importanttargets[0].GetComponent <elementaction>();

        if (distance > worldsafedistance && (eleref.purestate && !eleref.captured))
        {
            transform.LookAt(importanttargets[0].position);
            transform.position = Vector3.MoveTowards(transform.position, importanttargets[0].position, movespeed * Time.deltaTime);

            if (busy)
            {
                enemystate = 5;
                return;
            }
        }
        else
        {
            enemystate = 2;
        }
    }