Esempio n. 1
0
    public PlayerStatus getPlayerStatus()
    {
        PlayerStatus.Builder builder = PlayerStatus.CreateBuilder();

        builder.SetName(name);

        builder.SetStrength(strength);
        builder.SetDefence(defense);
        builder.SetEfficiency(efficiency);
        builder.SetEncryption(encryption);
        builder.SetSecurity(security);
        builder.SetAlgorithmPoints(algorithmPoints);
        builder.SetIntegrity(integrity);
        builder.SetRma(rma);
        builder.SetDeaths(deaths);
        builder.SetXpBytes(xpBytes);
        //builder.SetBytes (bytes);
        //builder.SetBytesRemaining (bytesToNextVersion);

        GlobalPosition.Builder positionBuilder = GlobalPosition.CreateBuilder();
        positionBuilder.SetAreaX(MasterDriver.Instance.CurrentArea.position.x);
        positionBuilder.SetAreaY(MasterDriver.Instance.CurrentArea.position.y);
        positionBuilder.SetLocalX((int)gameObject.transform.position.x);
        positionBuilder.SetLocalY((int)gameObject.transform.position.z);
        builder.SetPlayerPosition(positionBuilder.Build());

        builder.SetRotation((int)MasterDriver.Instance.getCamera().rotation.eulerAngles.y);

        InventoryData.Builder inventoryBuilder = InventoryData.CreateBuilder();
        foreach (Item i in inventory)
        {
            if (i.gameObject.GetComponent <Weapon>() == null)
            {
                inventoryBuilder.AddObject(i.getDirectObject().getDirectObjectAsProtobuf());
            }
            else
            {
                Debug.Log("SAVING WEAPON");
                inventoryBuilder.AddObject(i.getDirectObject().getDirectObjectAsProtobuf((Weapon)i));
            }
        }
        builder.SetInventory(inventoryBuilder.Build());

        builder.SetVersion(version);

        List <Point> visitedAreas = Status.playerStatus.getVisitedAreas();

        foreach (Point p in visitedAreas)
        {
            PointProto.Builder pBuilder = PointProto.CreateBuilder();
            pBuilder.SetX(p.x);
            pBuilder.SetY(p.y);
            builder.AddVisitedAreas(pBuilder.Build());
        }

        return(builder.Build());
    }