Пример #1
0
    private RC_Player FindActivePlayer()
    {
        JCS_PlayerManager pm = JCS_PlayerManager.instance;

        List <JCS_Player> players       = pm.GetJCSPlayerList();
        List <JCS_Player> activePlayers = new List <JCS_Player>();

        for (int index = 0;
             index < players.Count;
             ++index)
        {
            RC_Player rcPlayer = ((RC_Player)players[index]);

            // only player that are not dead.
            if (!rcPlayer.IsDead)
            {
                activePlayers.Add(rcPlayer);
            }
        }

        JCS_Player currentPlayerAndNotDead =
            pm.FindPlayerByDirectionUsingList(mTrackingTarget, activePlayers);

        return((RC_Player)currentPlayerAndNotDead);
    }
Пример #2
0
    /// <summary>
    /// Decide which player we want to track.
    /// </summary>
    private void DecideTrack()
    {
        if (RC_GameSettings.instance.GAME_OVER)
        {
            // stop tracking if the game is over.
            mJCSCamera.SetFollowing(false);
            return;
        }

        JCS_Player target = FindActivePlayer();

        // set the player to follow.
        if (target != null)
        {
            mJCSCamera.SetFollowTarget(target.transform);
            mJCSCamera.SetFollowing(true);
        }
        else
        {
            mJCSCamera.SetFollowing(false);
        }

        // down cast to rc player.
        mTrackingPlayer = (RC_Player)target;
    }
Пример #3
0
    //========================================
    //      Unity's function
    //------------------------------
    private void OnTriggerEnter(Collider other)
    {
        if (!mAutoEffect)
            return;

        RC_Player p = other.GetComponent<RC_Player>();
        if (p == null)
            return;

        DoEffect(p);
    }
Пример #4
0
    /* Variables */

    /* Setter & Getter */

    /* Functions */

    private void OnTriggerEnter(Collider other)
    {
        RC_Player p = other.GetComponent <RC_Player>();

        if (p != null)
        {
            // reach the goal! game is over.
            RC_GameSettings.instance.GAME_OVER = true;

            RC_GameManager.instance.DoExitGame();
        }
    }
Пример #5
0
    private void PickCallback(Collider other)
    {
        // apply effect to player
        RC_Player p = other.GetComponent <RC_Player>();

        if (p == null)
        {
            JCS_Debug.LogError("You are using RC game object but the player isn't RC gameobject...");
            return;
        }

        mEffectObject.DoEffect(p);
    }
Пример #6
0
    private void PickCallback(Collider other)
    {
        // apply value to gold system.
        RC_Player p = other.GetComponent <RC_Player>();

        if (p == null)
        {
            JCS_Debug.LogError("You are using RC game object but the player isn't RC gameobject...");
            return;
        }

        p.CurrentGold += mCashValue;

        // if is single player mode,
        // then we can just save to data directly.
        if (RC_GameSettings.instance.GAME_MODE == RC_GameMode.SINGLE_PLAYERS)
        {
            RC_GameSettings.GAME_DATA.Gold += mCashValue;
        }
    }
Пример #7
0
    //========================================
    //      Self-Define
    //------------------------------
    //----------------------
    // Public Functions
    public void DoEffect(RC_Player p)
    {
        switch (mEffectType)
        {
            case RC_EffectType.BLOCK:
                p.Block();
                break;
            case RC_EffectType.SPEED_UP:
                p.DeltaSpeed(mSpeedUp);
                break;
            case RC_EffectType.SPEED_DOWN:
                p.DeltaSpeed(mSpeedDown);
                break;
            case RC_EffectType.PUSH_UP:
                p.PushY(mPushForce);
                break;
            case RC_EffectType.PUSH_DOWN:
                p.PushY(-mPushForce);
                break;
            case RC_EffectType.WEAK:
                p.DeltaJumpForce(mJumpForceDown, 0);        // make it cannot jump
                break;
            case RC_EffectType.ENERGETIC:
                p.DeltaJumpForce(mJumpForceUp, 0);
                break;
            case RC_EffectType.ADD_POINT:
                p.DeltaPoint(JCS_Mathf.ToPositive(mPoint));
                break;
            case RC_EffectType.LOSE_POINT:
                p.DeltaPoint(JCS_Mathf.ToNegative(mPoint));
                break;

        }

        //----------------------
        // Protected Functions

        //----------------------
        // Private Functions

    }
Пример #8
0
    /* Setter & Getter */

    public void SetRCPlayer(RC_Player p)
    {
        this.mRCPlayer = p;
    }
Пример #9
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);
            }
        }
    }