Ejemplo n.º 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;
    }
Ejemplo n.º 2
0
 // Update is called once per frame
 void LateUpdate()
 {
     if (mActive && !mParticles.IsAlive())
     {
         PoolController.ReleaseAuto(transform);
     }
 }
Ejemplo n.º 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);
                 * }*/
            }
        }
Ejemplo n.º 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);
            }
Ejemplo n.º 7
0
        void DoDespawn()
        {
            if (despawnCallback != null)
            {
                despawnCallback(gameObject);
            }

            PoolController.ReleaseAuto(transform);
        }
Ejemplo n.º 8
0
    void Awake()
    {
        mPool = M8.PoolController.CreatePool(poolName);
        mPool.AddType(template, poolCapacity, poolCapacity);

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

        ApplyParams();
    }
Ejemplo n.º 9
0
        public static void ReleaseByGroup(string group, Transform entity)
        {
            PoolController pc = GetPool(group);

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

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

            if (pc != null)
            {
                pc.Release(pdc);
            }
        }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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;
    }
Ejemplo n.º 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;
        }
    }
Ejemplo n.º 18
0
        public static void ReleaseAuto(PoolDataController poolCtrl)
        {
            PoolController pc = GetPool(poolCtrl.group);

            if (pc != null)
            {
                pc.Release(poolCtrl);
            }
            else
            {
                poolCtrl.gameObject.SetActive(false);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 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;
    }
Ejemplo n.º 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));
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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();
    }
Ejemplo n.º 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;
    }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 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
        }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 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;
    }
Ejemplo n.º 30
0
 public void Release()
 {
     PoolController.ReleaseAuto(this);
 }