예제 #1
0
 private void RpcLoadActionBarFromDatabase(string actionBar, string playerName)
 {
     if (GameObject.Find("LocalPlayer").GetComponent <PlayerRpg>().playerName.Equals(playerName))
     {
         GlobalSerialization.DeserializeActionBar(actionBar, SerializationDatabase.instance.inventory, SerializationDatabase.instance.abs);
     }
 }
예제 #2
0
    private void TestSpAquisitionSerialization()
    {
        bool[,] tab = new bool[99, 3];

        int counter = 29;

        for (int i = 0; i < 99; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (counter > 0)
                {
                    tab[i, j] = true;
                    counter--;
                }
                else
                {
                    tab[i, j] = false;
                }
            }
        }

        Debug.Log(tab);
        string serial = GlobalSerialization.SerializeSpAquisitionTable(tab);

        Debug.Log(serial);
        bool[,] deserializedTab = GlobalSerialization.DeserializeSpAquisitionTable(serial);
        Debug.Log(deserializedTab);
    }
예제 #3
0
 private void RpcLoadItemFromDatabase(int id, int x, int y, int upgrade, int quantity, string playerName)
 {
     if (GameObject.Find("LocalPlayer").GetComponent <PlayerRpg>().playerName.Equals(playerName))
     {
         GlobalSerialization.DeserializeItem(new SerialItem(id, x, y, upgrade, quantity), SerializationDatabase.instance.inventory);
     }
 }
예제 #4
0
 public void CallCmdSerializePlayerPosition()
 {
     if (isLocalPlayer)
     {
         SerialPosition spos = GlobalSerialization.SerializePosition(gameObject);
         CmdSerializePlayerPosition(spos.posX, spos.posY, spos.rotZ, GetComponent <PlayerRpg>().playerName);
     }
 }
예제 #5
0
    private void SerializeItems()
    {
        serializedItems = new List <SerialItem>();

        for (int i = 0; i < itemsParentObject.transform.childCount; i++)
        {
            serializedItems.Add(GlobalSerialization.SerializeItem(itemsParentObject.transform.GetChild(i).GetComponent <ItemUI>()));
        }
    }
예제 #6
0
    private void RpcLoadPositionFromDatabase(float x, float y, float z, string playerName)
    {
        PlayerRpg localPlayer = GameObject.Find("LocalPlayer").GetComponent <PlayerRpg>();

        if (localPlayer.playerName.Equals(playerName))
        {
            GlobalSerialization.DeserializePosition(new SerialPosition(x, y, z), localPlayer.gameObject);
        }
    }
예제 #7
0
 public void CallCmdSerializePlayerRpg()
 {
     if (isLocalPlayer)
     {
         SerialPlayerRpg spr = GlobalSerialization.SerializePlayerRpg(GetComponent <PlayerRpg>());
         CmdSerializePlayerRpg(spr.cName, spr.yang, spr.level, spr.exp,
                               spr.sPoints, spr.sPointsTab, spr.cHp, spr.cEn, spr.cSt,
                               spr.bVit, spr.bInt, spr.bStr, spr.bDex, GetComponent <PlayerRpg>().playerName);
     }
 }
예제 #8
0
    private void RpcLoadPlayerRpgFromDatabase(string cName, long yang, int level, long exp,
                                              int sPoints, string sPointsTab, float cHp, float cEn, float cSt,
                                              int bVit, int bInt, int bStr, int bDex, string playerName)
    {
        PlayerRpg localPlayer = GameObject.Find("LocalPlayer").GetComponent <PlayerRpg>();

        if (localPlayer.playerName.Equals(playerName))
        {
            GlobalSerialization.DeserializePlayerRpg(new SerialPlayerRpg(cName,
                                                                         yang, level, exp, sPoints, sPointsTab, cHp, cEn, cSt, bVit, bInt, bStr, bDex), localPlayer);
            localPlayer.SetupStatusAfterLoad();
        }
    }
예제 #9
0
    public void SetupSerializedValues(SerialPlayerRpg spr)
    {
        CmdSetName(spr.cName);
        Yang  = spr.yang;
        Level = spr.level;
        RefreshMaxExp();
        Exp                = spr.exp;
        StatusPoints       = spr.sPoints;
        spAcquisitionTable = GlobalSerialization.DeserializeSpAquisitionTable(spr.sPointsTab);

        BaseVit = spr.bVit;
        BaseInt = spr.bInt;
        BaseStr = spr.bStr;
        BaseDex = spr.bDex;
        CalculateStatsDerivatives();

        CmdManipulateHealth(spr.cHp);
        Energy  = spr.cEn;
        Stamina = spr.cSt;
    }
예제 #10
0
 //this is called on clients, assigned to button for tests
 public void SaveItemsToDatabase()
 {
     inventory.GetPlayerRpg().gameObject.GetComponent <PlayerNetwork>().CallCmdClearItemsOfPlayer();
     SerializeItems();
     foreach (SerialItem sitem in serializedItems)
     {
         inventory.GetPlayerRpg().gameObject.GetComponent <PlayerNetwork>().SerializeItem(sitem);
     }
     inventory.GetPlayerRpg().gameObject.GetComponent <PlayerNetwork>().CallCmdSerializeActionBar(GlobalSerialization.SerializeActionBar(abs));
     inventory.GetPlayerRpg().gameObject.GetComponent <PlayerNetwork>().CallCmdSerializePlayerPosition();
     inventory.GetPlayerRpg().gameObject.GetComponent <PlayerNetwork>().CallCmdSerializePlayerRpg();
 }