private void spawnChild()
    {
        int     childSpawnNodeCounter   = parentSpawnNode;
        Vector3 positionBeforeSpawnNode = transform.position;
        float   totalDistanceFromParent = 0;
        float   distanceToNextNode      = Vector3.Distance(positionBeforeSpawnNode, ownerArrowController.arrow.Nodes [childSpawnNodeCounter].Position.vector3());
        float   childSpawnDistance      = (childrenSpawnTime [0] - spawnTime) * ownerArrowController.speed;

        while (totalDistanceFromParent + distanceToNextNode < childSpawnDistance)
        {
            totalDistanceFromParent += distanceToNextNode;
            positionBeforeSpawnNode  = ownerArrowController.arrow.Nodes [childSpawnNodeCounter].Position.vector3();
            ++childSpawnNodeCounter;
            distanceToNextNode = Vector3.Distance(positionBeforeSpawnNode, ownerArrowController.arrow.Nodes [childSpawnNodeCounter].Position.vector3());
        }
        GameObject newChild    = Instantiate(GameController.getInstance().followKeyPrefab);
        FollowKey  childScript = newChild.GetComponent <FollowKey> ();

        childScript.spawnTime = childrenSpawnTime [0];
        if (childrenSpawnTime.Count > 0)
        {
            childScript.setChildrenSpawnTime(childrenSpawnTime.GetRange(1, childrenSpawnTime.Count - 1));
        }
        else
        {
            childScript.setChildrenSpawnTime(new List <float> ());
        }
        childScript.setOwnerArrow(ownerArrow);
        childScript.parentSpawnNode = childSpawnNodeCounter;
        newChild.transform.position = (childSpawnDistance - totalDistanceFromParent) *
                                      Vector3.Normalize(ownerArrowController.arrow.Nodes [childSpawnNodeCounter].Position.vector3() - positionBeforeSpawnNode) + positionBeforeSpawnNode;
        childSpawned = true;
    }
    private GameObject getFollowKeyInstance(int keySpawnNodeCounter)
    {
        GameObject newkey    = Instantiate(GameController.getInstance().followKeyPrefab);
        FollowKey  followKey = newkey.GetComponent <FollowKey> ();

        followKey.setChildrenSpawnTime(arrow.Keys [keyCounter].getChildrenSpawnTimes());
        followKey.setOwnerArrow(transform);
        followKey.setParentSpawnNode(keySpawnNodeCounter);
        return(newkey);
    }
Beispiel #3
0
 void Start()
 {
     parentFollowKey = GetComponentInParent <FollowKey> ();
 }