Ejemplo n.º 1
0
    private LightweightLabel CreateLabel(int id)
    {
        LightweightLabel label = Instantiate(LabelPrefab, LabelContainer);

        label.FirstSetup(id);
        return(label);
    }
Ejemplo n.º 2
0
    public void Create(UnitRow unitData, UserInfoRow user)
    {
        AgentRemote agentRemote = AgentPooling.GetItem(unitData.ID_Unit);

        if (agentRemote == null || user == null)
        {
            return;
        }
        else
        {
            agentRemote.Dispose();
            this.AddAgent(unitData.ID, agentRemote);

            LightweightLabel label = labelPooling.GetItem();
            agentRemote.transform.position = MapIns.CellToWorld(unitData.Position_Cell.Parse3Int().ToClientPosition());

            agentRemote.OnDead += delegate
            {
                AgentPooling.Release(agentRemote.Type, agentRemote);
                labelPooling.Release(label);

                MyAgentRemoteManager.Remove(agentRemote.AgentID);
                this.RemoveAgent(agentRemote.AgentID);
            };

            label.Initalize(agentRemote, MainCamera);
            bool isOwner = unitData.ID_User == PlayerInfo.Info.ID_User;

            agentRemote.Initalize(UnitTable, label, unitData, user, isOwner);

            if (isOwner)
            {
                if (agentRemote.NavAgent == null)
                {
                    agentRemote.gameObject.AddComponent <NavAgent>();
                }
                MyAgentRemoteManager.Add(agentRemote);
                agentRemote.name = "Owner " + unitData.ID;
            }
            else
            {
                agentRemote.name = "other " + unitData.ID;
            }
            agentRemote.gameObject.SetActive(true);
        }
    }
Ejemplo 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);
        }