Exemplo n.º 1
0
    public void Split()
    {
        GameObject enemyspawn1 = GameObject.Instantiate(Resources.Load("Prefabs/MainCanvas/Enemy")) as GameObject;

        Destroy(enemyspawn1.GetComponent <Enemy>());
        Splitter split = enemyspawn1.AddComponent <Splitter>() as Splitter;

        enemyspawn1.transform.SetParent(Dial.spawnLayer, false);
        GameObject enemyspawn2 = GameObject.Instantiate(Resources.Load("Prefabs/MainCanvas/Enemy")) as GameObject;

        Destroy(enemyspawn2.GetComponent <Enemy>());
        Splitter split2 = enemyspawn2.AddComponent <Splitter>() as Splitter;

        enemyspawn2.transform.SetParent(Dial.spawnLayer, false);

        split.groupAddedToBonus  = groupAddedToBonus;
        split2.groupAddedToBonus = groupAddedToBonus;

        split.size  = size - 1;
        split2.size = size - 1;
        if (size == 3)
        {
            split.SetSrcFileName("splitter2");
            split2.SetSrcFileName("splitter2");
            split.SetTrackLane(1);
            split2.SetTrackLane(-1);
            split.imtheleftone = true;
        }
        else if (size == 2)
        {
            split.SetSrcFileName("splitter3");
            if (imtheleftone)
            {
                split.SetTrackLane(1);
                split2.SetTrackLane(0);
                split2.OverrideMoverLane(-2f);
                split.imtheleftone = true;
            }
            else
            {
                split.SetTrackLane(0);
                split2.SetTrackLane(-1);
                split.OverrideMoverLane(2f);
                split.imtheleftone = true;
            }
            split2.SetSrcFileName("splitter3");
        }
        split.InitializePartnersForSomeReason();
        split2.InitializePartnersForSomeReason();

        foreach (Splitter s in partners)
        {
            if (s == this)
            {
                continue;
            }
            s.AddPartner(split);
            s.AddPartner(split2);
            split.AddPartner(s);
            split2.AddPartner(s);
        }
        AddPartner(split);
        AddPartner(split2);
        split.AddPartner(split2);
        split2.AddPartner(split);

        //split.SetProgress(progress);
        //split2.SetProgress(progress);
        split.SetTrackID(trackID);
        split2.SetTrackID(trackID);

        /*if(imtheleftone){
         *      split.talktome = true;
         *      split2.talktome = true;
         * }*/
        split.GetComponent <RectTransform>().anchoredPosition  = rt.anchoredPosition;
        split2.GetComponent <RectTransform>().anchoredPosition = rt.anchoredPosition;
        split.StartMoving();
        split2.StartMoving();
        split.justStarted  = true;
        split2.justStarted = true;
        //split.Bounce (true);
        //split2.Bounce (false);

        PlayDead();
    }