예제 #1
0
    /// <summary>
    /// 添加角色到角色总列表
    /// </summary>
    /// <param name="headAdd">添加到列表头部</param>
    /// <param name="serverGid">服务器gid</param>
    /// <param name="id">角色uid</param>
    /// <param name="tid"></param>
    /// <param name="name"></param>
    /// <param name="lv"></param>
    /// <param name="offtime">上次登陆时间</param>
    /// <param name="pos">位置</param>
    public void AddCharacter(bool headAdd, string serverGid, ulong id, int tid, string name, int lv, ulong offtime, int pos, int rank)
    {
        ServerInfoVO serverInfo = GetServerBy(serverGid);

        if (serverInfo == null)
        {
            return;
        }
        if (serverInfo.CharacterList == null)
        {
            serverInfo.CharacterList = new List <CharacterVO>();
        }

        CharacterVO player = new CharacterVO();

        player.UId           = id;
        player.Name          = name;
        player.Tid           = tid;
        player.Level         = lv;
        player.DanLevel      = rank;
        player.LastLoginTime = (int)offtime;
        if (headAdd)
        {
            serverInfo.CharacterList.Insert(0, player);
        }
        else
        {
            serverInfo.CharacterList.Add(player);
        }
    }
예제 #2
0
 private void LogCharacterParameter(CharacterVO data)
 {
     if (data != null)
     {
         Debug.Log(string.Format("<color=cyan>id={0}, type={1}, assetName={2}, moveSpeed={3}, baseHp={4}, baseSp={5}, baseAkt={6}, baseDef={7}</color>",
                                 data.id, data.type, data.assetName, data.moveSpeed, data.baseHp, data.baseSp, data.baseAtk, data.baseDef));
     }
 }
예제 #3
0
        private void LoadCharacter(string characterId, bool doTransition)
        {
            this.CharacterId = characterId;
            CharacterVO characterVO = Service.StaticDataController.Get <CharacterVO>(characterId);

            this.characterAssetName = characterVO.AssetName;
            this.assetManager.Load(ref this.charHandle, this.characterAssetName, new AssetSuccessDelegate(this.OnCharacterLoaded), new AssetFailureDelegate(this.OnCharacterLoadFailed), doTransition);
        }
예제 #4
0
    /// <summary>
    /// 更新角色列表
    /// </summary>
    private void UpdateCharacterList(int selectIndex)
    {
        List <CharacterVO> datas = m_ServerListProxy.GetLastLoginServer().CharacterList;

        m_CharacterToggleList.Clear();
        //  m_CharacterItemRoot.GetComponent<ToggleGroup>().allowSwitchOff = true;
        //int index = 0;
        int count = datas != null ? datas.Count : 0;

        SetHotKeyEnabled("f", datas.Count < 5);
        m_Title.text = string.Format(TableUtil.GetLanguageString("mailbox_title_1004"), datas.Count, 5);
        for (int i = 0; i < count; i++)
        {
            int sign = i;

            CharacterVO data = datas[i];

            Transform item =
                sign < m_CharacterItemRoot.childCount ?
                m_CharacterItemRoot.GetChild(sign) :
                GameObject.Instantiate(m_CharacterItemPrefab, m_CharacterItemRoot).transform;
            item.gameObject.SetActive(true);

            Toggle toggle = null;
            if (m_EletmentDic.ContainsKey(sign))
            {
                toggle = m_EletmentDic[sign].m_Toggle;
                m_EletmentDic[sign].InitData(data);
            }
            else
            {
                Eletment eletment = new Eletment();
                eletment.InitEletment(item);
                eletment.InitData(data);
                m_EletmentDic.Add(sign, eletment);
                toggle = eletment.m_Toggle;
            }
            toggle.onValueChanged.RemoveAllListeners();
            toggle.group = m_CharacterItemRoot.GetComponent <ToggleGroup>();
            toggle.group.allowSwitchOff = true;
            m_CharacterToggleList.Add(toggle);
            //  toggle.isOn = false;
            m_LastSelectIndex = -1;
            toggle.onValueChanged.AddListener((select) => {
                toggle.group.allowSwitchOff = false;
                OnToggleClick(select, item.gameObject, sign);
            });
            toggle.isOn = false;
        }
        for (int i = count; i < m_CharacterItemRoot.childCount; i++)
        {
            m_CharacterItemRoot.GetChild(i).GetComponent <Toggle>().onValueChanged.RemoveAllListeners();
            m_CharacterItemRoot.GetChild(i).gameObject.SetActive(false);
        }
        m_CharacterToggleList[selectIndex].isOn = true;

        FocusTo(m_CharacterToggleList[selectIndex]);
    }
예제 #5
0
 /// <summary>
 /// 获取角色列表中当前选中的角色
 /// </summary>
 /// <returns></returns>
 public CharacterVO GetCurrentCharacterVO()
 {
     if (m_CurrentCharacterVO == null)
     {
         m_CurrentCharacterVO     = new CharacterVO();
         m_CurrentCharacterVO.Tid = (int)GetCfgEternityProxy().GetMalePlayerByIndex(0).Id;
     }
     return(m_CurrentCharacterVO);
 }
예제 #6
0
 private void TryPlayGreet()
 {
     if (this.greet)
     {
         CharacterVO characterVO = Service.StaticDataController.Get <CharacterVO>(this.Character);
         if (characterVO.Greets != null)
         {
             int num = Service.Rand.ViewRangeInt(0, characterVO.Greets.Length);
             Service.EventManager.SendEvent(EventId.PlayHoloGreet, characterVO.Greets[num]);
         }
     }
 }
예제 #7
0
        /// <summary>
        /// Create a new Unit and initialize default equipment and weapons
        /// </summary>
        public Unit CreateNewUnit(string unitUID, string characterUID, CombatantFactionEnum faction)
        {
            UnitVO      unitVO = metadataMap.GetVO <UnitVO>(unitUID);
            CharacterVO charVO = metadataMap.GetVO <CharacterVO>(characterUID);

            List <Equipment> defaultEquipment = GetEquipmentListFromUIDs(unitVO.equipmentUIDs);

            List <Equipment> defaultWeapons = GetEquipmentListFromUIDs(unitVO.weaponsUIDs);

            Unit unit = new Unit(unitVO, charVO, faction, defaultEquipment, defaultWeapons);

            return(unit);
        }
예제 #8
0
        void GrantReward(string[] args)
        {
            CommodityType cType = CommodityType.Livre;
            int           val   = 0;
            string        id    = "";

            if (args.Length > 1)
            {
                if (!Enum.TryParse <CommodityType>(args[1], ignoreCase: true, out cType))
                {
                    error("Can't interpret {0} as a CommodityType.", args[1]);
                }
            }

            if (args.Length == 3)
            {
                // "reward CommodityType value"
                if (!int.TryParse(args[2], out val))
                {
                    error("Can't interpret {0} as a number.", args[2]);
                }
            }
            else if (args.Length == 4)
            {
                id = args[2];
                // "reward CommodityType ID value"
                if (!int.TryParse(args[3], out val))
                {
                    error("Can't interpret {0} as a number.", args[3]);
                }
            }
            else
            {
                error("'reward' requires either type and value, or type, ID, and value.");
                return;
            }

            if (cType == CommodityType.Favor)
            {
                CharacterVO character = AmbitionApp.GetModel <CharacterModel>().GetCharacter(id);
                if (character == null)
                {
                    error("Character '{0}' not found.", id);
                    return;
                }
            }

            AmbitionApp.SendMessage(new CommodityVO(cType, id, val));
        }
예제 #9
0
 /// <summary>
 /// 设置当前创角时 角色信息
 /// </summary>
 public void SetCurrentCharacter()
 {
     if (m_CurrentCharacterVO == null)
     {
         m_CurrentCharacterVO = new CharacterVO();
     }
     if (m_IsMale)
     {
         m_CurrentCharacterVO.Tid = (int)GetCfgEternityProxy().GetMalePlayerByIndex(m_SkinIndex).Id;
     }
     else
     {
         m_CurrentCharacterVO.Tid = (int)GetCfgEternityProxy().GetFamalePlayerByIndex(m_SkinIndex).Id;
     }
     SendNotification(NotificationName.MSG_CHARACTER_CREATE_CURRENT_CHARACTERVO_CHANGE);
 }
예제 #10
0
 /// <summary>
 /// 设置当前选中的角色列表中的角色
 /// </summary>
 /// <param name="characterVO"></param>
 public void SetCurrentCharacterVO(CharacterVO characterVO)
 {
     m_CurrentCharacterVO = new CharacterVO();
     if (characterVO != null)
     {
         m_CurrentCharacterVO.Tid           = characterVO.Tid;
         m_CurrentCharacterVO.UId           = characterVO.UId;
         m_CurrentCharacterVO.Level         = characterVO.Level;
         m_CurrentCharacterVO.DanLevel      = characterVO.DanLevel;
         m_CurrentCharacterVO.LastLoginTime = characterVO.LastLoginTime;
         m_CurrentCharacterVO.Name          = characterVO.Name;
     }
     else
     {
         m_CurrentCharacterVO.Tid = (int)GetCfgEternityProxy().GetMalePlayerByIndex(0).Id;
     }
     SendNotification(NotificationName.MSG_CHARACTER_CREATE_CURRENT_CHARACTERVO_CHANGE);
 }
예제 #11
0
        public Unit(
            UnitVO vo,
            CharacterVO pilot,
            CombatantFactionEnum faction,
            List <Equipment> equipment,
            List <Equipment> weapons)
        {
            this.vo = vo;

            this.pilot   = pilot;
            this.faction = faction;

            // Initialize the unit with max supplies
            hp   = vo.hp;
            ammo = vo.ammo;
            fuel = vo.fuel;

            this.equipment = equipment;
            this.weapons   = weapons;
        }
예제 #12
0
 void MakeDateable(string[] args)
 {
     if (args.Length <= 1)
     {
         error("usage: 'sempai <character_id>' where character_id is a romance option");
     }
     else
     {
         CharacterModel model     = AmbitionApp.GetModel <CharacterModel>();
         CharacterVO    character = model.GetCharacter(args[1]);
         if (character != null)
         {
             character.Favor      = 100;
             character.IsDateable = true;
             character.Acquainted = true;
             log("{0} is now dateable.", args[1]);
         }
         else
         {
             error("error: could not find character '{0}'", args[1]);
         }
     }
 }
예제 #13
0
 /// <summary>
 /// 初始化数据
 /// </summary>
 /// <param name="data">数据</param>
 public void InitData(CharacterVO data)
 {
     m_NameText.text  = data.Name;
     m_LevelText.text = string.Format(TableUtil.GetLanguageString("character_text_1019"), data.Level);
 }
예제 #14
0
        void SetCommodity(string[] args)
        {
            CommodityType cType = CommodityType.Livre;
            GameModel     game  = AmbitionApp.GetModel <GameModel>();

            int    val = 0;
            string id  = "";

            if (args.Length > 1)
            {
                if (!Enum.TryParse <CommodityType>(args[1], ignoreCase: true, out cType))
                {
                    error("Can't interpret {0} as a CommodityType.", args[1]);
                }
            }

            if (args.Length == 3)
            {
                // "reward CommodityType value"
                if (!int.TryParse(args[2], out val))
                {
                    error("Can't interpret {0} as a number.", args[2]);
                }
            }
            else if (args.Length == 4)
            {
                id = args[2];
                // "reward CommodityType ID value"
                if (!int.TryParse(args[3], out val))
                {
                    error("Can't interpret {0} as a number.", args[3]);
                }
            }
            else
            {
                error("'set' requires either type and value, or type, ID, and value.");
                return;
            }


            FactionType factionType;
            FactionVO   faction;

            switch (cType)
            {
            case CommodityType.Livre:
                AmbitionApp.Game.Livre = val;
                AmbitionApp.SendMessage(GameConsts.LIVRE, val);
                break;

            case CommodityType.Exhaustion:
                AmbitionApp.Game.Exhaustion = val;
                break;

            case CommodityType.Credibility:
                AmbitionApp.Game.Credibility = val;
                AmbitionApp.SendMessage(GameConsts.CREDIBILITY, val);
                break;

            case CommodityType.Peril:
                AmbitionApp.Game.Peril = val;
                AmbitionApp.SendMessage(GameConsts.PERIL, val);
                break;

            case CommodityType.Power:
                if (id != null && Enum.TryParse <FactionType>(id, true, out factionType))
                {
                    AmbitionApp.Politics.Factions.TryGetValue(factionType, out faction);
                    if (faction != null)
                    {
                        faction.Power = val;
                    }
                }
                else
                {
                    Debug.LogWarning("SetCommodityCmd with FactionPower for unidentified faction ");
                }
                break;

            case CommodityType.Allegiance:
                if (id != null && Enum.TryParse <FactionType>(id, true, out factionType))
                {
                    AmbitionApp.Politics.Factions.TryGetValue(factionType, out faction);
                    if (faction != null)
                    {
                        faction.Allegiance = val;
                    }
                }
                else
                {
                    Debug.LogWarning("SetCommodityCmd with FactionAllegiance for unidentified faction ");
                }
                break;

            case CommodityType.Favor:
                CharacterVO character = AmbitionApp.GetModel <CharacterModel>().GetCharacter(id);
                if (character == null)
                {
                    Debug.LogErrorFormat("Unrecognized character '{0}'", id);
                }
                else
                {
                    character.Favor = val;
                    if (character.Favor < 0)
                    {
                        character.Favor = 0;
                    }
                    else if (character.Favor > 100)
                    {
                        character.Favor = 100;
                    }
                }
                break;

            default:
                Debug.LogWarningFormat("Don't know how to set commodity type '{0}'", cType);
                break;
            }
        }