Ejemplo n.º 1
0
    protected void AddChips(Transform parent, long chips)
    {
        for (int i = parent.childCount - 1; i >= 0; i--)
        {
            GameObject.DestroyImmediate(parent.GetChild(i).gameObject);
        }

        BetData bd = BlackJack_Data.GetInstance().m_BetData[m_BjGameBase.m_RoomInfo.m_nRoomLevel - 1];

        int[] grades = bd.m_nGrades;
        for (int i = grades.Length - 1; i >= 0; i--)
        {
            if (chips >= grades[i] || i == 0)
            {
                int index = i + (chips > grades[i] ? 2 : 1);
                UnityEngine.Object obj     = (GameObject)m_BjGameBase.m_AssetBundle.LoadAsset("Model_chouma" + index);
                GameObject         gameObj = GameMain.instantiate(obj) as GameObject;
                gameObj.transform.SetParent(parent, false);
                gameObj.GetComponentInChildren <TextMesh>().text = GameFunction.FormatCoinText(chips);

                break;
            }
        }


        CustomAudioDataManager.GetInstance().PlayAudio(1003);
    }
Ejemplo n.º 2
0
 void ShowChipsTip(bool bShow, int cardPos = 0)
 {
     if (m_ChipPointArray[cardPos, 0].childCount > 0)
     {
         Transform t = m_ChipPointArray[cardPos, 0].GetChild(0).Find("Tips");
         t.gameObject.SetActive(bShow);
         if (bShow)
         {
             int index = cardPos > 0 ? (cardPos - 1) : cardPos;
             t.GetComponentInChildren <TextMesh>().text = GameFunction.FormatCoinText(m_nChipInCoin[index]);
         }
     }
 }
Ejemplo n.º 3
0
    IEnumerator PopCoin(Fishing_Fish fish, FishingFishData fd, bool bLocal, long getCoin, Vector3 center, Vector3 targetPos, byte getSkillId)
    {
        //DebugLog.Log("num:" + num + " center:" + center + " target:" + targetPos);

        if (getCoin <= 0)
        {
            yield break;
        }

        CGame_Fishing game = fish.m_CatchRole.GameBase;
        AssetBundle   ab   = game.FishingAssetBundle;
        Canvas        cv   = game.GameCanvas;
        Transform     root = cv.transform.Find("Root");

        GameObject prefab;

        GameObject big = null;

        if (fd.m_nMultiple >= 20)
        {
            prefab = (GameObject)ab.LoadAsset("FishCoin_big");
            big    = ((GameObject)GameMain.instantiate(prefab));
            big.transform.SetParent(root, false);
            big.transform.localPosition = center;
            game.m_AddItems.Add(big);

            Camera.main.DOShakePosition(1f, 1f).OnComplete(() =>
            {
                Camera.main.transform.position = game.CameraSourcePos;
            });

            CustomAudioDataManager.GetInstance().PlayAudio(1004);
        }
        else
        {
            CustomAudioDataManager.GetInstance().PlayAudio(1003);
        }

        yield return(new WaitUntil(() => m_bDeathEnd));

        Transform effectTfm = fish.transform.parent.Find("Effect");

        if (effectTfm != null)
        {
            effectTfm.DOScale(Vector3.zero, 1f);
        }
        fish.transform.parent.DOScale(Vector3.zero, 1f);

        prefab = (GameObject)ab.LoadAsset(bLocal ? "Text_HurtNum" : "Text_HurtNum_other");
        GameObject textObj = ((GameObject)GameMain.instantiate(prefab));

        textObj.transform.SetParent(root.Find("HurtNum"), false);
        textObj.transform.localPosition = center;
        textObj.transform.localScale    = Vector3.zero;
        textObj.transform.GetComponent <Text>().text = GameFunction.FormatCoinText(getCoin, true, false);
        game.m_AddItems.Add(textObj);
        textObj.transform.DOScale(new Vector3(1f, 1f, 1f), 0.5f).OnComplete(() =>
        {
            textObj.transform.DOScale(new Vector3(1f, 1f, 1f), 0.5f).OnComplete(() =>
            {
                game.m_AddItems.Remove(textObj);
                Destroy(textObj);
            });
        });

        bool bCoin = true;

        if (getSkillId > 0 && bLocal)
        {
            if (getSkillId == RoomInfo.NoSit)//lottery
            {
                prefab = (GameObject)ab.LoadAsset("Skill_Ticket");
                bCoin  = false;
            }
            else
            {
                prefab = (GameObject)ab.LoadAsset("Skill_" + getSkillId);
            }
            if (prefab != null)
            {
                GameObject skillObj = Instantiate(prefab);
                skillObj.transform.SetParent(root, false);
                skillObj.transform.localPosition = center;
                game.m_AddItems.Add(skillObj);
                skillObj.transform.DOLocalMove(center + new Vector3(0, 100f, 0f), 1f).OnComplete(() =>
                {
                    game.m_AddItems.Remove(skillObj);
                    Destroy(skillObj);
                });
            }
        }

        if (bCoin)
        {
            int   num    = Mathf.CeilToInt((float)fd.m_nMultiple / 5) + 2;
            float radius = (num - 1) * 10f;
            float halfPi = Mathf.PI * 0.5f;
            float angle;
            prefab = (GameObject)ab.LoadAsset("FishCoin");
            GameObject coin;
            Vector3    pos;

            List <GameObject> coinList = new List <GameObject>();

            for (int i = 0; i < num; i++)
            {
                angle = Random.Range(0f, halfPi) * 4f;
                coin  = ((GameObject)GameMain.instantiate(prefab));
                coin.transform.SetParent(root, false);
                coin.transform.localPosition = center;
                pos = center + new Vector3(Mathf.Sin(angle), Mathf.Cos(angle)) * Random.Range(0f, radius);
                coin.transform.DOLocalMove(pos, 0.5f);
                //DebugLog.Log(i + ": angle:" + angle + " pos:" + pos);

                coinList.Add(coin);
                game.m_AddItems.Add(coin);

                yield return(new WaitForEndOfFrame());
            }

            yield return(new WaitForSecondsRealtime(1f));

            CustomAudioDataManager.GetInstance().PlayAudio(1002);

            float flyTime = 0.5f;

            foreach (GameObject obj in coinList)
            {
                if (obj == null)
                {
                    continue;
                }

                Vector3 dir   = targetPos - obj.transform.localPosition;
                Vector3 speed = new Vector3(dir.x / flyTime, 0f);
                float   a     = dir.y * 2f / (flyTime * flyTime);

                DOTween.To(() => obj.transform.localPosition,
                           r =>
                {
                    obj.transform.localPosition += (speed * Time.unscaledDeltaTime);
                    speed.y = speed.y + a * Time.unscaledDeltaTime;
                },
                           targetPos, flyTime);
            }

            yield return(new WaitForSecondsRealtime(flyTime));

            foreach (GameObject obj in coinList)
            {
                if (obj == null)
                {
                    continue;
                }

                game.m_AddItems.Remove(obj);
                Destroy(obj);
            }
        }

        if (big != null)
        {
            game.m_AddItems.Remove(big);
            Destroy(big);
        }
    }
Ejemplo n.º 4
0
    bool HandleGetRoundScore(uint _msgType, UMessage _ms)
    {
        long videoId = _ms.ReadLong();
        byte res     = _ms.ReadByte();//是否成功 1成功有数据 0没有

        if (res == 0)
        {
            return(false);
        }

        AssetBundle bundle = AssetBundleManager.GetAssetBundle(GameDefine.HallAssetbundleName);

        if (bundle == null)
        {
            return(false);
        }

        if (!ShowRoundScore(true))
        {
            return(false);
        }

        Transform  parent = LobbyUITfm.Find("middle/Viewport_video/Content_video");
        GameObject assetObj = (GameObject)bundle.LoadAsset("video_record");
        Transform  tfm, child;
        long       time;
        Color      winCol  = new Color(0.851f, 0.231f, 0.165f);
        Color      loseCol = new Color(0.349f, 0.51f, 0.737f);

        byte nRoundNum = _ms.ReadByte(); //打了几局
        byte nRoleNum  = _ms.ReadByte(); //几个人

        for (byte i = 1; i <= nRoundNum; i++)
        {
            time = _ms.ReadLong();
            tfm  = (Instantiate(assetObj)).transform;
            tfm.SetParent(parent, false);
            Text t = tfm.Find("Textju").GetComponent <Text>();
            t.text = i.ToString();
            t      = tfm.Find("TextTime").GetComponent <Text>();
            System.DateTime sdt = GameCommon.ConvertLongToDateTime(time);
            t.text = sdt.ToString("yyyy年MM月dd日HH:mm");
            uint[] playerIds = new uint[nRoleNum];
            byte   k         = 0;
            for (; k < nRoleNum; ++k)
            {
                uint nUseid = (uint)_ms.ReadInt();
                int  nScore = _ms.ReadInt();//积分
                byte sit    = _ms.ReadByte();

                if (!m_CurData.result.ContainsKey(nUseid))
                {
                    continue;
                }

                playerIds[sit] = nUseid;

                AppointmentRecordPlayer player = m_CurData.result[nUseid];

                child = tfm.Find("playerinfo_" + (k + 1));
                Image img = child.Find("Image_HeadBG/Image_HeadMask/Image_HeadImage").GetComponent <Image>();
                img.sprite = GameMain.hall_.GetIcon(player.url, nUseid, player.faceid);
                t          = child.Find("TextName").GetComponent <Text>();
                t.text     = player.playerName;
                t          = child.Find("TextJifen").GetComponent <Text>();
                t.text     = GameFunction.FormatCoinText(nScore, true, false);
                t.color    = nScore > 0 ? winCol : loseCol;
            }

            m_IndexPlayers.Add(i, new List <uint>(playerIds));

            for (; k < tfm.childCount; k++)
            {
                child = tfm.Find("playerinfo_" + (k + 1));
                if (child == null)
                {
                    break;
                }
                child.gameObject.SetActive(false);
            }

            byte temp = i;
            tfm.Find("Button_start").GetComponent <Button>().onClick.AddListener(() => OnClickStart(videoId, temp));
            //tfm.FindChild("Button_share").GetComponent<Button>().onClick.AddListener(() => OnClickShare(videoId, temp));
            tfm.Find("Button_share").gameObject.SetActive(false);
        }

        return(true);
    }