Inheritance: EditorWindow
Beispiel #1
0
    private void doReadMap()
    {
        //Debug.Log("Read Map");
        //ps: var JsonFile = Resources.Load(@"MapConfig/mapConfig") as TextAsset;
        var JsonFile    = Resources.Load(@"MapConfig/" + inputFiledName.text) as TextAsset;
        var JsonObj     = JsonMapper.ToObject(JsonFile.text);
        var JsonItems   = JsonObj["MapBlocks"];
        var JsonEnemies = JsonObj["EnemyBlocks"];

        //读图块
        foreach (JsonData item in JsonItems)
        {
            //Debug.Log("x:" + item["position.x"]);
            //Debug.Log("y:" + item["position.y"]);
            //Debug.Log("type:" + item["type"]);

            var x            = Convert.ToSingle(item["position.x"].ToString());
            var y            = Convert.ToSingle(item["position.y"].ToString());
            var type         = int.Parse(item["type"].ToString());
            var blockEvent   = item["blockEvent"].ToString();
            var doEventTimes = int.Parse(item["doEventTimes"].ToString());

            MapEditor.getInstance().drawBlock(new Vector3(x, y, 0), type, blockEvent, doEventTimes);
        }

        //读敌人
        foreach (JsonData item in JsonEnemies)
        {
            var x    = Convert.ToSingle(item["position.x"].ToString());
            var y    = Convert.ToSingle(item["position.y"].ToString());
            var type = item["type"].ToString();

            EnemyEditor.getInstance().drawEnemy(new Vector3(x, y, 0), type);
        }
    }
Beispiel #2
0
    private void doCreateMap(string path)
    {
        StringBuilder sb     = new StringBuilder();
        JsonWriter    writer = new JsonWriter(sb);

        writer.WriteObjectStart();

        writer.WritePropertyName("MapBlocks");

        writer.WriteArrayStart();

        foreach (var item in MapEditor.getInstance().MapStructList)
        {
            //Debug.Log(MapEditor.getInstance().MapStructList.Count);
            writer.WriteObjectStart();
            writer.WritePropertyName("position.x");
            writer.Write(item.x);
            writer.WritePropertyName("position.y");
            writer.Write(item.y);
            writer.WritePropertyName("type");
            writer.Write(item.type);
            writer.WritePropertyName("blockEvent");
            writer.Write(item.blockEvent);
            writer.WritePropertyName("doEventTimes");
            writer.Write(item.doEventTimes);
            writer.WriteObjectEnd();
        }

        writer.WriteArrayEnd();

        writer.WritePropertyName("EnemyBlocks");

        writer.WriteArrayStart();

        //写入敌人数据
        foreach (var item in GameObject.FindGameObjectWithTag("EnemyPack").GetComponentsInChildren <Rigidbody2D>())
        {
            writer.WriteObjectStart();
            writer.WritePropertyName("position.x");
            writer.Write(item.transform.position.x);
            writer.WritePropertyName("position.y");
            writer.Write(item.transform.position.y);
            writer.WritePropertyName("type");
            writer.Write(item.name);
            writer.WriteObjectEnd();
        }

        writer.WriteArrayEnd();

        writer.WriteObjectEnd();

        StreamWriter sw;

        sw = File.CreateText(path);

        //写入
        sw.WriteLine(sb);
        //关闭
        sw.Close();
    }
Beispiel #3
0
 public ClientConnection(String ip, int port, MapEditor editor)
 {
     tcpclnt     = new TcpClient();
     this.ip     = ip;
     this.port   = port;
     this.editor = editor;
 }
Beispiel #4
0
    // Use this for initialization
    void Start()
    {
        mapEditor         = ((ScreenEditor)Screen.screen).mapEditor.GetComponent <MapEditor>();
        platformsPannel   = transform.FindChild("PanelPlatforms").gameObject;
        backgroundsPannel = transform.FindChild("PanelBackgrounds").gameObject;
        itemsPannel       = transform.FindChild("PanelItems").gameObject;

        platformsGrid   = platformsPannel.GetComponent <GridLayoutGroup>();
        backgroundsGrid = backgroundsPannel.GetComponent <GridLayoutGroup>();
        itemsGrid       = itemsPannel.GetComponent <GridLayoutGroup>();

        platformsGrid.cellSize   = new Vector2(mapEditor.cellSize, mapEditor.cellSize);
        backgroundsGrid.cellSize = new Vector2(mapEditor.cellSize, mapEditor.cellSize);
        itemsGrid.cellSize       = new Vector2(mapEditor.cellSize, mapEditor.cellSize);

        //gui on top of shown tile GUI
        saveButtonObj        = transform.FindChild("ButtonSave").gameObject;
        mapChoiceDropdownObj = transform.FindChild("DropdownMapChoice").gameObject;
        mapNameInputObj      = transform.FindChild("InputMapName").gameObject;

        saveButton        = saveButtonObj.GetComponent <Button>();
        mapChoiceDropdown = mapChoiceDropdownObj.GetComponent <Dropdown>();
        mapNameInput      = mapNameInputObj.GetComponent <InputField>();

        SaveButtonListener();
        InitMapChoiceItems();
        MapChoiceDropdownListener();

        //InitPlatformToolSprites();
        CreatePanelItems(ResourceReader.platformSpriteMap, ref platformsGrid);
        CreatePanelItems(ResourceReader.backgroundSpriteMap, ref backgroundsGrid);
        CreatePanelItems(ResourceReader.itemSpriteMap, ref itemsGrid);
    }
Beispiel #5
0
 public UndoMapRemove(MapEditor Editor, MapProject Project, int MapIndex)
 {
     _MapEditor  = Editor;
     _MapIndex   = MapIndex;
     _MapProject = Project;
     _RemovedMap = _MapProject.Maps[_MapIndex];
 }
Beispiel #6
0
    /// <summary>
    /// Load settings from the settings file
    /// </summary>
    public static void loadSettings()
    {
        setSettingsFilePath();
        MapEditor.setWorldsFilesPath();
        if (File.Exists(settingsFilePath))//Load previous settings
        {
            loadInfoFromFile();
        }
        else//create the settings file with the default value. (To creae the file when first installed, or if deleted
        {
            createSettingsFile();
        }
        //Reading a txt file inside resources folder of the roject un adroid build (Android)

        //TextAsset level = Resources.Load<TextAsset>("Files/SettingsFile");
        //using(StreamReader sr= new StreamReader(new MemoryStream(level.bytes)))
        //{
        //    string line="";
        //    while (!sr.EndOfStream)
        //    {
        //        line = sr.ReadLine();
        //    }
        //    Debug.Log(line);
        //}
    }
 public UpgradePlayerDataBinding(MapEditor _mapEditor, int _player, int _objid, UpgradeDataBinding _binding)
 {
     mapEditor = _mapEditor;
     player    = _player;
     objid     = _objid;
     binding   = _binding;
 }
Beispiel #8
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            Constants.FONT = LoadingUtils.load <SpriteFont>(Content, "SpriteFont1");
            GameStateMachine.getInstance().init(GraphicsDevice, Content);
            SoundManager.getInstance().init(Content);

            this.fadeParams = new FadeEffectParams {
                OriginalColour      = Color.Black,
                State               = FadeEffect.FadeState.Out,
                TotalTransitionTime = TRANSITION_TIME
            };
            this.fadeEffect = new FadeEffect(fadeParams);

            StaticDrawable2DParams transitionParms = new StaticDrawable2DParams {
                Texture     = LoadingUtils.load <Texture2D>(Content, "Chip"),
                Scale       = new Vector2(Constants.RESOLUTION_X, Constants.RESOLUTION_Y),
                LightColour = Color.Black
            };

            this.transitionItem = new StaticDrawable2D(transitionParms);
            this.transitionItem.addEffect(this.fadeEffect);

#if WINDOWS
#if DEBUG
            ScriptManager.getInstance().LogFile = "Log.log";
            ScriptManager.getInstance().registerObject(MapEditor.getInstance(), "editor");
            Debug.debugChip = LoadingUtils.load <Texture2D>(Content, "Chip");
            Debug.debugRing = TextureUtils.create2DRingTexture(GraphicsDevice, (int)Constants.BOUNDING_SPHERE_SIZE, Color.White);
#endif
#endif
        }
 public MapEditorUI(MapEditor editorInstance)
 {
     mapRefreshRequested = true;
     currentColor        = 0;
     currentSection      = EditorUISection.EditMap;
     EditorInstance      = editorInstance;
 }
Beispiel #10
0
    static public void AddMapEditor()
    {
        GameObject go     = new GameObject("MapEditor");
        MapEditor  editor = go.AddComponent <MapEditor>();

        editor.isEnabled = true;
    }
Beispiel #11
0
 public UndoMapTileExchange(MapEditor Editor, MapProject Project, int TileIndex1, int TileIndex2)
 {
     _MapEditor  = Editor;
     _MapProject = Project;
     _TileIndex1 = TileIndex1;
     _TileIndex2 = TileIndex2;
 }
        public MapRenderer(IntPtr mapRenderWindowHandle, IntPtr tileSetRenderHandle, MapEditor.MapEditorProperties mapEditorProperties)
        {
            _mapRenderWindow = new RenderWindow(mapRenderWindowHandle);
            _tileSetRenderWindow = new RenderWindow(tileSetRenderHandle);
            _mapRenderWindow.MouseButtonPressed += mapRenderWindow_MouseButtonPressed;
            _mapRenderWindow.MouseMoved += mapRenderWindow_MouseMoved;
            _tileSetRenderWindow.MouseButtonPressed += tileSetRenderWindow_MouseButtonPressed;
            _tileSetRenderWindow.MouseMoved += tileSetRenderWindow_MouseMoved;
            _tileSetRenderWindow.MouseButtonReleased += tileSetRenderWindow_MouseButtonReleased;

            _mapEditorProperties = mapEditorProperties;
            _mapEditorProperties.CurrentLayer = World.Map.Layers.Ground;
            _mapEditorProperties.MapView = new View(this._mapRenderWindow.DefaultView);

            _mousePositionText = new Text("", new Font(AppDomain.CurrentDomain.BaseDirectory + "/Data/Graphics/Fonts/MainFont.ttf"), 20);

            this.LoadTileSets();

            _tileSetView = this._tileSetRenderWindow.DefaultView;

            this.Running = true;

            this._mapRenderWindow.SetActive(false);
            this._tileSetRenderWindow.SetActive(false);

            new Thread(UpdateLoop).Start();
        }
    public void Execute(FormScript formScript)
    {
        formScript.writeLog();
        formScript.writeLog("Script for export current screen to png image");

        var formMain = formScript.getFormMain();

        formScript.writeLog();

        int currentScreenNo = formMain.screenNo;

        formScript.writeLog(String.Format("Current active screen: {0}", currentScreenNo));

        var activeScreen = formMain.screens[currentScreenNo];
        int w            = activeScreen.width;
        int h            = activeScreen.height;
        var im           = MapEditor.screenToImage(formMain.screens, currentScreenNo, new MapEditor.RenderParams
        {
            bigBlocks = formMain.bigBlocks,
            curScale  = formMain.curScale,
            width     = w,
            height    = h,
        });
        var fname = ConfigScript.ConfigDirectory + String.Format("screen{0}.png", currentScreenNo);

        im.Save(fname);
        formScript.writeLog(String.Format("Screen exported to file: {0}", fname));
    }
 public void Init(MapEditor editor)
 {
     mapEditor = editor;
     titleContent = new GUIContent("Новая карта");
     minSize = new Vector2(250.0f, 180.0f);
     maxSize = minSize;
 }
Beispiel #15
0
 public MapEditorMenu(MapEditor editor)
 {
     Editor   = editor;
     KeepOpen = true;
     AddItem(new LocalizedGossipMenuItem(
                 OnLoadClicked, convo =>
     {
         if (!GOMgr.Loaded || !NPCMgr.Loaded)
         {
             return(!convo.Speaker.HasUpdateAction(
                        action => action is PeriodicLoadMapTimer));
         }
         return(false);
     }, RealmLangKey.EditorMapMenuLoadData));
     AddItem(new LocalizedGossipMenuItem(convo =>
     {
         Editor.Map.SpawnMapLater();
         convo.Character.AddMessage(convo.Invalidate);
     }, convo =>
     {
         if (GOMgr.Loaded && NPCMgr.Loaded && !Editor.Map.IsSpawned)
         {
             return(!Editor.Map.IsSpawning);
         }
         return(false);
     }, RealmLangKey.EditorMapMenuSpawnMap));
     AddItem(new LocalizedGossipMenuItem(convo =>
     {
         Editor.Map.ClearLater();
         convo.Character.AddMessage(convo.Invalidate);
     }, convo => Editor.Map.IsSpawned, RealmLangKey.AreYouSure,
                                         RealmLangKey.EditorMapMenuClearMap));
     AddItem(new LocalizedGossipMenuItem(
                 convo => Editor.IsVisible = true, convo =>
     {
         if (Editor.Map.IsSpawned)
         {
             return(!Editor.IsVisible);
         }
         return(false);
     }, RealmLangKey.EditorMapMenuShow));
     AddItem(new LocalizedGossipMenuItem(
                 convo => Editor.IsVisible = false, convo =>
     {
         if (Editor.Map.IsSpawned)
         {
             return(Editor.IsVisible);
         }
         return(false);
     }, RealmLangKey.EditorMapMenuHide));
     AddItem(new LocalizedGossipMenuItem(
                 convo => Editor.Map.SpawnPointsEnabled = true,
                 convo => !Editor.Map.SpawnPointsEnabled,
                 RealmLangKey.EditorMapMenuEnableAllSpawnPoints));
     AddItem(new LocalizedGossipMenuItem(
                 convo => Editor.Map.SpawnPointsEnabled = false,
                 convo => Editor.Map.SpawnPointsEnabled, RealmLangKey.AreYouSure,
                 RealmLangKey.EditorMapMenuDisableAllSpawnPoints));
     AddQuitMenuItem(convo => Editor.Leave(convo.Character), RealmLangKey.Done);
 }
Beispiel #16
0
    static void Init()
    {
        // Get existing open window or if none, make a new one:
        MapEditor window = (MapEditor)EditorWindow.GetWindow(typeof(MapEditor));

        window.Show();
    }
Beispiel #17
0
        public static void OnGui(LevelMapArray config, MapEditor wind)
        {
            if (!string.IsNullOrEmpty(wind.selectedLevel) && !EditorTool.IsMatch(config.ConfigID, wind.selectedLevel))
            {
                return;
            }
            if (wind.selectedLevel_Type != 0 && wind.selectedLevel_Type != LevelMgr.GetInstance().GetLevelConfig(config.ConfigID).Config.LevelType)
            {
                return;
            }

            GUILayout.BeginHorizontal();

            GUILayout.Label(config.Id.ToString(), GUILayout.Width(200));
            GUILayout.Label(string.Format("{0}", config.ConfigID), GUILayout.Width(250));
            GUILayout.Label(string.Format("{0} X {1}", config.MapWidth, config.MapHeight), GUILayout.Width(200));
            bool isEdit = GUILayout.Button("修改", GUILayout.Width(50));

            if (isEdit)
            {
                wind.curLevelId = config.Id;
                wind.Pagetype   = MapEditor.PageType.Editor;
            }
            bool isDelete = GUILayout.Button("删除", GUILayout.Width(50));

            if (isDelete)
            {
                m_deletegroup.Add(config);
            }
            GUILayout.EndHorizontal();
        }
Beispiel #18
0
    static void Init()
    {
        //Récupère la window existante, et si elle n'existe pas, on en créer une nouvelle
        MapEditor window = (MapEditor)EditorWindow.GetWindow(typeof(MapEditor));

        window.Show();
    }
Beispiel #19
0
 // Use this for initialization
 void Start()
 {
     map       = FindObjectOfType <Map>();
     mapEditor = FindObjectOfType <MapEditor>();
     xy        = map.FindGameObject(map.itemMap, gameObject);
     //Debug.Log(name + " " + xy[0]+" "+xy[1]);
 }
Beispiel #20
0
 public UndoMapTileRemove(MapEditor Editor, MapProject Project, int TileIndex)
 {
     _MapEditor   = Editor;
     _TileIndex   = TileIndex;
     _MapProject  = Project;
     _RemovedTile = _MapProject.Tiles[TileIndex];
 }
        public void Init(MapEditor mapEditor)
        {
            dialogableControlPanels.Clear();
            this.mapEditor = mapEditor;

            mapSetting.SetMapEditor(mapEditor);
            playerSetting.SetMapEditor(mapEditor);
            forceSetting.SetMapEditor(mapEditor);
            unitSetting.SetMapEditor(mapEditor);
            upgradeSetting.SetMapEditor(mapEditor);
            techSetting.SetMapEditor(mapEditor);
            soundSetting.SetMapEditor(mapEditor);
            stringSetting.SetMapEditor(mapEditor);
            classTriggerEditor.SetMapEditor(mapEditor, true);
            brinfingTriggerEditor.SetMapEditor(mapEditor, false);


            TabItemAdd(mapSetting, "맵");
            TabItemAdd(playerSetting, "플레이어");
            TabItemAdd(forceSetting, "세력");
            TabItemAdd(unitSetting, "유닛");
            TabItemAdd(upgradeSetting, "업그레이드");
            TabItemAdd(techSetting, "테크");
            TabItemAdd(soundSetting, "사운드");
            TabItemAdd(stringSetting, "스트링");
            TabItemAdd(classTriggerEditor, "트리거");
            TabItemAdd(brinfingTriggerEditor, "브리핑");
        }
Beispiel #22
0
    public void Trigger()
    {
        MapEditor mapEditor = FindObjectOfType <MapEditor>();

        transform.position = mapEditor.basicMap[0, 0].transform.position +
                             new Vector3(mapEditor.mapSize.x * mapEditor.tileSize.x / 2f, mapEditor.mapSize.y * mapEditor.tileSize.y / 2 + 0.25f * mapEditor.tileSize.y, 0) + Vector3.back * 10;
    }
Beispiel #23
0
		///// <summary>
		///// Whether to also spawn a DO to make this Figurine appear clearer
		///// </summary>
		//[NotVariable]
		//public static bool AddDecoMarker = true;

		public SpawnPointFigurine(MapEditor editor, NPCSpawnPoint spawnPoint)
			: base(editor, spawnPoint)
		{
			m_position = spawnPoint.Position;

			NPCFlags = NPCFlags.Gossip;
		}
Beispiel #24
0
        public void UpdateMap(MapUpdate mapUpdate, MapEditor editor)
        {
            lock (mapUpdateLock) // não permitir salvar ao atualizar o mapa.
            {
                BatchAction batchAction = mapUpdate.batchAction;

                if (mapUpdate.updateType == UpdateType.UPDATE_TYPE_UNDO)
                {
                    foreach (Action action in batchAction.actions.Reverse <Action>())
                    {
                        action.SetMap(this);
                        action.SetEditor(editor);
                        action.undo();
                    }
                }
                else
                {
                    foreach (Action action in batchAction.actions)
                    {
                        action.SetMap(this);
                        action.SetEditor(editor);
                        switch (mapUpdate.updateType)
                        {
                        case UpdateType.UPDATE_TYPE_COMMIT:
                            action.commit();
                            break;

                        case UpdateType.UPDATE_TYPE_REDO:
                            action.redo();
                            break;
                        }
                    }
                }
            }
        }
        public bool Execute(MapEditor _mapEditor)
        {
            // old name == new name?
//             if (oldName == newName) {
//                 return false;
//             }
//             // judge if the name duplicate
//             MaterialTemplateList list = Mgr<CatProject>.Singleton.materialList1;
//             Material oldMaterial = list.GetMaterial(oldName);
//             // old material dose not exit
//             if (oldMaterial == null){
//                 MessageBox.Show("Error, no material has a name: " + oldName);
//                 return false;
//             }
//             // new name is occupied
//             if (list.ContainKey(newName)) {
//                 if (list.GetMaterial(newName) != oldMaterial) {
//                     MessageBox.Show("Error, existing material named: " + newName);
//                 }
//                 // else, dose not change the name at all
//                 return false;
//             }
//             // rename
//             list.RemoveItem(oldName);
//             oldMaterial._name = newName;
//             list.AddMaterial(oldMaterial);
            return(true);
        }
Beispiel #26
0
    // Use this for initialization
    void Awake()
    {
        Instance = this;
        //If in editor and map editor enable, disable all game parts
        if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.WindowsEditor)
        {
            if (isEnabled)
            {
                //Hide Gameplay object
                GameObject obj = GameObject.Find("GamePlay");
                obj.SetActive(false);
                hiddenObjects.Add(obj);

                //Hide MapManager object
                obj = GameObject.Find("MapManager");
                obj.SetActive(false);
                hiddenObjects.Add(obj);

                //Hide SoundEffect object
                obj = GameObject.Find("SoundEffect");
                obj.SetActive(false);
                hiddenObjects.Add(obj);

                //Set all map to 1 (mean all square not empty)
                for (int i = 0; i < map.Length; i++)
                {
                    map[i] = 1;
                }
                //Gen squares to edit
                GenSquares();
            }
        }
    }
Beispiel #27
0
    static void Open()
    {
        MapEditor win = GetWindow <MapEditor>();

        win.titleContent = new GUIContent("Map Editor");
        win.Show();
    }
Beispiel #28
0
        ///// <summary>
        ///// Whether to also spawn a DO to make this Figurine appear clearer
        ///// </summary>
        //[NotVariable]
        //public static bool AddDecoMarker = true;

        public SpawnPointFigurine(MapEditor editor, NPCSpawnPoint spawnPoint)
            : base(editor, spawnPoint)
        {
            m_position = spawnPoint.Position;

            NPCFlags = NPCFlags.Gossip;
        }
Beispiel #29
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="game">The reference to the game object</param>
        /// <param name="name">The name identifier of the map (used to load data from file)</param>
        public Map(Game game, string name) : base(game)
        {
            Name = name;

            Camera = new Camera(
                this,
                new Vector2(Game.InternalSize.Width / 2, Game.InternalSize.Height / 2),
                new Viewport(0, 0, (int)Game.InternalSize.Width, (int)Game.InternalSize.Height)
                );

            // Components
            sections        = new Dictionary <int, MapSection>();
            transitionGuide = new TransitionGuide();
            mapEditor       = new MapEditor(this);
            sectionEditor   = new MapSectionEditor(this);
            colliders       = new Dictionary <string, Collider>();

            // Load map descriptor
            LoadFromFile("Content/Descriptors/Maps/" + name + ".map");

            // Initialization of the toolbar only after loading a map
            sectionEditor.InitializeToolbar();

            // Play the specified music if any
            if (MusicName is string musicName)
            {
                Game.AudioManager?.PlayMusic(musicName);
            }
        }
Beispiel #30
0
 protected SpawnEditorMenu(MapEditor editor, NPCSpawnPoint spawnPoint, EditorFigurine figurine)
 {
     Editor     = editor;
     SpawnPoint = spawnPoint;
     Figurine   = figurine;
     KeepOpen   = true;
 }
        public void SetMapEditor(MapEditor mapEditor, bool IsTrigger)
        {
            this.mapEditor = mapEditor;

            this.IsTrigger = IsTrigger;
            ValueSelecterControl.SetMapEditor(mapEditor);


            if (IsTrigger)
            {
                TrigEditPlusBtn.Visibility = Visibility.Visible;
                triggerlist = mapEditor.mapdata.Triggers;
                TrigConditionBtn.Visibility = Visibility.Visible;
            }
            else
            {
                TrigEditPlusBtn.Visibility = Visibility.Collapsed;
                triggerlist = mapEditor.mapdata.Brifings;
                TrigConditionBtn.Visibility = Visibility.Collapsed;
            }

            MainListBox.ItemsSource = triggerlist;


            TrigEditWindowOpen    = false;
            EditWindow.Visibility = Visibility.Hidden;

            SearchType.SelectedIndex = 0;
            ToolBoxRefresh();
        }
 public UndoMapSwap(MapEditor Editor, MapProject Project, int MapIndex1, int MapIndex2)
 {
     _MapEditor  = Editor;
     _MapProject = Project;
     _MapIndex1  = MapIndex1;
     _MapIndex2  = MapIndex2;
 }
Beispiel #33
0
		protected SpawnEditorMenu(MapEditor editor, NPCSpawnPoint spawnPoint, EditorFigurine figurine)
		{
			Editor = editor;
			SpawnPoint = spawnPoint;
			Figurine = figurine;
			KeepOpen = true;
		}
Beispiel #34
0
        private void button2_Click(object sender, EventArgs e)
        {
            Close();

            using (MapEditor editor = new MapEditor())
                editor.Run();
        }
Beispiel #35
0
		public WaypointFigurine(MapEditor editor, NPCSpawnPoint spawnPoint, WaypointEntry wp)
			: base(editor, spawnPoint)
		{	
			m_Waypoint = wp;

			//GossipMenu = m_SpawnPoint.GossipMenu;
			NPCFlags = NPCFlags.Gossip;
		}
Beispiel #36
0
	public override void Begin(ContextBase context)
	{
		m_entryAction = context.ActionOnEnter;
		m_levelToLoad = context.Level;

		Game.Instance.LoadLevel("Editor");
		m_editor = Game.Instance.UICore.Create<MapEditor>(Resources.Load("Prefabs/UI/EditorMenu") as GameObject);
	}
        public SpawnPointEditorMenu(MapEditor editor, NPCSpawnPoint spawnPoint, EditorFigurine figurine)
            : base(editor, spawnPoint, figurine)
        {
            AddItem(new LocalizedGossipMenuItem(convo => MoveTo(convo.Character),
                //convo => ,
                                                RealmLangKey.EditorSpawnPointMenuMoveOverHere));

            AddQuitMenuItem();
        }
Beispiel #38
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            mSpriteBatch = new SpriteBatch(GraphicsDevice);

            GraphicsManager.Initialize(GraphicsDevice, mSpriteBatch);
            Console.WriteLine(Content.RootDirectory);
            AssetLibrary.LoadContent(Content);
            CollisionMeshManager.LoadContent(Content);
            mWorldEditor = new MapEditor(GraphicsDevice, mCamera, Content, this, Parent as EditorForm);

            ResizedWindow(null, null);
            this.Resize += ResizedWindow;
        }
Beispiel #39
0
		public MapEditorMenu(MapEditor editor)
		{
			Editor = editor;
			KeepOpen = true;

			AddItem(new LocalizedGossipMenuItem(OnLoadClicked,
				convo => (!GOMgr.Loaded || !NPCMgr.Loaded) &&		// timer not running yet
					!convo.Speaker.HasUpdateAction(action => action is PeriodicLoadMapTimer),
				RealmLangKey.EditorMapMenuLoadData));

			AddItem(new LocalizedGossipMenuItem(convo =>
				{
					Editor.Map.SpawnMapLater();
					convo.Character.AddMessage(convo.Invalidate);		// show menu again, when done spawning
				},
				convo => GOMgr.Loaded && NPCMgr.Loaded && !Editor.Map.IsSpawned && !Editor.Map.IsSpawning,
				RealmLangKey.EditorMapMenuSpawnMap));

			AddItem(new LocalizedGossipMenuItem(convo =>
				{
					Editor.Map.ClearLater();
					convo.Character.AddMessage(convo.Invalidate);		// show menu again, when done clearing
				},
				convo => Editor.Map.IsSpawned,
				RealmLangKey.AreYouSure,
				RealmLangKey.EditorMapMenuClearMap));

			AddItem(new LocalizedGossipMenuItem(convo => Editor.IsVisible = true,
				convo => Editor.Map.IsSpawned && !Editor.IsVisible,
				RealmLangKey.EditorMapMenuShow));

			AddItem(new LocalizedGossipMenuItem(convo => Editor.IsVisible = false,
				convo => Editor.Map.IsSpawned && Editor.IsVisible,
				RealmLangKey.EditorMapMenuHide));

			AddItem(new LocalizedGossipMenuItem(convo => Editor.Map.SpawnPointsEnabled = true,
				convo => !Editor.Map.SpawnPointsEnabled,
				RealmLangKey.EditorMapMenuEnableAllSpawnPoints));

			AddItem(new LocalizedGossipMenuItem(convo => Editor.Map.SpawnPointsEnabled = false,
				convo => Editor.Map.SpawnPointsEnabled,
				RealmLangKey.AreYouSure,
				RealmLangKey.EditorMapMenuDisableAllSpawnPoints));


			// leave the editor
			AddQuitMenuItem(convo => Editor.Leave(convo.Character));
		}
Beispiel #40
0
		protected EditorFigurine(MapEditor editor, NPCSpawnPoint spawnPoint)
		{
			if (_sharedAuras == null)
			{
				_sharedAuras = new AuraCollection(this);
			}

			m_auras = _sharedAuras;
			Editor = editor;
			m_SpawnPoint = spawnPoint;

			var entry = m_SpawnPoint.SpawnEntry.Entry;
			GenerateId(entry.Id);

			UnitFlags = UnitFlags.SelectableNotAttackable | UnitFlags.Possessed;
			DynamicFlags = UnitDynamicFlags.TrackUnit;
			EmoteState = EmoteType.StateDead;
			NPCFlags |= NPCFlags.Gossip;
			Model = entry.GetRandomModel();
			EntryId = entry.Id;

			// speed must be > 0
			// because of the way the client works
			const float speed = 1f;
			m_runSpeed = speed;
			m_swimSpeed = speed;
			m_swimBackSpeed = speed;
			m_walkSpeed = speed;
			m_walkBackSpeed = speed;
			m_flightSpeed = speed;
			m_flightBackSpeed = speed;

			SetInt32(UnitFields.MAXHEALTH, int.MaxValue);
			SetInt32(UnitFields.BASE_HEALTH, int.MaxValue);
			SetInt32(UnitFields.HEALTH, int.MaxValue);

			// just make a smaller version of the creature to be spawned
			SetFloat(ObjectFields.SCALE_X, entry.Scale * DefaultScale);

			m_evades = true;
		}
Beispiel #41
0
 protected EditorFigurine(MapEditor editor, NPCSpawnPoint spawnPoint) :
     base(spawnPoint.SpawnEntry.Entry.NPCId)
 {
     Editor = editor;
     m_SpawnPoint = spawnPoint;
 }
Beispiel #42
0
	void OnEnable()
	{
		Instance = this;
		for(int i = 0; i < transform.childCount; ++i)
			transform.GetChild(i).gameObject.SetActive(true);
	}
Beispiel #43
0
	void OnDisable()
	{
		Instance = null;
		for(int i = 0; i < transform.childCount; ++i)
			transform.GetChild(i).gameObject.SetActive(false);
	}
Beispiel #44
0
 private void toolStripButton_mapEdit_Click(object sender, EventArgs e)
 {
     MapEditor form = new MapEditor();
     form.Show();
 }
Beispiel #45
0
		//private readonly NPCSpawnPoint m_point;

		//public WaypointEditorMenu(NPCSpawnPoint point)
		//    : base(point.SpawnEntry.Entry.NameGossipId)
		//{
		//    m_point = point;

		//    KeepOpen = true;

		//    AddItem(new GossipMenuItem("Go to Spawn", HandleTeleport));
		//    AddItem(new GossipMenuItem("Remove Spawn", HandleRemove,
		//        "This will remove the Spawn with all its Waypoints (" + m_point.SpawnEntry.Entry + ")"));

		//    AddItem(new GossipMenuItem("Waypoint List", WPMenu = CreateWaypointMenu()));
		//    AddItem(new GossipMenuItem("Add new Wapyoint", HandleAddWP));

		//    AddQuitMenuItem();
		//}

		///// <summary>
		///// The Waypoint-submenu
		///// </summary>
		//public GossipMenu WPMenu
		//{
		//    get;
		//    internal set;
		//}

		///// <summary>
		///// Returns the GossipMenuItem of the given Waypoint from this menu
		///// </summary>
		///// <param name="wp"></param>
		//public void RemoveWPItem(WaypointEntry wp)
		//{
		//    foreach (var item in WPMenu.GossipItems)
		//    {
		//        if (item is WPItem && ((WPItem)item).Wp == wp)
		//        {
		//            WPMenu.GossipItems.Remove(item);
		//            return;
		//        }
		//    }
		//}

		///// <summary>
		///// Creates and returns the sub-menu for Waypoints
		///// </summary>
		///// <returns></returns>
		//private GossipMenu CreateWaypointMenu()
		//{
		//    var menu = new GossipMenu(m_point.SpawnEntry.Entry.NameGossipId);

		//    menu.AddGoBackItem("Go back...");
		//    foreach (var wp in m_point.SpawnEntry.Waypoints)
		//    {
		//        menu.AddItem(new WPItem(m_point, wp));
		//    }
		//    menu.AddQuitMenuItem();
		//    return menu;
		//}

		///// <summary>
		///// Handle what happens when clicking on the Teleport option
		///// </summary>
		//void HandleTeleport(GossipConversation convo)
		//{
		//    convo.Character.TeleportTo(m_point);
		//}

		///// <summary>
		///// Handle what happens when clicking on the Remove option
		///// </summary>
		//private void HandleRemove(GossipConversation convo)
		//{
		//    m_point.RemoveSpawnLater();
		//}

		///// <summary>
		///// Handle what happens when clicking on the Add WP button
		///// </summary>
		//private void HandleAddWP(GossipConversation convo)
		//{
		//    var chr = convo.Character;
		//    m_point.InsertAfter(null, chr.Position, chr.Orientation);
		//}

		//public NPCSpawnPoint Point
		//{
		//    get { return m_point; }
		//}

		///// <summary>
		///// A GossipMenuItem for each Waypoint
		///// </summary>
		//public class WPItem : GossipMenuItem
		//{
		//    private readonly NPCSpawnPoint m_Point;
		//    private WaypointEntry m_wp;

		//    public WPItem(NPCSpawnPoint point, WaypointEntry wp)
		//    {
		//        m_Point = point;
		//        m_wp = wp;
		//        Text = "WP #" + wp.Id;

		//        SubMenu = new GossipMenu(point.SpawnEntry.Entry.NameGossipId);
		//        SubMenu.AddGoBackItem();
		//        SubMenu.AddRange(
		//            new GossipMenuItem("Go to Point" + Text, HandleGoto),
		//            new GossipMenuItem("Remove", HandleRemove),
		//            new GossipMenuItem("Move Point here", HandleMoveOver),
		//            new GossipMenuItem("Insert New", HandleInsert));
		//    }

		//    public WaypointEntry Wp
		//    {
		//        get { return m_wp; }
		//    }

		//    public NPCSpawnPoint Point
		//    {
		//        get { return m_Point; }
		//    }

		//    /// <summary>
		//    /// Go to the WP
		//    /// </summary>
		//    void HandleGoto(GossipConversation convo)
		//    {
		//        convo.Character.TeleportTo(m_Point.Map, m_wp.Position);
		//    }

		//    /// <summary>
		//    /// Remove the WP
		//    /// </summary>
		//    void HandleRemove(GossipConversation convo)
		//    {
		//        m_Point.RemoveWP(m_wp);

		//        // the WP is now gone, so let's send the Menu again (without this Item in it)
		//        convo.Invalidate();
		//    }

		//    /// <summary>
		//    /// Move the Waypoint over to the Character
		//    /// </summary>
		//    void HandleMoveOver(GossipConversation convo)
		//    {
		//        m_Point.MoveWP(m_wp, convo.Character.Position);
		//    }

		//    /// <summary>
		//    /// Insert a new WP
		//    /// </summary>
		//    void HandleInsert(GossipConversation convo)
		//    {
		//        m_Point.InsertAfter(m_wp, convo.Character.Position, convo.Character.Orientation);
		//    }
		//}
		public WaypointEditorMenu(MapEditor editor, NPCSpawnPoint spawnPoint, EditorFigurine figurine) : base(editor, spawnPoint, figurine)
		{
		}
Beispiel #46
0
    public void Save(MapEditor.Map map, int speed, int mapWidth, int mapHeight, string levelName)
    {
        #if UNITY_EDITOR
        string filePath = UnityEditor.EditorUtility.SaveFilePanel("Save level", "/Assets/Levels/", levelName, "lel");

        if (filePath == null || filePath == "" || filePath.Length == 0)
        {
            return;
        }

        StreamWriter writer = File.CreateText(filePath);
        writer.WriteLine(speed.ToString());
        writer.WriteLine(mapWidth.ToString());
        writer.WriteLine(mapHeight.ToString());

        for (int y = 0; y < mapHeight; ++y)
        {
            for (int x = 0; x < mapWidth; ++x)
            {
                writer.WriteLine(map.Rows[y].Tiles[x].Index);
            }
        }
        writer.Close();
        #endif
    }
Beispiel #47
0
 // Destrucción
 void OnDestroy()
 {
     SceneView.onSceneGUIDelegate -= onSceneGUIFunc;
     window = null;
 }
Beispiel #48
0
 static void Init()
 {
     if (window == null)
     {
         window = EditorWindow.GetWindow<MapEditor >(false, "MapEditor", true);
         window.onSceneGUIFunc = new SceneView.OnSceneFunc(OnSceneGUI);
         SceneView.onSceneGUIDelegate += window.onSceneGUIFunc;
     }
 }
Beispiel #49
0
 void Awake()
 {
     singleton = this;
 }
Beispiel #50
0
    void OnEnable()
    {
        mapEditor = (MapEditor)target;

        if(listMap == null && mapEditor.maps != null)
            listMap = mapEditor.maps.roadMapEasy;

        if(previewBlock == null)
            previewBlock = GameObject.FindWithTag("EditorPreviewBlock");
    }