Beispiel #1
0
    private void SetInfo(WorldResTownInfo info)
    {
        _curInfo = info;
        if (_curInfo == null)
        {
            return;
        }

        _imageResType.gameObject.SetActive(false);

        if (_curInfo.UserEntityID == 0)
        {
            // 无人资源岛
            WorldMapConfig cfg = WorldMapConfigLoader.GetConfig(_curInfo.MapConfigID);
            if (cfg != null)
            {
                _textUserName.text       = cfg.CityName;
                _imgUserIcon.sprite      = ResourceManager.Instance.GetResIcon(_curInfo.ProduceType);
                _textuserLevel.text      = "Lv" + _curInfo.MapLevel;
                _textUserFightScore.text = "0";
            }
        }
        else
        {
            // 玩家资源岛
            _textUserLevelText.gameObject.SetActive(true);
            _textUserFightScoreText.gameObject.SetActive(true);

            _textUserName.text       = _curInfo.UserName;
            _textuserLevel.text      = "Lv" + _curInfo.UserLevel;
            _textUserFightScore.text = _curInfo.UserFightScore.ToString();
            _imgUserIcon.sprite      = ResourceManager.Instance.GetPlayerIcon(_curInfo.UserIcon);
        }


        switch (_curInfo.ProduceType)
        {
        case ResourceType.MONEY:
            _textRewardText.text = Str.Get("UI_WORLD_RES_PRODUCE_MONEY");
            break;

        case ResourceType.WOOD:
            _textRewardText.text = Str.Get("UI_WORLD_RES_PRODUCE_WOOD");
            break;

        case ResourceType.STONE:
            _textRewardText.text = Str.Get("UI_WORLD_RES_PRODUCE_STONE");
            break;

        case ResourceType.GOLD:
            _textRewardText.text = Str.Get("UI_WORLD_RES_PRODUCE_GOLD");
            break;
        }
        _imgReward.sprite     = ResourceManager.Instance.GetResIcon(_curInfo.ProduceType);
        _textRewardValue.text = _curInfo.ProduceValue.ToString();

        // 我方资源城还显示总产值和剩余时间
        if (_curInfo.IsMyCity())
        {
            _textTotalText.gameObject.SetActive(true);
            _textTimeText.gameObject.SetActive(true);

            _imgTotal.sprite     = ResourceManager.Instance.GetResIcon(_curInfo.ProduceType);
            _textTotalValue.text = _curInfo.GetTotalProduceValue().ToString();
            _textTime.text       = Utils.GetCountDownString(_curInfo.GetConquerCD());
        }
        else
        {
            _textTotalText.gameObject.SetActive(false);
            _textTimeText.gameObject.SetActive(false);
        }

        // TODO 根据品阶设置背景
        if (_curInfo.HeroInfoList.Count > 0)
        {
            _heroBg1.gameObject.SetActive(true);
            _heroIcon1.gameObject.SetActive(true);
            _heroIcon1.sprite = ResourceManager.Instance.GetHeroIcon(_curInfo.HeroInfoList[0].heroCfgID);
        }
        else
        {
            _heroBg1.gameObject.SetActive(false);
            _heroIcon1.gameObject.SetActive(false);
        }

        if (_curInfo.HeroInfoList.Count > 1)
        {
            _heroBg2.gameObject.SetActive(true);
            _heroIcon2.gameObject.SetActive(true);
            _heroIcon2.sprite = ResourceManager.Instance.GetHeroIcon(_curInfo.HeroInfoList[1].heroCfgID);
        }
        else
        {
            _heroBg2.gameObject.SetActive(false);
            _heroIcon2.gameObject.SetActive(false);
        }

        if (_curInfo.HeroInfoList.Count > 2)
        {
            _heroBg3.gameObject.SetActive(true);
            _heroIcon3.gameObject.SetActive(true);
            _heroIcon3.sprite = ResourceManager.Instance.GetHeroIcon(_curInfo.HeroInfoList[2].heroCfgID);
        }
        else
        {
            _heroBg3.gameObject.SetActive(false);
            _heroIcon3.gameObject.SetActive(false);
        }

        if (_curInfo.IsMyCity())
        {
            _btnDefendBuild.gameObject.SetActive(true);
            _btnDetect.gameObject.SetActive(false);
            _btnAttack.gameObject.SetActive(false);
            _btnSwitch.gameObject.SetActive(false);
        }
        else
        {
            _btnDefendBuild.gameObject.SetActive(false);
            _btnDetect.gameObject.SetActive(true);
            _btnAttack.gameObject.SetActive(true);

            if (_curInfo.CouldRefresh())
            {
                _btnSwitch.gameObject.SetActive(true);
            }
            else
            {
                _btnSwitch.gameObject.SetActive(false);
            }
        }
    }
Beispiel #2
0
    public virtual void Deserialize(PPlayerMapInfo data)
    {
        MapPosition = data.mapPos;

        if (data.mapType == eWorldMapType.PLAYER_CITY_MAP)
        {
            IsNpc = false;
            if (data.simRoleAttr != null)
            {
                UserEntityID = data.simRoleAttr.playerId;
                UserName     = data.simRoleAttr.roleName;
                UserIcon     = data.simRoleAttr.headImage;

                UserLevel       = data.simRoleAttr.level;
                UserPalaceLevel = data.simRoleAttr.mainBuildLevel;
                UserFightScore  = data.simRoleAttr.fighting;
            }
        }
        else if (data.mapType == eWorldMapType.NPC_CITY_MAP)
        {
            IsNpc = true;
            if (data.simRoleAttr != null)
            {
                UserEntityID = data.simRoleAttr.playerId;

                WorldMapConfig cfg = WorldMapConfigLoader.GetConfig((int)UserEntityID);

                UserName = cfg.CityName;
                UserIcon = data.simRoleAttr.headImage;

                if (data.getAssertInfo != null)
                {
                    // 已经侦查
                    UserLevel       = cfg.PlayerLevel;
                    UserPalaceLevel = cfg.CityLevel;
                    UserFightScore  = cfg.BattlePower;
                    HeroInfoList.Clear();
                    AddNpcHero(cfg.DefenseHero1);
                    AddNpcHero(cfg.DefenseHero2);
                    AddNpcHero(cfg.DefenseHero3);
                }
                else
                {
                    // 尚未侦查
                    UserLevel       = 0;
                    UserPalaceLevel = 0;
                    UserFightScore  = -1;
                }
            }
        }

        if (data.getAssertInfo != null)
        {
            RewardMoney = data.getAssertInfo.gold;
            RewardWood  = data.getAssertInfo.wood;
            RewardStone = data.getAssertInfo.stone;
            RewardGold  = data.getAssertInfo.yuanbao;
        }
        else
        {
            // 尚未侦查
            RewardMoney = -1;
            RewardWood  = -1;
            RewardStone = -1;
            RewardGold  = -1;
        }

        if (data.heroInfos != null)
        {
            foreach (var item in data.heroInfos)
            {
                WorldCityHeroInfo info = new WorldCityHeroInfo();
                info.heroCfgID      = item.heroCfgId;
                info.heroLevel      = item.level;
                info.heroQuality    = item.jinjie;
                info.heroStar       = item.heroStar;
                info.heroFightScore = item.fighting;
                HeroInfoList.Add(info);
            }
        }

        RefreshRemainTime.SetTimeMilliseconds(data.refreshLeftTime);
    }