Exemplo n.º 1
0
 private ComboBox CreateByTypeObj(AutoTileMapSerializeData map, eSlotAonTypeObj typeObj)
 {
     if (typeObj == eSlotAonTypeObj.House)
     {
         var count = map.OverlayCountAt(typeObj);
         var g     = new GUIContent[count];
         for (int i = 0; i < count; ++i)
         {
             var t = map.GetOverlayByIdxRef(i, typeObj);
             g[i] = new GUIContent(string.Format("({0}) {1}", i, t.Name()));
         }
         var c = new ComboBox(new Rect(0, 0, 150, 20), g);
         return(c);
     }
     else
     {
         var count = map.TriggerCountAt(typeObj);
         var g     = new GUIContent[count];
         for (int i = 0; i < count; ++i)
         {
             var t = map.GetTriggerByIdxRef(i, typeObj);
             g[i] = new GUIContent(string.Format("({0}) {1}", i, t.Name()));
         }
         var c = new ComboBox(new Rect(0, 0, 150, 20), g);
         return(c);
     }
 }
Exemplo n.º 2
0
 public ComboBox TypeObj(AutoTileMapSerializeData map, eSlotAonTypeObj typeObj)
 {
     if (_CacheCType.ContainsKey(typeObj) == false || _CacheCType[typeObj] == null)
     {
         ComboBox c = CreateByTypeObj(map, typeObj);
         _CacheCType[typeObj] = c;
         return(c);
     }
     return(_CacheCType[typeObj]);
 }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        Debug.LogFormat("Start");

        var map      = (AutoTileMap)autoTileMap.GetComponent("AutoTileMap");
        var filePath = "Assets/Map.xml";
        AutoTileMapSerializeData mapData = AutoTileMapSerializeData.LoadFromFile(filePath);

        map.MapData.Data.CopyData(mapData);
        map.LoadMap();

        //var playerPrefab = (GameObject)Resources.Load("/Assets/CreativeSpore/RpgMapEditor/Samples/Prefabs/Player.prefab", typeof(GameObject));
        Instantiate(playerPrefab, new Vector3(25.0f, -25.0f), Quaternion.identity);
    }
Exemplo n.º 4
0
 /*
  * private ComboBox _script = null;
  * public void ResetDataScriptList(){
  *      _script = null;
  * }
  * public ComboBox Scripts(AutoTileMap autoTileMap){
  *      if(_script == null){
  *              List<AutoTileMapSerializeData.Script> ScriptData = autoTileMap.MapSelect.ScriptData;
  *              var comboBoxList = new GUIContent[ScriptData.Count];
  *              for (int i = 0; i < ScriptData.Count; ++i)
  *              {
  *                      var s = ScriptData[i];
  *                      comboBoxList[i] = new GUIContent(string.Format("({0}) {1}", i.ToString(), s.Name()));
  *              }
  *              _script = new ComboBox(new Rect(0, 0, 150, 20), comboBoxList[0], comboBoxList, new GUIContent("Pick Script..."));
  *      }
  *      return _script;
  * }
  */
 public ComboBox Scripts(AutoTileMapSerializeData map)
 {
     return(TypeObj(map, eSlotAonTypeObj.Script));
 }
Exemplo n.º 5
0
 public ComboBox WarpListMap(AutoTileMapSerializeData map)
 {
     return(TypeObj(map, eSlotAonTypeObj.Warps));
 }
Exemplo n.º 6
0
 // private ComboBox _HouseListMap = null;
 // public void ResetDataHouseListMap(){
 // _HouseListMap = null;
 // }
 // private void UpdateDataHouseListMap( AutoTileMap autoTileMap){
 //  var data = autoTileMap.MapSelect.HouseData;
 //  var g = new GUIContent[data.Count];
 //  for (int i = 0; i < data.Count; ++i)
 //  {
 //      g[i] = new GUIContent( string.Format( "House ({0}) {1}", i,  data[i].NameHouse));
 //  }
 //  _HouseListMap = new ComboBox(new Rect(0, 0, 150, 20), g.Length > 0 ? g[0] : null, g);
 // }
 public ComboBox HouseListMap(AutoTileMapSerializeData map)
 {
     return(TypeObj(map, eSlotAonTypeObj.House));
 }
Exemplo n.º 7
0
 /*
  * private ComboBox _NPCList = null;
  * public void ResetDataNPCList(){
  *      _NPCList = null;
  * }
  * private void UpdateDataNPCList( AutoTileMap autoTileMap){
  *      var data = autoTileMap.MapSelect.NPCData;
  *      var g = new GUIContent[data.Count];
  *      for (int i = 0; i < data.Count; ++i)
  *      {
  *              g[i] = new GUIContent( string.Format( "NPC ({0}) {1}", i,  data[i].NameNpc));
  *      }
  *      _NPCList = new ComboBox(new Rect(0, 0, 150, 20), g.Length > 0 ? g[0] : null, g);
  * }
  * public ComboBox NPCList( AutoTileMap autoTileMap){
  *      if(_NPCList == null){
  *              UpdateDataNPCList( autoTileMap);
  *      }
  *      return _NPCList;
  * }
  */
 public ComboBox NPCList(AutoTileMapSerializeData map)
 {
     return(TypeObj(map, eSlotAonTypeObj.Person));
 }
Exemplo n.º 8
0
    public void MapOnGUI(TilesetAON tilesetAON, AutoTileMapSerializeData d, AutoTileMap autoTileMap, AComponent_Button.OnClick closeDialog)
    {
        float W_ScopeList  = 200;
        float yGui         = 0f;
        Rect  rectMenuLeft = new Rect(0, 0, W_ScopeList, Screen.height);

        AONGUI.Box(rectMenuLeft, "", tilesetAON.ListStyleBlack);
        {
            Rect rect = new Rect(0, 0, W_ScopeList, Screen.height);
            yGui = 4f;
            AONGUI.Box(rect, "", tilesetAON.ListStyleBlack);
            AONGUI.Button(new Rect(4, yGui, 45, 26), "Back", closeDialog);
            AONGUI.Label(new Rect(54, yGui, W_ScopeList - 54, 26), "Map edit");
            yGui += 32f;
            OnGUIMenuLeft(tilesetAON, ref yGui, rectMenuLeft);
        }
        Rect rectContent = new Rect(W_ScopeList, 0, Screen.width - W_ScopeList, Screen.height);

        AONGUI.Box(rectContent, "");
        yGui = 0f;

        if (mMenuLeft == EMenuLeft.General)
        {
            OnGuiGeneral(tilesetAON, autoTileMap, rectContent);
        }
        else if (mMenuLeft == EMenuLeft.FlagMap)
        {
            FlagGui.DisOnGUI(d.FlagMap, ref yGui, rectContent, null, tilesetAON.ListStyleBlack2, "Flag map edit :");
        }
        else if (mMenuLeft == EMenuLeft.Action)
        {
            // OnGUITriggerList(tilesetAON, d, eSlotAonTypeObj.Warps, DefineAON.IdSlot_Warps, ref yGui, rectContent);
            if (d.ListFlagAction == null)
            {
                d.ListFlagAction = new List <FlagAction>();
            }
            if (d.ListFlagAction.Count == 0)
            {
                d.ListFlagAction.Add(new FlagAction());
            }
            d.ListFlagAction[0].Name  = "";
            d.ListFlagAction[0].Key   = "";
            d.ListFlagAction[0].Value = 0;
            Rect rect     = new Rect(W_ScopeList, 0, Screen.width - W_ScopeList, Screen.height);
            bool isWaitUI = false;
            if (FlagAction.OnGUIFlagActionList(ref yGui, ref isWaitUI, rectContent, d.ListFlagAction, d.FlagMap, tilesetAON.ListStyleBlack2))
            {
                return;
            }
        }
        else if (mMenuLeft == EMenuLeft.Warp)
        {
            OnGUITriggerList(tilesetAON, d, eSlotAonTypeObj.Warps, DefineAON.IdSlot_Warps, ref yGui, rectContent);
        }
        else if (mMenuLeft == EMenuLeft.NPC)
        {
            OnGUITriggerList(tilesetAON, d, eSlotAonTypeObj.Person, DefineAON.IdSlot_NPC, ref yGui, rectContent);
        }
        else if (mMenuLeft == EMenuLeft.Script)
        {
            OnGUITriggerList(tilesetAON, d, eSlotAonTypeObj.Script, DefineAON.IdSlot_Script, ref yGui, rectContent);
        }
        // float yGui = 0f;
        // bool isUpdateFlag = FlagGui.DisOnGUI( ref d.FlagMap, ref yGui, rect, null, tilesetAON.ListStyleBlack2, "Flag map edit :");
    }
Exemplo n.º 9
0
    private void OnGUITriggerList(TilesetAON tilesetAON, AutoTileMapSerializeData d, eSlotAonTypeObj e, int idSlotTrigger, ref float yGui, Rect rect)
    {
        float W_ScopeList = 200;

        AONGUI.Label(new Rect(rect.x + 4, yGui + DefineAON.GUI_Y_Label, W_ScopeList, DefineAON.GUI_Height_Label), e.ToString() + " list :");
        yGui += 32f;
        d.TriggerCountAt(e);
        var comboBoxTrigger = ComboBoxHelper.Instance.TypeObj(d, e);

        comboBoxTrigger.Rect.x            = rect.x;
        comboBoxTrigger.Rect.y            = yGui;
        comboBoxTrigger.Rect.width        = W_ScopeList;
        comboBoxTrigger.Rect.height       = 32f;
        comboBoxTrigger.SelectedItemIndex = currentIdxTrigger;
        comboBoxTrigger.Show(rect.height - yGui - 32f, "defause", true, false, (int idxTrigger) => {
            currentIdxTrigger = comboBoxTrigger.SelectedItemIndex;
            refTrigger        = null;
        });

        var autoTileMap = AutoTileMap_Editor.Instance;

        if (autoTileMap == null || autoTileMap.MapSelect != d)
        {
            return;
        }
        if (comboBoxTrigger.IsDropDownListVisible)
        {
            //Create new
            AONGUI.Button(new Rect(rect.x, rect.y + rect.height - 32f, W_ScopeList, DefineAON.GUI_Height_Button), "Create new " + e.ToString(), () => {
                autoTileMap.MapSelect.CreateNewTrigger(e);
            });
        }
        Trigger trigger = d.GetTriggerByIdxRef(currentIdxTrigger, e);

        if (trigger == null)
        {
            return;
        }
        yGui   = 4f;
        rect.x = rect.x + W_ScopeList + 10;
        if (string.IsNullOrEmpty(trigger.Name()))
        {
            AONGUI.Label(new Rect(rect.x, yGui, rect.width, 32), "Name: NULL");
        }
        else
        {
            AONGUI.Label(new Rect(rect.x, yGui, rect.width, 32), "Name: " + trigger.Name());
        }
        yGui += 32f;

        if (refTrigger == null)
        {
            refTrigger = new List <AutoTile>();
            var triggerLink   = d.TriggerLink;
            var tileMapWidth  = autoTileMap.MapTileWidth;
            var tileMapHeight = autoTileMap.MapTileHeight;
            int layerTrigger  = (int)eSlotAonTypeLayer.Trigger;
            for (int x = 0; x < tileMapWidth; x++)
            {
                for (int y = 0; y < tileMapHeight; y++)
                {
                    var a = autoTileMap.GetAutoTile(x, y, layerTrigger);
                    if (a == null)
                    {
                        continue;
                    }
                    if (a.Id < 0)
                    {
                        continue;
                    }
                    int idSlot = a.Id;
                    if (idSlot != idSlotTrigger)
                    {
                        continue;
                    }
                    if (currentIdxTrigger != d.GetTriggerRef(x, y))
                    {
                        continue;
                    }
                    refTrigger.Add(a);
                }
            }
        }
        AONGUI.Label(new Rect(rect.x, yGui, rect.width, 32), "Reference on map: " + refTrigger.Count);
        yGui += 32f;
        AONGUI.Label(new Rect(rect.x, yGui, rect.width, 32), "----Edit----");
        yGui += 32f;
        if (e == eSlotAonTypeObj.Script)
        {
            yGui += 16f;
            AONGUI.Button(new Rect(rect.x, yGui, 100, DefineAON.GUI_Height_Label), "Edit", () => {
                tilesetAON.TriggerShowMoreInfo = trigger;
            });
        }
        else
        {
            bool isShowMoreInfo = true;
            trigger.ShowGUI(new Rect(rect.x, yGui, rect.width, rect.y + rect.height - yGui), AutoTileMap_Editor.Instance, tilesetAON, ref isShowMoreInfo, null);
        }
    }