Exemple #1
0
        protected override bool UpdateOrInsert(UnitRow updateData)
        {
            bool isUpdate = base.UpdateOrInsert(updateData);

            if (isUpdate)
            {
                Observer_Unit tempObs = ObserverPooling.GetItem();
                tempObs.RefreshSubject(updateData);

                Observer_Unit notifyObserver = Observers.FirstOrDefault_R(tempObs);
                ObserverPooling.Release(tempObs);

                if (notifyObserver != null)
                {
                    Notify(notifyObserver);
                }
            }

            return(isUpdate);
        }
Exemple #2
0
        public void Initalize(
            JSONTable_Unit subject,
            LightweightLabel label,
            UnitRow unitData,
            UserInfoRow user,
            bool isOwner)

        {
            Label       = label;
            unitSubject = subject;

            AgentInfo.UserInfo = user;
            AgentInfo.UnitInfo = unitData;

            IsOwner = isOwner;

            //string format = IsOwner ? "{0}" : "<color=red>{0}</color>"; // not friend

            //if (!IsOwner)
            //{
            //    bool isFriend = Singleton.Instance<FriendSys>().IsMyFriend(user.ID_User);
            //    format = isFriend ? "<color=green>{0}</color>" : format; // friend
            //}

            string format = GetLabelFormat();


            Label.NameInGame = string.Format(format, "Id " + unitData.ID + ": " + user.NameInGame);
            Label.SetHP(unitData.Hea_cur, unitData.Health);
            Label.Quality = unitData.Quality;
            Label.gameObject.SetActive(true);

            observer = subject.ObserverPooling.GetItem();
            observer.RefreshSubject(unitData);
            observer.OnSubjectUpdated += SubjectChanged;
            subject.Register(observer);
        }