Пример #1
0
    void OnEnable()
    {
        string objectPath = EditorPrefs.GetString("UnitDataPath");
        unitPDataList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(UnitDataList)) as UnitDataList;
           
        string atkPath = EditorPrefs.GetString("AttackDatabasePath");
        atkDataList = AssetDatabase.LoadAssetAtPath(atkPath, typeof(AttackDataList)) as AttackDataList;

    }
Пример #2
0
    private void Start()
    {
        UnitDataList unitDataList = JsonUtility.FromJson <UnitDataList>(jsonFile.text);

        foreach (UnitData u in unitDataList.units)
        {
            Debug.Log("Found unit: " + u.name);
        }
    }
Пример #3
0
    void OnEnable()
    {
        //Link to the correct DB on enable. CardDataPath is necessarry for the other links
        string objectPath = EditorPrefs.GetString("CardDataPath");
        cardDataList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(CardDataList)) as CardDataList;

        string atkPath = EditorPrefs.GetString("AttackDatabasePath");
        atkDataList = AssetDatabase.LoadAssetAtPath(atkPath, typeof(AttackDataList)) as AttackDataList;

        string unitPath = EditorPrefs.GetString("UnitDataPath");
        unitDataList = AssetDatabase.LoadAssetAtPath(unitPath, typeof(UnitDataList)) as UnitDataList;

    }
Пример #4
0
    static Startup()
    {
        //Get all the database paths setup for the editor
        string atkPath = "Assets/AttackList.asset";
        string unitPath = "Assets/UnitList.asset";
        string cardPath = "Assets/CardList.asset";

        //Attacks
        EditorPrefs.SetString("AttackDatabasePath", atkPath);
        attackDataList = AssetDatabase.LoadAssetAtPath(atkPath, typeof(AttackDataList)) as AttackDataList;
        if(attackDataList == null)
        {
            Debug.Log("No attack database, creating empty one.");
            AttackDataList asset = ScriptableObject.CreateInstance<AttackDataList>();
            AssetDatabase.CreateAsset(asset, atkPath);
            AssetDatabase.SaveAssets();
        }

        //Creatures
        EditorPrefs.SetString("UnitDataPath", unitPath);
        unitDataList = AssetDatabase.LoadAssetAtPath(unitPath, typeof(UnitDataList)) as UnitDataList;
        if (unitDataList == null)
        {
            Debug.Log("No unit database, creating empty one.");
            UnitDataList asset = ScriptableObject.CreateInstance<UnitDataList>();
            AssetDatabase.CreateAsset(asset, unitPath);
            AssetDatabase.SaveAssets();
        }

        //Cards
        EditorPrefs.SetString("CardDataPath", cardPath);
        cardDataList = AssetDatabase.LoadAssetAtPath(cardPath, typeof(CardDataList)) as CardDataList;
        if(cardDataList == null)
        {
            Debug.Log("No card database, creating empty one.");
            CardDataList asset = ScriptableObject.CreateInstance<CardDataList>();
            AssetDatabase.CreateAsset(asset, cardPath);
            AssetDatabase.SaveAssets();
        }
    }
Пример #5
0
    internal void SpawnUnits(GameObject reference, UnitDataList unitDataList)
    {
        int unitDataIndex = 0;

        UnitData[] unitDataArr = unitDataList.units;
        for (int i = 0; i < gameMap.rows; i++)
        {
            for (int j = 0; j < gameMap.cols; j++)
            {
                bool spawnCondition = side == Side.Player ? j <= gameMap.cols / 2 : j > gameMap.cols / 2;
                Tile tile           = gameMap.GetTileAtPosition(i, j);
                if (tile.GetTileType() != Tile.TileTypes.Stone &&
                    tile.GetTileType() != Tile.TileTypes.Water &&
                    spawnCondition && unitDataIndex < unitDataArr.Length)
                {
                    UnitData unitData = unitDataArr[unitDataIndex++];
                    CreateUnit(i, j, reference, unitData);
                }
            }
        }
        Destroy(reference);
    }
Пример #6
0
Файл: SRC.cs Проект: 7474/SRC
        public SRC(ILoggerFactory loggerFactory)
        {
            Log = loggerFactory.CreateLogger("SRCCore");

            Help              = new Help(this);
            Event             = new Event(this);
            Expression        = new Expression(this);
            Map               = new Map(this);
            Commands          = new Commands.Command(this);
            Sound             = new Sound(this);
            Effect            = new Effect(this);
            COM               = new COM(this);
            InterMission      = new InterMission(this);
            FileHandleManager = new FileHandleManager();

            PDList  = new PilotDataList(this);
            NPDList = new NonPilotDataList(this);
            UDList  = new UnitDataList(this);
            IDList  = new ItemDataList(this);
            MDList  = new MessageDataList(this);
            EDList  = new MessageDataList(this);
            ADList  = new MessageDataList(this);
            EADList = new MessageDataList(this);
            DDList  = new DialogDataList(this);
            SPDList = new SpecialPowerDataList(this);
            ALDList = new AliasDataList(this);
            TDList  = new TerrainDataList(this);
            BCList  = new BattleConfigDataList(this);

            PList = new Pilots.Pilots(this);
            UList = new Units.Units(this);
            IList = new Items.Items(this);

            // XXX 別な実装をするならコンストラクタでは設定しない
            SystemConfig = new LocalFileConfig();
        }
Пример #7
0
 public void Awake()
 {
     unitDataList = JsonUtility.FromJson <UnitDataList>(jsonFile.text);
 }
Пример #8
0
    void OnGUI()
    {
        /***********************************/
        //Header
        /***********************************/

        if (atkDataList == null)
        {
            string objectPath = EditorPrefs.GetString("AttackDatabasePath");
            atkDataList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(AttackDataList)) as AttackDataList;

        }
        if (unitDataList == null)
        {
            string objectPath = EditorPrefs.GetString("UnitDataPath");
            unitPDataList = AssetDatabase.LoadAssetAtPath(objectPath, typeof(UnitDataList)) as UnitDataList;
        }

        if(cardDataBase == null)
        {
            cardDataBase = (CardDatabase)EditorWindow.GetWindow(typeof(CardDatabase));
        }

        GUILayout.Label("Unit Data Editor", EditorStyles.boldLabel);
        if (unitDataList.unitList.Count == 0)
        {
            EditorGUILayout.LabelField("No Unit database available, error.");
        }
        else
        {
            if (buttonToggled == null || buttonToggled.Count < unitDataList.unitList.Count)
            {
                buttonToggled = new List<bool>();
                toggledIndex = 0;
                for (int i = 0; i < unitDataList.unitList.Count; i++)
                    buttonToggled.Add(false);
            }

            if (toggledIndex > unitDataList.unitList.Count)
            {
                Debug.Log("Index was out of bounds");
                toggledIndex = unitDataList.unitList.Count - 1;
            }

            /************************************************************/

            /******************************************/
            //Display things
            /******************************************/
            if (unitDataList != null)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(10);
                EditorGUILayout.LabelField("Unit List Data", EditorStyles.boldLabel);
                filterType = (UnitTypes)EditorGUILayout.EnumPopup(filterType);

                if (GUILayout.Button("Sort", GUILayout.ExpandWidth(false)))
                {
                    sortByName();
                }

                GUILayout.EndHorizontal();
                if (unitDataList.unitList == null)
                {
                    Debug.Log("Mistakes were made - You should never reach this");
                }

                /****************************************/
                //How the list will look
                /***************************************/

                if (unitDataList.unitList.Count > 0)
                {
                    if (unitDataList.unitList[toggledIndex].uType != filterType)
                    {
                        toggledIndex = 0;
                        findNext();
                    }

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.BeginVertical();
                    //----------Show all the buttons-----------
                    showScrollButtons();
                    //-----------------------------------------
                    EditorGUILayout.EndVertical();
                    GUILayout.Space(5);


                    EditorGUILayout.BeginVertical();
                    //---------Current selection info-----------

                    //SHOW UNIT SUMMARY
                    showUnitSummary();

                    /*************************************/
                    //UnitAttack WindowSpawn
                    /************************************/
                    GUILayout.Space(10);
                    EditorGUILayout.LabelField("Unit Attacks");

                    atkScroll = EditorGUILayout.BeginScrollView(atkScroll, GUILayout.Height(120));
                    foreach (string x in unitDataList.unitList[toggledIndex].attacksData.ToList<String>())
                    {
                        AttackData knownAtk = atkDataList.findByID(x);
                        if (knownAtk != null)
                        {
                            EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.TextField(knownAtk.aName, knownAtk.pattern.ToString());
                            EditorGUILayout.TextField("Damage: " + knownAtk.expectedMin + " - " + knownAtk.expectedMax);
                            EditorGUILayout.TextField("Range: " + knownAtk.range.ToString());
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                    EditorGUILayout.EndScrollView();
                    

                    if (GUILayout.Button("Link this unit"))
                    {
                        cardDataBase.assignElement(unitDataList.unitList[toggledIndex].uniqueId);
                        cardDataBase.Repaint();
                    }
                    EditorGUILayout.EndVertical();
                    GUILayout.EndHorizontal();
                }
                else
                {
                    GUILayout.Label("This Unit List is Empty.");
                }

                if (GUI.changed)
                {
                    EditorUtility.SetDirty(unitDataList);
                }
            }
        }
    }