Ejemplo n.º 1
0
    //void OnCollisionEnter(Collision collision)
    //{
    //    if(!following && collision.gameObject.name == "Player")
    //    {
    //        Leader leader = collision.gameObject.GetComponent<Leader>();
    //        Transform targ;
    //        if (leader.line.Count == 0)
    //        {
    //            targ = leader.transform;
    //        }
    //        else
    //        {
    //            targ = leader.line.Last.Value.transform;
    //        }
    //        target.target = targ;
    //        leader.line.AddLast(this);
    //        following = true;

    //        CreateFriend.i.AttemptFriend(gameObject, new List<GameObject>());
    //    }
    //}

    public void AttemptFollow(GameObject player)
    {
        UnitData uD = GetComponent <UnitData>();

        if (!following && uD.alive)
        {
            Leader       leader       = player.GetComponentInParent <Leader>();
            CreateFriend createFriend = player.GetComponentInParent <CreateFriend>();
            Transform    targ;
            if (leader.line.Count == 0)
            {
                targ = player.transform;
            }
            else
            {
                targ = leader.line.Last.Value.transform;
            }
            target.target = targ;
            leader.line.AddLast(this);
            following = true;
            createFriend.SpawnHeart(this.transform);
            FollowerListingManager.i.AddFriend(gameObject);
        }

        if (!uD.alive)
        {
            CreateFriend.i.AttemptFriend(gameObject, GameObject.FindObjectOfType <Leader>().line);
        }
    }