Esempio n. 1
0
    protected override void Awake()
    {
        base.Awake();

        UnitTable = SyncData?.UnitTable;
        Users     = SyncData?.UserInfos;

        PlayerInfo           = Singleton.Instance <PlayerInfo>();
        MyAgentRemoteManager = Singleton.Instance <MyAgentRemoteManager>();
        Events = Singleton.Instance <EventListenersController>();

        labelPooling = new Pooling <LightweightLabel>(CreateLabel, 10);
        Events.On("R_UNIT", R_UNIT_CREATE_UNIT);
    }
Esempio n. 2
0
    private void R_DEPLOY(SocketIOEvent obj)
    {
        Debugger.Log(obj);
        string      json = obj.data["R_DEPLOY"].ToString();
        UnitRow     unit = JsonUtility.FromJson <UnitRow>(json);
        UserInfoRow user = SyncData.UserInfos.GetUserById(unit.ID_User);

        unitDataReference.Create(unit, user);

        JSONTable_Unit units = SyncData.UnitTable;

        units.Insert(unit);
        //SelectAgentPanel.Add(unit);
        //Debugger.Log("added " + unit.ID);
    }
Esempio n. 3
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);
        }