예제 #1
0
    void Awake()
    {
        int blobCapacity = GameData.instance.blobSpawnCount;

        mBlobActives = new M8.CacheList <Blob>(blobCapacity);

        //setup pool
        mPool = M8.PoolController.CreatePool(poolGroup);
        for (int i = 0; i < templateGroups.Length; i++)
        {
            var grp = templateGroups[i];
            for (int j = 0; j < grp.templates.Length; j++)
            {
                mPool.AddType(grp.templates[j], blobCapacity, blobCapacity);
            }
        }

        //generate spawn points
        mSpawnPts = new Vector2[spawnPointsRoot.childCount];
        for (int i = 0; i < spawnPointsRoot.childCount; i++)
        {
            mSpawnPts[i] = spawnPointsRoot.GetChild(i).position;
        }

        if (spawnPointsShuffle)
        {
            M8.ArrayUtil.Shuffle(mSpawnPts);
        }

        mCurSpawnPtInd = 0;
    }
예제 #2
0
 // Update is called once per frame
 void LateUpdate()
 {
     if (mActive && !mParticles.IsAlive())
     {
         PoolController.ReleaseAuto(transform);
     }
 }
예제 #3
0
        /// <summary>
        /// Explicit call to remove entity.
        /// </summary>
        public virtual void Release()
        {
            if (poolData != null)
            {
#if POOLMANAGER
                transform.parent = PoolManager.Pools[poolData.group].group;
                PoolManager.Pools[poolData.group].Despawn(transform);
#else
                PoolController.ReleaseByGroup(poolData.group, transform);
#endif
            }
            else
            {
                //just disable the object, really no need to destroy
                OnDespawned();
                gameObject.SetActive(false);

                /*
                 * if(gameObject.activeInHierarchy)
                 *  StartCoroutine(DestroyDelay());
                 * else {
                 *  Destroy(gameObject);
                 * }*/
            }
        }
예제 #4
0
    public GridEntity Spawn(GridCell cell, GridCell cellSize)
    {
        GridEntity ret = null;

        //ensure we can spawn on given cell info
        var container = GridEditController.instance.entityContainer;

        if (container.IsPlaceable(cell, cellSize, null))
        {
            if (!mPool)
            {
                mPool = M8.PoolController.CreatePool(poolGroup);
                mPool.AddType(template, poolCapacity, poolCapacity);
            }

            if (mSpawnParms == null)
            {
                mSpawnParms = new M8.GenericParams();
            }

            mSpawnParms[GridEntity.parmData]      = this;
            mSpawnParms[GridEntity.parmCellIndex] = cell;
            mSpawnParms[GridEntity.parmCellSize]  = cellSize;

            ret = mPool.Spawn <GridEntity>(template.name, name, container.root, mSpawnParms);
        }

        return(ret);
    }
            public void Spawn()
            {
                Transform t = PoolController.Spawn(grp, type, type + id, null, pos, rot);

                SceneSerializer ss = t.GetComponent <SceneSerializer>();

                ss.__SetID(id);
            }
            public void Spawn()
            {
                var spawned = PoolController.SpawnFromGroup(grp, type, type + id, null, pos, rot, null);

                SceneSerializer ss = spawned.GetComponent <SceneSerializer>();

                ss.__SetID(id);
            }
예제 #7
0
        void DoDespawn()
        {
            if (despawnCallback != null)
            {
                despawnCallback(gameObject);
            }

            PoolController.ReleaseAuto(transform);
        }
예제 #8
0
    void Awake()
    {
        mPool = M8.PoolController.CreatePool(poolName);
        mPool.AddType(template, poolCapacity, poolCapacity);

        mActives = new M8.CacheList <M8.PoolDataController>(activeCount);

        ApplyParams();
    }
예제 #9
0
        public static void ReleaseByGroup(string group, Transform entity)
        {
            PoolController pc = GetPool(group);

            if (pc != null)
            {
                pc.Release(entity);
            }
        }
예제 #10
0
        public static void Expand(string group, string type, int amount)
        {
            PoolController pc = GetPool(group);

            if (pc != null)
            {
                pc.Expand(type, amount);
            }
        }
예제 #11
0
        public static void ReleaseFromGroup(string group, PoolDataController pdc)
        {
            PoolController pc = GetPool(group);

            if (pc != null)
            {
                pc.Release(pdc);
            }
        }
예제 #12
0
    void Awake()
    {
        mPool = M8.PoolController.CreatePool(poolGroup);

        for (int i = 0; i < templates.Length; i++)
        {
            var template = templates[i];
            mPool.AddType(template.name, template.template, template.capacity, template.capacity);
        }
    }
예제 #13
0
        /// <summary>
        /// Group name is based on the name of the game object with the PoolController component
        /// </summary>
        public static PoolController GetPool(string group)
        {
            PoolController ctrl = null;

            if (mControllers != null)
            {
                mControllers.TryGetValue(group, out ctrl);
            }

            return(ctrl);
        }
예제 #14
0
        public static PoolDataController SpawnFromGroup(string group, string type, string name, Transform toParent, Vector3 position, Quaternion rotation, GenericParams parms)
        {
            PoolController pc = GetPool(group);

            if (pc != null)
            {
                return(pc._Spawn(type, name, toParent, position, rotation, parms));
            }

            return(null);
        }
예제 #15
0
        public static PoolDataController SpawnFromGroup(string group, string type, string name, Transform toParent, Vector2 position, GenericParams parms)
        {
            PoolController pc = GetPool(group);

            if (pc != null)
            {
                return(pc._Spawn(type, name, toParent, new Vector3(position.x, position.y, 0f), null, parms));
            }

            return(null);
        }
예제 #16
0
    protected override void OnInstanceInit()
    {
        base.OnInstanceInit();

        mGoblinPoolCtrl = M8.PoolController.GetPool(goblinPool);
        mGoblinPoolCtrl.AddType(goblinTemplate, goblinPts.Length, goblinPts.Length);
        mGoblins = new M8.CacheList <UnitEntity>(goblinPts.Length);

        var dragGuideGO = GameObject.FindGameObjectWithTag(tagDragGuide);

        mDragGuide = dragGuideGO.GetComponent <DragToGuideWidget>();

        titleAnim.gameObject.SetActive(false);
        motionIllustrationAnim.gameObject.SetActive(false);

        block1ForceNetGO.SetActive(false);
        block1ForceGravityGO.SetActive(false);
        block1ForceBalancedGO.SetActive(false);
        block1ForceUnbalancedGO.SetActive(false);
        block1ForceKnightGO.SetActive(false);
        block1ForceGoblinGO.SetActive(false);
        block1NetForceDirRoot.gameObject.SetActive(false);
        block1NetForceNoneGO.SetActive(false);

        block2ForcesGO.SetActive(false);
        block2ForceNetGO.SetActive(false);
        block2ForceGravityGO.SetActive(false);
        block2ForceBalancedGO.SetActive(false);
        block2ForceUnbalancedGO.SetActive(false);
        block2NetForceDirRoot.gameObject.SetActive(false);
        block2NetForceNoneGO.SetActive(false);

        interfaceRootGO.SetActive(false);

        princessGO.SetActive(false);

        victoryGO.SetActive(false);

        block1.gameObject.SetActive(false);
        block1.transform.position = block1StartPt.position;

        for (int i = 0; i < block1Wheels.Length; i++)
        {
            var suspension = block1Wheels[i].suspension;
            suspension.frequency       = block1WheelsAirFreq;
            block1Wheels[i].suspension = suspension;
        }

        block2.gameObject.SetActive(false);
        block2.transform.position = block2StartPt.position;

        signalUnitDragEnd.callback += OnSignalUnitDragEnd;
    }
예제 #17
0
    private void Init()
    {
        if (!mIsInit)
        {
            mPool = M8.PoolController.CreatePool(poolGroup);
            mPool.AddType(template, capacity, capacity);

            points = new M8.CacheList <PointData>(capacity);

            mIsInit = true;
        }
    }
예제 #18
0
        public static void ReleaseAuto(PoolDataController poolCtrl)
        {
            PoolController pc = GetPool(poolCtrl.group);

            if (pc != null)
            {
                pc.Release(poolCtrl);
            }
            else
            {
                poolCtrl.gameObject.SetActive(false);
            }
        }
예제 #19
0
        public static Transform Spawn(string group, string type, string name, Transform toParent, Vector3 position)
        {
            PoolController pc = GetPool(group);

            if (pc != null)
            {
                return(pc.Spawn(type, name, toParent, position));
            }
            else
            {
                return(null);
            }
        }
예제 #20
0
    public void Fill(MixedNumber[] numbers)
    {
        if (!mPool)
        {
            mPool = M8.PoolController.CreatePool(cardPoolGroup);
            mPool.AddType(cardTemplate, cardPoolCapacity, cardPoolCapacity);
        }

        if (cards != null)
        {
            Clear();
        }
        else
        {
            cards = new CardWidget[slotAnchors.Length];
        }

        M8.ArrayUtil.Shuffle(numbers);

        count = numbers.Length;
        if (count > slotAnchors.Length)
        {
            count = slotAnchors.Length;
        }

        for (int i = 0; i < count; i++)
        {
            mCardParms[CardWidget.parmWholeEnabled]   = cardWholeEnabled;
            mCardParms[CardWidget.parmNumber]         = numbers[i];
            mCardParms[CardWidget.parmCanDragInside]  = false;
            mCardParms[CardWidget.parmCanDragOutside] = true;
            mCardParms[CardWidget.parmFractionVisual] = false;
            mCardParms[CardWidget.parmCardDrop]       = this;
            mCardParms[CardWidget.parmCardDropIndex]  = i;

            var newCard = mPool.Spawn <CardWidget>(cardTemplate.name, "", null, mCardParms);

            newCard.transform.SetParent(slotAnchors[i], false);
            newCard.transform.localPosition = Vector3.zero;

            cards[i] = newCard;

            slotAnchors[i].gameObject.SetActive(true);
        }

        for (int i = count; i < slotAnchors.Length; i++)
        {
            slotAnchors[i].gameObject.SetActive(false);
        }
    }
예제 #21
0
    void Awake()
    {
        mSpawnPts = new M8.CacheList <Transform>(root.childCount);
        for (int i = 0; i < root.childCount; i++)
        {
            mSpawnPts.Add(root.GetChild(i));
        }

        mPlantActives = new M8.CacheList <M8.PoolDataController>(root.childCount);

        mPoolCtrl = M8.PoolController.CreatePool(poolName);
        mPoolCtrl.AddType(template, mSpawnPts.Capacity, mSpawnPts.Capacity);

        signalTreeChanged.callback += OnScaleTreeChange;
    }
예제 #22
0
        public static T SpawnFromGroup <T>(string group, string type, string name, Transform toParent, Vector3 position, GenericParams parms)
        {
            PoolController pc = GetPool(group);

            if (pc != null)
            {
                var spawned = pc._Spawn(type, name, toParent, position, null, parms);
                if (spawned)
                {
                    return(spawned.GetComponent <T>());
                }
            }

            return(default(T));
        }
예제 #23
0
        public static Transform Spawn(string group, string type, string name, Transform toParent, Vector2 position)
        {
            PoolController pc = GetPool(group);

            if (pc != null)
            {
                Transform t = pc.Spawn(type, name, toParent, position);
                Vector3   p = t.localPosition;
                p.z             = 0.0f;
                t.localPosition = p;
                return(t);
            }
            else
            {
                return(null);
            }
        }
예제 #24
0
    public override void Init()
    {
        base.Init();

        if (!mPool)
        {
            if (entityTemplate)
            {
                mPool = M8.PoolController.CreatePool(entityPoolGroup);
                mPool.AddType(entityTemplate, entityCount, entityCount);

                mActiveUnits = new M8.CacheList <M8.EntityBase>(entityCount);
            }
        }

        mParms[parmDragWorld] = cursorWorld;

        UpdateState();
    }
예제 #25
0
    void Awake()
    {
        mPool = M8.PoolController.CreatePool(poolGroup);
        mPool.AddType(connectTemplate, capacity, capacity);

        //setup group
        mGroupActives = new M8.CacheList <Group>(groupCapacity);
        mGroupCache   = new M8.CacheList <Group>(groupCapacity);

        //fill up cache
        for (int i = 0; i < groupCapacity; i++)
        {
            mGroupCache.Add(new Group());
        }

        signalListenBlobDragBegin.callback += OnBlobDragBegin;
        signalListenBlobDragEnd.callback   += OnBlobDragEnd;
        signalListenBlobDespawn.callback   += OnBlobDespawn;

        signalListenBlobConnectDelete.callback += OnBlobConnectDelete;
    }
예제 #26
0
        public static void ReleaseAuto(GameObject entity)
        {
            //NOTE: don't really need to destroy
            PoolDataController pdc = entity.GetComponent <PoolDataController>();

            if (pdc != null)
            {
                PoolController pc = GetPool(pdc.group);
                if (pc != null)
                {
                    pc.Release(pdc);
                }
                else
                {
                    entity.SetActive(false);
                }
            }
            else
            {
                entity.SetActive(false);
            }
        }
예제 #27
0
        public static T Spawn <T>(string spawnGroup, string typeName, Vector3 position) where T : EntityBase
        {
#if POOLMANAGER
            SpawnPool pool = PoolManager.Pools[spawnGroup];

            Transform spawned = pool.Spawn(pool.prefabs[typeName]);
            T         ent     = spawned != null?spawned.GetComponent <T>() : null;

            if (ent != null)
            {
                ent.transform.position = position;

                //add pool data controller
            }

            return(ent);
#else
            Transform spawned = PoolController.Spawn(spawnGroup, typeName, typeName, null, position);
            T         ent     = spawned != null?spawned.GetComponent <T>() : null;

            return(ent);
#endif
        }
예제 #28
0
    void Awake()
    {
        mPool = M8.PoolController.CreatePool(cardPoolGroup);
        mPool.AddType(cardTemplate, cardPoolCapacity, cardPoolCapacity);

        answerInput.submitCallback  += OnInputSubmit;
        operandSlots.updateCallback += OnSlotUpdated;

        if (activeGO)
        {
            activeGO.SetActive(false);
        }

        if (dragInstruct)
        {
            mDragInstructEnabled = true;
        }

        if (dragInstructDialogGO)
        {
            dragInstructDialogGO.SetActive(false);
        }
    }
예제 #29
0
    protected override void OnInstanceInit()
    {
        base.OnInstanceInit();

        //spawn stuff
        int enterCount = spawnEnterPointsRoot.childCount;

        mPool = M8.PoolController.CreatePool(spawnPoolGroup);
        mPool.AddType(spawnTemplate, enterCount, enterCount);

        mEnterPoints = new Vector2[enterCount];
        for (int i = 0; i < mEnterPoints.Length; i++)
        {
            mEnterPoints[i] = spawnEnterPointsRoot.GetChild(i).position;
        }

        mSpawns = new M8.CacheList <SpawnData>(enterCount);

        mSpawnParm = new M8.GenericParams();
        mSpawnParm[UnitVelocityMoveController.parmDir] = Vector2.left;

        //setup boulder stuff
        mBoulderUnitParms[UnitEntity.parmPosition] = (Vector2)boulderUnit.transform.position;
        mBoulderUnitParms[UnitEntity.parmNormal]   = Vector2.up;

        boulderUnit.gameObject.SetActive(false);
        //

        interactionGO.SetActive(false);
        proceedGO.SetActive(false);

        playUI.interactable = false;

        //signals
        signalSpawnGoalReached.callback += OnSignalSpawnReachGoal;
        signalProceed.callback          += OnSignalProceed;
    }
예제 #30
0
 public void Release()
 {
     PoolController.ReleaseAuto(this);
 }