public void Eat(M8.EntityBase victim, int score) { Vector2 pos = transform.position; Vector2 dest = victim.transform.position; Vector2 dir = dest - pos; float dist = dir.magnitude; if (dist > 0f) { dir /= dist; } var spawnPos = pos + dir * spawnArmRadius; var arm = M8.PoolController.SpawnFromGroup <EntityPhagocyteTentacle>(spawnArmPoolGroup, spawnArmEntityRef, spawnArmEntityRef, null, spawnPos, null); arm.setStateCallback += OnArmChangeState; arm.releaseCallback += OnArmRelease; arm.Gather(victim, dir, dist, score); mArms.Add(arm); if (animator && animator.currentPlayingTakeName == takeNormal) { animator.Play(takeSeek); } }
void OnGhostBlockRelease(M8.EntityBase ent) { if (mBlockGhost == ent) //we shouldn't really get here with an active ghost { mBlockGhost.dimensionChangedCallback -= OnGhostBlockDimensionChanged; mBlockGhost.releaseCallback -= OnGhostBlockRelease; mBlockGhost = null; ClearDragging(); UpdateCount(); } else { for (int i = 0; i < mGhostActives.Count; i++) { if (mGhostActives[i] == ent) { mGhostActives[i].dimensionChangedCallback -= OnGhostBlockDimensionChanged; mGhostActives[i].releaseCallback -= OnGhostBlockRelease; mGhostMatterCount -= mGhostActives[i].matterCount; mGhostActives.RemoveAt(i); UpdateCount(); break; } } } UpdateInteractible(); }
void Awake() { if (!entity) { entity = GetComponent <M8.EntityBase>(); } }
void OnEntityChangeState(M8.EntityBase ent) { mState = (EntityState)ent.state; switch (mState) { case EntityState.Spawn: sprite.gameObject.SetActive(false); break; case EntityState.Normal: case EntityState.Victory: if ((EntityState)ent.prevState == EntityState.Spawn) { mIsGrounded = true; } else { mIsGrounded = heroEntity.moveCtrl.isGrounded; } mMoveState = heroEntity.moveState; mVelY = Mathf.Sign(heroEntity.moveCtrl.localVelocity.y) * velYThreshold; UpdateAnim(); break; } }
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 OnEntityStateChanged(M8.EntityBase ent) { for (int i = 0; i < data.Length; i++) { data[i].Apply(ent.state); } }
void OnEntityStateChanged(M8.EntityBase ent) { if (unit.prevState == state) { if (applyRigidbodyMode) { unit.body.bodyType = mPreviousRigidbodyMode; } } if (unit.state == state) { unit.physicsEnabled = true; mCurVelocity = mDir * mInitSpeed; if (applyRigidbodyMode) { mPreviousRigidbodyMode = unit.body.bodyType; unit.body.bodyType = rigidbodyMode; } if (unit.body.bodyType == RigidbodyType2D.Dynamic) { unit.body.velocity = mCurVelocity; } } }
protected override void OnDespawned() { mBody.velocity = Vector2.zero; mBody.angularVelocity = 0f; mIsForceActive = false; if (mEntAttach) { mEntAttach.releaseCallback -= OnAttachDespawn; mEntAttach = null; } mJoint.connectedBody = null; mBalloonTrans.localRotation = Quaternion.identity; ropeSprite.transform.localRotation = Quaternion.identity; balloonSprite.color = mBalloonSpriteDefaultColor; ropeSprite.color = mRopeSpriteDefaultColor; widgetSprite.color = mWidgetDefaultColor; base.OnDespawned(); }
void OnEntitySpawned(M8.EntityBase ent) { for (int i = 0; i < data.Length; i++) { data[i].Hide(); } }
void OnEntityDeathWatchRelease(M8.EntityBase ent) { //disperse spawned entities if we didn't get a chance to launch if (!mIsLaunched) { mIsLaunched = true; //can no longer launch //set spawned pathogens to wander for (int i = 0; i < mSpawnedPathogens.Count; i++) { if (mSpawnedPathogens[i]) { if (mSpawnedPathogens[i].state != (int)EntityState.Dead) { mSpawnedPathogens[i].state = (int)EntityState.Wander; } mSpawnedPathogens[i].releaseCallback -= OnSpawnedEntityRelease; //no longer need to listen } } mSpawnedPathogens.Clear(); } ent.releaseCallback -= OnEntityDeathWatchRelease; }
void OnEntityStateChanged(M8.EntityBase ent) { if (ent.state == stateFrom) { StartCoroutine(DoStateChange()); } }
IEnumerator DoLaunch(M8.EntityBase cannonEnt) { var unitForceApply = cannonEnt.GetComponent <UnitStateForceApply>(); while (!unitForceApply.unit.physicsEnabled) { yield return(null); } graphControl.tracer.body = unitForceApply.unit.body; graphControl.tracer.Record(); //wait for cannon to end while (unitForceApply.unit.physicsEnabled) { yield return(null); } cameraShaker.Shake(); graphControl.tracer.Stop(); GraphPopulate(true); launchReadyGO.SetActive(true); cannonLaunch.interactable = true; if (mIsShowGraphReminder) { graphReminderGO.SetActive(true); mIsShowGraphReminder = false; } }
void OnBlockSpawned(M8.EntityBase ent) { block.modeChangedCallback += OnBlockModeChanged; GameMapController.instance.modeChangeCallback += OnGameModeChanged; UpdateCollider(); }
void OnBlockSpawned(M8.EntityBase ent) { block.modeChangedCallback += OnBlockModeChanged; block.dimensionChangedCallback += OnBlockDimensionChanged; GameMapController.instance.modeChangeCallback += OnGameModeChanged; GameMapController.instance.blockSelectedChangeCallback += OnGameBlockSelectedChange; }
void OnAttachDespawn(M8.EntityBase ent) { mEntAttach.releaseCallback -= OnAttachDespawn; mEntAttach = null; mJoint.enabled = false; mJoint.connectedBody = null; }
void OnEntityStateChanged(M8.EntityBase ent) { if (unit.state == moveState) { unit.physicsEnabled = true; unit.body.bodyType = RigidbodyType2D.Dynamic; } }
void OnEntityRelease(M8.EntityBase ent) { ent.releaseCallback -= OnEntityRelease; mActiveUnits.Remove(ent); UpdateState(); }
void Awake() { mEnt = GetComponent <M8.EntityBase>(); if (mEnt) { mEnt.setStateCallback += OnEntityStateChanged; } }
void OnHeroChangeState(M8.EntityBase ent) { if ((EntityState)ent.state != EntityState.Normal) { mIsDragging = false; mIsStopOnLanding = false; HideInterfaceDisplays(); } }
void OnTargetReleased(M8.EntityBase ent) { //fail safe if not despawned by released somehow RemoveTarget((UnitEntity)ent); if (mActiveTargets.Count == 0) { OnFinish(); } }
public void Gather(M8.EntityBase target, Vector2 dir, float dist, int aScore) { mTarget = target; mTargetDir = dir; mDist = dist; mScore = aScore; state = (int)EntityState.Gather; }
void OnEntitySpawn(EntitySpawner aSpawner, M8.EntityBase ent) { if (growth > 0) { var mucusForm = (EntityMucusForm)ent; mucusForm.SetGrow(growth); } }
void Awake() { if (!entity) { entity = GetComponent <M8.EntityBase>(); } entity.setStateCallback += OnEntityStateChanged; }
void OnArmChangeState(M8.EntityBase ent) { switch ((EntityState)ent.state) { case EntityState.Gathered: ReleaseArm((EntityPhagocyteTentacle)ent); break; } }
void OnMucusStateChanged(M8.EntityBase ent) { switch ((EntityState)ent.state) { case EntityState.Gathered: Grow(); break; } }
void OnBlockDespawned(M8.EntityBase ent) { ClearCallbacks(); if (mRout != null) { StopCoroutine(mRout); mRout = null; } }
void OnTargetChangeState(M8.EntityBase ent) { //targetStateDespawn if (ent.state == targetStateDespawn) { RemoveTarget((UnitEntity)ent); if (mActiveTargets.Count == 0) { OnFinish(); } } }
void OnBlockDespawned(M8.EntityBase ent) { block.modeChangedCallback -= OnBlockModeChanged; block.dimensionChangedCallback -= OnBlockDimensionChanged; if (GameMapController.instance) { GameMapController.instance.modeChangeCallback -= OnGameModeChanged; GameMapController.instance.blockSelectedChangeCallback -= OnGameBlockSelectedChange; } mIsDragging = false; }
void OnEntityStateChanged(M8.EntityBase ent) { if (mEnt.state == (int)state) { MissionController.instance.Signal(signal, null); if (once) { mEnt.setStateCallback -= OnEntityStateChanged; mEnt = null; } } }
void OnEntityStateChanged(M8.EntityBase ent) { for (int i = 0; i < states.Length; i++) { var dat = states[i]; if (unit.state == dat.state) { unit.physicsEnabled = true; unit.body.bodyType = dat.bodyType; break; } } }