void OnFightStateMapping(object p1, object p2) { CatDebug.LogFunc(); Transform hsl = _stageNode.GetRef("HeroSelectList"); hsl.gameObject.SetActive(false); Transform readyBtn = _stageNode.GetRef("ButtonReady"); readyBtn.gameObject.SetActive(false); foreach (KeyValuePair <int, Transform> pair in _nodeUIs) { Dropable dropable = pair.Value.GetComponentInChildren <Dropable>(); dropable.enabled = true; } Dictionary <int, FightHero> heroes = (Dictionary <int, FightHero>)p1; foreach (KeyValuePair <int, Transform> pair in _fightHeroNodes) { Dragable dragable = pair.Value.GetComponentInChildren <Dragable>(); HeroData hd = (HeroData)heroes[pair.Key].CreatureData; dragable.DragIcon = GameResSys.Instance.GetItem(hd.FightIcon); } //create hero show list CreateHeroShowList(heroes); }
void OnCreateHeroStartNode(object p1, object p2) { CatDebug.LogFunc(); HeroData heroData = (HeroData)p1; int targetNodeId = (int)p2; if (_heroSelectNodes.ContainsKey(heroData.Id)) { Dragable d = _heroSelectNodes[heroData.Id].GetComponentInChildren <Dragable>(); d.SetEnable(false); } GameObject go = InsHeroNode(heroData, false);//这里的英雄还可能与其他英雄交换,故不添加特殊dragicon go.transform.SetParent(_stageNodeRootTrans); //go.GetComponent<Button>().onClick.AddListener(() => { }); Dropable drop = go.AddComponent <Dropable>(); drop.ActionId = heroData.Id; drop.OnDroped = DropOnHero; Transform target = _nodeUIs[targetNodeId]; UINode targetNode = target.GetComponent <UINode>(); go.transform.SetParent(targetNode.GetRef("HeroRoot")); _fightHeroNodes.Add(heroData.Id, go.transform); }
public override void Enter(GameStateParameter parameter) { CatDebug.LogFunc(); base.Enter(parameter); EventSys.Instance.AddHander(InputEvent.LoginLogin, OnLoginEvent); }
void StartPreLoad() { CatDebug.LogFunc(); foreach (GameStateConfig.PreLoadResConfig preLoadResConfig in GsDetail.PreLoadUi) { string path = preLoadResConfig.AssetBundle; EventSys.Instance.AddEvent(FrameEvent.AddPreLoadRes, path); } EventSys.Instance.AddEvent(FrameEvent.PreLoadStart); }
/// <summary> /// 清理,p1=true是彻底清理 /// 可以在资源使用完成后false清理, /// 在切换游戏状态时可以true清理。 /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> void Clear(object p1, object p2) { CatDebug.LogFunc("isTrue=" + p1); bool isClearAll = (bool)p1; foreach (KeyValuePair <string, AssetBundle> pair in _assetCache) { pair.Value.Unload(isClearAll); } _assetCache.Clear(); }
protected void StartInsUi() { CatDebug.LogFunc(); if (GsDetail.PreLoadUi.Count > 0) { EventSys.Instance.AddEvent(LogicEvent.UiInsStart, GsDetail.PreLoadUi); } else { EventSys.Instance.AddEvent(LogicEvent.UiInsEnd); } }
public virtual void Init() { CatDebug.LogFunc(); GameStateConfig GsConfig = ConfigSys.Instance.GetConfig <GameStateConfig>(); GsConfig.GameStateDetails.TryGetValue(GetName(), out GsDetail); if (GsDetail == null) { throw new KeyNotFoundException(GetName()); } }
/// <summary> /// 开始加载所有文件 /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> void OnStartPreLoad(object p1, object p2) { CatDebug.LogFunc(); if (_resPath.Count == 0) { EventSys.Instance.AddEvent(FrameEvent.PreloadEnd); } PrepareResDependencies(_resPath.ToArray()); //start load first layer res _nowLevel = 0; StartLoadResInLayer(_nowLevel); }
protected void StartLoadScene() { CatDebug.LogFunc(); string sceneName = GsDetail.SceneName; if (!string.IsNullOrEmpty(sceneName)) { EventSys.Instance.AddEvent(LogicEvent.SceneLoadStart, sceneName, false); } else { EventSys.Instance.AddEvent(LogicEvent.SceneLoadEnd, sceneName); } }
void CreateFightHeros(object p1, object p2) { Dictionary <int, int> selectedHeros = (Dictionary <int, int>)p1; _heros = new Dictionary <int, FightHero>(); foreach (KeyValuePair <int, int> pair in selectedHeros) { Hero hero = PlayerDataMgr.Instance.GetHero(pair.Key); FightHero fHero = new FightHero(hero); fHero.NowNodeId = pair.Value; _heros.Add(fHero.Id, fHero); } CatDebug.LogFunc(); }
void OnUseItemToHero(object p1, object p2) { int targetHeroId = (int)p1; int itemId = (int)p2; CatDebug.LogFunc("targetHeroId = " + targetHeroId + ", itemId = " + itemId); FightHero originHero = FightDataMgr.Instance.GetHero(_nowHeroId); FightHero targetHero = FightDataMgr.Instance.GetHero(targetHeroId); Item item = targetHero.Items[itemId]; if (item.Id == 1) { int nowHp = targetHero.CreatureData.Hp.Value; if (nowHp >= 0) { targetHero.CreatureData.Hp.Value = System.Math.Min(nowHp + 100, targetHero.CreatureData.HpMax.Value); originHero.DelItem(item.Id, 1); EventSys.Instance.AddEvent(ViewEvent.FightUpdateAllHeroState, _heros); EventSys.Instance.AddEvent(ViewEvent.FightHeroHpSupply, targetHero.Id, 100); originHero.IsActioned = true; CheckChangeTurnToEnemy(); } } else if (item.Id == 2) { int nowMp = targetHero.CreatureData.Mp.Value; targetHero.CreatureData.Mp.Value = System.Math.Min(nowMp + 100, targetHero.CreatureData.MpMax.Value); originHero.DelItem(item.Id, 1); EventSys.Instance.AddEvent(ViewEvent.FightUpdateAllHeroState, _heros); EventSys.Instance.AddEvent(ViewEvent.FightHeroMpSupply, targetHero.Id, 100); originHero.IsActioned = true; CheckChangeTurnToEnemy(); } else { EventSys.Instance.AddEvent(ViewEvent.FightShowTipNotSupportYet); } }
void StartAI(object p1, object p2) { CatDebug.LogFunc(); Dictionary <int, FightHero> heroes = (Dictionary <int, FightHero>)p1; List <Enemy> enemies = (List <Enemy>)p2; foreach (Enemy enemy in enemies) { if (enemy.CreatureData.Hp.Value > 0) { //目前AI只有一种行为就是普通攻击 FightHero targetHero = SelectHero(heroes); if (targetHero != null) { EventSys.Instance.AddEventNow(AiInputEvent.Attack, enemy, targetHero); } } } EventSys.Instance.AddEvent(AiInputEvent.AiActionEnd); }
public void OnDrop(PointerEventData eventData) { //if (eventData.pointerDrag != null) //{ //Image img = eventData.pointerDrag.GetComponent<Image>(); //if (img != null) //{ // GetComponent<Image>().sprite = img.sprite; // GetComponent<Image>().color = new Color(1, 1, 1, 1);//我刚开始把图片设为了透明 //} //} CatDebug.LogFunc(eventData.pointerDrag.name); if (Dragable.StartDrag) { if (OnDroped != null) { OnDroped(ActionId); } Dragable.StartDrag = false; } }
/// <summary> /// 将英雄拖拽到地图节点上 /// </summary> /// <param name="p1"></param> /// <param name="p2"></param> void OnFightDragOnNode(object p1, object p2) { int heroId = (int)p1; int targetNodeId = (int)p2; CatDebug.LogFunc(" p1 = " + heroId + ", p2 = " + targetNodeId); switch (_fState) { case FSubState.SelectHero: //拖拽一个英雄到一个无人的起始节点上 Hero h = PlayerDataMgr.Instance.GetHero(heroId); if (h != null) { if (_selectedHeros.ContainsKey(h.Id)) //从另一个起始节点拖拽到新起始节点,即替换英雄起始位置 { _selectedHeros[h.Id] = targetNodeId; EventSys.Instance.AddEvent(ViewEvent.ResetHeroStartNode, heroId, targetNodeId); } else //从英雄列表中拖拽到起始节点 { _selectedHeros.Add(h.Id, targetNodeId); EventSys.Instance.AddEvent(ViewEvent.CreateHeroStartNode, h.CreatureData, targetNodeId); } } break; case FSubState.Mapping: BaseStageNode node = _stageConfig.GetNode(targetNodeId); if (node.IsPassed) { EventSys.Instance.AddEvent(ViewEvent.ShowTipNodePassed); return; } FightHero fh = FightDataMgr.Instance.GetHero(heroId); BaseStageNode heroNode = _stageConfig.GetNode(fh.NowNodeId); if (!heroNode.NextNodes.Contains(targetNodeId)) { EventSys.Instance.AddEvent(ViewEvent.ShowTipNotNextNode); return; } string nodeType = node.NodeType; if (nodeType.Equals(typeof(StageNodeFight).Name)) { EventSys.Instance.AddEvent(LogicEvent.StartFightRound, new [] { heroId }, targetNodeId); } else if (nodeType.Equals(typeof(StageNodeReward).Name)) { Reward r = FightDataMgr.Instance.GetReward(targetNodeId); EventSys.Instance.AddEvent(ViewEvent.ShowNodeRewardGet, r, new [] { targetNodeId, heroId }); } else if (nodeType.Equals(typeof(StageNodeSafe).Name)) { fh.NowNodeId = targetNodeId; EventSys.Instance.AddEvent(ViewEvent.GetSafeReturnToStage, fh); } break; } }