public void Restart()
    {
        if (container)
        {
            //Place all the point away from camera sight
            for (int i = 0; i < points.Count; i++)
            {
                points[i].transform.position = new Vector2(-999, -999);
            }
        }
        //Delete all the vertices points
        if (!(figure is null))
        {
            figure.Clear();
        }

        //Obtain data for the new configuration
        ChangeVertices(true);
        ChangeLength(true);
        ChangeSpeed();
        ChangeProportion(true);

        counter = 0;
        CounterUI.GetComponent <Text>().text = "Iteration: " + counter;
        figure   = new Figure(n, side, prefabPoint);
        vertices = figure.GetVertices();

        //Start position is random choosen
        currentPositionPoint = new Vector2(Random.Range(-side, side), Random.Range(-side, side)) * 1.5f;
        //Instantiate/set position of the point at position:currentPositionPoint
        DrawPoint(currentPositionPoint);
    }
示例#2
0
    IEnumerator Dead()
    {
        if (bigEnoughToExplode())
        {
            Instantiate(zombieExplosion, transform.position, Quaternion.identity);
        }
        else
        {
            GetComponent <Animation>().Play("ZombieDead");
            yield return(new WaitForSeconds(GetComponent <Animation>().GetClip("ZombieDead").length));
        }

        Destroy(gameObject);

        CounterUI.Add(1);

        yield return(0);
    }
    void DrawPoint(Vector2 posVertex)
    {
        GameObject tmp;

        if (counter < points.Count)
        {
            //The pool is still full so just set the position the the point at index counter
            points[counter].transform.position = posVertex;
        }
        else
        {
            //The pool is empty. Create a new object and add it to the pool
            tmp      = Instantiate(prefabPoint, posVertex, Quaternion.identity);
            tmp.name = "Point " + counter;
            tmp.transform.localScale = Vector3.one / 2;
            tmp.transform.SetParent(container.transform);
            points.Add(tmp);
        }
        //Update counter
        counter++;
        //Update UI
        CounterUI.GetComponent <Text>().text = "Iteration: " + counter;
    }
示例#4
0
 public void OnDead()
 {
     fsm.ChangeState((int)state.Dead);
     CounterUI.Add(1);
 }
示例#5
0
 public void Awake()
 {
     main = this;
 }