Ejemplo n.º 1
0
    void Awake()
    {
        entity.spawnCallback   += OnEntitySpawn;
        entity.releaseCallback += OnEntityRelease;

        mEntityMucusForm = entity as EntityMucusForm;
    }
Ejemplo n.º 2
0
    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
    }
Ejemplo n.º 3
0
    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();
    }
Ejemplo n.º 4
0
    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();
    }