protected override void Awake() { base.Awake(); //initialize data/variables mHeatCollides = new M8.CacheList <HeatController.Contact>(heatCollideCapacity); mMoveCtrl = GetComponentInChildren <EntityHeroMoveController>(); mMoveCtrl.collisionEnterCallback += OnMoveCollisionEnter; mMoveCtrl.collisionExitCallback += OnMoveCollisionExit; mMoveCtrl.triggerEnterCallback += OnMoveTriggerEnter; mMoveCtrl.triggerExitCallback += OnMoveTriggerExit; mStartPos = transform.position; if (spawnAnim) { spawnAnim.gameObject.SetActive(false); } if (deathAnim) { deathAnim.gameObject.SetActive(false); } }
protected virtual void Awake() { if (!dirHolder) { dirHolder = transform; } mBody = GetComponent <Rigidbody2D>(); mColls = new M8.CacheList <CollideInfo>(maxColls); mContactPoints = new ContactPoint2D[maxColls]; //mTopBottomColCos = Mathf.Cos(sphereCollisionAngle * Mathf.Deg2Rad); mSlopLimitCos = Mathf.Cos(slopLimit * Mathf.Deg2Rad); mAboveLimitCos = Mathf.Cos(aboveLimit * Mathf.Deg2Rad); mColl = GetComponent <Collider2D>(); if (mColl != null) { if (mColl is CircleCollider2D) { mRadius = ((CircleCollider2D)mColl).radius; } else if (mColl is CapsuleCollider2D) { mCapsuleColl = mColl as CapsuleCollider2D; mRadius = mCapsuleColl.size.y * 0.5f; } } mDefaultSpeedCap = speedCap; }
void Awake() { mEntity = GetComponent <M8.EntityBase>(); if (mEntity) { mEntity.spawnCallback += OnEntitySpawn; mEntity.releaseCallback += OnEntityRelease; } mBody = GetComponent <Rigidbody2D>(); mTriggerContacts = new M8.CacheList <Contact>(contactCapacity); mCollisionContacts = new M8.CacheList <Contact>(contactCapacity); //setup display if (displaySpriteColorRefs.Length > 0) { mDisplaySpriteColorDefaults = new Color[displaySpriteColorRefs.Length]; for (int i = 0; i < displaySpriteColorRefs.Length; i++) { if (displaySpriteColorRefs[i]) { mDisplaySpriteColorDefaults[i] = displaySpriteColorRefs[i].color; } } } for (int i = 0; i < displays.Length; i++) { if (displays[i].activeGO) { displays[i].activeGO.SetActive(false); } } }
void Awake() { cardTemplate.gameObject.SetActive(false); //setup cards var itemGrp = GridEditController.instance.levelData; var items = itemGrp.items; cards = new M8.CacheList <GridEntityCardWidget>(items.Length); for (int i = 0; i < items.Length; i++) { var itm = items[i]; var cardWidget = Instantiate(cardTemplate, container); cardWidget.Setup(itm); cardWidget.gameObject.SetActive(true); cards.Add(cardWidget); } RefreshCount(); signalListenEntitySizeChanged.callback += OnEntitySizeChanged; signalListenMapChanged.callback += OnMapChanged; GridEditController.instance.editChangedCallback += OnEditModeChanged; }
/// <summary> /// This will group up entities with the same data if they are neighboring each other /// </summary> public List <List <GridEntity> > GenerateEntityGroups() { var entGroups = new List <List <GridEntity> >(); var ents = new M8.CacheList <GridEntity>(entities); while (ents.Count > 0) { var entList = new List <GridEntity>(); var ent = ents.RemoveLast(); if (ent.data == _doodadEntityData) //exclude doodads { continue; } entList.Add(ent); //check neighbors GroupAddEntities(ent, ents, entList); entGroups.Add(entList); } return(entGroups); }
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; }
void Awake() { mSpawnedPathogens = new M8.CacheList <EntityCommon>(spawnAnchors.Length); if (entityDeathWatch) { entityDeathWatch.releaseCallback += OnEntityDeathWatchRelease; } }
void Awake() { mPool = M8.PoolController.CreatePool(poolName); mPool.AddType(template, poolCapacity, poolCapacity); mActives = new M8.CacheList <M8.PoolDataController>(activeCount); ApplyParams(); }
private void Init() { if (!mIsInit) { mPool = M8.PoolController.CreatePool(poolGroup); mPool.AddType(template, capacity, capacity); points = new M8.CacheList <PointData>(capacity); mIsInit = true; } }
public override bool Evaluate(ShapeProfile shapeProfile) { var equalCount = 0; var sides = shapeProfile.sideLengths; if (sides.Length % 2 != 0) { return(false); } var hSideCount = sides.Length / 2; if (mPairs == null || mPairs.Count != hSideCount) { mPairs = new M8.CacheList <Pair>(hSideCount); } else { mPairs.Clear(); } for (int i = 0; i < sides.Length; i++) { //make sure these are not already paired var indA = i; if (IsPaired(indA)) { continue; } var indB = i < sides.Length - 1 ? i + 1 : 0; if (IsPaired(indB)) { continue; } var sideLenA = Mathf.RoundToInt(sides[indA]); var sideLenB = Mathf.RoundToInt(sides[indB]); if (sideLenA == sideLenB) { mPairs.Add(new Pair { indA = indA, indB = indB }); equalCount++; } } return(equalCount >= count); }
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; }
void Awake() { if (!_controller) { _controller = GetComponent <GridController>(); } //init containers var cellSize = _controller.cellSize; entities = new M8.CacheList <GridEntity>(cellSize.row * cellSize.col); }
protected override void Awake() { base.Awake(); //initialize data/variables mArms = new M8.CacheList <EntityPhagocyteTentacle>(targetCapacity); if (animator) { animator.takeCompleteCallback += OnAnimatorComplete; } }
protected override void OnInstanceInit() { base.OnInstanceInit(); mIsPointerActive = false; if (pointerGO) { pointerGO.SetActive(false); } if (pointer) { pointer.gameObject.SetActive(false); } for (int i = 0; i < pointerDisplays.Length; i++) { pointerDisplays[i].SetActive(false); } for (int i = 0; i < stages.Length; i++) { stages[i].gameObject.SetActive(false); } //grab mucus form spawner var spawnerMucusForms = new List <EntitySpawnerMucusForm>(); for (int i = 0; i < spawnerActivates.Length; i++) { if (spawnerActivates[i]) { var spawnerMucusForm = spawnerActivates[i].GetComponent <EntitySpawnerMucusForm>(); if (spawnerMucusForm) { spawnerMucusForms.Add(spawnerMucusForm); } } } mSpawnerMucusForms = spawnerMucusForms.ToArray(); // mVictimCount = 0; mCellWallsAlive = new M8.CacheList <EntityCommon>(cellWalls.Length); mEnemies = new M8.CacheList <EntityCommon>(enemyActiveCacheCapacity); mModalTimeResultParams = new M8.GenericParams(); }
void Awake() { for (int i = 0; i < spawnPts.Length; i++) { spawnPts[i].Init(); } detectTrigger.enterCallback += OnDetectTriggerEnter; mTargetPotentialEntities = new M8.CacheList <EntityCommon>(launchCapacity); detectTrigger.gameObject.SetActive(false); }
void Awake() { mDisplayActives = new M8.CacheList <GameObject>(capacity); mDisplayInactives = new M8.CacheList <GameObject>(capacity); for (int i = 0; i < capacity; i++) { var newGO = Object.Instantiate <GameObject>(template); newGO.transform.SetParent(templateRoot); newGO.SetActive(false); mDisplayInactives.Add(newGO); } }
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; }
public void Init(string group, Transform inactiveHolder) { if (string.IsNullOrEmpty(name) && template) { name = template.name; } this.mInactiveHolder = inactiveHolder; mNameHolder = 0; mActives = new CacheList <PoolDataController>(maxCapacity); mAvailable = new CacheList <PoolDataController>(maxCapacity); Expand(group, startCapacity); }
void Awake() { #if UNITY_EDITOR if (!Application.isPlaying) { return; } #endif mBuoyancy = GetComponent <BuoyancyEffector2D>(); mColl = GetComponent <BoxCollider2D>(); mSurfaceBaseLevel = mBuoyancy.surfaceLevel; mSurfaceCache = new M8.CacheList <SurfaceCache>(triggerCacheCapacity); mKillableCache = new M8.CacheList <KillableCache>(triggerCacheCapacity); }
void OnEnable() { mIsLogEnabled = defaultLogEnabled; mIsUnityLogEnabled = defaultUnityLogEnabled; if (mIsUnityLogEnabled) { Application.logMessageReceived += OnUnityLog; } mLogTypeFilters = new CacheList <LogType>(System.Enum.GetValues(typeof(LogType)).Length); for (int i = 0; i < defaultLogTypeFilters.Length; i++) { SetLogFilter(defaultLogTypeFilters[i], true); } //fill in commands from ConsoleClassRegisterAttribute RegisterCommandsFromClasses(); }
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(); }
void Awake() { if (!templateIsPrefab) { template.gameObject.SetActive(false); } mLogWidgets = new CacheList <ConsoleDisplayUnityUILogWidget>(console.maxLog); mLogCacheWidgets = new CacheList <ConsoleDisplayUnityUILogWidget>(console.maxLog); //fill in logs RefreshLogs(); RefreshErrorToggle(); RefreshWarningToggle(); RefreshInfoToggle(); console.refreshCallback += RefreshLogs; }
void Awake() { if (block) { block.modeChangedCallback += OnBlockChangeMode; mIsTriggerActive = false; //allow block's mode to determine when to activate trigger } else { mIsTriggerActive = true; //activate trigger on start } mCollContacts = new Collider2D[connectCapacity]; mReceivers = new M8.CacheList <Contact>(connectCapacity); mTriggerBoxColl = GetComponent <BoxCollider2D>(); UpdateTriggerCollider(); }
protected override void OnInstanceInit() { if (max <= 0) { max = sfx.Length; } mSfx = new Dictionary <string, SoundData>(sfx.Length); foreach (SoundData sd in sfx) { mSfx.Add(sd.name, sd); } //generate pool mAvailable = new CacheList <SoundPlayer>(max); for (int i = 0; i < max; i++) { mAvailable.Add(CreateSource(i)); } }
private void InitShapes() { var gos = GameObject.FindGameObjectsWithTag(GameData.instance.tagShape); var shapeList = new List <ShapeProfile>(); for (int i = 0; i < gos.Length; i++) { var go = gos[i]; var shape = go.GetComponent <ShapeProfile>(); if (shape) { shapeList.Add(shape); } } mShapes = shapeList.ToArray(); mShapesCollected = new M8.CacheList <ShapeProfile>(mShapes.Length); }
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; }
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; }
void Awake() { var levelCtrl = LevelController.instance; levelCtrl.shapeCollectedCallback += OnShapeCollected; var count = levelCtrl.shapes.Length; mCollectItems = new M8.CacheList <CollectCounterItem>(count); var baseLen = (count - 1) * space; if (count > 1) { var s = baseSpriteRender.size; s.x = baseLen; baseSpriteRender.size = s; } else { baseSpriteRender.gameObject.SetActive(false); } var x = -baseLen * 0.5f; for (int i = 0; i < count; i++) { var itm = Instantiate(itemTemplate, itemRoot); itm.transform.localPosition = new Vector3(x, 0f, 0f); mCollectItems.Add(itm); x += space; } itemTemplate.gameObject.SetActive(false); }
void Awake() { if (isMain && main == null) { main = this; } if (!root) { root = transform; } mModals = new Dictionary <string, IModalController>(); //grab modals in root, and register for (int i = 0; i < root.childCount; i++) { //TODO: ModalController dependency, maybe just look for IModalController var ctrl = root.GetChild(i).GetComponent <ModalController>() as IModalController; if (ctrl != null) { //prevent duplicate if (!mModals.ContainsKey(ctrl.id)) { ctrl.Init(); mModals.Add(ctrl.id, ctrl); ctrl.SetOwner(this); } } } //instantiate prefabs, put them in root, and register for (int i = 0; i < prefabs.Length; i++) { if (!prefabs[i]) { continue; } //TODO: ModalController dependency, maybe just look for IModalController var prefabCtrl = prefabs[i] as IModalController; //prevent duplicate if (prefabCtrl == null || mModals.ContainsKey(prefabCtrl.id)) { continue; } ModalController ctrl = Instantiate(prefabs[i], root, false); var ctrlTrans = ctrl.transform; ctrlTrans.localPosition = Vector3.zero; ctrlTrans.localRotation = Quaternion.identity; ctrlTrans.localScale = Vector3.one; //init and add var iCtrl = ctrl as IModalController; iCtrl.Init(); mModals.Add(iCtrl.id, iCtrl); iCtrl.SetOwner(this); } int maxModalCount = mModals.Count; mModalStack = new Stack <IModalController>(maxModalCount); mCommands = new Queue <Command>(maxModalCount); mModalCache = new CacheList <IModalController>(maxModalCount); }
/// <summary> /// Returns how much was added /// </summary> private int GroupAddEntities(GridEntity srcEnt, M8.CacheList <GridEntity> ents, List <GridEntity> group) { var addedCount = 0; var _cellInd = new GridCell(); var _cellSize = new GridCell(); int curInd = ents.Count - 1; while (curInd >= 0) { var checkEnt = ents[curInd]; if (checkEnt.data != srcEnt.data) { curInd--; continue; } //check with top/bottom extended _cellInd = srcEnt.cellIndex; _cellInd.row -= 1; _cellSize = srcEnt.cellSize; _cellSize.row += 2; if (GridCell.IsIntersectFloor(_cellInd, _cellSize, checkEnt.cellIndex, checkEnt.cellSize)) { ents.RemoveAt(curInd); group.Add(checkEnt); addedCount++; //check this entity with the rest var subAddCount = GroupAddEntities(checkEnt, ents, group); if (subAddCount > 0) { addedCount += subAddCount; curInd = ents.Count - 1; } else { curInd--; } continue; } //check with left/right extended _cellInd = srcEnt.cellIndex; _cellInd.col -= 1; _cellSize = srcEnt.cellSize; _cellSize.col += 2; if (GridCell.IsIntersectFloor(_cellInd, _cellSize, checkEnt.cellIndex, checkEnt.cellSize)) { ents.RemoveAt(curInd); group.Add(checkEnt); addedCount++; //check this entity with the rest var subAddCount = GroupAddEntities(checkEnt, ents, group); if (subAddCount > 0) { addedCount += subAddCount; curInd = ents.Count - 1; } else { curInd--; } continue; } curInd--; } return(addedCount); }