コード例 #1
0
            private void Update()
            {
                if (Input.GetMouseButtonUp((int)MouseButton.Left))
                {
                    Instance.EndSelect(DecorationMaster.GetMousePos());
                }
                else if (Input.GetMouseButtonUp((int)MouseButton.Right))
                {
                    MyCursor.cursorTexture = GUIController.Instance.images["arrow"];
                    Destroy(gameObject);
                }

                if (Input.GetMouseButtonDown((int)MouseButton.Left))
                {
                    Instance.StartSelect(DecorationMaster.GetMousePos());
                }

                if (Instance.start.x < 0)
                {
                    return;
                }
                var mouse = DecorationMaster.GetMousePos();

                line.SetPositions(new Vector3[] {
                    Instance.start,
                    new Vector2(mouse.x, Instance.start.y),
                    mouse,
                    new Vector2(Instance.start.x, mouse.y),
                    Instance.start,
                });
                //Logger.LogDebug(GetScreenPos(mouse));
            }
コード例 #2
0
 private void Update()
 {
     transform.position = DecorationMaster.GetMousePos();
     if (Input.GetMouseButtonUp((int)MouseButton.Right))
     {
         Destroy(gameObject);
     }
     else if (Input.GetMouseButtonUp((int)MouseButton.Left))
     {
         SetupAll();
     }
 }
コード例 #3
0
        public void EndSelect(Vector2 Pos)
        {
            UnityEngine.Object.Destroy(tmp);
            start = GetScreenPos(start);
            end   = GetScreenPos(Pos);
            if (end.x <= start.x || end.y >= start.y)
            {
                return;
            }
            //Camera.main.WorldToScreenPoint

            var gos = UnityEngine.Object.FindObjectsOfType <CustomDecoration>().Select(x => x.gameObject);

            InRangeObjs.Clear();
            foreach (var go in gos)
            {
                if (is_in_range(GetScreenPos(go)))
                {
                    InRangeObjs.Add(go);
                    //go.GetComponent<CustomDecoration>().enabled = false;
                    //Logger.Log(go.name);
                }
            }

            //var x = (int)(end.x + start.x) / 2;
            //var y = (int)(start.y + end.y) / 2;
            //SetCursorPos(x, 1080 - y);
            tmp = new GameObject();
            tmp.transform.position = DecorationMaster.GetMousePos();
            tmp.AddComponent <SpriteRenderer>().sprite = Sprite.Create(new Texture2D(20, 20), new Rect(0, 0, 20, 20), Vector2.one * 0.5f);

            foreach (var go in InRangeObjs)
            {
                var clone = go.GetComponent <CustomDecoration>().CopySelf();
                clone.SetActive(true);
                //Logger.LogDebug($"1-{go.transform.position},{clone.transform.position}");
                //clone.GetComponent<CustomDecoration>().enabled = false;
                //Logger.LogDebug($"2-{go.transform.position},{clone.transform.position}");
                clone.transform.SetParent(tmp.transform);
            }
            tmp.AddComponent <BlockMover>();
            //Logger.LogDebug($"Start:{start}.End:{end},Mid:{x},{y}");

            MyCursor.cursorTexture = GUIController.Instance.images["arrow"];
        }
コード例 #4
0
        public override void Initialize(Dictionary <string, Dictionary <string, GameObject> > preloadedObjects)
        {
            instance = this;

            //new Test();
            //return;

            #region VerifyVersion
            Logger.Log("Load Global Json");
            ItemSettings global = SerializeHelper.LoadGlobalSettings <ItemSettings>();
            if (global != null)
            {
                if (global.mod_version > Version)
                {
                    new ErrorPanel($"Require Version:{global.mod_version},BUT you Version:{Version}\n(你的MOD版本该更新了)");
                    throw new FileLoadException("Try To Load an newer json data in an older mod,please update mod");
                }

                ItemData = global;
                Logger.Log("Loaded Json");
            }
            #endregion

            #region Init GameObject
            ObjectLoader.Load(preloadedObjects);
            BehaviourProcessor.RegisterBehaviour <Particle>();
            BehaviourProcessor.RegisterBehaviour <Draw>();
            BehaviourProcessor.RegisterBehaviour <OtherBehaviour>();
            BehaviourProcessor.RegisterBehaviour <AreaBehaviour>();
            BehaviourProcessor.RegisterBehaviour <MovablePlatform>();
            BehaviourProcessor.RegisterBehaviour <ModifyGameItem>();
            BehaviourProcessor.RegisterBehaviour <Mana>();
            BehaviourProcessor.RegisterBehaviour <AudioBehaviours>();
            BehaviourProcessor.RegisterBehaviour <OneShotBehaviour>();
            BehaviourProcessor.RegisterBehaviour <Scope>();
            BehaviourProcessor.RegisterBehaviour <Bench>();
            BehaviourProcessor.RegisterSharedBehaviour <DefaultBehaviour>();
            BehaviourProcessor.RegisterSharedBehaviour <UnVisableBehaviour>();
            BehaviourProcessor.RegisterSharedBehaviour <DelayResizableBehaviour>();
            #endregion

            #region InitGUI
            UIObj = new GameObject();
            UIObj.AddComponent <GUIController>();
            UnityEngine.Object.DontDestroyOnLoad(UIObj);
            GUIController.Instance.BuildMenus();
            #endregion

            #region SetupCallBack
            SelectGetter  = GetKeyPress;
            SelectGetter += PickPanel.SelectFocus;
            UnityEngine.SceneManagement.SceneManager.sceneLoaded += SpawnFromSettings;
            UnityEngine.SceneManagement.SceneManager.sceneLoaded += ShowRespawn;
            UnityEngine.SceneManagement.SceneManager.sceneLoaded += AutoSaveModification;
            On.GameManager.PositionHeroAtSceneEntrance           += HeroOutBoundSave;
            ModHooks.Instance.LanguageGetHook     += DLanguage.MyLanguage;
            ModHooks.Instance.ApplicationQuitHook += SaveJson;
            if (Settings.CreateMode)
            {
                ModHooks.Instance.HeroUpdateHook += OperateItem;
            }
            #endregion

            UserLicense.ShowLicense();
        }