Exemple #1
0
 void setChildrensVarsInit()
 {
     foreach (Transform l_Child in gameObject.transform)
     {
         BallToShoot l_Ball = l_Child.GetComponent <BallToShoot>();
         l_Ball.ballColor = baseColor;
     }
 }
Exemple #2
0
    void setBallTarget()
    {
        setAllTargetsColor();

        ballTarget   = pathTargets[pathTargets.Count - 1].GetComponent <BallToShoot>();
        targetRender = ballTarget.gameObject.GetComponent <Renderer>();
        targetRender.material.color = targetColor;

        ballTarget.isTarget = true;
    }
Exemple #3
0
    bool createPath()
    {
        pathTargets.Clear();

        //Select 1rst path point
        BallToShoot l_RandomObject = targets[Random.Range(0, targets.Count)].GetComponent <BallToShoot>();

        pathTargets.Add(l_RandomObject.gameObject);

        //Next path points until fill list
        for (int i = 0; i < pathSize; ++i)
        {
            //Reference to last obj
            BallToShoot l_PrevObj = l_RandomObject;
            //Next point on neightbours
            l_RandomObject = l_PrevObj.neightbours[Random.Range(0, l_PrevObj.neightbours.Count)].GetComponent <BallToShoot>();

            //Check if is on list

            //Neightbours count
            int l_Neightbours = l_PrevObj.neightbours.Count;
            while (true)
            {
                //If no neightbours, fails
                if (l_Neightbours <= 0)
                {
                    return(false);
                }

                //If invalid point
                if (pathTargets.Contains(l_RandomObject.gameObject) || (pathTargets.Contains(ballTarget.gameObject) && ballTarget != null))
                {
                    l_Neightbours--;
                    l_RandomObject = l_PrevObj.neightbours[Random.Range(0, l_PrevObj.neightbours.Count)].GetComponent <BallToShoot>();
                }
                //If correct
                else
                {
                    break;
                }
            }
            //add point
            pathTargets.Add(l_RandomObject.gameObject);
        }
        StartCoroutine(createPathLines());
        return(true);
    }
Exemple #4
0
    IEnumerator createPathLines()
    {
        destroyChildrensOnList();

        BallToShoot l_PathPoint = pathTargets[0].GetComponent <BallToShoot>();

        for (int i = 1; i < pathTargets.Count; ++i)
        {
            BallToShoot l_NextPoint = pathTargets[i].GetComponent <BallToShoot>();
            l_PathPoint.createLineToPoint(l_NextPoint.gameObject, lineColor);
            if (i != pathTargets.Count - 1)
            {
                yield return(new WaitForSecondsRealtime(0.35f));
            }
            l_PathPoint = l_NextPoint;
        }
        setBallTarget();

        yield return(new WaitForSecondsRealtime(0.2f));

        destroyChildrensOnList();
    }