示例#1
0
        private void Start()
        {
            _hasMoved = false;
            MapGenerator.GenerateMap();
            inputListener.ButtonClicked += OnButtonClicked;
            inputListener.StartListening();
            PlayerRef.PlayerDied   += OnPlayerDied;
            PlayerRef.QuestUpdated += OnQuestUpdated;
            PlayerRef.NeedsRefresh += PrintMap;
            movement                       = new Movement();
            movement.PlayerMoved          += ShowMap;
            movement.PlayerAttacked       += ShowMap;
            movement.NeedRefresh          += PrintMap;
            questService                   = new QuestService();
            questService.QuestUpdated     += OnQuestUpdated;
            isPlaying                      = true;
            GameMessage.NewMessageOccured += OnNewMessageOccured;

            PrintMap();
        }
        public static GameObject CreateInputWindow(string newKeyName)
        {
            Canvas canvas = CreateCanvas(null, "Input assign", 20, false);

            InputAssign assign = canvas.gameObject.AddComponent <InputAssign>();
            //assign.keyName = newKeyName;

            InputListener listener = canvas.gameObject.AddComponent <InputListener>();

            listener.StartListening(true, true);
            listener.OnInputRecived.AddListener(assign.Assign);

            //back color
            Image backColor = CreateImageObject(canvas.transform, Color.black, "Color");

            HorizontalLayoutGroup backColorGroup = backColor.gameObject.AddComponent <HorizontalLayoutGroup>();

            backColorGroup.padding = new RectOffset(5, 5, 5, 5);
            backColorGroup.childForceExpandHeight = false;
            backColorGroup.childForceExpandWidth  = false;
            backColorGroup.childAlignment         = TextAnchor.MiddleCenter;

            ContentSizeFitter backColorContentFit = backColor.gameObject.AddComponent <ContentSizeFitter>();

            backColorContentFit.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
            backColorContentFit.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;
            //text
            TextMeshProUGUI text = CreateTextObject(backColor.transform);

            text.text  = "Assign the new key";
            text.color = new Color(1f, 1f, 1f);

            ContentSizeFitter textContentFit = text.gameObject.AddComponent <ContentSizeFitter>();

            textContentFit.horizontalFit = ContentSizeFitter.FitMode.PreferredSize;
            textContentFit.verticalFit   = ContentSizeFitter.FitMode.PreferredSize;

            text.transform.position = new Vector2(0f, 0f);

            return(canvas.gameObject);
        }