Exemple #1
0
    /// <summary>
    /// 单击节点显示详情
    /// </summary>
    /// <param name="p1"></param>
    /// <param name="p2"></param>
    void OnStateNodeClicked(object p1, object p2)
    {
        int           nodeId = (int)p1;
        BaseStageNode node   = _stageConfig.GetNode(nodeId);

        if (node.IsPassed)
        {
            return;
        }
        if (node.HiddenDetail)
        {
            EventSys.Instance.AddEvent(ViewEvent.ShowNodeUnKnow, nodeId);
            return;
        }
        Type type = node.GetType();

        if (type == typeof(StageNodeFight))
        {
            Enemy e = FightDataMgr.Instance.GetEnemy(nodeId);
            EventSys.Instance.AddEvent(ViewEvent.ShowNodeFightDetails, e.CreatureData, nodeId);
        }
        else if (type == typeof(StageNodeReward))
        {
            Reward r = FightDataMgr.Instance.GetReward(nodeId);
            EventSys.Instance.AddEvent(ViewEvent.ShowNodeRewardDetails, r, nodeId);
        }
        else if (type == typeof(StageNodeHidden))
        {
        }
        else if (type == typeof(StageNodeSafe))
        {
            EventSys.Instance.AddEvent(ViewEvent.ShowNodeSafeDetails, nodeId);
        }
    }
Exemple #2
0
    /// <summary>
    /// 将英雄拖拽到其他英雄节点上
    /// </summary>
    /// <param name="p1"></param>
    /// <param name="p2"></param>
    void OnFightDragOnHero(object p1, object p2)
    {
        int dragHeroId   = (int)p1; //
        int targetHeroId = (int)p2; //

        switch (_fState)
        {
        case FSubState.SelectHero:
            if (_selectedHeros.ContainsKey(dragHeroId))
            {
                //交换两个英雄的起始节点
                int nodeId = _selectedHeros[dragHeroId];
                _selectedHeros[dragHeroId]   = _selectedHeros[targetHeroId];
                _selectedHeros[targetHeroId] = nodeId;

                int[] param1 = new[] { dragHeroId, _selectedHeros[dragHeroId] };
                int[] param2 = new[] { targetHeroId, _selectedHeros[targetHeroId] };
                EventSys.Instance.AddEvent(ViewEvent.ExchangeHeroStartNode, param1, param2);
            }
            else
            {
                //拖拽一个英雄到有已有英雄存在的起始节点上(替换出战英雄)
                //p1 = 新选中的出战英雄
                //p2 = 已经在节点上,需要被替换的英雄
                Hero newHero = PlayerDataMgr.Instance.GetHero(dragHeroId);
                //Hero targetHero = PlayerDataMgr.Instance.GetHero(targetHeroId);
                int nodeId = _selectedHeros[targetHeroId];
                _selectedHeros.Remove(targetHeroId);
                _selectedHeros[dragHeroId] = nodeId;
                EventSys.Instance.AddEvent(ViewEvent.ReplaceHeroStartNode, newHero.CreatureData, new [] { targetHeroId, nodeId });
            }
            break;

        case FSubState.Mapping:
            //将英雄拖拽到英雄身上,除非是安全屋,否则不可能
            FightHero     fh        = FightDataMgr.Instance.GetHero(targetHeroId);
            BaseStageNode stageNode = _stageConfig.GetNode(fh.NowNodeId);
            if (stageNode.NodeType.Equals(typeof(StageNodeSafe).Name))
            {
                FightHero dragHero = FightDataMgr.Instance.GetHero(dragHeroId);
                dragHero.NowNodeId = fh.NowNodeId;
                EventSys.Instance.AddEvent(ViewEvent.GetSafeReturnToStage, dragHero);
            }
            else
            {
                EventSys.Instance.AddEvent(ViewEvent.ShowTipNodePassed);
            }
            break;
        }
    }
Exemple #3
0
    void OnFightDragAllOnNode(object p1, object p2)
    {
        int fromNodeId   = (int)p1;
        int targetNodeId = (int)p2;

        StageNodeSafe fromNode   = (StageNodeSafe)_stageConfig.GetNode(fromNodeId);
        BaseStageNode targetNode = _stageConfig.GetNode(targetNodeId);

        if (!fromNode.NextNodes.Contains(targetNodeId))
        {
            EventSys.Instance.AddEvent(ViewEvent.ShowTipNotNextNode);
            return;
        }

        if (targetNode.GetType() != typeof(StageNodeFight))
        {
            EventSys.Instance.AddEvent(ViewEvent.ShowTipNotSupportYet);
            return;
        }

        switch (_fState)
        {
        case FSubState.SelectHero:
            break;

        case FSubState.Mapping:

            List <int> heros = new List <int>();
            foreach (var pair in FightDataMgr.Instance.GetHeros())
            {
                if (pair.Value.NowNodeId == fromNode.Id)
                {
                    heros.Add(pair.Value.Id);
                }
            }
            EventSys.Instance.AddEvent(LogicEvent.StartFightRound, heros.ToArray(), targetNodeId);
            break;
        }
    }
    void CreateNode(BaseStageNode stageNode, float posX, float posY)
    {
        GameObject go     = Instantiate(_stageNodeModel);
        UINode     uiNode = go.GetComponent <UINode>();

        go.transform.SetParent(_stageNodeRootTrans);
        go.transform.localPosition = new Vector3(posX, posY, 0);

        Button btn = uiNode.GetRef("Button").GetComponent <Button>();

        btn.onClick.AddListener(() => { OnNodeClicked(stageNode.Id); });

        Image nodeImage = uiNode.GetRef("Button").GetComponent <Image>();

        if (stageNode.NodeType.Equals(typeof(StageNodeFight).Name))
        {
            nodeImage.sprite = GameResSys.Instance.GetCard(stageNode.Icon);
        }
        else
        {
            nodeImage.sprite = GameResSys.Instance.GetNodeSprite(stageNode.Icon);
        }

        Dropable drop = uiNode.GetRef("Button").gameObject.AddComponent <Dropable>();

        drop.ActionId = stageNode.Id;
        drop.OnDroped = DropOnNode;
        if (!stageNode.NodeType.Equals(typeof(StageNodeStart).Name))
        {
            drop.enabled = false;
        }

        uiNode.GetRef("All").gameObject.SetActive(false);

        _nodeUIs.Add(stageNode.Id, go.transform);
    }
    void CreateNode(BaseStageNode stageNode, float posX, float posY)
    {
        GameObject go = Instantiate(NodeModel);

        go.transform.SetParent(StageNodeTrans);
        go.GetComponent <Button>().onClick.AddListener(() => { OnNodeClicked(stageNode.Id); });
        go.transform.localPosition = new Vector3(posX, posY, 0);

        Image  nodeImage = go.GetComponent <Image>();
        Sprite newSprite;

        if (stageNode.NodeType.Equals(typeof(StageNodeFight).Name))
        {
            newSprite = GameResSys.Instance.GetCard(stageNode.Icon);
        }
        else
        {
            newSprite = GameResSys.Instance.GetNodeSprite(stageNode.Icon);
        }

        nodeImage.sprite = newSprite;

        nodeUIs.Add(stageNode.Id, go.transform);
    }
Exemple #6
0
    /// <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;
        }
    }