Ejemplo n.º 1
0
 public CreateFacebookPlayer(Guid playerId, string userName, PlayerSource source, long facebookUid, string authToken)
     : base(playerId, userName)
 {
     Source = source;
     FacebookUid = facebookUid;
     AuthToken = authToken;
 }
        private void playerName_TextChanged(object sender, TextChangedEventArgs e)
        {
            UpdateButtonVisibility();

            if (string.IsNullOrEmpty(playerName.Text) || !playerName.IsFocused)
            {
                SimilarPlayers.Clear();
                suggestionPopup.IsOpen = false;
                return;
            }

            if (SelectedPlayer != null && SelectedPlayer.Name != playerName.Text)
            {
                SelectedPlayer = null;
            }

            List <Player> similar = PlayerSource.Where((p) => p.Name.StartsWith(playerName.Text, StringComparison.OrdinalIgnoreCase)).ToList();

            foreach (Player p in SimilarPlayers.ToList())
            {
                if (!similar.Contains(p))
                {
                    SimilarPlayers.Remove(p);
                }
            }

            similar.ForEach((p) => {
                if (!SimilarPlayers.Contains(p))
                {
                    SimilarPlayers.Add(p);
                }
            });

            suggestionPopup.IsOpen = SimilarPlayers.Count > 0;
        }
        private async Task <StreamContext> GetStreamContextFromWatchPageAsync(VideoId videoId)
        {
            var watchPage = await WatchPage.GetAsync(_httpClient, videoId);

            var playerConfig = watchPage.TryGetPlayerConfig();

            var playerResponse =
                playerConfig?.GetPlayerResponse() ??
                watchPage.TryGetPlayerResponse() ??
                throw VideoUnplayableException.Unplayable(videoId);

            var previewVideoId = playerResponse.TryGetPreviewVideoId();

            if (!string.IsNullOrWhiteSpace(previewVideoId))
            {
                throw VideoRequiresPurchaseException.Preview(videoId, previewVideoId);
            }

            var playerSourceUrl = watchPage.TryGetPlayerSourceUrl() ?? playerConfig?.GetPlayerSourceUrl();
            var playerSource    = !string.IsNullOrWhiteSpace(playerSourceUrl)
                ? await PlayerSource.GetAsync(_httpClient, playerSourceUrl)
                : null;

            var cipherOperations = playerSource?.GetCipherOperations().ToArray() ?? Array.Empty <ICipherOperation>();

            if (!playerResponse.IsVideoPlayable())
            {
                throw VideoUnplayableException.Unplayable(videoId, playerResponse.TryGetVideoPlayabilityError());
            }

            if (playerResponse.IsLive())
            {
                throw VideoUnplayableException.LiveStream(videoId);
            }

            var streamInfoProviders = new List <IStreamInfoProvider>();

            // Streams from player config
            if (playerConfig != null)
            {
                streamInfoProviders.AddRange(playerConfig.GetStreams());
            }

            // Streams from player response
            streamInfoProviders.AddRange(playerResponse.GetStreams());

            // Streams from DASH manifest
            var dashManifestUrl = playerResponse.TryGetDashManifestUrl();

            if (!string.IsNullOrWhiteSpace(dashManifestUrl))
            {
                var dashManifest = await GetDashManifestAsync(dashManifestUrl, cipherOperations);

                streamInfoProviders.AddRange(dashManifest.GetStreams());
            }

            return(new StreamContext(streamInfoProviders, cipherOperations));
        }
Ejemplo n.º 4
0
 public IUserActions Get(PlayerSource type)
 {
     switch (type)
     {
         case PlayerSource.Facebook:
             return new FacebookUserActions(_facebookClientProvider, _playerReadModel, _playerSession, _bus);
         case PlayerSource.Native:
             return new NativeUserActions(_playerSession, _bus, _playerReadModel);
         default:
             throw new ArgumentOutOfRangeException("type", "Not a supported player source type.");
     }
 }
Ejemplo n.º 5
0
    //========================== Create New Player Data =============================

    public void CreateNewPlayerData()
    {
        PlayerSource NewPlayer = new PlayerSource();

        NewPlayer.CurrentStore     = 0;
        NewPlayer.Money            = Random.Range(600, 800) * 5;
        NewPlayer.If_Tutorial      = true;
        NewPlayer.Step_Of_Tutorial = 1;

        SlaveDoll AddSlv = new SlaveDoll();

        AddSlv.Skin       = Random.Range(1, 6);
        AddSlv.Health     = Random.Range(50, 90) * 5;
        AddSlv.FullHealth = AddSlv.Health;
        AddSlv.Damage     = Random.Range(4, 12) * 5;
        AddSlv.Accuracy   = Random.Range(3, 10);
        AddSlv.Start_Fhp  = AddSlv.FullHealth;
        AddSlv.Start_Dmg  = AddSlv.Damage;
        AddSlv.Start_Acc  = AddSlv.Accuracy;
        AddSlv.Heal_Units = 3;
        AddSlv.Shot_Units = 5;
        AddSlv.Rush_Units = 3;
        AddSlv.Level      = 1;
        NewPlayer.Slaves.Add(AddSlv);

        for (int a = 0; a < 2; a++)
        {
            ItemDoll Item = new ItemDoll();
            Item.TypeOfItem    = "Stuff";
            Item.Name          = "Water";
            Item.Skin          = 2;
            Item.Liters        = 100;
            Item.Price         = 100;
            NewPlayer.Items[a] = Item;
        }

        ItemDoll wpn = new ItemDoll();

        wpn.TypeOfItem     = "Weapon";
        wpn.Skin           = Random.Range(1, 11);
        wpn.Condition      = Random.Range(1, 5);
        wpn.Price          = 30;
        NewPlayer.Items[2] = wpn;

        string       PlayerToStr = JsonUtility.ToJson(NewPlayer);
        StreamWriter WriteData   = new StreamWriter(Application.persistentDataPath + "/PlayerData.json");

        WriteData.Write(PlayerToStr);
        WriteData.Close();
    }
Ejemplo n.º 6
0
 public override void OnNavigatedTo(object paramter)
 {
     if (paramter is Uri) // 直接是视频地址
     {
         PlayerSource = paramter as Uri;
         Title        = PlayerSource.ToString();
     }
     else if (paramter is Tuple <Uri, string> ) // 视频地址 + 标题
     {
         var tpar = paramter as Tuple <Uri, string>;
         PlayerSource = tpar.Item1;
         Title        = tpar.Item2;
     }
 }
Ejemplo n.º 7
0
 public CriAtomExPlayer GetPlayer(Guid trackId)
 {
     if (this.playerTable.ContainsKey(trackId))
     {
         return(this.playerTable[trackId].player);
     }
     else
     {
         PlayerSource playerSource = new PlayerSource(this.listener3d);
         try {
             this.playerTable.Add(trackId, playerSource);
         } catch (Exception e) {                 /* impossible */
             Debug.LogError("[CRIWARE] Timeline Previewer: Failed adding preview player (" + e.Message + ")");
         }
         return(playerSource.player);                /* return the created player anyway */
     }
 }
Ejemplo n.º 8
0
        private async Task <PlayerSource> GetVideoPlayerSourceAsync(string sourceUrl)
        {
            // Try to resolve from cache first
            var playerSource = _playerSourceCache.GetOrDefault(sourceUrl);

            if (playerSource != null)
            {
                return(playerSource);
            }

            // Get parser
            var parser = await GetPlayerSourceParserAsync(sourceUrl).ConfigureAwait(false);

            // Extract cipher operations
            var operations = parser.ParseCipherOperations();

            return(_playerSourceCache[sourceUrl] = new PlayerSource(operations));
        }
Ejemplo n.º 9
0
        private void UnscrambleVideoInfo(PlayerSource playerSource, VideoInfo videoInfo)
        {
            if (playerSource == null)
            {
                throw new ArgumentNullException(nameof(playerSource));
            }
            if (videoInfo == null)
            {
                throw new ArgumentNullException(nameof(videoInfo));
            }
            if (!videoInfo.NeedsDeciphering)
            {
                throw new Exception("Given video info does not need to be deciphered");
            }

            // Decipher streams
            foreach (var streamInfo in videoInfo.Streams.Where(s => s.NeedsDeciphering))
            {
                string sig    = streamInfo.Signature;
                string newSig = playerSource.Unscramble(sig);
                streamInfo.Url = streamInfo.Url.SetQueryStringParameter("signature", newSig);
                streamInfo.NeedsDeciphering = false;
            }
        }
Ejemplo n.º 10
0
    //======================================================= LOAD INVENTORY ===========================================================

    public void LoadAll()
    {
        string       json     = File.ReadAllText(Application.persistentDataPath + "/PlayerData.json").ToString();
        PlayerSource LoadData = JsonUtility.FromJson <PlayerSource>(json);

        PlayInv.Money            = LoadData.Money;
        PlayInv.StoreID          = LoadData.CurrentStore;
        PlayInv.If_Tutorial      = LoadData.If_Tutorial;
        PlayInv.Step_Of_Tutorial = LoadData.Step_Of_Tutorial;

        int GetSlave = 0;

        foreach (SlaveDoll LoadSlave in LoadData.Slaves)
        {
            if (LoadSlave.StatusEmpty == false)
            {
                GameObject Slave = Instantiate(Resources.Load("HeroPrefab")) as GameObject;
                Slave.name = "Slv_" + GetSlave;
                SlaveProperties SlvProp = Slave.GetComponent <SlaveProperties>();
                SlvProp.Number      = LoadSlave.Number;
                SlvProp.Health      = LoadSlave.Health;
                SlvProp.FullHealth  = LoadSlave.FullHealth;
                SlvProp.Damage      = LoadSlave.Damage;
                SlvProp.Accuracy    = LoadSlave.Accuracy;
                SlvProp.Battles     = LoadSlave.Battles;
                SlvProp.Level       = LoadSlave.Level;
                SlvProp.Skin        = LoadSlave.Skin;
                SlvProp.Price       = LoadSlave.Price;
                SlvProp.Efficiency  = LoadSlave.Efficiency;
                SlvProp.WeaponSkin  = LoadSlave.WeaponSkin;
                SlvProp.HaveGun     = LoadSlave.HaveGun;
                SlvProp.FullPackage = LoadSlave.FullPackage;
                SlvProp.Start_Fhp   = LoadSlave.Start_Fhp;
                SlvProp.Start_Dmg   = LoadSlave.Start_Dmg;
                SlvProp.Start_Acc   = LoadSlave.Start_Acc;
                SlvProp.Shot_Units  = LoadSlave.Shot_Units;
                SlvProp.Heal_Units  = LoadSlave.Heal_Units;
                SlvProp.Rush_Units  = LoadSlave.Rush_Units;

                GameObject Pack      = SlvProp.InventoryPack.gameObject;
                int        PackPlace = 0;
                foreach (ItemDoll Item in LoadSlave.Package)
                {
                    if (Item != null)
                    {
                        if (Item.TypeOfItem == "Weapon")
                        {
                            GameObject       Wpn     = Instantiate(Resources.Load("WeaponDoll")) as GameObject;
                            WeaponProperties WpnProp = Wpn.GetComponent <WeaponProperties>();
                            WpnProp.Skin       = Item.Skin;
                            WpnProp.WeapName   = Item.Name;
                            WpnProp.Damage     = Item.Damage;
                            WpnProp.Condition  = Item.Condition;
                            WpnProp.Bullets    = Item.Bullets;
                            WpnProp.Efficiency = Item.Efficiency;
                            WpnProp.Price      = Item.Price;
                            WpnProp.Bought     = true;
                            Wpn.name           = WpnProp.WeapName + PackPlace;
                            Wpn.transform.SetParent(Pack.transform.GetChild(PackPlace).transform);
                            Wpn.transform.localPosition = new Vector3(0, 0, 0);
                            SlvProp.WeaponXRef          = Wpn;
                        }
                        if (Item.TypeOfItem == "Stuff")
                        {
                            GameObject Stuff   = Instantiate(Resources.Load("OtherStuff")) as GameObject;
                            OtherStuff StfProp = Stuff.GetComponent <OtherStuff>();
                            StfProp.Skin   = Item.Skin;
                            StfProp.Name   = Item.Name;
                            StfProp.Liters = Item.Liters;
                            StfProp.Price  = Item.Price;
                            StfProp.Bought = true;
                            Stuff.name     = StfProp.Name + PackPlace;
                            Stuff.transform.SetParent(Pack.transform.GetChild(PackPlace).transform);
                            Stuff.transform.localPosition = new Vector3(0, 0, 0);
                        }
                    }
                    PackPlace += 1;
                }

                PlayInv.SlavePlace[GetSlave] = Slave;
                Slave.transform.SetParent(SlaveSource.transform);
            }
            GetSlave += 1;
        }

        if (ItemsSource != null)
        {
            int NumItem = 0;
            foreach (ItemDoll Item in LoadData.Items)
            {
                if (Item != null)
                {
                    if (Item.TypeOfItem == "Weapon")
                    {
                        GameObject       Wpn     = Instantiate(Resources.Load("WeaponDoll")) as GameObject;
                        WeaponProperties WpnProp = Wpn.GetComponent <WeaponProperties>();
                        WpnProp.Skin             = Item.Skin;
                        WpnProp.WeapName         = Item.Name;
                        WpnProp.Damage           = Item.Damage;
                        WpnProp.Condition        = Item.Condition;
                        WpnProp.Bullets          = Item.Bullets;
                        WpnProp.Efficiency       = Item.Efficiency;
                        WpnProp.Price            = Item.Price;
                        WpnProp.Bought           = true;
                        Wpn.name                 = WpnProp.WeapName + NumItem;
                        PlayInv.Package[NumItem] = Wpn;
                        Wpn.transform.SetParent(ItemsSource.transform);
                        Wpn.transform.localPosition = new Vector3(0, 0, 0);
                    }
                    if (Item.TypeOfItem == "Stuff")
                    {
                        GameObject Stuff   = Instantiate(Resources.Load("OtherStuff")) as GameObject;
                        OtherStuff StfProp = Stuff.GetComponent <OtherStuff>();
                        StfProp.Skin             = Item.Skin;
                        StfProp.Name             = Item.Name;
                        StfProp.Liters           = Item.Liters;
                        StfProp.Price            = Item.Price;
                        StfProp.Bought           = true;
                        Stuff.name               = StfProp.Name + NumItem;
                        PlayInv.Package[NumItem] = Stuff;
                        Stuff.transform.SetParent(ItemsSource.transform);
                        Stuff.transform.localPosition = new Vector3(0, 0, 0);
                    }
                }
                NumItem += 1;
            }
        }
    }
Ejemplo n.º 11
0
        private async Task <PlayerSource> GetVideoPlayerSourceAsync(string sourceUrl)
        {
            // Original code credit:
            // https://github.com/flagbug/YoutubeExtractor/blob/3106efa1063994fd19c0e967793315f6962b2d3c/YoutubeExtractor/YoutubeExtractor/Decipherer.cs
            // No copyright, MIT license
            // Regexes found in this method have been sourced by contributors and from other projects

            // Try to resolve from cache first
            var playerSource = _playerSourceCache.GetOrDefault(sourceUrl);

            if (playerSource != null)
            {
                return(playerSource);
            }

            // Get player source code
            var sourceRaw = await _httpClient.GetStringAsync(sourceUrl).ConfigureAwait(false);

            // Find the name of the function that handles deciphering
            var entryPoint = Regex.Match(sourceRaw, @"(\w+)&&(\w+)\.set\(\w+,(\w+)\(\1\)\);return\s+\2").Groups[3].Value;

            if (entryPoint.IsBlank())
            {
                throw new ParseException("Could not find the entry function for signature deciphering.");
            }

            // Find the body of the function
            var entryPointPattern = @"(?!h\.)" + Regex.Escape(entryPoint) + @"=function\(\w+\)\{(.*?)\}";
            var entryPointBody    = Regex.Match(sourceRaw, entryPointPattern, RegexOptions.Singleline).Groups[1].Value;

            if (entryPointBody.IsBlank())
            {
                throw new ParseException("Could not find the signature decipherer function body.");
            }
            var entryPointLines = entryPointBody.Split(";").ToArray();

            // Identify cipher functions
            string reverseFuncName  = null;
            string sliceFuncName    = null;
            string charSwapFuncName = null;
            var    operations       = new List <ICipherOperation>();

            // Analyze the function body to determine the names of cipher functions
            foreach (var line in entryPointLines)
            {
                // Break when all functions are found
                if (reverseFuncName.IsNotBlank() && sliceFuncName.IsNotBlank() && charSwapFuncName.IsNotBlank())
                {
                    break;
                }

                // Get the function called on this line
                var calledFuncName = Regex.Match(line, @"\w+(?:.|\[)(\""?\w+(?:\"")?)\]?\(").Groups[1].Value;
                if (calledFuncName.IsBlank())
                {
                    continue;
                }

                // Find cipher function names
                if (Regex.IsMatch(sourceRaw, $@"{Regex.Escape(calledFuncName)}:\bfunction\b\(\w+\)"))
                {
                    reverseFuncName = calledFuncName;
                }
                else if (Regex.IsMatch(sourceRaw,
                                       $@"{Regex.Escape(calledFuncName)}:\bfunction\b\([a],b\).(\breturn\b)?.?\w+\."))
                {
                    sliceFuncName = calledFuncName;
                }
                else if (Regex.IsMatch(sourceRaw,
                                       $@"{Regex.Escape(calledFuncName)}:\bfunction\b\(\w+\,\w\).\bvar\b.\bc=a\b"))
                {
                    charSwapFuncName = calledFuncName;
                }
            }

            // Analyze the function body again to determine the operation set and order
            foreach (var line in entryPointLines)
            {
                // Get the function called on this line
                var calledFuncName = Regex.Match(line, @"\w+(?:.|\[)(\""?\w+(?:\"")?)\]?\(").Groups[1].Value;
                if (calledFuncName.IsBlank())
                {
                    continue;
                }

                // Swap operation
                if (calledFuncName == charSwapFuncName)
                {
                    var index = Regex.Match(line, @"\(\w+,(\d+)\)").Groups[1].Value.ParseInt();
                    operations.Add(new SwapCipherOperation(index));
                }
                // Slice operation
                else if (calledFuncName == sliceFuncName)
                {
                    var index = Regex.Match(line, @"\(\w+,(\d+)\)").Groups[1].Value.ParseInt();
                    operations.Add(new SliceCipherOperation(index));
                }
                // Reverse operation
                else if (calledFuncName == reverseFuncName)
                {
                    operations.Add(new ReverseCipherOperation());
                }
            }

            return(_playerSourceCache[sourceUrl] = new PlayerSource(operations));
        }
Ejemplo n.º 12
0
        private async Task <PlayerSource> GetPlayerSourceAsync(string version)
        {
            // Original code credit: Decipherer class of https://github.com/flagbug/YoutubeExtractor

            // Try to resolve from cache first
            var playerSource = _playerSourceCache.GetOrDefault(version);

            if (playerSource != null)
            {
                return(playerSource);
            }

            // Get player source code
            string request  = $"https://www.youtube.com/yts/jsbin/player-{version}/base.js";
            string response = await _httpService.GetStringAsync(request).ConfigureAwait(false);

            // Find the name of the function that handles deciphering
            string funcName = Regex.Match(response, @"\""signature"",\s?([a-zA-Z0-9\$]+)\(").Groups[1].Value;

            if (funcName.IsBlank())
            {
                throw new ParseException("Could not find the entry function for signature deciphering");
            }

            // Find the body of the function
            string funcPattern = @"(?!h\.)" + Regex.Escape(funcName) + @"=function\(\w+\)\{(.*?)\}";
            string funcBody    = Regex.Match(response, funcPattern, RegexOptions.Singleline).Groups[1].Value;

            if (funcBody.IsBlank())
            {
                throw new ParseException("Could not find the signature decipherer function body");
            }
            var funcLines = funcBody.Split(";").ToArray();

            // Identify cipher functions
            string reverseFuncName  = null;
            string sliceFuncName    = null;
            string charSwapFuncName = null;
            var    operations       = new List <ICipherOperation>();

            // Analyze the function body to determine the names of cipher functions
            foreach (string line in funcLines)
            {
                // Break when all functions are found
                if (reverseFuncName.IsNotBlank() && sliceFuncName.IsNotBlank() && charSwapFuncName.IsNotBlank())
                {
                    break;
                }

                // Get the function called on this line
                string calledFunctionName = Regex.Match(line, @"\w+\.(\w+)\(").Groups[1].Value;
                if (calledFunctionName.IsBlank())
                {
                    continue;
                }

                // Find cipher function names
                if (Regex.IsMatch(response, $@"{Regex.Escape(calledFunctionName)}:\bfunction\b\(\w+\)"))
                {
                    reverseFuncName = calledFunctionName;
                }
                else if (Regex.IsMatch(response,
                                       $@"{Regex.Escape(calledFunctionName)}:\bfunction\b\([a],b\).(\breturn\b)?.?\w+\."))
                {
                    sliceFuncName = calledFunctionName;
                }
                else if (Regex.IsMatch(response,
                                       $@"{Regex.Escape(calledFunctionName)}:\bfunction\b\(\w+\,\w\).\bvar\b.\bc=a\b"))
                {
                    charSwapFuncName = calledFunctionName;
                }
            }

            // Analyze the function body again to determine the operation set and order
            foreach (string line in funcLines)
            {
                // Get the function called on this line
                string calledFunctionName = Regex.Match(line, @"\w+\.(\w+)\(").Groups[1].Value;
                if (calledFunctionName.IsBlank())
                {
                    continue;
                }

                // Swap operation
                if (calledFunctionName == charSwapFuncName)
                {
                    int index = Regex.Match(line, @"\(\w+,(\d+)\)").Groups[1].Value.ParseInt();
                    operations.Add(new SwapCipherOperation(index));
                }
                // Slice operation
                else if (calledFunctionName == sliceFuncName)
                {
                    int index = Regex.Match(line, @"\(\w+,(\d+)\)").Groups[1].Value.ParseInt();
                    operations.Add(new SliceCipherOperation(index));
                }
                // Reverse operation
                else if (calledFunctionName == reverseFuncName)
                {
                    operations.Add(new ReverseCipherOperation());
                }
            }

            return(_playerSourceCache[version] = new PlayerSource(version, operations));
        }
Ejemplo n.º 13
0
 private void Apply(PlayerCreated e)
 {
     _id = e.Id;
     _userName = e.UserName;
     _source = e.Source;
     _externalId = e.ExternalId;
 }
Ejemplo n.º 14
0
 public Player(Guid id, string userName, PlayerSource source, string externalId)
 {
     ApplyChange(new PlayerCreated(id, userName, source, externalId));
 }
Ejemplo n.º 15
0
    //======================================================= LOAD STORE ITEMS ===========================================================

    public void LoadStoreInfo(int StoreID)
    {
        if (File.Exists(Application.persistentDataPath + "/StoresStack.json"))
        {
            if (File.Exists(Application.persistentDataPath + "/PlayerData.json"))
            {
                string       GetPlayInfo   = File.ReadAllText(Application.persistentDataPath + "/PlayerData.json");
                PlayerSource GetPlaySource = JsonUtility.FromJson <PlayerSource>(GetPlayInfo);

                string     GetStoresInfo = File.ReadAllText(Application.persistentDataPath + "/StoresStack.json");
                StoreStack GetStore      = JsonUtility.FromJson <StoreStack>(GetStoresInfo);

                PlayInv.StoreID = GetPlaySource.CurrentStore;
                PlayInv.Money   = GetPlaySource.Money;

                int SlaveNum  = 0;
                int WeaponNum = 0;
                int BulletNum = 0;
                int StuffNum  = 0;
                foreach (StorePoint Store in GetStore.storePoint)
                {
                    if (Store.StoreID == PlayInv.StoreID)
                    {
                        PlayInv.TypeOfStore = Store.TypeOfStore;
                        foreach (SlvLot Slave in Store.Lot1)
                        {
                            GameObject Slv = Instantiate(Resources.Load("HeroPrefab")) as GameObject;
                            Slv.name = "Slv_" + SlaveNum;
                            SlaveProperties SlvProp = Slv.GetComponent <SlaveProperties>();
                            SlvProp.Skin       = Slave.Skin;
                            SlvProp.FullHealth = Slave.FullHealth;
                            SlvProp.Health     = Slave.Health;
                            SlvProp.Damage     = Slave.Damage;
                            SlvProp.Accuracy   = Slave.Accuracy;
                            SlvProp.Price      = Slave.Price;
                            SlvProp.Level      = Slave.Level;
                            SlvProp.Start_Fhp  = Slave.St_Health;
                            SlvProp.Start_Dmg  = Slave.St_Damage;
                            SlvProp.Start_Acc  = Slave.St_Accuracy;
                            SlvProp.Shot_Units = Slave.Shot_Units;
                            SlvProp.Heal_Units = Slave.Heal_Units;
                            SlvProp.Rush_Units = Slave.Rush_Units;
                            PlayInv.Items.Add(Slv);
                            SlaveNum += 1;
                        }
                        foreach (WpnLot Weapon in Store.Lot2)
                        {
                            GameObject Wpn = Instantiate(Resources.Load("WeaponDoll")) as GameObject;
                            Wpn.name = "Wpn_" + WeaponNum;
                            WeaponProperties WpnProp = Wpn.GetComponent <WeaponProperties>();
                            WpnProp.WeapName  = Weapon.Name;
                            WpnProp.Skin      = Weapon.Skin;
                            WpnProp.Price     = Weapon.Price;
                            WpnProp.Damage    = Weapon.Damage;
                            WpnProp.Condition = Weapon.Condition;
                            WpnProp.Bullets   = Weapon.Bullets;
                            PlayInv.Items.Add(Wpn);
                            WeaponNum += 1;
                        }
                        foreach (BulLot Bullets in Store.Lot3)
                        {
                            GameObject Bul = Instantiate(Resources.Load("BulletsDoll")) as GameObject;
                            Bul.name = "Bul_" + BulletNum;
                            BulletsProperties BulProp = Bul.GetComponent <BulletsProperties>();
                            BulProp.Name  = Bullets.Name;
                            BulProp.Skin  = Bullets.Skin;
                            BulProp.Count = Bullets.Count;
                            BulProp.Price = Bullets.Price;
                            PlayInv.Items.Add(Bul);
                            BulletNum += 1;
                        }
                        foreach (StffLot Stuff in Store.Lot4)
                        {
                            GameObject Stf = Instantiate(Resources.Load("OtherStuff")) as GameObject;
                            Stf.name = "Stf_" + StuffNum;
                            OtherStuff StfProp = Stf.GetComponent <OtherStuff>();
                            StfProp.Skin   = Stuff.Skin;
                            StfProp.Price  = Stuff.Price;
                            StfProp.Liters = Stuff.Liters;
                            PlayInv.Items.Add(Stf);
                            StuffNum += 1;
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 16
0
 // Use this for initialization
 void Start()
 {
     _playersource = GameObject.FindGameObjectWithTag("ZeroPlayer").GetComponent <PlayerSource>();
 }
Ejemplo n.º 17
0
    //======================================================= SAVE INVENTORY ===========================================================

    public void SaveAll()
    {
        PlayerSource newInventory = new PlayerSource();

        newInventory.Money            = PlayInv.Money;
        newInventory.CurrentStore     = PlayInv.StoreID;
        newInventory.If_Tutorial      = PlayInv.If_Tutorial;
        newInventory.Step_Of_Tutorial = Tutor.Steps;

        foreach (GameObject Slave in PlayInv.SlavePlace)
        {
            SlaveDoll newSlave = new SlaveDoll();
            if (Slave != null)
            {
                SlaveProperties GetSlv = Slave.GetComponent <SlaveProperties>();
                newSlave.StatusEmpty = false;
                newSlave.Number      = GetSlv.Number;
                newSlave.Health      = GetSlv.Health;
                newSlave.FullHealth  = GetSlv.FullHealth;
                newSlave.Damage      = GetSlv.Damage;
                newSlave.Accuracy    = GetSlv.Accuracy;
                newSlave.Battles     = GetSlv.Battles;
                newSlave.Level       = GetSlv.Level;
                newSlave.Skin        = GetSlv.Skin;
                newSlave.Price       = GetSlv.Price;
                newSlave.Efficiency  = GetSlv.Efficiency;
                newSlave.WeaponSkin  = GetSlv.WeaponSkin;
                newSlave.HaveGun     = GetSlv.HaveGun;
                newSlave.FullPackage = GetSlv.FullPackage;
                newSlave.Start_Fhp   = GetSlv.Start_Fhp;
                newSlave.Start_Dmg   = GetSlv.Start_Dmg;
                newSlave.Start_Acc   = GetSlv.Start_Acc;
                newSlave.Heal_Units  = GetSlv.Heal_Units;
                newSlave.Shot_Units  = GetSlv.Shot_Units;
                newSlave.Rush_Units  = GetSlv.Rush_Units;
                int GetStuffPlace = 0;
                GetSlv.InventoryPack.gameObject.active = true;
                foreach (Transform Place in GetSlv.InventoryPack.transform)
                {
                    if (Place.transform.childCount != 0)
                    {
                        GameObject GetItem = Place.transform.GetChild(0).gameObject;
                        if (GetItem.GetComponent <WeaponProperties>() != null)
                        {
                            ItemDoll         GetPlace = new ItemDoll();
                            WeaponProperties GetWpn   = GetItem.GetComponent <WeaponProperties>();
                            GetPlace.TypeOfItem = "Weapon";
                            GetPlace.Skin       = GetWpn.Skin;
                            GetPlace.Name       = GetWpn.WeapName;
                            GetPlace.Damage     = GetWpn.Damage;
                            GetPlace.Condition  = GetWpn.Condition;
                            GetPlace.Efficiency = GetWpn.Efficiency;
                            GetPlace.Price      = GetWpn.Price;
                            GetPlace.Bullets    = GetWpn.Bullets;
                            newSlave.Package[Place.transform.GetSiblingIndex()] = GetPlace;
                        }
                        if (GetItem.GetComponent <OtherStuff>() != null)
                        {
                            ItemDoll   GetPlace = new ItemDoll();
                            OtherStuff GetStf   = GetItem.GetComponent <OtherStuff>();
                            GetPlace.TypeOfItem = "Stuff";
                            GetPlace.Skin       = GetStf.Skin;
                            GetPlace.Price      = GetStf.Price;
                            GetPlace.Liters     = GetStf.Liters;
                            GetPlace.Name       = GetStf.Name;
                            newSlave.Package[Place.transform.GetSiblingIndex()] = GetPlace;
                        }
                    }
                }
            }
            else
            {
                newSlave.StatusEmpty = true;
            }
            newInventory.Slaves.Add(newSlave);
        }

        int NumPlace = 0;

        foreach (GameObject Item in PlayInv.Package)
        {
            if (Item != null)
            {
                if (Item.GetComponent <WeaponProperties>() != null)
                {
                    ItemDoll         GetPlace = new ItemDoll();
                    WeaponProperties GetWpn   = Item.GetComponent <WeaponProperties>();
                    GetPlace.TypeOfItem          = "Weapon";
                    GetPlace.Skin                = GetWpn.Skin;
                    GetPlace.Name                = GetWpn.WeapName;
                    GetPlace.Damage              = GetWpn.Damage;
                    GetPlace.Condition           = GetWpn.Condition;
                    GetPlace.Efficiency          = GetWpn.Efficiency;
                    GetPlace.Price               = GetWpn.Price;
                    GetPlace.Bullets             = GetWpn.Bullets;
                    newInventory.Items[NumPlace] = GetPlace;
                }
                if (Item.GetComponent <OtherStuff>() != null)
                {
                    ItemDoll   GetPlace = new ItemDoll();
                    OtherStuff GetStf   = Item.GetComponent <OtherStuff>();
                    GetPlace.TypeOfItem          = "Stuff";
                    GetPlace.Skin                = GetStf.Skin;
                    GetPlace.Price               = GetStf.Price;
                    GetPlace.Liters              = GetStf.Liters;
                    GetPlace.Name                = GetStf.Name;
                    newInventory.Items[NumPlace] = GetPlace;
                }
            }
            NumPlace += 1;
        }

        string       SaveData  = JsonUtility.ToJson(newInventory);
        StreamWriter WriteData = new StreamWriter(Application.persistentDataPath + "/PlayerData.json");

        WriteData.Write(SaveData);
        WriteData.Close();
    }
Ejemplo n.º 18
0
 public PlayerCreated(Guid id, string userName, PlayerSource source, string externalId)
 {
     Id = id;
     UserName = userName;
     Source = source;
     ExternalId = externalId;
 }