Esempio n. 1
0
    public void AddDragGroup(DragGroup group)
    {
        SoundManager.instance.PlayOneShot(SoundManager.instance.counterUpdates);
        // add to end
        CreatureCtrl[]      children       = group.GetComponentsInChildren <CreatureCtrl>();
        ConvertedNestCtrl[] convertedNests = group.GetComponentsInChildren <ConvertedNestCtrl>();
        int startingSeatIdx        = _creatures.Count;
        int convertedNestIdxOffset = 0;

        for (int i = 0; i < children.Length; ++i)
        {
            /*children[i].transform.localPosition = getMountByIdx(++startingSeatIdx).transform.localPosition;
             * children[i].transform.SetParent(this.transform, false);
             * children[i].prevLocalPosition = children[i].transform.localPosition;*/

            // reparent creature
            children[i].transform.SetParent(this.transform, true);
            children[i].prevLocalPosition = getMountByIdx(++startingSeatIdx).transform.localPosition;

            // have chicken drop to 'ground level'
            //children[i].SetBool("dragged", true);
            children[0].transform.localScale = ChickenSettings.instance.dropScale;    // new Vector3(0.66f, 2.5f, 1f);
            children[i].StartMove(new Vector3(children[0].transform.position.x, -2.5f, children[0].transform.position.z), true, ChickenSettings.instance.dropSpeed, true);
            children[i].onMoveEnd = Creature_onFellToGround;


            // insure dropped creatures have no anim active but 'idle'
            children[i].SetBool("inColumn", false);
            children[i].SetBool("fullTen", false);
            children[i].SetBool("inCar", true);
            children[i].SetTrigger("reset");

            // sort added creatures in reverse order
            children[i].inner.GetComponent <SpriteRenderer>().sortingOrder = Mathf.Abs(startingSeatIdx - maxCreatures) - convertedNestIdxOffset;
            if (children[i].GetComponent <ConvertedNestCtrl>() != null)
            {
                convertedNestIdxOffset += 2;
                children[i].inner.FindChild("nestsChicken_11").GetComponent <SpriteRenderer>().sortingOrder = Mathf.Abs(startingSeatIdx - maxCreatures) - convertedNestIdxOffset + 2;
                children[i].inner.FindChild("nestBG").GetComponent <SpriteRenderer>().sortingOrder          = Mathf.Abs(startingSeatIdx - maxCreatures) - convertedNestIdxOffset;
                for (int j = 1; j <= 10; ++j)
                {
                    children[i].inner.FindChild("nestsChicken_" + j.ToStringLookup()).GetComponent <SpriteRenderer>().sortingOrder = Mathf.Abs(startingSeatIdx - maxCreatures) + 1 - convertedNestIdxOffset;
                }
            }
            _creatures.Add(children[i]);
        }
    }
Esempio n. 2
0
    public void AddDragGroup(DragGroup group)
    {
        SoundManager.instance.PlayOneShot(SoundManager.instance.counterUpdates);

        CreatureCtrl[] children        = group.GetComponentsInChildren <CreatureCtrl>();
        int            startingSeatIdx = this.GetComponentsInChildren <CreatureCtrl>().Length;

        for (int i = 0; i < children.Length; ++i)
        {
            children[i].transform.localPosition = mSeats[startingSeatIdx++].transform.localPosition;
            children[i].transform.SetParent(seats.transform, false);
        }

        if (startingSeatIdx == size)
        {
            isFilled = true;
        }
    }