예제 #1
0
    /// <summary>
    /// Spawn a wave by passing in wave count.
    /// </summary>
    /// <param name="spawnIndex"> spawn wave index. </param>
    public void SpawnAWave(int spawnIndex)
    {
        // if the enemy we assign is null, will cause errors.
        if (this.mLevelEnemy[spawnIndex] == null)
        {
            JCS_Debug.LogReminder("Make sure all the enemy in handler are assigned");
            return;
        }


        for (int count = 0;
             count < mEnemyPerWave;
             ++count)
        {
            if (BF_GameManager.instance.MOB_CURRENT_IN_SCENE >= BF_GameSettings.instance.TOTAL_MOB_IN_SCENE)
            {
                // don't spawn any more monster if there are too many monster in the scene.
                break;
            }

            // Spawn a monster.
            // add monster count in scene.
            ++BF_GameManager.instance.MOB_CURRENT_IN_SCENE;

            BF_LiveObject bf_liveObject = (BF_LiveObject)JCS_Utility.SpawnGameObject(
                this.mLevelEnemy[spawnIndex],
                this.mSpawnTransform.position);

            // Set live object in the scene layer.
            JCS_OrderLayerObject jcsolo = bf_liveObject.GetComponent <JCS_OrderLayerObject>();
            JCS_2DDynamicSceneManager.instance.SetObjectParentToOrderLayerByOrderLayerIndex(ref jcsolo, mOrderLayer);
        }
    }
예제 #2
0
    /// <summary>
    /// Spawn the player according to the pointed position.
    /// </summary>
    private void SpawnPlayers()
    {
        BF_GameSettings bfgs = BF_GameSettings.instance;

        BF_Player[] bfPlayers = bfgs.CHARACTERS_IN_GAME;

        for (int index = 0; index < bfgs.CHARACTERS_IN_TEAM; ++index)
        {
            if (mSpawnPos[index] == null)
            {
                JCS_Debug.LogReminder("No Spawn position references, plz check the transform in the array");
                break;
            }

            if (bfPlayers[index] == null)
            {
                JCS_Debug.LogError("Character you want to spawn does not exist");
                break;
            }

            // Spawn the player, and get the
            // player we just spawned, in order
            // to set facing.
            BF_Player bfp = (BF_Player)JCS_Utility.SpawnGameObject(
                bfPlayers[index],
                mSpawnPos[index].transform.position);

            // set the starting faceing
            bfp.TurnFace(mSpawnPos[index].Facing);

            // Set player in the order layer (scene layer).
            JCS_OrderLayerObject jcsolo = bfp.GetComponent <JCS_OrderLayerObject>();
            JCS_2DDynamicSceneManager.instance.SetObjectParentToOrderLayerByOrderLayerIndex(ref jcsolo, mOrderLayer);
        }
    }
예제 #3
0
    /// <summary>
    /// Spawn the player at the beginning of the game.
    /// </summary>
    private void SpawnPlayer()
    {
        RC_GameSettings gs = RC_GameSettings.instance;

        for (int index = 0;
             index < RC_GameSettings.instance.PLAYER_IN_GAME;
             ++index)
        {
            if (gs.PLAYERS[index] == null)
            {
                JCS_Debug.LogError("Player List in RC_GameSetting are null");
                return;
            }

            RC_Player rcp = (RC_Player)JCS_Utility.SpawnGameObject(gs.PLAYERS[index]);

            // set control index
            rcp.ControlIndex = index;

            JCS_OrderLayerObject jcsOlo = rcp.GetComponent <JCS_OrderLayerObject>();
            if (jcsOlo != null)
            {
                JCS_2DDynamicSceneManager jcs2ddsm = JCS_2DDynamicSceneManager.instance;
                jcs2ddsm.SetObjectParentToOrderLayerByOrderLayerIndex(
                    ref jcsOlo,
                    ORDER_LAYER_FOR_ALL_PLAYER);
            }

            if (gs.LIQUID_MODE)
            {
                if (gs.GLOBAL_LIQUIDBAR != null)
                {
                    // spawn a 3d liquid bar
                    JCS_3DLiquidBar lb = (JCS_3DLiquidBar)JCS_Utility.SpawnGameObject(gs.GLOBAL_LIQUIDBAR);
                    rcp.SetLiquidBar(lb);
                }
                else
                {
                    JCS_Debug.LogError("No liquid bar attach to `RC_GameSetting` and u still want to access it");
                }
            }

            // only webcam mode need the pointer.
            if (gs.WEBCAM_MODE)
            {
                RC_PlayerPointer rcpp = (RC_PlayerPointer)JCS_Utility.SpawnGameObject(gs.PLAYER_POINTERS[index]);

                // let rc pp knows the rc player.
                rcpp.SetRCPlayer(rcp);

                // let rc player know his rc player pointer
                rcp.SetRCPlayerPointer(rcpp);

                // set player to player pointer's transform.
                // so the player can follow the player
                rcpp.transform.SetParent(rcp.transform);
            }

            // create Revive Pointer
            {
                RC_RevivePointer rcrp = (RC_RevivePointer)JCS_Utility.SpawnGameObject(gs.PLAYER_REVIVE_POINTERS[index]);
                rcrp.SetRCPlayer(rcp);
                rcp.SetRCRevivePointer(rcrp);

                rcrp.transform.SetParent(rcp.transform);
            }
        }
    }