Ejemplo n.º 1
0
 void Update()
 {
     if (FinishingGrid() && !inCollision)
     {
         transform.position = RandomDirVelo.Round2NearestPosFullTile(transform);
         curDir             = RandomDirVelo.GetPossibleNewDir(transform);
         velocity           = Direction.GetVector3ByDirection(curDir);
     }
 }
Ejemplo n.º 2
0
    IEnumerator Detour(GameObject collisionGameObject)
    {
        inCollision = true;

        transform.position = RandomDirVelo.Round2NearestPosFullTile(transform);
        curDir             = RandomDirVelo.GetPossibleNewDir(transform);
        velocity           = Direction.GetVector3ByDirection(curDir);

        inCollision = false;
        yield return(null);
    }
Ejemplo n.º 3
0
    IEnumerator Detour(GameObject collisionGameObject)
    {
        inCollision        = true;
        transform.position = RandomDirVelo.Round2NearestPosFullTile(transform);

        curDir   = RandomDirVelo.GetPossibleNewDir(transform);
        velocity = Direction.GetVector3ByDirection(curDir);

        for (float i = 0; i < 1; i += moveSpeed * Time.deltaTime)
        {
            yield return(new WaitForSeconds(Time.deltaTime));
        }

        inCollision = false;
    }
Ejemplo n.º 4
0
    IEnumerator move()
    {
        while (true)
        {
            if (!inCollision)
            {
                float moveTileNum = Mathf.Ceil(Random.Range(0, 3));

                curDir   = RandomDirVelo.GetPossibleNewDir(transform);
                velocity = Direction.GetVector3ByDirection(curDir);

                for (float i = 0; i < moveTileNum; i += Time.deltaTime * moveSpeed)
                {
                    yield return(new WaitForFixedUpdate());
                }
                velocity           = Vector3.zero;
                transform.position = RandomDirVelo.Round2NearestPosFullTile(transform);

                yield return(new WaitForSeconds(waitingTime));
            }
        }
    }
Ejemplo n.º 5
0
 void Start()
 {
     transform.position = RandomDirVelo.Round2NearestPosFullTile(transform);
     originalPosition   = transform.position;
     trapInStatic       = true;
 }