示例#1
0
    public void DoDrop(int groupIndex, Vector3 pos)
    {
        Group dat = groups[groupIndex];

        int r = Random.Range(0, dat.range) + 1;

        if (r <= dat.itemRange)
        {
            string spawnType = null;

            for (int i = 0, max = dat.items.Length, w = 0; i < max; i++)
            {
                ItemData drop = dat.items[i];
                w += drop.weight;

                if (r <= w)
                {
                    spawnType = drop.itemSpawnType;
                    break;
                }
            }

            if (!string.IsNullOrEmpty(spawnType))
            {
                Debug.Log("dropping: " + spawnType);
                mCtrl.Spawn(spawnType, spawnType, null, pos, Quaternion.identity);
            }
        }
    }
示例#2
0
 void OnEntityStateChange(EntityBase ent)
 {
     if ((EntityState)ent.state == EntityState.Dead)
     {
         PoolController.Spawn(deathSpawnGroup, deathSpawnType, deathSpawnType, null, ent.transform.position, Quaternion.identity);
     }
 }
示例#3
0
        // Code that runs on entering the state.
        public override void OnEnter()
        {
#if POOLMANAGER
            Debug.LogError("Not implemented!");
#else
            Transform t = PoolController.Spawn(group.Value, type.Value, name.IsNone ? type.Value : name.Value, parent.Value == null ? null : parent.Value.transform);
#endif
            if (t != null)
            {
                if (!toGameObject.IsNone)
                {
                    toGameObject.Value = t.gameObject;
                }

                if (!position.IsNone)
                {
                    t.position = position.Value;
                }
            }
            else
            {
                Debug.LogWarning("Unable to spawn: " + type.Value + " group: " + group.Value);
            }

            Finish();
        }
示例#4
0
 void OnLand(PlatformerController ctrl)
 {
     if (state != (int)EntityState.Invalid)
     {
         Vector2 p = transform.position;
         PoolController.Spawn("fxp", "landdust", "landdust", null, p);
     }
 }
示例#5
0
    void OnLanded(PlatformerController ctrl)
    {
        mJump         = false;
        mLastJumpTime = Time.fixedTime;

        Vector2 p = transform.position;

        PoolController.Spawn("fxp", "landdust", "landdust", null, p);
    }
示例#6
0
    public void DoDrop(int groupIndex, Vector3 pos)
    {
        Group dat = groups[groupIndex];

        int r = Random.Range(0, dat.range) + 1;

        if (r <= dat.itemRange)
        {
            string spawnType = null;

            for (int i = 0, max = dat.items.Length, w = 0; i < max; i++)
            {
                ItemData drop = dat.items[i];
                w += drop.weight;

                if (r <= w)
                {
                    spawnType = drop.itemSpawnType;
                    break;
                }
            }

            if (!string.IsNullOrEmpty(spawnType))
            {
                /*if(spawnType == "itemLife") {
                 *  if(LevelController.isLifeUpDropped)
                 *      return;
                 *  else
                 *      LevelController.isLifeUpDropped = true;
                 * }*/

                //Debug.Log("dropping: " + spawnType);

                if (spawnType == "itemLife")
                {
                    if (LevelController.isTimeTrial)
                    {
                        return;
                    }
                    if (SlotInfo.gameMode == SlotInfo.GameMode.Hardcore)
                    {
                        if (LevelController.isLifeUpDropped)
                        {
                            return;
                        }
                        else
                        {
                            LevelController.isLifeUpDropped = true;
                        }
                    }
                }

                mCtrl.Spawn(spawnType, spawnType, null, pos, Quaternion.identity);
            }
        }
    }
示例#7
0
    void OnBuddyHPChange(Stats aStat, float delta)
    {
        int deadInd = -1;
        int stunInd = -1;

        for (int i = 0; i < mBuddyStats.Length; i++)
        {
            if (mBuddyStats[i] == aStat)
            {
                if (aStat.lastDamageSource && aStat.lastDamageSource.stun)
                {
                    stunInd = i;
                }

                if (aStat.curHP <= 0)
                {
                    deadInd = i;
                    mNumDead++;
                }
            }
        }

        if (deadInd != -1)
        {
            buddies[deadInd].SetActive(false);
            Vector3 pt = buddies[deadInd].collider.bounds.center;
            pt.z = 0.0f;
            PoolController.Spawn(deathSpawnGroup, mDeathSpawnType, mDeathSpawnType, null, pt, Quaternion.identity);
        }

        projectile.SetActive(mNumDead == 0);

        if (mNumDead == mBuddyStats.Length)
        {
            state = (int)EntityState.Dead;
        }
        else
        {
            if (deadInd != -1)
            {
                for (int i = 0; i < mBuddyAnims.Length; i++)
                {
                    if (i != deadInd)
                    {
                        mBuddyAnims[i].Play("sad");
                    }
                }
            }
            else if (stunInd != -1)
            {
                state = (int)EntityState.Stun;
            }
        }
    }
示例#8
0
    void OnInputJump(InputManager.Info dat)
    {
        if (dat.state == InputManager.State.Pressed)
        {
            InputManager input = Main.instance.input;

            Weapon curWpn = currentWeapon;
            if (curWpn == null || curWpn.Jump(this) == false)
            {
                if (!mSliding)
                {
                    if (input.GetAxis(0, InputAction.MoveY) < -0.1f && mCtrl.isGrounded)
                    {
                        if (!curWpn.isFireActive || curWpn.allowSlide)
                        {
                            SetSlide(true);
                        }
                    }
                    else
                    {
                        mCtrl.Jump(true);
                        if (mCtrl.isJumpWall)
                        {
                            Vector2 p = mCtrlSpr.wallStickParticle.transform.position;
                            PoolController.Spawn("fxp", "wallSpark", "wallSpark", null, p);
                            sfxWallJump.Play();
                        }
                    }
                }
                else
                {
                    if (input.GetAxis(0, InputAction.MoveY) >= 0.0f)
                    {
                        //if we can stop sliding, then jump
                        SetSlide(false, false);
                        if (!mSliding)
                        {
                            mCtrl.Jump(true);
                        }
                    }
                }
            }
        }
        else if (dat.state == InputManager.State.Released)
        {
            mCtrl.Jump(false);
        }
    }
示例#9
0
    void OnLanded(PlatformerController ctrl)
    {
        if (mCurPhase != Phase.None)
        {
            switch (mCurPhase)
            {
            case Phase.Jump:
            case Phase.AirStrike:
            case Phase.ThrowGrenades:
                Jump(0);
                ToPhase(Phase.Move);
                break;
            }

            Vector2 p = transform.position;
            PoolController.Spawn("fxp", "landdust", "landdust", null, p);
        }
    }
示例#10
0
    void Die()
    {
        if (!string.IsNullOrEmpty(deathSpawnGroup) && !string.IsNullOrEmpty(deathSpawnType))
        {
            Vector2 p = (explodeOfsTarget ? explodeOfsTarget : transform).localToWorldMatrix.MultiplyPoint(explodeOfs);//explodeOnDeath ? transform.localToWorldMatrix.MultiplyPoint(explodeOfs) : transform.position;

            PoolController.Spawn(deathSpawnGroup, deathSpawnType, deathSpawnType, null, p, Quaternion.identity);
        }

        if (explodeOnDeath && explodeRadius > 0.0f)
        {
            DoExplode();
        }

        if (releaseOnDie)
        {
            Release();
        }
    }
示例#11
0
    EntityBase Spawn(PoolController pool, Vector3 spawnPos, Quaternion spawnRot, GenericParams parms)
    {
        var spawned = pool.Spawn(data.entityRef, data.entityRef, spawnTo, spawnPos, spawnRot, null);

        var entity = spawned.GetComponent <EntityBase>();

        if (entity && !mSpawnedEntities.Exists(entity))
        {
            mSpawnedEntities.Add(entity);
            EntityRegisterCallbacks(entity, true);
        }

        if (spawnCallback != null)
        {
            spawnCallback(this, entity);
        }

        return(entity);
    }
示例#12
0
    public virtual bool ApplyDamage(Damage damage, Vector3 hitPos, Vector3 hitNorm)
    {
        mLastDamage     = damage;
        mLastDamagePos  = hitPos;
        mLastDamageNorm = hitNorm;

        if (!isInvul && mCurHP > 0.0f)
        {
            float amt = CalculateDamageAmount(damage);

            if (amt > 0.0f)
            {
                if (curHP - amt <= 0.0f && itemDropIndex >= 0)
                {
                    //Debug.Log("drop?");
                    ItemDropManager.instance.DoDrop(itemDropIndex, transform.localToWorldMatrix.MultiplyPoint(itemDropOfs));
                }

                curHP -= amt;

                ApplyDamageEvent(damage);

                return(true);
            }
            else
            {
                if (!string.IsNullOrEmpty(damage.noDamageSfx))
                {
                    SoundPlayerGlobal.instance.Play(damage.noDamageSfx);
                }

                if (!string.IsNullOrEmpty(damage.noDamageSpawnGroup) && !string.IsNullOrEmpty(damage.noDamageSpawnType))
                {
                    PoolController.Spawn(damage.noDamageSpawnGroup, damage.noDamageSpawnType, null, null, new Vector2(hitPos.x, hitPos.y));
                }
            }
        }

        return(false);
    }
    void OnTriggerEnter(Collider col)
    {
        PlatformerController ctrl = col.GetComponent <PlatformerController>();

        if (ctrl && M8.ArrayUtil.Contains(tags, col.tag))
        {
            if (mCurColCount < maxCols)
            {
                mCtrls[mCurColCount].Apply(collider, info, ctrl);

                if (mCurColCount == 0 && !string.IsNullOrEmpty(spawnGrp) && !string.IsNullOrEmpty(spawnType))
                {
                    PoolController.Spawn(spawnGrp, spawnType, spawnType, null, col.transform.position, Quaternion.identity);
                }

                mCurColCount++;
            }
            else
            {
                Debug.LogWarning("exceeded count");
            }
        }
    }
    void OnTriggerExit(Collider col)
    {
        for (int i = 0; i < mCurColCount; i++)
        {
            if (mCtrls[i].collider == col)
            {
                mCtrls[i].Revert(collider, info);

                if (mCurColCount > 1)
                {
                    mCtrls[i] = mCtrls[mCurColCount - 1];
                }

                if (mCurColCount == 1 && !string.IsNullOrEmpty(spawnGrp) && !string.IsNullOrEmpty(spawnType))
                {
                    PoolController.Spawn(spawnGrp, spawnType, spawnType, null, col.transform.position, Quaternion.identity);
                }

                mCurColCount--;
                break;
            }
        }
    }
    void DoSpawn(Collider col)
    {
        Vector3 pos = useColliderPos ? col.bounds.center : col.transform.position;

        PoolController.Spawn(entGroup, entType, entType, null, pos + ofs, Quaternion.identity);
    }
示例#16
0
    protected override void StateChanged()
    {
        switch ((EntityState)prevState)
        {
        case EntityState.Normal:
            Jump(0.0f);
            break;

        case EntityState.Stun:
            if (stunGO)
            {
                stunGO.SetActive(false);
            }

            SetPhysicsActive(true, true);

            CancelInvoke("DoStun");
            break;

        case EntityState.RespawnWait:
            if (activator)
            {
                activator.deactivateDelay = mDefaultDeactiveDelay;
            }

            mStats.isInvul = false;
            break;
        }

        switch ((EntityState)state)
        {
        case EntityState.Dead:
            if (mUseBossHP)
            {
                mUseBossHP = false;
                HUD.instance.barBoss.animateEndCallback -= OnHPBarFilled;
            }

            if (weaponIndexUnlock != -1)
            {
                //save weapon info for victory screen
                Player player = Player.instance;
                ModalVictory.sWeaponIconRef  = player.weapons[weaponIndexUnlock].iconSpriteRef;
                ModalVictory.sWeaponTitleRef = player.weapons[weaponIndexUnlock].labelTextRef;

                if (!LevelController.isTimeTrial)
                {
                    SlotInfo.WeaponUnlock(weaponIndexUnlock);
                }
            }

            if (disablePhysicsOnDeath)
            {
                SetPhysicsActive(false, false);
            }

            Blink(0.0f);
            mStats.isInvul = true;

            if (visibleGO)
            {
                visibleGO.SetActive(false);
            }

            if (mIsSuddenDeath)      //don't spawn death stuff if we fall in death
            {
                mIsSuddenDeath = false;
            }
            else
            {
                if (!string.IsNullOrEmpty(deathSpawnGroup) && !string.IsNullOrEmpty(deathSpawnType))
                {
                    Vector3 pt = (deathSpawnAttach ? deathSpawnAttach : transform).localToWorldMatrix.MultiplyPoint(deathSpawnOfs); pt.z = 0;
                    PoolController.Spawn(deathSpawnGroup, deathSpawnType, deathSpawnType, null, pt, Quaternion.identity);
                }

                if (deathActivateGO)
                {
                    deathActivateGO.SetActive(true);
                }
            }

            if (toRespawnAuto)
            {
                if (gameObject.activeSelf)
                {
                    StartCoroutine(DoRespawnWaitDelayKey);
                }
                else
                {
                    ToRespawnWait();
                }
            }
            else if (releaseOnDeath)
            {
                Release();
            }
            break;

        case EntityState.Stun:
            if (stunGO)
            {
                stunGO.SetActive(true);
            }

            SetPhysicsActive(false, true);

            Invoke("DoStun", stunDelay);

            SoundPlayerGlobal.instance.Play(soundStun);
            break;

        case EntityState.RespawnWait:
            //Debug.Log("respawn wait");
            RevertTransform();

            if (activator)
            {
                activator.deactivateDelay = 0.0f;
                activator.ForceActivate();
            }

            if (mBodyCtrl)
            {
                mBodyCtrl.moveSide = 0.0f;
            }

            if (mBodySpriteCtrl)
            {
                mBodySpriteCtrl.ResetAnimation();
            }

            if (rigidbody && !rigidbody.isKinematic)
            {
                rigidbody.velocity = Vector3.zero;
            }
            break;
        }
    }
示例#17
0
    void OnLanded(PlatformerController ctrl)
    {
        Vector2 p = transform.position;

        PoolController.Spawn("fxp", "landdust", "landdust", null, p);
    }