示例#1
0
 /// <summary>
 /// 返回按钮事件
 /// </summary>
 private void OnBackButtonClick()
 {
     EventCenter.BroadCast(EventType.PlayButtonClip);
     //发布显示MainPanel的事件码
     EventCenter.BroadCast(EventType.ShowMainPanel);
     gameObject.SetActive(false);
 }
示例#2
0
    private void OnPlayCardClicked()
    {
        Card[]  cards   = view.GetSelectedCards();
        CardSet cardSet = CardSet.GetCardSet(cards);

        if (cards.Length == 0)
        {
            EventCenter.BroadCast(EventType.UIFlashHint, "请选择要出的牌");
            return;
        }

        if (cardSet.Type == CardSetType.Invalid)
        {
            EventCenter.BroadCast(EventType.UIFlashHint, "无效的组合");
            return;
        }

        CardSet lastHand = Models.gameModel.playModel.lastHand;

        if (lastHand != null && !cardSet.IsGreaterThan(lastHand))
        {
            EventCenter.BroadCast(EventType.UIFlashHint, "无法大过上家");
            return;
        }

        //出牌合法,向服务器发送数据
        NetMsgCenter.Instance.SendPlayCardMsg(cardSet);
    }
示例#3
0
    void HandleLoginSRes(int responseCode)
    {
        switch (responseCode)
        {
        case AccountReturnCode.userNotFound:
            EventCenter.BroadCast(EventType.UIFlashHint, "用户名不存在");
            break;

        case AccountReturnCode.passwordNotMatch:
            EventCenter.BroadCast(EventType.UIFlashHint, "用户名与密码不匹配");
            break;

        case AccountReturnCode.userOnline:
            EventCenter.BroadCast(EventType.UIFlashHint, "用户已在线");
            break;

        case AccountReturnCode.success:
            //登录成功,获取当前登录的用户信息
            NetMsgCenter.Instance.SendNetMsg(OpCode.account, AccountCode.getUserInfoCReq, null);    //这个请求不需要发送对象
            EventCenter.BroadCast(EventType.UIFlashHint, "登录成功,加载用户信息。。。");
            NetMsgCenter.Instance.ListenServerMsgOnce(OpCode.account, AccountCode.getUserInfoSRes, (msg) =>
            {
                LoadingManager.LoadSceneByLoadingPanel(Constants.SceneName.Lobby);
            });    //收到服务器发回的用户信息后再切换场景
            break;

        default:
            Debug.LogWarning("服务器返回了未知的登录返回码");
            break;
        }
    }
示例#4
0
 public static void GiveUnderCards(int playerIndex)
 {
     Debug.Assert(playerIndex >= 1 && playerIndex <= 3);
     if (playerIndex == 1)
     {
         EventCenter.BroadCast(EventType.MainPlayerRemoveCards, MainPlayerHand.GetCards());
         MainPlayerHand.AddCards(underCards);
         MainPlayerHand.Sort();
         EventCenter.BroadCast(EventType.MainPlayerAddCards, MainPlayerHand.GetCards());
     }
     else if (playerIndex == 2)
     {
         EventCenter.BroadCast(EventType.Player2RemoveCards, Player2Hand.GetCards());
         Player2Hand.AddCards(underCards);
         Player2Hand.Sort();
         EventCenter.BroadCast(EventType.Player2AddCards, Player2Hand.GetCards());
     }
     else
     {
         EventCenter.BroadCast(EventType.Player3RemoveCards, Player3Hand.GetCards());
         Player3Hand.AddCards(underCards);
         Player3Hand.Sort();
         EventCenter.BroadCast(EventType.Player3AddCards, Player3Hand.GetCards());
     }
 }
 private void PlayerGameOverOrNot()
 {
     if (GetComponent <Rigidbody2D>().velocity.y < 0f && !GameManager.Instance().isGameOver)
     {
         if (!IsPlayerJumpCastDwRay())
         {
             GetComponent <SpriteRenderer>().sortingLayerName = "Default";
             GetComponent <BoxCollider2D>().enabled           = false;
             GameManager.Instance().isGameOver = true;
             Debug.Log("GameOver");
         }
         else if (IsPlayerJumpCastFwRay())
         {
             GameObject deadEffect = Instantiate(varsContainer.playerDeadEffectGo);
             deadEffect.transform.position = transform.position;
             GameManager.Instance().isGameOver = true;
             Debug.Log("GameOver");
             //TODO Disactive or not?
             gameObject.SetActive(false);
             EventCenter.BroadCast(EventType.ShowGameOverPanel, true);
         }
     }
     if (GameManager.Instance().isGameOver&& (transform.position.y - Camera.main.transform.position.y <= -6f))
     {
         //TODO Disactive or not?
         //Destroy(gameObject);
         gameObject.SetActive(false);
         EventCenter.BroadCast(EventType.ShowGameOverPanel, true);
     }
 }
示例#6
0
 /// <summary>
 /// 商店按钮点击后触发
 /// </summary>
 private void OnShopButtonClick()
 {
     Debug.Log(GameManager.Instance.GetSelectSkin());
     //发布显示ShopPanel的事件码
     EventCenter.BroadCast(EventType.PlayButtonClip);
     EventCenter.BroadCast(EventType.ShowShopPanel);
 }
    private bool IsPlayerJumpCastDwRay()
    {
        RaycastHit2D hit = Physics2D.Raycast(rayCastDwTf.position, Vector2.down, 1f, platformLayerMask);

        if (hit.collider != null)
        {
            if (hit.collider.tag == "Platform")
            {
                if (curStandingPlatform != hit.collider.gameObject)
                {
                    //To broad cast an add score event.
                    if (curStandingPlatform == null)
                    {
                        curStandingPlatform = hit.collider.gameObject;
                        return(true);
                    }
                    curStandingPlatform = hit.collider.gameObject;
                    EventCenter.BroadCast(EventType.AddPlayerScore);
                    EventCenter.BroadCast(EventType.UpdatePlayerUIScore, GameManager.Instance().playerScore);
                }
                return(true);
            }
        }
        return(false);
    }
示例#8
0
 private void ShowQuitPanel()
 {
     EventCenter.BroadCast(EventType.PlayButtonClip);
     gameObject.SetActive(true);
     bg.DOColor(new Color(bg.color.r, bg.color.g, bg.color.b, 0.4f), 0.2f);
     dialog.transform.DOScale(Vector3.one, 0.2f);
 }
    /// <summary>
    /// 主玩家出牌
    /// </summary>
    private void MainPlayerPlayCard()
    {
        if (!isMyTurn)
        {
            EventCenter.BroadCast(EventType.UIFlashHint, "现在无法出牌");
            return;
        }

        Card[] cards = view.GetSelectedCards();
        if (cards.Length == 0)
        {
            EventCenter.BroadCast(EventType.UIFlashHint, "请选择要出的牌");
            return;
        }

        CardSet cardSet = CardSet.GetCardSet(cards);

        Debug.LogFormat("main player cardset:{0}", cardSet);
        if (cardSet.Type == CardSetType.Invalid)
        {
            EventCenter.BroadCast(EventType.UIFlashHint, "无效的组合");
            view.UnselectAllCard();
        }
        else if (!cardSet.IsGreaterThan(CardManager.LastHand))//牌型不同,或者没对方大
        {
            EventCenter.BroadCast(EventType.UIFlashHint, "无法大过上家");
            view.UnselectAllCard();
        }
        else //合法的出牌
        {
            PlayCard(cardSet);
        }
    }
示例#10
0
 private void Awake()
 {
     GetComponent <Button>().onClick.AddListener(() =>
     {
         EventCenter.BroadCast <string>(EventType.ShowText, "你好");
         //Debug.Log(EventCenter.eventTable);
     });
 }
示例#11
0
 /// <summary>
 /// Yes按钮点击触发
 /// </summary>
 private void OnYesButtonClick()
 {
     EventCenter.BroadCast(EventType.PlayButtonClip);
     //调用GameManager的重置游戏方法
     GameManager.Instance.ResetGame();
     //重新加载场景
     SceneManager.LoadScene(SceneManager.GetActiveScene().name);
 }
示例#12
0
文件: BtnClick.cs 项目: zxc6114/0
 public void Awake()
 {
     GetComponent <Button>().onClick.AddListener(() =>
     {
         EventCenter.BroadCast(EventType.ShowText);
     }
                                                 );
 }
示例#13
0
 /// <summary>
 /// 开始按钮点击后触发
 /// </summary>
 private void OnStartButtonClick()
 {
     GameManager.Instance.isGameStarted = true;//游戏开始,设置为true
     //GameManager.Instance.isGameOvered = false;//游戏开始,设置为false
     EventCenter.BroadCast(EventType.PlayButtonClip);
     EventCenter.BroadCast(EventType.ShowGamePanel);
     gameObject.SetActive(false);
 }
 private void Awake()
 {
     GetComponent <Button>().onClick.AddListener(() =>
     {
         //EventCenter.BroadCast(EventType.ShowText);
         EventCenter.BroadCast(EventType.ShowText, "Hello!!!");
     });
 }
示例#15
0
 /// <summary>
 /// 返回按钮点击
 /// </summary>
 private void OnBackButtonClick()
 {
     EventCenter.BroadCast(EventType.PlayButtonClip);
     img_Back.color = new Color(img_Back.color.r, img_Back.color.g, img_Back.color.b, 0);
     scoreList.transform.DOScale(Vector3.zero, 0.2f).OnComplete(() => {
         gameObject.SetActive(false);
     });
 }
示例#16
0
 private static void CleanCards()
 {
     EventCenter.BroadCast(EventType.MainPlayerRemoveCards, MainPlayerHand.GetCards());
     EventCenter.BroadCast(EventType.Player2RemoveCards, Player2Hand.GetCards());
     EventCenter.BroadCast(EventType.Player3RemoveCards, Player3Hand.GetCards());
     MainPlayerHand.Clear();
     Player2Hand.Clear();
     Player3Hand.Clear();
 }
示例#17
0
 private void OnNoButtonClick()
 {
     EventCenter.BroadCast(EventType.PlayButtonClip);
     //消失动画播放完之后,隐藏gameobject
     bg.DOColor(new Color(bg.color.r, bg.color.g, bg.color.b, 0.4f), 0.2f);
     dialog.transform.DOScale(Vector3.one, 0.2f).OnComplete(() => {
         gameObject.SetActive(false);
     });
 }
示例#18
0
 /// <summary>
 /// 增加钻石个数
 /// </summary>
 private void AddGameDiamond()
 {
     if (isGameStarted == false || isGameOvered || isGamePaused)
     {
         return;
     }
     gameDiamond++;
     EventCenter.BroadCast(EventType.UpdateDiamondText, gameDiamond);
 }
示例#19
0
 /// <summary>
 /// Pause按钮点击后触发
 /// </summary>
 private void OnPauseButtonClick()
 {
     EventCenter.BroadCast(EventType.PlayButtonClip);
     btn_Play.gameObject.SetActive(true);
     btn_Pause.gameObject.SetActive(false);
     //Game Pause
     GameManager.Instance.isGamePaused = true;
     Time.timeScale = 0;
 }
示例#20
0
 /// <summary>
 /// 增加游戏分数
 /// </summary>
 private void AddGameScore()
 {
     if (isGameStarted == false || isGameOvered || isGamePaused)
     {
         return;
     }
     gameScore++;
     EventCenter.BroadCast(EventType.UpdateScoreText, gameScore);
 }
示例#21
0
 /// <summary>
 /// 检测是否碰到钻石:碰撞双方都没有勾选isTrigger
 /// </summary>
 /// <param name="collision">钻石</param>
 private void OnCollisionEnter2D(Collision2D collision)
 {
     //玩家吃到钻石
     if (collision.gameObject.CompareTag("Pickup"))
     {
         EventCenter.BroadCast(EventType.AddDiamond);
         //播放钻石音效
         GameManager.Instance.AudioPlay(vars.diamondClip);
         collision.gameObject.SetActive(false);
     }
 }
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "Diamond")
     {
         GameObject pickUpEffect = Instantiate(varsContainer.pickupItemEffectGo);
         pickUpEffect.transform.position = transform.position;
         collision.gameObject.SetActive(false);
         EventCenter.BroadCast(EventType.AddDiamondCount);
         EventCenter.BroadCast(EventType.UpdatePlayerDiamondUICount, GameManager.Instance().playerDiamondCount);
     }
 }
示例#23
0
 private void Start()
 {
     //再来一次时候的判断,true的时候直接ShowGamePanel
     if (GameData.IsAgainGame)
     {
         EventCenter.BroadCast(EventType.ShowGamePanel);
         gameObject.SetActive(false);
     }
     //一开始更改btnShop的Image为选中的皮肤
     Changebtn_ShopImage(GameManager.Instance.GetSelectSkin());
     SetSoundButtonSprite();
 }
示例#24
0
 /// <summary>
 /// 选择按钮事件
 /// </summary>
 private void OnSelectButtonClick()
 {
     EventCenter.BroadCast(EventType.PlayButtonClip);
     //广播选择的皮肤下标事件码
     EventCenter.BroadCast(EventType.SelectSkin, selectIndex);
     //设置选择的皮肤下标
     GameManager.Instance.SetSelectSkin(selectIndex);
     Debug.Log(GameManager.Instance.GetSelectSkin());
     //广播显示MainPanel事件码
     EventCenter.BroadCast(EventType.ShowMainPanel);
     //隐藏
     gameObject.SetActive(false);
 }
 protected void OnReadyBtnClicked()
 {
     if (readyBtnStatus)
     {
         readyButtonText.text = "取消准备";
         EventCenter.BroadCast(EventType.Ready);
     }
     else
     {
         readyButtonText.text = "准备";
         EventCenter.BroadCast(EventType.UnReady);
     }
     readyBtnStatus = !readyBtnStatus;
 }
示例#26
0
    private void OnPlayCardHintClicked()
    {
        var     cardHand = Models.gameModel.playModel.MainPlayerHand;
        CardSet hintSet  = cardHand.GetCardSetGreater(Models.gameModel.playModel.lastHand);

        if (hintSet.Type == CardSetType.Invalid)
        {
            EventCenter.BroadCast(EventType.UIFlashHint, "没有可出的牌");
            NetMsgCenter.Instance.SendPassTurnMsg();
            return;
        }
        view.UnselectAllCard();
        view.SelectCards(hintSet.Cards);
    }
 private void PlayerJump()
 {
     isJumping = true;
     if (isMoveLeft)
     {
         transform.localScale = new Vector3(-1f, 1f, 1f);
         DoTweenPlayerJumpAnimation(nextLeftPlatformPos);
     }
     else
     {
         transform.localScale = Vector3.one;
         DoTweenPlayerJumpAnimation(nextRightPlatformPos);
     }
     EventCenter.BroadCast(EventType.DecidePath);
 }
示例#28
0
 void HandleRegisterSRes(int responseCode)
 {
     if (responseCode == AccountReturnCode.success)
     {
         EventCenter.BroadCast(EventType.UIFlashHint, "注册成功");
     }
     else if (responseCode == AccountReturnCode.userExist)
     {
         EventCenter.BroadCast(EventType.UIFlashHint, "用户名已存在");
     }
     else
     {
         Debug.LogWarning("服务器返回了未知的注册返回码");
     }
 }
示例#29
0
 void OnLoginBtnClicked()
 {
     if (userNameField == null || userNameField.text == "")
     {
         EventCenter.BroadCast(EventType.UIFlashHint, "用户名为空");
     }
     else if (passwordField == null || passwordField.text == "")
     {
         EventCenter.BroadCast(EventType.UIFlashHint, "密码为空");
     }
     else
     {
         NetMsgCenter.Instance.SendLoginMsg(userNameField.text, passwordField.text);
     }
 }
示例#30
0
    // === auto generated code end ===

    private void Awake()
    {
        // === auto generated code begin ===
        title     = transform.Find("Title").GetComponent <UnityEngine.UI.Text>();
        resetBtn  = transform.Find("Buttons/ResetBtn").GetComponent <UnityEngine.UI.Button>();
        exitBtn   = transform.Find("Buttons/ExitBtn").GetComponent <UnityEngine.UI.Button>();
        coinTitle = transform.Find("CoinPanel/CoinTitle").GetComponent <UnityEngine.UI.Text>();
        coinText  = transform.Find("CoinPanel/CoinText").GetComponent <UnityEngine.UI.Text>();
        // === auto generated code end ===

        resetBtn.onClick.AddListener(() => { EventCenter.BroadCast(EventType.MatchReset); Hide(); });
        exitBtn.onClick.AddListener(() => { EventCenter.BroadCast(EventType.MatchExit); Hide(); });

        EventCenter.AddListener(EventType.MatchOver, Show);
    }