예제 #1
0
    IEnumerator createTail()
    {
        creatingTail = true;
        yield return(new WaitForSeconds(0.5f));

        if (back == null || back.activeSelf == false)
        {
            if (back == null || back.activeSelf == false)
            {
                tail = TailPool.getTail();
                tail.transform.localScale = new Vector3(0, 0, 0);
                tail.transform.position   = gameObject.transform.position;
                if (gameObject.GetComponent <EnemyBack>() != null && tail != null)
                {
                    gameObject.GetComponent <EnemyBack>().back = tail;
                    tail.GetComponent <EnemyTail>().front      = gameObject;
                }
                yield return(new WaitForSeconds(0.05f));

                for (int i = 0; i < 22; i++)
                {
                    if (tail != null)
                    {
                        tail.transform.localScale += new Vector3(0.005f, 0.005f, 0.005f);
                        yield return(new WaitForSeconds(0.01f));
                    }
                }
            }
        }


        creatingTail = false;
    }
예제 #2
0
    public IEnumerator attachCreature()
    {
        tempBack = mainHead.GetComponent <EnemyHead>().back;
        if (tempBack != null)
        {
            for (int i = 0; i < 50; i++)
            {
                if (tempBack.GetComponent <EnemyBack>().back != null)
                {
                    if (tempBack.GetComponent <EnemyBack>().back.GetComponent <EnemyTail>() != null)
                    {
                        tempTail = tempBack.GetComponent <EnemyBack>().back;
                        break;
                    }
                    tempBack = tempBack.GetComponent <EnemyBack>().back;
                }
                else
                {
                    break;
                }
            }
        }
        attachingCreature = true;
        yield return(new WaitForSeconds(0.8f));

        tempBack.GetComponent <EnemyBack>().back = back;
        back.GetComponent <EnemyBack>().front    = tempBack;
        TailPool.goInPool(tempTail);
        HeadPool.goHeadInPool(gameObject);
    }
예제 #3
0
    void Update()
    {
        speed = EnemyHead.speed / 10.0f;


        if (front != null)
        {
            transform.position = Vector3.Lerp(transform.position, front.transform.position, speed);
            moveDirection      = front.transform.position - transform.position;
            if (moveDirection != Vector3.zero)
            {
                float angle = Mathf.Atan2(-moveDirection.x, moveDirection.y) * Mathf.Rad2Deg;
                transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
            }
        }
        if (front == null || front.activeSelf == false)
        {
            TailPool.goInPool(gameObject);
        }
    }