Esempio n. 1
0
 public void Load(SkillsPlayer skillsplayer, List <Players> players, List <Txs> txs, int height, string address)
 {
     for (int i = 0; i < txs.Count; i++)
     {
         players = GetPlayers(address, txs[i].Height);
         if (!txs[i].Sender)
         {
             List <Players> _players    = GetPlayers(txs[i].AddressSender, txs[i].Height);
             int            seed        = int.Parse(AttachmentBase58.HexToDecimal(AttachmentBase58.Base58NumericDecode(txs[i].Tx.Substring(0, 4))));
             LinearConRng   rnd         = new LinearConRng(seed);
             int            enemy       = rnd.NextInt(0, _players.Count);
             SkillsPlayer   skillsEnemy = AddressSkills(txs[i].AddressSender, txs[i].Height);
             if (_players[enemy].Address == address && skillsEnemy.Height <= txs[i].Height)
             {
                 var panelGO = Instantiate(GameHistory, transform);
                 panelGO.GetComponent <GameHistoryPanel>().SetStats(txs[i].Tx, txs[i].AddressSender, skillsplayer.Skills, skillsEnemy.Skills, Convert.ToInt32(txs[i].Sender));
                 panels.Add(panelGO);
             }
         }
         else
         {
             int          seed        = int.Parse(AttachmentBase58.HexToDecimal(AttachmentBase58.Base58NumericDecode(txs[i].Tx.Substring(0, 4))));
             LinearConRng rnd         = new LinearConRng(seed);
             int          enemy       = rnd.NextInt(0, players.Count);
             SkillsPlayer skillsEnemy = AddressSkills(players[enemy].Address, txs[i].Height);
             if (skillsEnemy.Height <= txs[i].Height)
             {
                 var panelGO = Instantiate(GameHistory, transform);
                 panelGO.GetComponent <GameHistoryPanel>().SetStats(txs[i].Tx, players[enemy].Address, skillsplayer.Skills, players[enemy].Skills, Convert.ToInt32(txs[i].Sender));
                 panels.Add(panelGO);
             }
         }
     }
 }
Esempio n. 2
0
    public void LoadSelectedSkills()
    {
        SkillsPlayer skills = FindObjectOfType <LoadGameHistory>().AddressSkills(UserInfo.address, new Node(Node.MainNetHost).GetHeight());

        if (skills.Skills != null && skills.Skills.Length == 3)
        {
            SelectedSkills ss = FindObjectOfType <SelectedSkills>();
            ss.SelSkills = skills.Skills;
            for (int i = 0; i < ss.SelSkills.Length; i++)
            {
                ss.selected[i].transform.GetChild(0).GetComponent <Image>().sprite = Resources.LoadAll <Sprite>("SkillPreview")[skills.Skills[i]];
                FindObjectOfType <ContentSkillsController>().skillsUI[skills.Skills[i]].GetComponent <ContentSkill>().ChangeColor();
            }
        }
        else
        {
            SelectedSkills ss = FindObjectOfType <SelectedSkills>();
            for (int i = 0; i < ss.SelSkills.Length; i++)
            {
                if (ss.SelSkills[i] != -1)
                {
                    ss.selected[i].transform.GetChild(0).GetComponent <Image>().sprite = null;
                    FindObjectOfType <ContentSkillsController>().ClearState(ss.SelSkills[i]);
                }
            }
            for (int i = 0; i < ss.SelSkills.Length; i++)
            {
                ss.SelSkills[i] = -1;
            }
        }
    }
Esempio n. 3
0
    public SkillsPlayer AddressSkills(string address, int height)
    {
        SkillsPlayer skills = new SkillsPlayer();
        var          node   = new Node(Node.MainNetHost);

        Dictionary <string, object>[] player = node.GetTransactionsByAddress(AddressInfo.recipient[0], 1000);
        for (int j = 0; j < player.Length; j++)
        {
            bool correctTx = int.Parse(player[j].GetValue("type").ToString()) == 4 &&
                             player[j].GetValue("assetId") != null &&
                             player[j].GetValue("assetId").ToString() == AddressInfo.Asset &&
                             int.Parse(player[j].GetValue("amount").ToString()) >= 100000000 &&
                             !string.IsNullOrEmpty(player[j].GetValue("attachment").ToString()) &&
                             int.Parse(player[j].GetValue("height").ToString()) <= height;

            if (correctTx && player[j].GetValue("sender").ToString() == address)
            {
                string DecodedAttachment = AttachmentBase58.Base58NumericDecode(Encoding.UTF8.GetString(Base58.Decode(player[j].GetValue("attachment").ToString())));

                string[] info = new string[3];
                info = DecodedAttachment.Split('A');
                if (string.IsNullOrEmpty(info[0]))
                {
                    info[0] = "0";
                }
                int[] skillsArr = new int[3];
                try
                {
                    if (int.TryParse(info[0], out skillsArr[0]) &&
                        int.TryParse(info[1], out skillsArr[1]) &&
                        int.TryParse(info[2], out skillsArr[2]) &&
                        skillsArr[0] >= 0 && skillsArr[0] < FindObjectOfType <Skills>().skills.Count&&
                        skillsArr[1] >= 0 && skillsArr[1] < FindObjectOfType <Skills>().skills.Count&&
                        skillsArr[2] >= 0 && skillsArr[2] < FindObjectOfType <Skills>().skills.Count)
                    {
                        if (skills.Height == -1)
                        {
                            skills = new SkillsPlayer(skillsArr, int.Parse(player[j].GetValue("height").ToString()));
                        }
                        else
                        {
                            skills.SetPrevSkills(true, int.Parse(player[j].GetValue("height").ToString()));
                            return(skills);
                        }
                    }
                }
                catch
                {
                    continue;
                }
            }
        }

        return(skills);
    }
Esempio n. 4
0
 public void LoadPrevHistory(SkillsPlayer skillsplayer, List <Players> players, List <Txs> txs, int height, string address)
 {
     while (skillsplayer.PrevSkills)
     {
         skillsplayer = AddressSkills(address, height);
         int height_new = skillsplayer.Height;
         skillsplayer = AddressSkills(address, skillsplayer.HeightPrev);
         players      = GetPlayers(address, height_new);
         txs          = LoadTx(address, skillsplayer.Height, height_new);
         Load(skillsplayer, players, txs, height, address);
     }
 }
Esempio n. 5
0
    public void LoadHistory(string address)
    {
        for (int i = 0; i < panels.Count; i++)
        {
            Destroy(panels[i]);
        }

        int height = new Node(Node.MainNetHost).GetHeight();

        SkillsPlayer   skillsplayer = AddressSkills(address, height);
        List <Players> players      = GetPlayers(address, height);
        List <Txs>     txs          = LoadTx(address, skillsplayer.Height, height);

        Load(skillsplayer, players, txs, height, address);
        LoadPrevHistory(skillsplayer, players, txs, height, address);
    }