void Awake() { entity.spawnCallback += OnEntitySpawn; entity.releaseCallback += OnEntityRelease; mEntityMucusForm = entity as EntityMucusForm; }
void Grow() { if (!mSpawnedMucusForm) { //generate a new form Vector2 spawnPos = mucusFormSpawnAt.position; mSpawnedMucusForm = M8.PoolController.SpawnFromGroup <EntityMucusForm>(mucusFormPoolGroup, mucusFormSpawnRef, mucusFormSpawnRef, null, spawnPos, null); } if (mSpawnedMucusForm) { mSpawnedMucusForm.Grow(); //full? if (mSpawnedMucusForm.currentGrowthCount >= mSpawnedMucusForm.stats.growthMaxCount) { if (animator) { animator.Stop(); } if (gatherDisplayRoot) { gatherDisplayRoot.SetActive(false); } } //Debug.Log("growth count: "+mSpawnedMucusForm.currentGrowthCount); } //check if form becomes bigger than us //make our area bigger }
public void Cancel() { if (!mIsActive) { return; } mIsActive = false; //revert all mucus for (int i = 0; i < mMucusGathering.Count; i++) { if (mMucusGathering[i]) { if (mMucusGathering[i].state == (int)EntityState.Gather || mMucusGathering[i].state == (int)EntityState.Gathered) { mMucusGathering[i].SetGather(null); } mMucusGathering[i].setStateCallback -= OnMucusStateChanged; } } mMucusGathering.Clear(); if (mSpawnedMucusForm) { mSpawnedMucusForm.Cancel(); mSpawnedMucusForm = null; } Inactive(); }
public void Release(Vector2 dir, float dist, Bounds bounds) { if (!mIsActive) { return; } mIsActive = false; //revert currently gathering mucuses, release those that are already gathered for (int i = 0; i < mMucusGathering.Count; i++) { if (mMucusGathering[i]) { if (mMucusGathering[i].state == (int)EntityState.Gather) { mMucusGathering[i].SetGather(null); } else if (mMucusGathering[i].state == (int)EntityState.Gathered) { mMucusGathering[i].Release(); } mMucusGathering[i].setStateCallback -= OnMucusStateChanged; } } mMucusGathering.Clear(); //launch mucus form if available if (mSpawnedMucusForm) { mSpawnedMucusForm.Launch(dir, dist, bounds); mSpawnedMucusForm = null; } Inactive(); }