Ejemplo n.º 1
0
    void checkColls(Vector3 pos)
    {
        var colls = Physics2D.OverlapCircleAll(transform.position + pos, 0.1f);

        foreach (var item in colls)
        {
            if (item.tag == "Path")
            {
                if (!item.GetComponent <Path_Object>().isSet)
                {
                    nextObject = item.gameObject.GetComponent <Path_Object>();
                    nextObject.setColliderToOff(this);
                    nextObject.isSet = true;
                    nextObject.Check();
                }
            }
        }
    }
Ejemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (!moveAfterPath)
     {
         transform.position = Vector3.Lerp(transform.position, transform.position + dir, time);
         if (transform.position.x >= positionStart.x + MaximumMove)
         {
             dir.x *= -1;
         }
         if (transform.position.x <= positionStart.x - MaximumMove)
         {
             dir.x *= -1;
         }
         if (transform.position.y >= positionStart.y + MaximumMove)
         {
             dir.y *= -1;
         }
         if (transform.position.y <= positionStart.y - MaximumMove)
         {
             dir.y *= -1;
         }
     }
     else
     {
         if (isStarted)
         {
             if ((pathOBJ.nextObject == null && !RepeatPath && !isBackwards) || (pathOBJ.lastObject == null && !RepeatPath && isBackwards))
             {
                 return;
             }
             if ((pathOBJ.nextObject == null && RepeatPath && !isBackwards) || (pathOBJ.lastObject == null && RepeatPath && isBackwards))
             {
                 isBackwards = !isBackwards;
             }
             if (transform.position.x >= pathOBJ.transform.position.x - platformThreshold && transform.position.x <= pathOBJ.transform.position.x + platformThreshold &&
                 transform.position.y >= pathOBJ.transform.position.y - platformThreshold && transform.position.y <= pathOBJ.transform.position.y + platformThreshold)
             {
                 pathOBJ = isBackwards ? pathOBJ.lastObject:pathOBJ.nextObject;
             }
             transform.position = Vector3.MoveTowards(transform.position, pathOBJ.transform.position, time);
         }
     }
 }
Ejemplo n.º 3
0
 void Start()
 {
     //GameManager.instance.onEntityLoad += OnEntityLoad;
     isStarted     = startFromBeginning;
     positionStart = transform.position;
     if (moveAfterPath)
     {
         if (pathOBJ == null)
         {
             var gb = Instantiate(pathPrefab, transform.position, Quaternion.identity);//GameManager.instance.levelLoader.InstantiateColorOBJ(new Color(50 / 255f, 10 / 255f, 50 / 255f), new Vector2(transform.position.x, transform.position.y - 0.01f));
             spawn   = gb;
             pathOBJ = gb.GetComponent <Path_Object>();
             if (!isCompleteCircle)
             {
                 pathOBJ.setColliderToOff(null);
                 pathOBJ.isSet = true;
             }
             pathOBJ.Check();
         }
     }
 }
Ejemplo n.º 4
0
 public void setColliderToOff(Path_Object lastOBJ)
 {
     coll.enabled = false;
     GetComponent <SpriteRenderer>().color = Color.red;
     lastObject = lastOBJ;
 }