Ejemplo n.º 1
0
    private RC_GameMode FindGameMode(int players)
    {
        switch (players)
        {
        case 1:
            return(RC_GameMode.SINGLE_PLAYERS);

        case 2:
            return(RC_GameMode.TWO_PLAYERS);

        case 4:
            return(RC_GameMode.FOUR_PLAYERS);

        case 8:
            return(RC_GameMode.EIGHT_PLAYERS);
        }

        // This should not happens...
        JCS_Debug.LogError(
            "RC_GameSetting",

            "Game Mode Undefined...");

        return(RC_GameMode.SINGLE_PLAYERS);
    }
Ejemplo n.º 2
0
    private void Start()
    {
        if (RC_GameSettings.instance.WEBCAM_MODE &&
            RC_GameSettings.instance.GAME_MODE != RC_GameMode.SINGLE_PLAYERS)
        {
            var gs = JCS_GameSettings.instance;

            mPlayerImage = JCS_Webcam.LoadImageByIndex(mRCPlayer.ControlIndex, mUnitPerPixel);

            if (mPhotoSpriteRenderer != null)
            {
                mPhotoSpriteRenderer.sprite = mPlayerImage;

                // order layer should be lower than the frame. (框框)
                mPhotoSpriteRenderer.sortingOrder = mOrderLayer - 1;
            }
            else
            {
                JCS_Debug.LogError("No Photo sprite renderer assigned");
            }
        }

        // find player position
        Vector3 newPos = mRCPlayer.transform.localPosition;

        // add pivot
        newPos += mOffset;

        // set pointer to player + pivot position
        this.transform.localPosition = newPos;
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Call this when the game is over.
    /// </summary>
    public void EndGame()
    {
        // if game is already over,
        // exit function call.
        if (GAME_IS_OVER)
        {
            return;
        }

        GAME_IS_OVER = true;

        if (mHealthTarget != null)
        {
            mHealthTarget.LiveObject.CanDamage = false;
        }
        else
        {
            JCS_Debug.LogReminder("No health object in the assign");
        }

        if (GAME_OVER_PANEL == null)
        {
            JCS_Debug.LogError("No game over panel have been set");
            return;
        }

        // active the game over panel.
        GAME_OVER_PANEL.Active();

        // Destroy all the live object in the scene.
        JCS_2DLiveObjectManager.instance.DestroyAllLiveObject();
    }
Ejemplo n.º 4
0
        private bool LoadWzFile(string name)
        {
            try
            {
                WzFile wzf = new WzFile(WzPath(name), mVersion, mEncVersion);
                wzf.ParseWzFile();
                {
                    mWzFiles[name] = wzf;
                    mWzDirs[name]  = new WzMainDirectory(wzf);

                    if (name == "Data")
                    {
                        foreach (WzDirectory mainDir in wzf.WzDirectory.WzDirectories)
                        {
                            mWzDirs[mainDir.Name.ToLower()] = new WzMainDirectory(wzf, mainDir);
                        }
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                JCS_Debug.LogError("Error initializing " + name + ".wz (" + e.Message + ").\r\nCheck that the directory is valid and the file is not in use.");
                return(false);
            }
        }
Ejemplo n.º 5
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);
        }
    }
        /// <summary>
        /// Decode the buffer by the public key.
        /// </summary>
        /// <param name="message"> buffer to decode. </param>
        /// <returns> decoded message. </returns>
        public System.Object Decode(System.Object message)
        {
            byte[] undecrypted = (byte[])message;

            int packetLength = undecrypted.Length - JCS_NetworkConstant.DECODE_BUFFER_LEN;

            // Check packet length
            if (undecrypted.Length < 0 || undecrypted.Length > JCS_NetworkConstant.INBUFSIZE)
            {
                // TODO(JenChieh): split the packet system
                JCS_Debug.LogError("Packet recieved is too big!!!");
                return(null);
            }

            // decrypt packet and check if damaged / wrong packet
            for (int index = 0; index < JCS_NetworkConstant.DECODE_BUFFER_LEN; ++index)
            {
                if ((char)undecrypted[index] != (char)JCS_NetworkConstant.DECODE_BUFFER[index])
                {
                    JCS_Debug.LogError("Wrong Packet Header!!!");
                    return(null);
                }
            }

            // Get the real message
            byte[] decryptedBuffer = new byte[packetLength];
            for (int index = 0; index < packetLength; ++index)
            {
                decryptedBuffer[index] = undecrypted[index + JCS_NetworkConstant.DECODE_BUFFER_LEN];
            }

            return(decryptedBuffer);
        }
        /// <summary>
        /// Encode the message before being sent to the other end.
        /// </summary>
        /// <param name="message"> buffer to encode. </param>
        /// <returns> encoded message. </returns>
        public System.Object Encode(System.Object message)
        {
            byte[] unencrypted = (byte[])message;

            int packetLength = JCS_NetworkConstant.ENCODE_BUFFER_LEN + unencrypted.Length;

            // Check packet length
            if (packetLength < 0 || packetLength > JCS_NetworkConstant.OUTBUFSIZE)
            {
                JCS_Debug.LogError("Packet you are sending is too big!");
                return(null);
            }

            byte[] encryptedBuffer = new byte[packetLength];

            // encrypt the packet for security usage
            for (int index = 0; index < JCS_NetworkConstant.ENCODE_BUFFER_LEN; ++index)
            {
                encryptedBuffer[index] = JCS_NetworkConstant.ENCODE_BUFFER[index];
            }

            // apply message
            for (int index = JCS_NetworkConstant.ENCODE_BUFFER_LEN; index < packetLength; ++index)
            {
                encryptedBuffer[index] = unencrypted[index - JCS_NetworkConstant.ENCODE_BUFFER_LEN];
            }

            return(encryptedBuffer);
        }
Ejemplo n.º 8
0
    public override void JCS_OnClickCallback()
    {
        if (mSlideCamera == null)
        {
            JCS_Debug.LogError("No JCS_2DSlideScreenCamera in the scene");
            return;
        }

        mSlideCamera.SwitchScene(JCS_2D4Direction.BOTTOM);
    }
Ejemplo n.º 9
0
    private void SaveGameData()
    {
        if (GAME_DATA == null)
        {
            JCS_Debug.LogError("Save Data without data");
            return;
        }

        GAME_DATA.Save <RC_GameData>(mFullFilePath, mFullFileName);
    }
Ejemplo n.º 10
0
    private void SaveGameData()
    {
        if (BF_GAME_DATA == null)
        {
            JCS_Debug.LogError(
                "Save Data without data??? (Fatal Error)");
            return;
        }

        BF_GAME_DATA.Save <BF_GameData>(mFullFilePath, mFullFileName);
    }
Ejemplo n.º 11
0
    public void PluseAppRect()
    {
        if (mType == JCS_IncDec.INCREASE)
        {
            ++mPanelIndex;
        }
        else
        {
            --mPanelIndex;
        }

        // check length
        if (mWebcamPanel.Length < mPanelIndex || mPanelIndex < 0)
        {
            JCS_Debug.LogError("Out of range index");

            return;
        }
        // check object
        if (mWebcamPanel[mPanelIndex] == null)
        {
            JCS_Debug.LogError("Call the function but does not assign panel at [" + mPanelIndex + "]...");
            return;
        }

        RectTransform appRectTransform = JCS_Canvas.instance.GetAppRect();
        Vector2       appRect          = appRectTransform.sizeDelta;

        Vector3 newPosButton          = mRectTransform.localPosition;
        Vector3 newPosWebcam          = mWebcam.GetRectTransform().localPosition;
        Vector3 newStartGameButtonPos = mStartGameButton.localPosition;

        newPosButton.x          += appRect.x;
        newPosWebcam.x          += appRect.x;
        newStartGameButtonPos.x += appRect.x;


        if ((mPanelIndex) == RC_GameSettings.instance.PLAYER_IN_GAME)
        {
            RC_GameSettings.instance.READY_TO_START_GAME = true;
        }
        else
        {
            mRectTransform.localPosition = newPosButton;
            mWebcam.GetRectTransform().localPosition = newPosWebcam;

            mWebcam.transform.SetParent(mWebcamPanel[mPanelIndex].transform);
            this.transform.SetParent(mWebcamPanel[mPanelIndex].transform);
        }

        mStartGameButton.localPosition = newStartGameButtonPos;
        mStartGameButton.SetParent(mWebcamPanel[mPanelIndex].transform);
    }
Ejemplo n.º 12
0
    /// <summary>
    /// In order to let the designer do all the job needed,
    /// set any button that will use to load the game scene
    /// in the array than call this function after scene
    /// name have been set, then it will make all the possible
    /// buttons that will load the game scene in the RC_Lobby to
    /// the correct scene name!
    /// </summary>
    public void SetCorrectSceneNameToAllButtonInScene()
    {
        foreach (JCS_LoadSceneButton btn in SCENE_BUTTONS)
        {
            if (btn == null)
            {
                JCS_Debug.LogError("You have open a space for button load in the scene, but does not assigned...");
                continue;
            }

            btn.SceneName = LEVEL_SELECTED_NAME;
        }
    }
Ejemplo n.º 13
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);
    }
Ejemplo n.º 14
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;
        }
    }
Ejemplo n.º 15
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);
            }
        }
    }