// 初始化 public void InitPanel(NewThings newThings) { tweencontain.transform.GetComponent <TweenTransform>().to = newThings.tf; tweenEffect.transform.GetComponent <TweenTransform>().to = newThings.tf; tweenEffect.transform.GetComponent <TweenTransform>().from = newThings.tf; switch (newThings.type) { case GetNewThingsType.T_Skill: NewSkill(newThings.id); NGUITools.SetActive(partnerIcon.gameObject, false); NGUITools.SetActive(skillIcon.gameObject, true); NGUITools.SetActive(fuctionPanel.gameObject, false); break; case GetNewThingsType.T_Partner: NewPartner(newThings.id); NGUITools.SetActive(skillIcon.gameObject, false); NGUITools.SetActive(partnerIcon.gameObject, true); NGUITools.SetActive(fuctionPanel.gameObject, false); break; case GetNewThingsType.T_Function: NewFunction(newThings.name, newThings.id); NGUITools.SetActive(skillIcon.gameObject, false); NGUITools.SetActive(partnerIcon.gameObject, false); NGUITools.SetActive(fuctionPanel.gameObject, true); break; } Invoke("OnTweenIcon", 1.7f); }
//新技能 void HasNewSkill() { RoleInfo role_info = LobbyClient.Instance.CurrentRole; if (role_info != null && role_info.SkillInfos != null) { SkillInfo skill_info = null; int index = 0; for (index = 0; index < role_info.SkillInfos.Count; ++index) { skill_info = role_info.SkillInfos[index]; if (skill_info != null && skill_info.SkillLevel <= 0) { if (skill_info.ConfigData != null && skill_info.ConfigData.ActivateLevel <= role_info.Level) { NewThings newThings = new NewThings(); newThings.id = skill_info.ConfigData.SkillId; newThings.type = GetNewThingsType.T_Skill; newThings.tf = GetBtnGameObject("Entrance-Skill").transform; newThingsList.Add(newThings); } } } } }
//有新伙伴 void HasNewPartener() { if (m_partnerId != 0) { RoleInfo role_info = LobbyClient.Instance.CurrentRole; if (null != role_info && role_info.PartnerStateInfo != null) { List <PartnerInfo> partners = role_info.PartnerStateInfo.GetAllPartners(); if (null == partners) { return; } for (int index = 0; index < partners.Count; ++index) { if (partners[index] != null && partners[index].Id == m_partnerId) { //找到添加伙伴信息 PartnerInfo info = partners[index]; Data_NpcConfig npcCfg = NpcConfigProvider.Instance.GetNpcConfigById(info.LinkId); if (npcCfg != null) { NewThings newThings = new NewThings(); newThings.id = info.LinkId; newThings.type = GetNewThingsType.T_Partner; newThings.tf = GetBtnGameObject("Entrance-Partner").transform; newThingsList.Add(newThings); } } } } m_partnerId = 0; } }
void OnGetNewThings(NewThings newThings) { getNewThings = CrossObjectHelper.TryCastObject <UnityEngine.GameObject>(ArkCrossEngine.ResourceSystem.GetSharedResource("UI/Common/GetNewThings")); //UnityEngine.Transform panel = transform.Find("UIPanel_1"); //UIAnchor-Center getNewThings = NGUITools.AddChild(gameObject, getNewThings); GetNewThings getNewScript = getNewThings.GetComponent <GetNewThings>(); getNewScript.InitPanel(newThings); }
private int bottomNewBtnNum = 0; //底部新增按钮数 void IsUnlockFunction(int level) { rightNewBtnNum = 0; bottomNewBtnNum = 0; foreach (LevelLock info in LevelLockProvider.Instance.GetData().Values) { if (info.m_Area == 1 && info.m_Type == 1 && !rightButtonList.Contains(info) && info.m_Level <= level) { rightButtonList.Add(info); rightNewBtnNum++; NewThings newThings = new NewThings(); newThings.id = info.m_Id; newThings.type = GetNewThingsType.T_Function; newThings.tf = GetBtnGameObject(info.m_Name).transform; newThings.name = info.m_Name; newThingsList.Add(newThings); } if (info.m_Area == 2 && info.m_Type == 1 && !bottomButtonList.Contains(info) && info.m_Level <= level) { bottomButtonList.Add(info); bottomNewBtnNum++; NewThings newThings = new NewThings(); newThings.id = info.m_Id; newThings.type = GetNewThingsType.T_Function; newThings.tf = GetBtnGameObject(info.m_Name).transform; newThings.name = info.m_Name; newThingsList.Add(newThings); } } int num = 0; if (rightNewBtnNum > 0) { num = LayoutRightBtns(); for (int i = 1; i <= rightNewBtnNum; i++) { SetBtnaActive(rightButtonList[num - i].m_Name, false); } TweenBtns(RightBtn, new UnityEngine.Vector3(0f, num * btnDistance, 0f), rightNewBtnNum); } if (bottomNewBtnNum > 0) { num = LayoutBottmBtns(); for (int i = 1; i <= bottomNewBtnNum; i++) { SetBtnaActive(bottomButtonList[num - i].m_Name, false); } TweenBtns(BottomBtn, new UnityEngine.Vector3(-num * btnDistance, 0f, 0f), bottomNewBtnNum + rightNewBtnNum); } time = 0f; }
private void HandlerAddPartner(int partnerId) { UnityEngine.GameObject btn = GetBtnGameObject("Entrance-Partner"); if (!NGUITools.GetActive(btn)) { m_partnerId = partnerId; return; } RoleInfo role_info = LobbyClient.Instance.CurrentRole; if (null != role_info && role_info.PartnerStateInfo != null) { List <PartnerInfo> partners = role_info.PartnerStateInfo.GetAllPartners(); if (null == partners) { return; } for (int index = 0; index < partners.Count; ++index) { if (partners[index] != null && partners[index].Id == partnerId) { //找到添加伙伴信息 PartnerInfo info = partners[index]; Data_NpcConfig npcCfg = NpcConfigProvider.Instance.GetNpcConfigById(info.LinkId); if (npcCfg != null) { NewThings newThings = new NewThings(); newThings.id = info.LinkId; newThings.type = GetNewThingsType.T_Partner; newThings.tf = GetBtnGameObject("Entrance-Partner").transform; newThingsList.Add(newThings); } } } } }
public AttackHostFromSrv RequestHost(AttackHostToSrv fromClient) { //Loger.Log($"Server AttackOnlineHost RequestHost State: {State} -> {fromClient.State}"); lock (SyncObj) { //первые 5 минут не проверяем на отключения, т.к. загрузка может быть долгой (а дисконектит уже после 10 сек) if ((fromClient.State == 10 || (DateTime.UtcNow - CreateTime).TotalSeconds > 8 * 60) && CheckConnect(false)) { return(new AttackHostFromSrv() { State = State }); } if (fromClient.State < State) { return(new AttackHostFromSrv() { ErrorText = "Unexpected request " + fromClient.State.ToString() + ". Was expected" + State.ToString() }); } if (fromClient.State == 2) { State = 2; return(new AttackHostFromSrv() { State = State, HostPlaceServerId = HostPlaceServerId, InitiatorPlaceServerId = InitiatorPlaceServerId, StartInitiatorPlayer = Attacker.Public.Login, TestMode = TestMode, }); } if (fromClient.State == 4) { MapSize = fromClient.MapSize; TerrainDefNameCell = fromClient.TerrainDefNameCell; TerrainDefName = fromClient.TerrainDefName; Thing = fromClient.Thing; ThingCell = fromClient.ThingCell; State = 4; return(new AttackHostFromSrv() { State = State, }); } if (fromClient.State == 5) { State = 5; return(new AttackHostFromSrv() { State = State, Pawns = Pawns }); } if (fromClient.State == 10) { State = 10; if (VictoryAttacker == null) { VictoryAttacker = fromClient.VictoryAttacker; } if (fromClient.NewPawnsId.Count > 0 || fromClient.NewThingsId.Count > 0 || fromClient.NewCorpses.Count > 0 || fromClient.Delete.Count > 0) { //удаляем из Delete если сейчас команда добавить с таким id foreach (var n in fromClient.NewPawnsId) { var index = Delete.IndexOf(n); if (index >= 0) { Delete.RemoveAt(index); } } foreach (var n in fromClient.NewThingsId) { var index = Delete.IndexOf(n); if (index >= 0) { Delete.RemoveAt(index); } } foreach (var corps in fromClient.NewCorpses) { var index = Delete.IndexOf(corps.CorpseId); if (index >= 0) { Delete.RemoveAt(index); } } //объединяем for (int i = 0; i < fromClient.NewPawnsId.Count; i++) { if (NewPawnsId.Contains(fromClient.NewPawnsId[i])) { continue; } NewPawnsId.Add(fromClient.NewPawnsId[i]); NewPawns.Add(fromClient.NewPawns[i]); } for (int i = 0; i < fromClient.NewThingsId.Count; i++) { if (NewThingsId.Contains(fromClient.NewThingsId[i])) { continue; } NewThingsId.Add(fromClient.NewThingsId[i]); NewThings.Add(fromClient.NewThings[i]); } for (int i = 0; i < NewCorpses.Count; i++) { if (fromClient.NewCorpses.Any(c => c.PawnId == NewCorpses[i].PawnId || c.CorpseId == NewCorpses[i].CorpseId)) { NewCorpses.RemoveAt(i--); } } for (int i = 0; i < fromClient.NewCorpses.Count; i++) { NewCorpses.Add(fromClient.NewCorpses[i]); } for (int i = 0; i < fromClient.Delete.Count; i++) { if (Delete.Contains(fromClient.Delete[i])) { continue; } Delete.Add(fromClient.Delete[i]); } for (int i = 0; i < fromClient.NewCorpses.Count; i++) { if (Delete.Contains(fromClient.NewCorpses[i].PawnId)) { continue; } Delete.Add(fromClient.NewCorpses[i].PawnId); } //на всякий случай корректируем: удаляем из добавляемых те, что на удаление foreach (var n in Delete) { var index = NewPawnsId.IndexOf(n); if (index >= 0) { NewPawnsId.RemoveAt(index); NewPawns.RemoveAt(index); } index = NewThingsId.IndexOf(n); if (index >= 0) { NewThingsId.RemoveAt(index); NewThings.RemoveAt(index); } for (int i = 0; i < NewCorpses.Count; i++) { if (n == NewCorpses[i].CorpseId) { NewCorpses.RemoveAt(i--); } } } } if (fromClient.UpdateState.Count > 0) { //объединяем for (int i = 0; i < fromClient.UpdateState.Count; i++) { var id = fromClient.UpdateState[i].HostThingID; UpdateState[id] = fromClient.UpdateState[i]; } } var res = new AttackHostFromSrv() { State = State, UpdateCommand = UpdateCommand.Values.ToList(), NeedNewThingIDs = NeedNewThingIDs.ToList(), SetPauseOnTime = SetPauseOnTimeToHost == null ? DateTime.MinValue : SetPauseOnTimeToHost.Value, VictoryHost = VictoryHostToHost, TerribleFatalError = TerribleFatalError, }; UpdateCommand = new Dictionary <int, AttackPawnCommand>(); NeedNewThingIDs = new HashSet <int>(); if (SetPauseOnTimeToHost != null) { Loger.Log("Server Send SetPauseOnTimeToHost=" + SetPauseOnTimeToHost.Value.ToGoodUtcString()); } Host.PVPHostLastTime = DateTime.UtcNow; SetPauseOnTimeToHost = null; VictoryHostToHost = false; return(res); } return(new AttackHostFromSrv() { ErrorText = "Unexpected request " + fromClient.State.ToString() + "! Was expected" + State.ToString() }); } }
public void Save(NewThings newThing) { context.NewThings.Add(newThing); context.SaveChanges(); }
public AttackHostFromSrv RequestHost(AttackHostToSrv fromClient) { lock (SyncObj) { if (fromClient.State < State) { return(new AttackHostFromSrv() { ErrorText = "Unexpected request " + fromClient.State.ToString() + ". Was expected" + State.ToString() }); } if (fromClient.State == 2) { State = 2; return(new AttackHostFromSrv() { State = State, HostPlaceServerId = HostPlaceServerId, InitiatorPlaceServerId = InitiatorPlaceServerId, StartInitiatorPlayer = Attacker.Public.Login }); } if (fromClient.State == 4) { State = 4; MapSize = fromClient.MapSize; TerrainDefNameCell = fromClient.TerrainDefNameCell; TerrainDefName = fromClient.TerrainDefName; Thing = fromClient.Thing; ThingCell = fromClient.ThingCell; return(new AttackHostFromSrv() { State = State, }); } if (fromClient.State == 5) { State = 5; return(new AttackHostFromSrv() { State = State, Pawns = Pawns }); } if (fromClient.State == 10) { State = 10; if (fromClient.NewPawnsId.Count > 0 || fromClient.NewThingsId.Count > 0 || fromClient.Delete.Count > 0) { //удаляем из Delete если сейчас команда добавитьс таким id foreach (var n in fromClient.NewPawnsId) { var index = Delete.IndexOf(n); if (index >= 0) { Delete.RemoveAt(index); } } foreach (var n in fromClient.NewThingsId) { var index = Delete.IndexOf(n); if (index >= 0) { Delete.RemoveAt(index); } } //объединяем for (int i = 0; i < fromClient.NewPawnsId.Count; i++) { if (NewPawnsId.Contains(fromClient.NewPawnsId[i])) { continue; } NewPawnsId.Add(fromClient.NewPawnsId[i]); NewPawns.Add(fromClient.NewPawns[i]); } for (int i = 0; i < fromClient.NewThingsId.Count; i++) { if (NewThingsId.Contains(fromClient.NewThingsId[i])) { continue; } NewThingsId.Add(fromClient.NewThingsId[i]); NewThings.Add(fromClient.NewThings[i]); } for (int i = 0; i < fromClient.Delete.Count; i++) { if (Delete.Contains(fromClient.Delete[i])) { continue; } Delete.Add(fromClient.Delete[i]); } //на всякий случай корректируем: удаляем из добавляемых те, что на удаление foreach (var n in Delete) { var index = NewPawnsId.IndexOf(n); if (index >= 0) { NewPawnsId.RemoveAt(index); NewPawns.RemoveAt(index); } index = NewThingsId.IndexOf(n); if (index >= 0) { NewThingsId.RemoveAt(index); NewThings.RemoveAt(index); } } } if (fromClient.UpdateState.Count > 0) { //объединяем for (int i = 0; i < fromClient.UpdateState.Count; i++) { var id = fromClient.UpdateState[i].HostThingID; UpdateState[id] = fromClient.UpdateState[i]; } } var res = new AttackHostFromSrv() { State = State, UpdateCommand = UpdateCommand.Values.ToList(), }; UpdateCommand = new Dictionary <int, AttackPawnCommand>(); return(res); } return(new AttackHostFromSrv() { ErrorText = "Unexpected request " + fromClient.State.ToString() + "! Was expected" + State.ToString() }); } }