Example #1
0
        //void OnGUI()
        //{

        //}

        protected void OnCheckScorePlayScaleEnd()
        {
            if (uiNumberScaled.Count > 0)
            {
                int           playerIndex = uiNumberScaled[0];
                PlayerUIParam uiParam     = (PlayerUIParam)uiParamList[playerIndex];
                uiParam.playinngScale = false;
                uiNumberScaled.RemoveAt(0);
            }
        }
Example #2
0
        public void ConfirmName(int playerIndex)
        {
            PlayerUIParam uiParam = uiParamList[playerIndex];

            if (uiParam.index < GameConfig.GAME_CONFIG_NAME_LEN - 1)
            {
                return;
            }
            uiParam.flag = true;
        }
Example #3
0
        public void DeleteName(int playerIndex)
        {
            PlayerUIParam uiParam = uiParamList[playerIndex];

            if (uiParam.index == 0)
            {
                return;
            }
            if (uiParam.flag)
            {
                return;
            }
            --uiParam.index;
            uiParam.name = uiParam.name.Substring(0, uiParam.index) + '_';
        }
Example #4
0
        public void PushName(int playerIndex, char value)
        {
            PlayerUIParam uiParam = uiParamList[playerIndex];

            if (uiParam.index >= GameConfig.GAME_CONFIG_NAME_LEN)
            {
                return;
            }
            if (uiParam.flag)
            {
                return;
            }
            char[] nameArray = uiParam.name.ToCharArray();
            nameArray[uiParam.index] = value;
            uiParam.name             = new string(nameArray) + '_';
            ++uiParam.index;
        }
Example #5
0
        // 加水等待
        //void PlayerUpdateAddWaterAnimation(int playerIndex, Player player)
        //{
        //    // 改函数在固定刷新函数中
        //    PlayView.PlayerPanel playerPanel = (PlayView.PlayerPanel)view.panelList[playerIndex];
        //    if (player.AddWaterTime <= 0)
        //    {
        //        playerPanel.image_WaitAddWater.gameObject.SetActive(false);
        //        return;
        //    }

        //    PlayerUIParam uiParam = (PlayerUIParam)uiParamList[playerIndex];
        //    uiParam.curFrame++;
        //    if (uiParam.curFrame >= 8)
        //    {
        //        uiParam.curFrame = 0;
        //    }
        //    // 替换公共加水等待图片
        //    playerPanel.image_WaitAddWater.sprite = view.image_AddWaters[uiParam.curFrame].sprite;
        //    playerPanel.image_WaitAddWater.SetNativeSize();
        //    playerPanel.image_WaitAddWater.gameObject.SetActive(true);
        //    uiParamList[playerIndex] = uiParam;
        //}

        // 缺水警告
        void PlayerUpdateWarning(int playerIndex, Player player)
        {
            PlayView.PlayerPanel playerPanel = (PlayView.PlayerPanel)view.panelList[playerIndex];
            PlayerUIParam        uiParam     = (PlayerUIParam)uiParamList[playerIndex];

            if (player.State == Player.StateType.Play)
            {
                if (player.LifeTime <= 10)
                {
                    playerPanel.image_TimerWarning.gameObject.SetActive(true);
                    if (uiParam.twGround == null)
                    {
                        Color color = playerPanel.image_TimerWarning.color;
                        color.a          = 0.0f;
                        uiParam.twGround = playerPanel.image_TimerWarning.DOColor(color, 0.2f);
                        uiParam.twGround.SetLoops(-1, LoopType.Yoyo);
                        uiParam.twGround.Play();
                    }
                    else
                    {
                        if (!uiParam.twGround.IsPlaying())
                        {
                            uiParam.twGround.Play();
                        }
                    }
                }
            }
            else
            {
                if (uiParam.twGround != null && uiParam.twGround.IsPlaying())
                {
                    playerPanel.image_TimerWarning.gameObject.SetActive(false);
                    uiParam.twGround.Pause();
                }
            }
        }
Example #6
0
        // 积分更新
        void PlayerUpdateScore(int playerIndex, Player player)
        {
            PlayView.PlayerPanel playerPanel = (PlayView.PlayerPanel)view.panelList[playerIndex];
            PlayerUIParam        uiParam     = (PlayerUIParam)uiParamList[playerIndex];

            if (player.State == Player.StateType.Play)
            {
                int score = player.Score;

                //if (uiParam.curScore + uiParam.addScore < player.Score)
                //{
                //    uiParam.addScore += (player.Score - (uiParam.curScore + uiParam.addScore));
                //}

                int  randomScore = Random.Range(1, 20);
                bool playScale   = false;
                if (uiParam.addScore > 0)
                {
                    if (uiParam.addScore >= randomScore)
                    {
                        uiParam.curScore += randomScore;
                        uiParam.addScore -= randomScore;
                    }
                    else
                    {
                        uiParam.curScore += uiParam.addScore;
                        uiParam.addScore  = 0;
                    }

                    playScale = true;
                }
                else
                {
                    if (playerPanel.image_NumberSlot1.gameObject.activeSelf && uiParam.curScore == player.Score)
                    {
                        return;
                    }
                }

                int value1 = uiParam.curScore % 10;
                int value2 = (uiParam.curScore / 10) % 10;
                int value3 = (uiParam.curScore / 100) % 10;
                int value4 = (uiParam.curScore / 1000) % 10;
                int value5 = (uiParam.curScore / 10000) % 10;
                playerPanel.image_NumberSlot1.sprite = view.image_Numbers[value1].sprite;
                playerPanel.image_NumberSlot2.sprite = view.image_Numbers[value2].sprite;
                playerPanel.image_NumberSlot3.sprite = view.image_Numbers[value3].sprite;
                playerPanel.image_NumberSlot4.sprite = view.image_Numbers[value4].sprite;
                playerPanel.image_NumberSlot5.sprite = view.image_Numbers[value5].sprite;
                Vector2 size = new Vector2(21, 29);
                playerPanel.image_NumberSlot1.rectTransform.sizeDelta = size;
                playerPanel.image_NumberSlot2.rectTransform.sizeDelta = size;
                playerPanel.image_NumberSlot3.rectTransform.sizeDelta = size;
                playerPanel.image_NumberSlot4.rectTransform.sizeDelta = size;
                playerPanel.image_NumberSlot5.rectTransform.sizeDelta = size;
                playerPanel.image_NumberSlot1.gameObject.SetActive(true);
                playerPanel.image_NumberSlot2.gameObject.SetActive(true);
                playerPanel.image_NumberSlot3.gameObject.SetActive(true);
                playerPanel.image_NumberSlot4.gameObject.SetActive(true);
                playerPanel.image_NumberSlot5.gameObject.SetActive(true);
                playerPanel.image_Head1.gameObject.SetActive(true);
                //playerPanel.image_Head2.gameObject.SetActive(true);
                playerPanel.image_HeadGround4.gameObject.SetActive(true);
                playerPanel.image_Head1Grey.gameObject.SetActive(false);
                playerPanel.image_image_HeadGroundGrey.gameObject.SetActive(false);
                playerPanel.image_HeadGround4Grey.gameObject.SetActive(false);

                if (!uiParam.playinngScale && playScale)
                {
                    Vector3  scaleEnd = new Vector3(1.5f, 1.5f, 1.5f);
                    Sequence sequence = DOTween.Sequence();
                    sequence.Append(playerPanel.image_NumberSlot1.rectTransform.DOScale(scaleEnd, 0.1f).SetLoops(2, LoopType.Yoyo));
                    sequence.Join(playerPanel.image_NumberSlot2.rectTransform.DOScale(scaleEnd, 0.1f).SetLoops(2, LoopType.Yoyo));
                    sequence.Join(playerPanel.image_NumberSlot3.rectTransform.DOScale(scaleEnd, 0.1f).SetLoops(2, LoopType.Yoyo));
                    sequence.Join(playerPanel.image_NumberSlot4.rectTransform.DOScale(scaleEnd, 0.1f).SetLoops(2, LoopType.Yoyo));
                    sequence.Join(playerPanel.image_NumberSlot5.rectTransform.DOScale(scaleEnd, 0.1f).SetLoops(2, LoopType.Yoyo));
                    sequence.SetLoops(1, LoopType.Yoyo);
                    uiNumberScaled.Add(playerIndex);
                    sequence.OnComplete(OnCheckScorePlayScaleEnd);
                    sequence.Play();
                    uiParam.playinngScale = true;
                }

                Main.IOManager.SetPlayerGameBegine(playerIndex, true);
            }
            else
            {
                if (player.State == Player.StateType.Idle)
                {
                    if (!Main.IOManager.GetIsSetGameEnd(playerIndex))
                    {
                        Main.IOManager.ComputeTicket(playerIndex, player.Score);
                        Main.IOManager.SetIsSetGameEnd(playerIndex, true);
                    }

                    uiParam.addScore      = 0;
                    uiParam.curScore      = 0;
                    uiParam.addTime       = 0.0f;
                    uiParam.playinngScale = false;
                }
                else if (player.State == Player.StateType.Wait)
                {
                    if (uiParam.addScore > 0)
                    {
                        uiParam.curScore += uiParam.addScore;
                        uiParam.addScore  = 0;
                    }
                }
                playerPanel.image_NumberSlot1.gameObject.SetActive(false);
                playerPanel.image_NumberSlot2.gameObject.SetActive(false);
                playerPanel.image_NumberSlot3.gameObject.SetActive(false);
                playerPanel.image_NumberSlot4.gameObject.SetActive(false);
                playerPanel.image_NumberSlot5.gameObject.SetActive(false);
                playerPanel.image_Head1.gameObject.SetActive(false);
                //playerPanel.image_Head2.gameObject.SetActive(false);
                playerPanel.image_HeadGround4.gameObject.SetActive(false);
                playerPanel.image_Head1Grey.gameObject.SetActive(true);
                playerPanel.image_image_HeadGroundGrey.gameObject.SetActive(true);
                playerPanel.image_HeadGround4Grey.gameObject.SetActive(true);

                //设置playerIndex为游戏结束状态
                Main.IOManager.SetPlayerGameEnd(playerIndex, true);
                Main.IOManager.SetPlayerGameBegine(playerIndex, false);


                //if (!Main.IOManager.GetIsSetGameEnd(playerIndex))
                //{
                //    Main.IOManager.SetPlayerGameEnd(playerIndex);
                //    Main.IOManager.ComputeTicket(playerIndex, player.Score);
                //    //让结束状态值发送一次
                //    Main.IOManager.SetIsSetGameEnd(playerIndex, true);
                //}
            }
        }
Example #7
0
        // AOE变化
        //void OnEventUpdateAoe()
        //{
        //    view.image_AoeBar.value = Main.GameMode.TotalAoePercent();
        //    AnimatorStateInfo info = view.animator_AOEFlash.GetCurrentAnimatorStateInfo(0);
        //    if (info.IsName("Idle"))
        //    {
        //        view.animator_AOEFlash.SetInteger("Flag", 1);
        //        view.Image_AoeSlotFlash.gameObject.SetActive(true);
        //    }
        //}

        void OnEventAppendScores(int index, int value)
        {
            PlayerUIParam uiParam = (PlayerUIParam)uiParamList[index];

            uiParam.addScore += value;
        }
Example #8
0
        public void UpdatePerFrame()
        {
            if (Main.GameMode.RunState() == RunMode.EndingEdit)
            {
                for (int index = 0; index < view.image_Edits.Count; ++index)
                {
                    Player player = Main.PlayerManager.getPlayer(index);
                    if (player == null)
                    {
                        return;
                    }
                    PlayerUpdateTarget(index, player);
                }
            }

            if (start == false)
            {
                remainTime -= Main.NonStopTime.deltaTime;
                if (Main.GameMode.RunState() == RunMode.EndingEdit)
                {
                    int     value   = (int)remainTime;
                    int     number1 = (value / 10) % 10;
                    int     number2 = (value / 1) % 10;
                    Vector2 size1   = new Vector2(37, 52);
                    Vector2 size2   = new Vector2(82, 58);
                    view.image_Time1.sprite = view.image_Numbers[number1].sprite;
                    view.image_Time2.sprite = view.image_Numbers[number2].sprite;
                    view.image_Time1.rectTransform.sizeDelta = size1;
                    view.image_Time2.rectTransform.sizeDelta = size1;

                    if (remainTime <= 0 && !start)
                    {
                        remainTime = 0;
                        start      = true;
                        List <string> names = new List <string>();
                        for (int index = 0; index < Main.PlayerCount(); ++index)
                        {
                            Player             player  = Main.PlayerManager.getPlayer(index);
                            RankView.EditPanel ui      = view.image_Edits[index];
                            PlayerUIParam      uiParam = uiParamList[index];
                            // 自动输入
                            for (int count = uiParam.index; count < GameConfig.GAME_CONFIG_NAME_LEN; ++count)
                            {
                                PushName(index, 'A');
                            }
                            ConfirmName(index);
                            names.Add(uiParam.name);
                        }

                        // 结算
                        EventDispatcher.TriggerEvent(GameEventDef.EVNET_RANK_EDIT_INPUT_COMPLETE, names[0], names[1], names[2]);
                    }

                    int playerCount   = 0;
                    int fullNameCount = 0;
                    for (int index = 0; index < Main.PlayerCount(); ++index)
                    {
                        Player             player  = Main.PlayerManager.getPlayer(index);
                        RankView.EditPanel ui      = view.image_Edits[index];
                        PlayerUIParam      uiParam = uiParamList[index];

                        if (player.State == Player.StateType.Play)
                        {
                            ++playerCount;
                            // 判断文字
                            Image image_key = GetKeyImageByPosition(Main.Controller.JoystickPosition(index));
                            if (image_key != null)
                            {
                                if (ui.image_Key != null && image_key.gameObject.name == ui.image_Key.name && !uiParam.flag)
                                {
                                    Animator          animator = ui.image_KeyPressed.GetComponent <Animator>();
                                    AnimatorStateInfo info     = animator.GetCurrentAnimatorStateInfo(0);
                                    if (info.IsName("Play") && info.normalizedTime >= 1.0f)
                                    {
                                        string keyName = ui.image_Key.name.Substring(9);
                                        // 添加
                                        if (keyName.Length == 1)
                                        {
                                            PushName(index, keyName[0]);
                                        }
                                        // 删除
                                        else if (keyName.Equals("Del"))
                                        {
                                            DeleteName(index);
                                        }
                                        // 确定
                                        else if (keyName.Equals("Enter"))
                                        {
                                            ConfirmName(index);
                                            Main.IOManager.SetPlayerGameBegine(index, false);
                                        }
                                        GameObject.Destroy(ui.image_KeyPressed.gameObject);
                                        ui.image_KeyPressed = null;
                                        ui.image_Key        = null;
                                    }
                                }
                                else
                                {
                                    if (ui.image_KeyPressed != null)
                                    {
                                        GameObject.Destroy(ui.image_KeyPressed);
                                        ui.image_KeyPressed = null;
                                    }

                                    ui.image_Key = image_key;
                                    string imageName = image_key.gameObject.name;
                                    string keyName   = imageName.Substring(9);
                                    if (keyName.Length > 1)
                                    {
                                        ui.image_KeyPressed = GameObject.Instantiate(view.image_KeyPressed2) as Image;
                                    }
                                    else
                                    {
                                        ui.image_KeyPressed = GameObject.Instantiate(view.image_KeyPressed1) as Image;
                                    }
                                    ui.image_KeyPressed.transform.parent = view.panel_KeyParent.transform;
                                    ui.image_KeyPressed.rectTransform.anchoredPosition = image_key.rectTransform.anchoredPosition;
                                    ui.image_KeyPressed.rectTransform.localScale       = Vector3.one;
                                    ui.image_KeyPressed.SetNativeSize();
                                    ui.image_KeyPressed.gameObject.SetActive(true);
                                }
                            }
                            else
                            {
                                if (ui.image_KeyPressed != null)
                                {
                                    GameObject.Destroy(ui.image_KeyPressed.gameObject);
                                    ui.image_KeyPressed = null;
                                    ui.image_Key        = null;
                                }
                            }

                            // 文字显示
                            ui.image_Head.gameObject.SetActive(true);
                            for (int count = 0; count < GameConfig.GAME_CONFIG_NAME_LEN; ++count)
                            {
                                if (uiParam.index >= count)
                                {
                                    // 显示文字
                                    int imageIndex = GetLetterImageIndexBy(uiParam.name[count]);
                                    ui.image_CharSlotList[count].sprite = view.image_EditChars[imageIndex].sprite;
                                    if (imageIndex == 26)
                                    {
                                        ui.image_CharSlotList[count].SetNativeSize();
                                    }
                                    else
                                    {
                                        ui.image_CharSlotList[count].rectTransform.sizeDelta = size2;
                                    }
                                    ui.image_CharSlotList[count].gameObject.SetActive(true);
                                }
                                else
                                {
                                    // 不显示
                                    ui.image_CharSlotList[count].gameObject.SetActive(false);
                                }
                            }

                            if (uiParam.flag)
                            {
                                ++fullNameCount;
                            }
                        }
                        else
                        {
                            ui.image_Head.gameObject.SetActive(false);
                        }
                        view.image_Edits[index] = ui;
                        uiParamList[index]      = uiParam;
                    }

                    // 判断是否输入完毕
                    if (fullNameCount == playerCount)
                    {
                        remainTime = 0;
                    }
                }
            }
        }