示例#1
0
 private void Awake()
 {
     instance = this;
     items    = new List <ChatItem>();
     prefab   = transform.GetChild(0).gameObject;
     scroll   = transform.parent.parent.GetComponent <ScrollRect>();
 }
示例#2
0
        // public static void LogAllChild(Transform tf, bool logSize = false, int idx = 0)
        // {
        //     string s = "";
        //     for (int i = 0; i < idx; i++)
        //     {
        //         s += "-- ";
        //     }
        //     s += tf.name + " " + tf.gameObject.activeSelf;
        //     if (logSize)
        //     {
        //         RectTransform rect = tf as RectTransform;
        //         if (rect == null)
        //         {
        //             s += " scale=" + tf.localScale.ToString();
        //         }
        //         else
        //         {
        //             s += " sizeDelta=" + rect.sizeDelta.ToString();
        //         }
        //     }
        //     // // // Main.Logger.Log(s);

        //     idx++;
        //     for (int i = 0; i < tf.childCount; i++)
        //     {
        //         Transform child = tf.GetChild(i);
        //         LogAllChild(child, logSize, idx);
        //     }
        // }

        void Awake()
        {
            int read_ququbattle_des = PlayerPrefs.GetInt("read_ququbattle_des", 0);

            if (read_ququbattle_des < 1)
            {
                PlayerPrefs.SetInt("read_ququbattle_des", 1);
                YesOrNoWindow.instance.SetYesOrNoWindow(-1, "只说一次!请认真阅读说明!", "键盘F1可以打开或者隐藏大厅,左上方文字也可以打开大厅。需要使用3只游戏正常途径获得的不同的蛐蛐出战才能战斗!", false, true);
            }

            instance = this;

            PlayerData.client_bet  = -98;
            PlayerData.client_ids  = new int[] { -98, -98, -98 };
            BattleData.battleDatas = new List <BattleData>();
            PlayerData.self        = new PlayerData();
            self          = PlayerData.self;
            self.level    = -1;
            self.desk_idx = -1;

            dataFile = gameObject.AddComponent <DataFile>();

            all = transform.Find("all").gameObject;
            Image bg = all.GetComponent <Image>();

            bg.color  = new Color(1, 1, 1, 1);
            bg.sprite = QuquBattleSystem.instance.GetComponent <Image>().sprite;

            Transform room_parent = transform.Find("all/Hall");

            hall  = room_parent.gameObject;
            rooms = new RoomObj[room_parent.childCount];
            for (int i = 0; i < rooms.Length; i++)
            {
                Transform child = room_parent.GetChild(i);
                rooms[i] = child.gameObject.AddComponent <RoomObj>();
                rooms[i].SetData(i, 0);
            }

            Transform desk_parent = transform.Find("all/Room");

            room = desk_parent.gameObject;
            Transform content = desk_parent.GetChild(0).GetChild(0);

            desks = new RoomDeskObj[content.childCount];
            for (int i = 0; i < desks.Length; i++)
            {
                Transform child = content.GetChild(i);
                desks[i] = child.gameObject.AddComponent <RoomDeskObj>();
            }

            Transform battle_desk = transform.Find("all/Desk");

            desk     = battle_desk.gameObject;
            ququDesk = desk.AddComponent <QuquDesk>();


            tTitle = transform.Find("all/Text").GetComponent <Text>();

            Transform chat_parent = transform.Find("all/chat");

            chat     = chat_parent.gameObject;
            ququChat = chat_parent.GetChild(0).GetChild(0).gameObject.AddComponent <QuquChat>();

            Transform tfInput = chat_parent.Find("InputField");

            inputField = tfInput.GetComponent <InputField>();
            Button sendChatBtn = chat_parent.Find("InputField/SendButton").GetComponent <Button>();

            sendChatBtn.onClick.AddListener(OnClickSendChat);
            Transform cpInputField = MassageWindow.instance.inputTextField.transform;
            // // // // Main.Logger.Log("复制1" + cpInputField.ToString());
            Image mImage = inputField.GetComponent <Image>();
            Image tImage = cpInputField.GetComponent <Image>();

            mImage.sprite = tImage.sprite;
            mImage.color  = tImage.color;
            inputField.transform.GetChild(0).GetComponent <Text>().text = "在此输入聊天内容";
            // // // // Main.Logger.Log("复制1");
            //LogAllChild(cpInputField.transform.parent.parent.parent);
            Transform cpBtn   = cpInputField.transform.parent.parent.parent.Find("ItemsBack/UseItemButton,631");
            Image     mmImage = sendChatBtn.GetComponent <Image>();
            Image     ttImage = cpBtn.GetComponent <Image>();

            mmImage.sprite = ttImage.sprite;
            mmImage.color  = ttImage.color;
            Text mt1 = tfInput.GetChild(0).GetComponent <Text>();
            Text mt2 = tfInput.GetChild(1).GetComponent <Text>();
            Text ct1 = cpInputField.GetChild(0).GetComponent <Text>();
            Text ct2 = cpInputField.GetChild(1).GetComponent <Text>();

            mt1.color = ct1.color;
            //mt1.font = ct1.font;
            mt1.fontSize  = ct1.fontSize;
            mt1.alignment = TextAnchor.MiddleCenter;
            mt2.color     = ct2.color;
            //mt2.font = ct2.font;
            mt2.fontSize  = ct2.fontSize;
            mt2.alignment = TextAnchor.MiddleCenter;

            // // // // Main.Logger.Log("复制1");

            Transform people_parent = transform.Find("all/people");

            people      = people_parent.gameObject;
            ququPlayers = people_parent.GetChild(0).GetChild(0).gameObject.AddComponent <QuquPlayers>();

            // // // // Main.Logger.Log("搬运聊天背景");
            Image chatBg   = chat_parent.GetComponent <Image>();
            Image propleBg = people_parent.GetComponent <Image>();
            Image chatBgCp = QuquBattleSystem.instance.transform.Find("BattleActorBack").GetComponent <Image>();

            if (chatBgCp)
            {
                // // // // Main.Logger.Log("搬运到聊天背景");
                chatBg.color    = chatBgCp.color;
                chatBg.sprite   = chatBgCp.sprite;
                propleBg.color  = chatBgCp.color;
                propleBg.sprite = chatBgCp.sprite;
            }
            // // // // Main.Logger.Log("搬运聊天背景完成 要搬运字体了");
            Text chatText   = ququChat.prefab.GetComponentInChildren <Text>();
            Text peopleText = ququPlayers.prefab.GetComponentInChildren <Text>();
            Text cpText     = QuquBattleSystem.instance.transform.Find("BattleActorBack/ActorBattleBodyNameBack/BattleBodyBack/BodyItemBack/ItemNameBack/ItemNameText").GetComponent <Text>();

            //chatText.font = cpText.font;
            chatText.color = cpText.color;
            //peopleText.font = cpText.font;
            chatText.color = cpText.color;
            Shadow shadow = cpText.GetComponent <Shadow>();

            if (shadow)
            {
                // // // // Main.Logger.Log("阴影");
                chatText.GetComponent <Shadow>().effectColor   = shadow.effectColor;
                peopleText.GetComponent <Shadow>().effectColor = shadow.effectColor;
            }
            // // // // Main.Logger.Log("完毕");
            ScrollRect cpScroll      = WorldMapSystem.instance.actorHolder.GetComponentInParent <ScrollRect>();
            Scrollbar  scrollbar     = cpScroll.verticalScrollbar;
            Image      handBg        = scrollbar.GetComponent <Image>();
            Image      handImg       = scrollbar.handleRect.GetComponent <Image>();
            Image      chatHandBg    = chat_parent.Find("Scrollbar Vertical").GetComponent <Image>();
            Image      chatHandImg   = chat_parent.Find("Scrollbar Vertical/Sliding Area/Handle").GetComponent <Image>();
            Image      peopleHandBg  = people_parent.Find("Scrollbar Vertical").GetComponent <Image>();
            Image      peopleHandImg = people_parent.Find("Scrollbar Vertical/Sliding Area/Handle").GetComponent <Image>();
            Image      roomHandBg    = desk_parent.Find("Scrollbar Vertical").GetComponent <Image>();
            Image      roomHandImg   = desk_parent.Find("Scrollbar Vertical/Sliding Area/Handle").GetComponent <Image>();

            chatHandBg.color     = handBg.color;
            chatHandBg.sprite    = handBg.sprite;
            chatHandImg.color    = handImg.color;
            chatHandImg.sprite   = handImg.sprite;
            peopleHandBg.color   = handBg.color;
            peopleHandBg.sprite  = handBg.sprite;
            peopleHandImg.color  = handImg.color;
            peopleHandImg.sprite = handImg.sprite;
            roomHandBg.color     = handBg.color;
            roomHandBg.sprite    = handBg.sprite;
            roomHandImg.color    = handImg.color;
            roomHandImg.sprite   = handImg.sprite;
            // // // // Main.Logger.Log("滑动条搬运完毕");



            inputField.characterLimit = 100;

            mask       = transform.Find("all/mask").GetComponent <Image>();
            tPeopleNum = transform.Find("people").GetComponent <Text>();

            tTitle.text     = self.player_name + " 大厅";
            tPeopleNum.text = "";
            Button btnPeopleNum = tPeopleNum.GetComponent <Button>();

            btnPeopleNum.onClick.AddListener(delegate { all.SetActive(true); });

            SetSelfData();


            QuquBattleSystem temp = QuquBattleSystem.instance;
            GameObject       obj  = GameObject.Instantiate(QuquBattleSystem.instance.gameObject);
            QuquBattleSystem tmp  = obj.GetComponent <QuquBattleSystem>();

            Object.DestroyImmediate(tmp);
            QuquBattleSystem.instance = temp;
            GuiQuquBattleSystem gui = obj.AddComponent <GuiQuquBattleSystem>();

            gui.Init();
            Transform tf = obj.transform;

            tf.SetParent(temp.transform.parent, false);
            tf.SetSiblingIndex(temp.transform.GetSiblingIndex() + 2);


            hall.SetActive(false);
            room.SetActive(false);
            desk.SetActive(false);
            chat.SetActive(false);
            people.SetActive(false);
            mask.enabled = false;
            //all.SetActive(false);
            SetHallActive(false);

            Text[] texts = transform.GetComponentsInChildren <Text>();
            foreach (var item in texts)
            {
                item.font = DateFile.instance.font;
            }
            InitBetAndQuqu();

            Invoke("SetQuquAndBet", 0.1f);
            Invoke("CloseQuquBattle", 0.4f);
        }