Пример #1
0
    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);
        }
    }
Пример #2
0
    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();
    }
Пример #3
0
 void Awake()
 {
     if (!entity)
     {
         entity = GetComponent <M8.EntityBase>();
     }
 }
Пример #4
0
    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;
        }
    }
Пример #5
0
    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);
            }
        }
    }
Пример #6
0
 void OnEntityStateChanged(M8.EntityBase ent)
 {
     for (int i = 0; i < data.Length; i++)
     {
         data[i].Apply(ent.state);
     }
 }
Пример #7
0
    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;
            }
        }
    }
Пример #8
0
    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();
    }
Пример #9
0
 void OnEntitySpawned(M8.EntityBase ent)
 {
     for (int i = 0; i < data.Length; i++)
     {
         data[i].Hide();
     }
 }
Пример #10
0
    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;
    }
Пример #11
0
 void OnEntityStateChanged(M8.EntityBase ent)
 {
     if (ent.state == stateFrom)
     {
         StartCoroutine(DoStateChange());
     }
 }
Пример #12
0
    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;
        }
    }
Пример #13
0
    void OnBlockSpawned(M8.EntityBase ent)
    {
        block.modeChangedCallback += OnBlockModeChanged;

        GameMapController.instance.modeChangeCallback += OnGameModeChanged;

        UpdateCollider();
    }
Пример #14
0
    void OnBlockSpawned(M8.EntityBase ent)
    {
        block.modeChangedCallback      += OnBlockModeChanged;
        block.dimensionChangedCallback += OnBlockDimensionChanged;

        GameMapController.instance.modeChangeCallback          += OnGameModeChanged;
        GameMapController.instance.blockSelectedChangeCallback += OnGameBlockSelectedChange;
    }
Пример #15
0
    void OnAttachDespawn(M8.EntityBase ent)
    {
        mEntAttach.releaseCallback -= OnAttachDespawn;
        mEntAttach = null;

        mJoint.enabled       = false;
        mJoint.connectedBody = null;
    }
Пример #16
0
 void OnEntityStateChanged(M8.EntityBase ent)
 {
     if (unit.state == moveState)
     {
         unit.physicsEnabled = true;
         unit.body.bodyType  = RigidbodyType2D.Dynamic;
     }
 }
Пример #17
0
    void OnEntityRelease(M8.EntityBase ent)
    {
        ent.releaseCallback -= OnEntityRelease;

        mActiveUnits.Remove(ent);

        UpdateState();
    }
Пример #18
0
 void Awake()
 {
     mEnt = GetComponent <M8.EntityBase>();
     if (mEnt)
     {
         mEnt.setStateCallback += OnEntityStateChanged;
     }
 }
Пример #19
0
 void OnHeroChangeState(M8.EntityBase ent)
 {
     if ((EntityState)ent.state != EntityState.Normal)
     {
         mIsDragging      = false;
         mIsStopOnLanding = false;
         HideInterfaceDisplays();
     }
 }
Пример #20
0
 void OnTargetReleased(M8.EntityBase ent)
 {
     //fail safe if not despawned by released somehow
     RemoveTarget((UnitEntity)ent);
     if (mActiveTargets.Count == 0)
     {
         OnFinish();
     }
 }
Пример #21
0
    public void Gather(M8.EntityBase target, Vector2 dir, float dist, int aScore)
    {
        mTarget    = target;
        mTargetDir = dir;
        mDist      = dist;
        mScore     = aScore;

        state = (int)EntityState.Gather;
    }
Пример #22
0
    void OnEntitySpawn(EntitySpawner aSpawner, M8.EntityBase ent)
    {
        if (growth > 0)
        {
            var mucusForm = (EntityMucusForm)ent;

            mucusForm.SetGrow(growth);
        }
    }
Пример #23
0
    void Awake()
    {
        if (!entity)
        {
            entity = GetComponent <M8.EntityBase>();
        }

        entity.setStateCallback += OnEntityStateChanged;
    }
Пример #24
0
 void OnArmChangeState(M8.EntityBase ent)
 {
     switch ((EntityState)ent.state)
     {
     case EntityState.Gathered:
         ReleaseArm((EntityPhagocyteTentacle)ent);
         break;
     }
 }
Пример #25
0
 void OnMucusStateChanged(M8.EntityBase ent)
 {
     switch ((EntityState)ent.state)
     {
     case EntityState.Gathered:
         Grow();
         break;
     }
 }
Пример #26
0
    void OnBlockDespawned(M8.EntityBase ent)
    {
        ClearCallbacks();

        if (mRout != null)
        {
            StopCoroutine(mRout);
            mRout = null;
        }
    }
Пример #27
0
 void OnTargetChangeState(M8.EntityBase ent)
 {
     //targetStateDespawn
     if (ent.state == targetStateDespawn)
     {
         RemoveTarget((UnitEntity)ent);
         if (mActiveTargets.Count == 0)
         {
             OnFinish();
         }
     }
 }
Пример #28
0
    void OnBlockDespawned(M8.EntityBase ent)
    {
        block.modeChangedCallback      -= OnBlockModeChanged;
        block.dimensionChangedCallback -= OnBlockDimensionChanged;

        if (GameMapController.instance)
        {
            GameMapController.instance.modeChangeCallback          -= OnGameModeChanged;
            GameMapController.instance.blockSelectedChangeCallback -= OnGameBlockSelectedChange;
        }

        mIsDragging = false;
    }
Пример #29
0
    void OnEntityStateChanged(M8.EntityBase ent)
    {
        if (mEnt.state == (int)state)
        {
            MissionController.instance.Signal(signal, null);

            if (once)
            {
                mEnt.setStateCallback -= OnEntityStateChanged;
                mEnt = null;
            }
        }
    }
Пример #30
0
 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;
         }
     }
 }