예제 #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;
         }
     }
 }