예제 #1
0
        private void addButton(HtStatus htStatus, GameObject gameObject)
        {
            Vector3 position = getGameObjectPosition(gameObject);
            Button  button   = new Button();

            button.name = gameObject.name;
            button.x    = position.x;
            button.y    = position.y;
            htStatus.buttons.Add(gameObject.name, button);
            File.AppendAllText("data.log", "button" + ":" + gameObject.name + ":" + position + System.Environment.NewLine);
        }
예제 #2
0
        private void addButtonByName(HtStatus htStatus, string name)
        {
            GameObject gameObject = GameObject.Find(name);

            if (gameObject == null)
            {
                File.AppendAllText("data.log", "cannot find game object of name:" + "name" + System.Environment.NewLine);
                return;
            }
            addButton(htStatus, gameObject);
        }
예제 #3
0
        public void theout(object source, System.Timers.ElapsedEventArgs e)
        {
            try
            {
                HtStatus   htStatus = new HtStatus();
                GameObject sceneMgr = GameObject.Find("SceneMgr");
                String     mode     = null;
                if (sceneMgr != null)
                {
                    mode          = ((SceneMgr)(sceneMgr.GetComponent <MonoBehaviour>())).GetMode().ToString();
                    htStatus.mode = mode;
                    File.AppendAllText("data.log", "mode" + ":" + mode + System.Environment.NewLine);
                }

                switch (mode)
                {
                case "HUB":
                    addButtonByName(htStatus, "TournamentButton");
                    break;

                case "TOURNAMENT":
                    addButtonByName(htStatus, "DeckName");
                    break;

                default:
                    File.AppendAllText("data.log", "unhandled mode" + ":" + mode + System.Environment.NewLine);
                    break;
                }

                StringWriter sw = new StringWriter();
                jsonSerializer.Serialize(sw, htStatus);
                updateState(sw.ToString());

                File.AppendAllText("data.log", "Timer scan game object ......" + System.Environment.NewLine);
                GameObject[] allObjects = UnityEngine.Object.FindObjectsOfType <GameObject>();
                foreach (GameObject go in allObjects)
                {
                    if (go.activeInHierarchy)
                    {
                        if (go.activeInHierarchy)
                        {
                            Vector3 boxPosition = Camera.main.WorldToScreenPoint(go.transform.position);
                            boxPosition.y = Screen.height - boxPosition.y;
                            File.AppendAllText("data.log", "CARD" + ":" + go.name + ":" + boxPosition + System.Environment.NewLine);
                        }
                    }
                }
            }
            catch (Exception e1)
            {
                File.AppendAllText("data.log", "unhandled mode" + ":" + e1 + System.Environment.NewLine);
            }
        }