예제 #1
0
    public override void HandleEvent(string eventName, object data)
    {
        switch (eventName)
        {
        case Consts.E_ShowCreate:
            ShowCreateArgs e1 = data as ShowCreateArgs;
            ShowCreatePanel(e1.Position, e1.UpSide);
            break;

        case Consts.E_ShowUpgrade:
            ShowUpgradeArgs e2 = data as ShowUpgradeArgs;
            ShowUpgradePanel(e2.Tower);
            break;

        case Consts.E_HidePopup:
            HideAllPanels();
            break;
        }
    }
예제 #2
0
    void map_OnTileClick(object sender, TileClickEventArgs e)
    {
        GameModel gm = GetModel <GameModel>();

        //游戏还未开始,那么不操作菜单
        if (!gm.IsPlaying)
        {
            return;
        }

        //如果有菜单显示,那么隐藏菜单
        if (TowerPopup.Instance.IsPopShow)
        {
            SendEvent(Consts.E_HidePopup);
            return;
        }

        //非放塔格子,不操作菜单
        if (!e.Tile.CanHold)
        {
            SendEvent(Consts.E_HidePopup);
            return;
        }

        if (e.Tile.Data == null)
        {
            ShowCreateArgs arg = new ShowCreateArgs()
            {
                Position = m_Map.GetPosition(e.Tile),
                UpSide   = e.Tile.Y < Map.RowCount / 2
            };
            SendEvent(Consts.E_ShowCreate, arg);
        }
        else
        {
            ShowUpgradeArgs arg = new ShowUpgradeArgs()
            {
                Tower = e.Tile.Data as Tower
            };
            SendEvent(Consts.E_ShowUpgrade, arg);
        }
    }
예제 #3
0
    void map_OnTileClick(object sender, TileClickEventArgs e)
    {
        GameModel gm = GetModel <GameModel>();

        //游戏还未开始,那么不操作菜单
        if (!gm.IsPlaying)
        {
            return;
        }

        //如果有菜单显示,那么隐藏菜单
        if (TowerPopup.Instance.IsPopShow)
        {
            SendEvent(Consts.E_HidePopup);
            return;
        }
        //点英雄
        if (e.Tile.isHero > 0)
        {
            if (e.Tile.isHero == 2)
            {
                e.Tile.Y = e.Tile.Y - 1;
            }
            ShowCreateArgs arg = new ShowCreateArgs()
            {
                Position  = m_Map.GetPosition(e.Tile),
                UpSide    = false,
                LeftEdge  = false,
                RightEdge = true
            };
            if (e.Tile.isHero == 2)
            {
                e.Tile.Y = e.Tile.Y + 1;
            }
            SendEvent(Consts.E_ShowHero, arg);
            return;
        }
        //非放塔格子,不操作菜单
        if (!e.Tile.CanHold)
        {
            SendEvent(Consts.E_HidePopup);
            return;
        }

        if (e.Tile.Data == null)
        {
            ShowCreateArgs arg = new ShowCreateArgs()
            {
                Position  = m_Map.GetPosition(e.Tile),
                UpSide    = e.Tile.Y < Map.RowCount / 2,
                LeftEdge  = (e.Tile.X == 0),
                RightEdge = (e.Tile.X == 11)
            };
            SendEvent(Consts.E_ShowCreate, arg);
        }
        else
        {
            ShowUpgradeArgs arg = new ShowUpgradeArgs()
            {
                Tower = e.Tile.Data as Tower
            };
            SendEvent(Consts.E_ShowUpgrade, arg);
        }
    }