public void SetInfo(WorldCityInfo info) { _curInfo = info; if (_curInfo == null) { // 玩家主城 } else { _imageRefreshFlag.gameObject.SetActive(_curInfo.CouldRefresh()); _imageIcon.sprite = ResourceManager.Instance.GetPlayerIcon(_curInfo.UserIcon); _userLevel.text = _curInfo.UserLevel != 0 ? _curInfo.UserLevel.ToString() : "?"; if (_curInfo.IsMyCity()) { _imageBg.sprite = _blueBg; } else { _imageBg.sprite = _redBg; } } }
private void CreateWorldCity(WorldCityInfo info) { WorldCity city = null; var townInfo = info as WorldResTownInfo; if (townInfo != null) { // 资源城 if (townInfo.ProduceType == ResourceType.STONE) { city = Instantiate(_resTownPrefabList[1]); } else { city = Instantiate(_resTownPrefabList[0]); } } else { // 主城 city = Instantiate(_worldCityPrefabList[0]); } city.gameObject.SetActive(true); Vector3 pos = GetSlotPosition(info.MapPosition, info is WorldResTownInfo); city.transform.SetParent(_panelCity, false); city.transform.localPosition = pos; city.CreateUserPanel(_userInfoPanelPrefab); city.SetInfo(info); _cityList.Add(city); }
public void AddAllCity() { if (Game.Instance.IsOffline) { int index = 0; for (int i = 0; i < 10; ++i) { ++index; WorldCityInfo city = new WorldCityInfo(); city.MapPosition = index; city.UserName = "******" + index; city.UserLevel = 11; city.UserFightScore = 1234; city.RewardMoney = 10000; city.RewardStone = 100; city.RewardWood = 10; int heroIndex = 0; foreach (var item in HeroConfigLoader.Data) { if (heroIndex >= 3) { break; } } WorldManager.Instance.CityList.Add(city); } for (int i = 0; i < 5; ++i) { ++index; WorldResTownInfo city = new WorldResTownInfo(); city.MapPosition = index; city.UserName = "******" + index; city.UserLevel = 11; city.UserFightScore = 1234; city.RewardMoney = 10000; city.RewardStone = 100; city.RewardWood = 10; int heroIndex = 0; foreach (var item in HeroConfigLoader.Data) { if (heroIndex >= 3) { break; } } WorldManager.Instance.CityList.Add(city); } } }
// 更换对手 private void OnSwitchCity(WorldCityInfo info) { WorldCity oldCity = GetCity(info.MapPosition); if (oldCity != null) { _cityList.Remove(oldCity); Destroy(oldCity.gameObject); } CreateWorldCity(info); }
public void SetInfo(WorldCityInfo info) { _curInfo = info; if (_userInfoPanel != null) { _userInfoPanel.SetInfo(_curInfo); } if (_curInfo == null) { return; } MapPosition = _curInfo.MapPosition; }
private void OnMsgGetPlayerWorldMap(byte[] buffer) { PWorldMapInfo ret = Net.Deserialize <PWorldMapInfo>(buffer); if (!Net.CheckErrorCode(ret.errorCode, eCommand.GET_PLYAYER_WORLD_MAP)) { return; } WorldManager.Instance.CityList.Clear(); //Log.Info("城池数据: {0} {1}", ret.playerMaps.Count, ret.sourceMaps.Count); foreach (var item in ret.playerMaps) { WorldCityInfo info = new WorldCityInfo(); info.Deserialize(item); WorldManager.Instance.CityList.Add(info); } // 刷新地图 UIManager.Instance.RefreshWindow <UIWorldMapView>(); }
// 请求侦查城池 public void RequestDetect(int mapPos) { PCMInt data = new PCMInt(); data.arg = mapPos; NetworkManager.Instance.Send(eCommand.SURVEY_CITY, data, (buffer) => { PPlayerMapInfo ret = Net.Deserialize <PPlayerMapInfo>(buffer); if (!Net.CheckErrorCode(ret.errorCode, eCommand.SURVEY_CITY)) { return; } WorldCityInfo info = GetCity(mapPos); if (info != null) { info.Deserialize(ret); } // 刷新地图 EventDispatcher.TriggerEvent(EventID.EVENT_WORLD_REFRESH_CITY, mapPos); UIManager.Instance.RefreshWindow <UIWorldCityInfoView>(); }); }
private void SetInfo(WorldCityInfo info) { _curInfo = info; if (_curInfo == null) { return; } const string UNKNOWN = "????"; _textUserName.text = _curInfo.UserName; _imgUserIcon.sprite = ResourceManager.Instance.GetPlayerIcon(_curInfo.UserIcon); _textuserLevel.text = _curInfo.UserLevel != 0 ? "Lv" + _curInfo.UserLevel : UNKNOWN; _textUserFightScore.text = _curInfo.UserFightScore != -1 ? _curInfo.UserFightScore.ToString() : UNKNOWN; _textRewardMoney.text = _curInfo.RewardMoney != -1 ?_curInfo.RewardMoney.ToString() : UNKNOWN; _textRewardWood.text = _curInfo.RewardWood != -1 ? _curInfo.RewardWood.ToString() : UNKNOWN; _textRewardStone.text = _curInfo.RewardStone != -1 ? _curInfo.RewardStone.ToString() : UNKNOWN; if (_curInfo.RewardGold > 0) { _textRewardGoldText.gameObject.SetActive(true); _textRewardGold.text = _curInfo.RewardGold.ToString(); } else { _textRewardGoldText.gameObject.SetActive(false); } // TODO 根据品阶设置背景 if (_curInfo.HeroInfoList.Count > 0) { _hero1Bg.gameObject.SetActive(true); _hero1Icon.gameObject.SetActive(true); _hero1Icon.sprite = ResourceManager.Instance.GetHeroIcon(_curInfo.HeroInfoList[0].heroCfgID); } else { _hero1Bg.gameObject.SetActive(false); _hero1Icon.gameObject.SetActive(false); } if (_curInfo.HeroInfoList.Count > 1) { _hero2Bg.gameObject.SetActive(true); _hero2Icon.gameObject.SetActive(true); _hero2Icon.sprite = ResourceManager.Instance.GetHeroIcon(_curInfo.HeroInfoList[1].heroCfgID); } else { _hero2Bg.gameObject.SetActive(false); _hero2Icon.gameObject.SetActive(false); } if (_curInfo.HeroInfoList.Count > 2) { _hero3Bg.gameObject.SetActive(true); _hero3Icon.gameObject.SetActive(true); _hero3Icon.sprite = ResourceManager.Instance.GetHeroIcon(_curInfo.HeroInfoList[2].heroCfgID); } else { _hero3Bg.gameObject.SetActive(false); _hero3Icon.gameObject.SetActive(false); } // 可以刷新 if (!_curInfo.IsMyCity() && _curInfo.CouldRefresh()) { _btnSwitch.gameObject.SetActive(true); } else { _btnSwitch.gameObject.SetActive(false); } PlayerLevelConfig cfg = PlayerLevelConfigLoader.GetConfig(UserManager.Instance.Level); _txtAttackCost.text = cfg.AttackCost.ToString(); }
public override void OnBindData(params object[] param) { _curInfo = param[0] as WorldCityInfo; }
// 添加一个新的城池 private void OnAddCity(WorldCityInfo info) { CreateWorldCity(info); }