예제 #1
0
        public override bool OnMessage(UIMessage msg)
        {
            if (msg.type == UIMsgType.NewGamePage_UpdateCamp)
            {
                int      campID   = (int)msg.content[0];
                CampInfo campInfo = GameManager.Instance.GetCampInfoData(campID);
                if (campInfo == null)
                {
                    return(false);
                }
                return(UpdateCampPanel(campInfo) && RefreshLeaderPanel(campInfo));
            }
            else if (msg.type == UIMsgType.LeaderPrepare_SelectLeader)
            {
                LeaderInfo info = (LeaderInfo)msg.content[0];
                return(AddLeader(info));
            }
            else if (msg.type == UIMsgType.NewGamePage_RemoveLeader)
            {
                LeaderInfo info = (LeaderInfo)msg.content[0];
                return(RemoveLeader(info));
            }

            return(true);
        }
예제 #2
0
    public override void Active()
    {
        data = JsonUtility.FromJson <SkillData>(PlayerPrefs.GetString(SkillName));
        LeaderInfo leader         = FindObjectOfType <LeaderInfo>();
        Animator   leaderAnimator = leader.GetComponentInChildren <Animator>();

        Vector3 pos = leader != null ? leader.transform.position : Vector3.zero;

        Collider[] colliders = Physics.OverlapSphere(pos, range + data.skillLevel * addRange);

        for (int i = 0; i < colliders.Length; ++i)
        {
            if (colliders[i].tag == "Tower")
            {
                var tempAttackBuff = colliders[i].GetComponent <AttackBuff>();
                if (tempAttackBuff != null)
                {
                    Destroy(tempAttackBuff);
                }
                var attackBuff = colliders[i].gameObject.AddComponent <AttackBuff>();
                attackBuff.DamageBuffRate     = 1f + damageBuffRate + data.skillLevel * addDamageRate;
                attackBuff.DamageBuffDuration = damageBuffDuration + data.skillLevel * addTime;
            }
        }

        leaderAnimator.SetTrigger("IsSkill");

        base.Active();
    }
예제 #3
0
        public static App Initialize(AppConfig config)
        {
            config.ThrowIfInvalid();
            var poller       = new LeaderInfoPoller(config.StorageAccount);
            var startOptions = new StartOptions();

            startOptions.Urls.Add(config.InternalUri);
            startOptions.Urls.Add(config.PublicUri);

            var auth = LoadAuth.LoadFromStorageAccount(config.StorageAccount);

            AddSystemAccess(auth, config.StorageAccount.GetSysPassword());
            var api          = ApiImplementation.Create(config.StorageAccount, poller, auth);
            var nancyOptions = new NancyOptions
            {
                Bootstrapper = new NancyBootstrapper(api, new UserValidator(auth))
            };
            var nodeInfo = new LeaderInfo(config.InternalUri);

            var selector = new LeaderLock(config.StorageAccount, nodeInfo, api);

            var cts = new CancellationTokenSource();
            // fire up leader and scheduler first
            var tasks = new List <Task> {
                selector.KeepTryingToAcquireLock(cts.Token),
                poller.KeepPollingForLeaderInfo(cts.Token),
            };


            // bind the API
            var webApp = WebApp.Start(startOptions, x => x.UseNancy(nancyOptions));

            return(new App(webApp, cts, tasks));
        }
예제 #4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public void update(org.neo4j.causalclustering.core.consensus.outcome.Outcome outcome) throws java.io.IOException
        public virtual void Update(Outcome outcome)
        {
            if (TermState().update(outcome.Term))
            {
                _termStorage.persistStoreData(TermState());
            }
            if (VoteState().update(outcome.VotedFor, outcome.Term))
            {
                _voteStorage.persistStoreData(VoteState());
            }

            LogIfLeaderChanged(outcome.Leader);
            _leader     = outcome.Leader;
            _leaderInfo = new LeaderInfo(outcome.Leader, outcome.Term);

            _leaderCommit       = outcome.LeaderCommit;
            _votesForMe         = outcome.VotesForMe;
            _preVotesForMe      = outcome.PreVotesForMe;
            _heartbeatResponses = outcome.HeartbeatResponses;
            _lastLogIndexBeforeWeBecameLeader = outcome.LastLogIndexBeforeWeBecameLeader;
            _followerStates = outcome.FollowerStates;
            _isPreElection  = outcome.PreElection;

            foreach (RaftLogCommand logCommand in outcome.LogCommands)
            {
                logCommand.ApplyTo(_entryLog, _log);
                logCommand.ApplyTo(_inFlightCache, _log);
            }
            _commitIndex = outcome.CommitIndex;
        }
예제 #5
0
        internal static void CasLeaders(HazelcastInstance hazelcastInstance, LeaderInfo leaderInfo, string dbName, Log log)
        {
            IAtomicReference <LeaderInfo> leaderRef = hazelcastInstance.getAtomicReference(DB_NAME_LEADER_TERM_PREFIX + dbName);

            LeaderInfo            current    = leaderRef.get();
            Optional <LeaderInfo> currentOpt = Optional.ofNullable(current);

//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
            bool sameLeader = currentOpt.map(LeaderInfo::memberId).Equals(Optional.ofNullable(leaderInfo.MemberId()));

            int termComparison = currentOpt.map(l => Long.compare(l.term(), leaderInfo.Term())).orElse(-1);

            bool greaterTermExists = termComparison > 0;

            bool sameTermButNoStepdown = termComparison == 0 && !leaderInfo.SteppingDown;

            if (sameLeader || greaterTermExists || sameTermButNoStepdown)
            {
                return;
            }

            bool success = leaderRef.compareAndSet(current, leaderInfo);

            if (!success)
            {
                log.Warn("Fail to set new leader info: %s. Latest leader info: %s.", leaderInfo, leaderRef.get());
            }
        }
 private void Awake()
 {
     info         = GetComponent <LeaderInfo>();
     animator     = info.animator;
     rangeImg     = info.rangeImg;
     fireEffect   = info.fireEffect;
     firePosition = info.firePosition;
 }
    private IEnumerator Start()
    {
        yield return(new WaitWhile(() => { return LeaderIndex == -1; }));

        leaderInfo = LeaderManager.Instance[LeaderIndex].GetComponent <LeaderInfo>();
        GetComponent <Button>().onClick.AddListener(ChangeLeaderDetail);
        GetComponent <Image>().sprite         = Resources.Load <Sprite>(leaderInfo.ID);
        GetComponent <Image>().preserveAspect = true;
    }
예제 #8
0
 public override bool OnMessage(UIMessage msg)
 {
     if (msg.type == UIMsgType.LeaderSelectPage_RefreshSelect)
     {
         LeaderInfo info = (LeaderInfo)msg.content[0];
         return(RefreshLeaderInfo(info));
     }
     return(false);
 }
예제 #9
0
        public override void SetLeader(LeaderInfo newLeader, string dbName)
        {
            LeaderInfo currentLeaderInfo = Leader;

            if (currentLeaderInfo.Term() < newLeader.Term() && LocalDBName().Equals(dbName))
            {
                Log.info("Leader %s updating leader info for database %s and term %s", MyselfConflict, dbName, newLeader.Term());
                Leader0 = newLeader;
            }
        }
예제 #10
0
        /// <summary>
        /// 绑定将领信息
        /// </summary>
        /// <param name="oobModel"></param>
        private void BindLeader(OOBInfo oobModel)
        {
            if (!string.IsNullOrEmpty(oobModel.leader))
            {
                LeaderInfo leaderInfo = leaderList.Find(l => l.ID.ToString() == oobModel.leader);
                if (leaderInfo != null)
                {
                    string leaderPath = RetuenPath(string.Concat(pathInfo.gfxPath, "pictures\\portraits\\", leaderInfo.picture, ".tga"));

                    Bitmap m_bmpLeader = DevIL.DevIL.LoadBitmap(leaderPath);
                    pb_Leader.Image         = m_bmpLeader;
                    txt_LeaderID.Text       = leaderInfo.ID.ToString();
                    txt_LeaderName.Text     = leaderInfo.name;
                    txt_LeaderSkill.Text    = leaderInfo.skill.ToString();
                    txt_LeaderMaxSkill.Text = leaderInfo.max_skill.ToString();
                    int num = leaderInfo.add_trait.Count;
                    if (num > 0)
                    {
                        pictureBox_trait1.Image = showTraitImage(leaderInfo.add_trait[0]);
                        traitList.Add(leaderTraitList.Find(t => t.traitCode == leaderInfo.add_trait[0]).traitName);
                    }
                    if (num > 1)
                    {
                        pictureBox_trait2.Image = showTraitImage(leaderInfo.add_trait[1]);
                        traitList.Add(leaderTraitList.Find(t => t.traitCode == leaderInfo.add_trait[1]).traitName);
                    }
                    if (num > 2)
                    {
                        pictureBox_trait3.Image = showTraitImage(leaderInfo.add_trait[2]);
                        traitList.Add(leaderTraitList.Find(t => t.traitCode == leaderInfo.add_trait[2]).traitName);
                    }
                    if (num > 3)
                    {
                        pictureBox_trait4.Image = showTraitImage(leaderInfo.add_trait[3]);
                        traitList.Add(leaderTraitList.Find(t => t.traitCode == leaderInfo.add_trait[3]).traitName);
                    }
                }
                else
                {
                    string leaderPath = RetuenPath(string.Concat(pathInfo.gfxPath, "pictures\\portraits\\empty_position.tga"));

                    Bitmap m_bmpLeader = DevIL.DevIL.LoadBitmap(leaderPath);
                    pb_Leader.Image = m_bmpLeader;
                }
            }
            else
            {
                string leaderPath = RetuenPath(string.Concat(pathInfo.gfxPath, "pictures\\portraits\\empty_position.tga"));

                Bitmap m_bmpLeader = DevIL.DevIL.LoadBitmap(leaderPath);
                pb_Leader.Image = m_bmpLeader;
            }
        }
예제 #11
0
        public override void HandleStepDown(long term, string dbName)
        {
            LeaderInfo localLeaderInfo = Leader;

            bool wasLeaderForDbAndTerm = Objects.Equals(MyselfConflict, localLeaderInfo.MemberId()) && LocalDBName().Equals(dbName) && term == localLeaderInfo.Term();

            if (wasLeaderForDbAndTerm)
            {
                Log.info("Step down event detected. This topology member, with MemberId %s, was leader in term %s, now moving " + "to follower.", MyselfConflict, localLeaderInfo.Term());
                HandleStepDown0(localLeaderInfo.StepDown());
            }
        }
예제 #12
0
 bool RemoveLeader(LeaderInfo info)
 {
     for (int i = 0; i < leaderCardList.Count; i++)
     {
         if (leaderCardList[i].currentState == LeaderPrepareCard.State.Select_Prepare && leaderCardList[i]._info == info)
         {
             leaderCardList[i].SetUpItem(LeaderPrepareCard.State.Empty, null, CampManager.Instance.PreparePage_CurrentSelect_CampID);
             DataManager.Instance.gamePrepareData.RemoveSelectLeaderInfo(info);
             break;
         }
     }
     return(true);
 }
예제 #13
0
        public override void OnLeaderSwitch(LeaderInfo leaderInfo)
        {
            _progressTracker.triggerReplicationEvent();
            MemberId newLeader = leaderInfo.MemberId();
            MemberId oldLeader = _leaderProvider.currentLeader();

            if (newLeader == null && oldLeader != null)
            {
                _log.info("Lost previous leader '%s'. Currently no available leader", oldLeader);
            }
            else if (newLeader != null && oldLeader == null)
            {
                _log.info("A new leader has been detected: '%s'", newLeader);
            }
            _leaderProvider.Leader = newLeader;
        }
예제 #14
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: private void refreshRoles() throws InterruptedException
        private void RefreshRoles()
        {
            WaitOnHazelcastInstanceCreation();
            LeaderInfo            localLeaderInfo   = _leaderInfo.get();
            Optional <LeaderInfo> localStepDownInfo = _stepDownInfo.get();

            if (localStepDownInfo.Present)
            {
                HazelcastClusterTopology.CasLeaders(_hazelcastInstance, localStepDownInfo.get(), _localDBName, Log);
                _stepDownInfo.compareAndSet(localStepDownInfo, null);
            }
            else if (localLeaderInfo.MemberId() != null && localLeaderInfo.MemberId().Equals(MyselfConflict))
            {
                HazelcastClusterTopology.CasLeaders(_hazelcastInstance, localLeaderInfo, _localDBName, Log);
            }

            _coreRoles = HazelcastClusterTopology.GetCoreRoles(_hazelcastInstance, AllCoreServers().members().Keys);
        }
예제 #15
0
        bool AddLeader(LeaderInfo info)
        {
            ///Add First
            bool isFull = true;

            for (int i = 0; i < leaderCardList.Count; i++)
            {
                if (leaderCardList[i].currentState == LeaderPrepareCard.State.Empty)
                {
                    leaderCardList[i].SetUpItem(LeaderPrepareCard.State.Select_Prepare, info);
                    leaderCardList[i].ShowRemoveBtn();
                    DataManager.Instance.gamePrepareData.AddSelectLeaderInfo(info);
                    isFull = false;
                    break;
                }
            }
            return(!isFull);
        }
예제 #16
0
        bool RefreshLeaderInfo(LeaderInfo info)
        {
            if (info == null)
            {
                return(false);
            }
            currentSelectLeaderInfo = info;
            _nameText.text          = info.leaderName;
            _speciesText.text       = info.speciesInfo.speciesName;
            _ageText.text           = info.currentAge.ToString();
            _sexText.text           = LeaderModule.GetLeaderGenderText(info.Gender);
            _birthlandText.text     = info.birthlandInfo.landName;
            _creedText.text         = info.creedInfo.creedName;

            SetUpAttribute(info.attributeInfoList);
            SetUpSkill(info.skillInfoList);
            SetUpStory(info.storyInfoList);
            return(true);
        }
예제 #17
0
        internal void CasLeaders(LeaderInfo leaderInfo, string dbName)
        {
            lock ( _leaderMap )
            {
                Optional <LeaderInfo> current = Optional.ofNullable(_leaderMap.get(dbName));

//JAVA TO C# CONVERTER TODO TASK: Method reference arbitrary object instance method syntax is not converted by Java to C# Converter:
                bool sameLeader = current.map(LeaderInfo::memberId).Equals(Optional.ofNullable(leaderInfo.MemberId()));

                int termComparison = current.map(l => Long.compare(l.term(), leaderInfo.Term())).orElse(-1);

                bool greaterTermExists = termComparison > 0;

                bool sameTermButNoStepDown = termComparison == 0 && !leaderInfo.SteppingDown;

                if (!(greaterTermExists || sameTermButNoStepDown || sameLeader))
                {
                    _leaderMap.put(dbName, leaderInfo);
                }
            }
        }
예제 #18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test void shouldListenToLeaderUpdates() throws ReplicationFailureException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        internal virtual void ShouldListenToLeaderUpdates()
        {
            OneProgressTracker oneProgressTracker = new OneProgressTracker(this);

            oneProgressTracker.Last.setReplicated();
            CapturingOutbound <Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage> outbound = new CapturingOutbound <Org.Neo4j.causalclustering.core.consensus.RaftMessages_RaftMessage>();
            RaftReplicator    replicator = GetReplicator(outbound, oneProgressTracker, new Monitors());
            ReplicatedInteger content    = ReplicatedInteger.valueOf(5);

            LeaderInfo lastLeader = _leaderInfo;

            // set initial leader, sens to that leader
            replicator.OnLeaderSwitch(lastLeader);
            replicator.Replicate(content, false);
            assertEquals(outbound.LastTo, lastLeader.MemberId());

            // update with valid new leader, sends to new leader
            lastLeader = new LeaderInfo(new MemberId(System.Guid.randomUUID()), 1);
            replicator.OnLeaderSwitch(lastLeader);
            replicator.Replicate(content, false);
            assertEquals(outbound.LastTo, lastLeader.MemberId());
        }
예제 #19
0
        private void BindDetail()
        {
            if (leaderID != 0)
            {
                LeaderInfo leaderInfo = leaderList.Find(l => l.ID == leaderID);
                string     leaderPath = ReturnLeaderPicturePath(leaderInfo.picture);

                Bitmap m_bmpLeader = DevIL.DevIL.LoadBitmap(leaderPath);
                picture_Leader.Image = m_bmpLeader;
                lbl_Name.Text        = leaderInfo.name;
                lbl_Skill.Text       = leaderInfo.skill.ToString();
                lbl_MaxSkill.Text    = leaderInfo.max_skill.ToString();
                int num = leaderInfo.add_trait.Count;
                if (num > 0)
                {
                    pictureBox_trait1.Image = showTraitImage(leaderInfo.add_trait[0]);
                    traitList.Add(leaderTraitList.Find(t => t.traitCode == leaderInfo.add_trait[0]).traitName);
                }
                if (num > 1)
                {
                    pictureBox_trait2.Image = showTraitImage(leaderInfo.add_trait[1]);
                    traitList.Add(leaderTraitList.Find(t => t.traitCode == leaderInfo.add_trait[1]).traitName);
                }
                if (num > 2)
                {
                    pictureBox_trait3.Image = showTraitImage(leaderInfo.add_trait[2]);
                    traitList.Add(leaderTraitList.Find(t => t.traitCode == leaderInfo.add_trait[2]).traitName);
                }
                if (num > 3)
                {
                    pictureBox_trait4.Image = showTraitImage(leaderInfo.add_trait[3]);
                    traitList.Add(leaderTraitList.Find(t => t.traitCode == leaderInfo.add_trait[3]).traitName);
                }
            }
            else
            {
                lbl_Name.Text = "无将领";
            }
        }
    static public List <LeaderInfo> GetLeadersDetailed(int UserId, int PortalId)
    {
        StaffBrokerDataContext d = new StaffBrokerDataContext();



        var s = from c in d.AP_StaffBroker_LeaderMetas where c.UserId == UserId select new { UserId = c.LeaderId, hasDelegated = c.DelegateId != null, isDelegate = false };

        s = s.Union(from c in d.AP_StaffBroker_LeaderMetas where (c.UserId == UserId) && !(c.DelegateId == null)select new { UserId = (int)c.DelegateId, hasDelegated = false, isDelegate = true });

        List <LeaderInfo> rtn = new List <LeaderInfo>();

        foreach (var row in s)
        {
            LeaderInfo insert = new LeaderInfo();
            insert.UserId       = row.UserId;
            insert.DisplayName  = DotNetNuke.Entities.Users.UserController.GetUserById(PortalId, row.UserId).DisplayName;
            insert.isDelegate   = row.isDelegate;
            insert.hasDelegated = row.hasDelegated;
            rtn.Add(insert);
        }
        return(rtn);
    }
예제 #21
0
 public override void HandleStepDown0(LeaderInfo steppingDown)
 {
     _sharedDiscoveryService.casLeaders(steppingDown, _localDBName);
 }
예제 #22
0
 public override void HandleStepDown0(LeaderInfo steppingDown)
 {
     _stepDownInfo.set(steppingDown);
 }
예제 #23
0
        void DatabaseRead()
        {
            // Create a utility to handle the SQL calls for this action.
            MSSqlUtility sqlUtil = new MSSqlUtility();

            //Create an empty row list to be used as the all cards holder
            List <SqlRow> allCardsRows = new List <SqlRow>();

            //Create an empty row list to be used as the all factions holder
            List <SqlRow> allFactionsRows = new List <SqlRow>();

            //Create an empty row list to be used as the all leaders holder
            List <SqlRow> allLeadersRows = new List <SqlRow>();

            try
            {
                allCardsRows = sqlUtil.ExecuteQuery(gAppOptions.SelectAllPlayerCards, connectionString, null);

                //READ LEADERS AND FACTIONS
                allFactionsRows = sqlUtil.ExecuteQuery(gAppOptions.SelectAllFactions, connectionString, null);
                allLeadersRows  = sqlUtil.ExecuteQuery(gAppOptions.SelectAllLeaders, connectionString, null);
                //Build the Factions and build the list
                if (allFactionsRows != null)
                {
                    foreach (SqlRow row in allFactionsRows)
                    {
                        //Assign the returned database values into the object
                        FactionInfo faction = new FactionInfo();
                        faction.FactionName = ((string)row["factionName"]).Trim();
                        faction.FactionAbbr = ((string)row["factionAbbreviation"]).Trim();
                        faction.FactionPerk = ((string)row["factionPerk"]).Trim();
                        faction.FactionId   = ((int)row["Id"]);
                        gAllFactions.Add(faction);
                    }
                }
                //Build the Leaders and build the list
                if (allLeadersRows != null)
                {
                    foreach (SqlRow row in allLeadersRows)
                    {
                        //Assign the returned database values into the object
                        LeaderInfo leader = new LeaderInfo();
                        leader.LeaderName        = ((string)row["leaderName"]).Trim();
                        leader.LeaderAbility     = ((string)row["leaderAbility"]).Trim();
                        leader.LeaderFaction     = ((string)row["leaderFaction"]).Trim();
                        leader.LeaderFactionAbbr = ((string)row["leaderFactionAbbreviation"]);
                        leader.LeaderId          = ((int)row["Id"]);
                        gAllLeaders.Add(leader);
                    }
                }
                //Build the motherlode deck by assigning the attributes from the database into the object attributes.
                //The TRY/CATCH is there to handle potential null values because C# null is not the same as DBNULL
                if (allCardsRows != null)
                {
                    foreach (SqlRow row in allCardsRows)
                    {
                        Card card = new Card();
                        //Read in card ID
                        try
                        {
                            card.CardId = ((int)row["Id"]);
                        }
                        catch { }
                        try
                        {
                            card.Name = ((string)row["cardName"]).Trim();
                        }
                        catch
                        { }
                        try
                        {
                            card.Power = (int)row["cardPower"];
                        }
                        catch { }
                        try
                        {
                            card.Faction = ((string)row["cardFaction"]).Trim();
                        }
                        catch { }
                        try
                        {
                            card.Quote = ((string)row["cardQuote"]).Trim();
                        }
                        catch { }
                        try
                        {
                            card.Hero = (bool)(row["cardHero"]);
                        }
                        catch { }
                        try
                        {
                            card.Range = ((string)row["cardRange"]).Trim();
                        }
                        catch { }
                        try
                        {
                            card.Ability = ((string)row["cardAbilities"]).Trim();
                        }
                        catch { }
                        try
                        {
                            card.Quote = ((string)row["cardQuote"]).Trim();
                        }
                        catch { }
                        //New logic to read image file from DB and build path. ImageFilePath
                        try
                        {
                            string cardImageFileName = (string)row["cardImageFileName"];
                            card.ImageFilePath = "~/Content/Images/" + (cardImageFileName.Trim().Replace(" ", "%20"));
                        }
                        catch { }
                        gAllCards.Add(card);
                    }
                }
            } // end of Try-No Touchy
            catch
            {
                //Do we need to perform an action on catch?
            }
        }
    public static List<LeaderInfo> GetLeadersDetailed(int UserId, int PortalId)
    {
        StaffBrokerDataContext d = new StaffBrokerDataContext();

        var s = from c in d.AP_StaffBroker_LeaderMetas where c.UserId == UserId select new { UserId = c.LeaderId, hasDelegated = c.DelegateId != null, isDelegate = false };

        s = s.Union(from c in d.AP_StaffBroker_LeaderMetas where (c.UserId == UserId) && !(c.DelegateId == null) select new { UserId = (int)c.DelegateId, hasDelegated = false, isDelegate = true });

        List<LeaderInfo> rtn = new List<LeaderInfo>();

        foreach (var row in s)
        {
            LeaderInfo insert = new LeaderInfo();
            insert.UserId = row.UserId;
            insert.DisplayName = DotNetNuke.Entities.Users.UserController.GetUserById(PortalId, row.UserId).DisplayName;
            insert.isDelegate = row.isDelegate;
            insert.hasDelegated = row.hasDelegated;
            rtn.Add(insert);
        }
        return rtn;
    }
예제 #25
0
    public void SetGameSateFromJson(string result)
    {
        //string json = @"{  CPU: 'Intel',  Drives: [    'DVD read/writer',    '500 gigabyte hard drive'  ]}";

        JObject jresult = JObject.Parse(result) as JObject;

        //Debug.Log(jresult["result"]["gamestate"]["channels"]);

        //================  Get channel Info  ==============//
        JObject jChannels = jresult["result"]["gamestate"]["channels"] as JObject;
        Dictionary <string, JObject> dictObj = jChannels.ToObject <Dictionary <string, JObject> >();

        List <ChannelInfo> oldChannelList = new List <ChannelInfo>();

        oldChannelList = GlobalData.ggameChannelList;
        if (GlobalData.ggameChannelList != null)
        {
            GlobalData.ggameChannelList.Clear();
        }
        if (GlobalData.ggameLobbyChannelList != null)
        {
            GlobalData.ggameLobbyChannelList.Clear();
        }

        foreach (KeyValuePair <string, JObject> item in dictObj)
        {
            ChannelInfo channelInfo = new ChannelInfo();
            channelInfo.id = item.Key;
            JArray a = item.Value["meta"]["participants"] as JArray;

            ChannelInfo oldChannel = null;
            foreach (ChannelInfo c in oldChannelList)
            {
                if (c.id == channelInfo.id)
                {
                    oldChannel = c;
                }
            }

            channelInfo.userNames  = new string[a.Count];
            channelInfo.statusText = item.Value["state"]["parsed"]["phase"].ToString();

            int index = 0;
            foreach (JObject j in a)
            {
                channelInfo.userNames[index++] = j["name"].ToString();
            }

            if (!GlobalData.bRunonce && a.Count > 1)
            {
                channelInfo.bignored = true;
                GlobalData.ggameIgnoredChannelIDs.Add(channelInfo.id);
                continue;
            }

            GlobalData.AddChannel(channelInfo);

            if (a.Count == 1)
            {
                GlobalData.ggameLobbyChannelList.Add(channelInfo);
            }

            if (!GlobalData.bLogin)
            {
                continue;
            }


            //====== case new channel, load channel service =============//
            if (channelInfo.userNames.Length > 1)
            {
                if (GlobalData.bOpenedChannel ||
                    (channelInfo.userNames[0] != GlobalData.gPlayerName.Substring(2) &&
                     channelInfo.userNames[1] != GlobalData.gPlayerName.Substring(2)))
                {
                    continue;
                }

                string opponentName = channelInfo.userNames[0];
                if (channelInfo.userNames[0] == GlobalData.gPlayerName.Substring(2))
                {
                    opponentName = channelInfo.userNames[1];
                }
                //=========================    ==============================//
                if (!GetComponent <GameUserManager>().IsExistName("p/" + opponentName))    //=== case  only other user====//
                {
                    Debug.Log("liveFlag:" + GlobalData.bLiveChannel);
                    if (!GlobalData.bLiveChannel && !GlobalData.IsIgnoreChannel(channelInfo.id))
                    //   if (!GlobalData.bLiveChannel)
                    {
                        GlobalData.bOpenedChannel = true;
                        //============= Create  Channe
                        GetComponent <GameUserManager>().StartGameByChannel(channelInfo.id);
                        //case menu is active, collapse  menu
                        GetComponent <GameUserManager>().InitMenu();
                        GlobalData.InitGameChannelData();

                        GlobalData.bLiveChannel = true;
                        GlobalData.bFinished    = false;
                        GlobalData.bPlaying     = false;
                    }
                    //Debug.Log(channelInfo.id);
                }
            }
        }
        //============================================================//
        if (!GlobalData.bRunonce)
        {
            GlobalData.bRunonce = true;
        }

        //============================= Get Leader Info ===============================//
        JObject jstatss = jresult["result"]["gamestate"]["gamestats"] as JObject;

        //Debug.Log(jstatss.ToString());
        if (jstatss == null)
        {
            return;
        }
        dictObj = jstatss.ToObject <Dictionary <string, JObject> >();

        if (GlobalData.ggameLeaderList != null)
        {
            GlobalData.ggameLeaderList.Clear();
        }

        foreach (KeyValuePair <string, JObject> item in dictObj)
        {
            LeaderInfo leaderInfo = new LeaderInfo();
            leaderInfo.playerName  = item.Key;
            leaderInfo.winCount    = int.Parse(item.Value["won"].ToString());
            leaderInfo.playedCount = leaderInfo.winCount + int.Parse(item.Value["lost"].ToString());
            GlobalData.ggameLeaderList.Add(leaderInfo);
        }
        //============================================================//
    }
예제 #26
0
 public override void OnLeaderSwitch(LeaderInfo leaderInfo)
 {
     _coreTopologyService.setLeader(leaderInfo, _dbName);
 }
예제 #27
0
 public override void Awake(params object[] paralist)
 {
     base.Awake(paralist);
     _info = (LeaderInfo)paralist[0];
     AddBtnClick();
 }
예제 #28
0
 public override void OnShow(params object[] paralist)
 {
     base.OnShow(paralist);
     _info = (LeaderInfo)paralist[0];
     SetUpDialog();
 }
예제 #29
0
 protected internal abstract void HandleStepDown0(LeaderInfo steppingDown);