Beispiel #1
0
    public int targetID = -1;               // カメラの中心となる個体

    //-----------------------------------------------------
    //【関数定義】初期化(オブジェクト起動時に実行される)(担当:小林)
    //-----------------------------------------------------
    void Start()
    {
        if (importPath.Length > 0)
        {
            // 遺伝データを読み込む
            System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(GenParam));
            System.IO.FileStream fs = new System.IO.FileStream(importPath, System.IO.FileMode.Open);
            GenParam             p  = (GenParam)xs.Deserialize(fs);

            this.param    = p;
            this.genCount = p.genCount;
        }
        else
        {
            param.creatureCount = this.creatureCount;
            param.surviveCount  = this.surviveCount;
            param.mutationCount = this.mutationCount;

            initParam();
        }

        // 新しく個体をcreaturecount個生成
        currentCreatures = new Creature[param.creatureCount];

        prepareCreatures();
        genDurationLeft = genDuration;

        // カメラの初期位置(右が進行方向)
          Camera.main.transform.position = new Vector3(100, 10, 0);

        Camera.main.transform.LookAt(new Vector3(-100, 10, 0));
    }
Beispiel #2
0
        /// <summary>
        /// do compile settings
        /// </summary>
        /// <param name="force">Whether or not,check diff.  false will be faster!</param>
        /// <param name="genCode">Generate static code?</param>
        public static void DoCompileSettings(bool force = true, string forceTemplate = null, bool canCustom = true)
        {
            if (canCustom && CustomCompileSettings != null)
            {
                CustomCompileSettings();
                return;
            }

            List <TableCompileResult> results = null;

            if (AppConfig.IsUseLuaConfig)
            {
                Log.Info("Start Compile to lua");
                var genParam = new GenParam()
                {
                    settingCodeIgnorePattern = AppConfig.SettingCodeIgnorePattern,
                    genCSharpClass           = false, genCodeFilePath = null, forceAll = true, ExportLuaPath = AppConfig.ExportLuaPath
                };
                var compilerParam = new CompilerParam()
                {
                    CanExportTsv = false, ExportTsvPath = AppConfig.ExportTsvPath, ExportLuaPath = AppConfig.ExportLuaPath
                };
                results = new BatchCompiler().CompileAll(AppConfig.SettingResourcesPath, AppConfig.ExportLuaPath, genParam, compilerParam);
            }
            else
            {
                if (string.IsNullOrEmpty(AppConfig.ExportTsvPath))
                {
                    Log.Error("Need to KEngineConfig: ExportTsvPath");
                    return;
                }
                Log.Info("Start Compile to c#+tsv");

                var template = force ? (forceTemplate ?? DefaultTemplate.GenCodeTemplateOneFile) : null;
                var genParam = new GenParam()
                {
                    forceAll = force, genCSharpClass = true, genCodeFilePath = AppConfig.ExportCSharpPath,
                    genCodeTemplateString    = template, changeExtension = AppConfig.SettingExt,
                    settingCodeIgnorePattern = AppConfig.SettingCodeIgnorePattern, nameSpace = "AppSettings"
                };
                var compilerParam = new CompilerParam()
                {
                    CanExportTsv = true, ExportTsvPath = AppConfig.ExportTsvPath, ExportLuaPath = null
                };
                results = new BatchCompiler().CompileAll(AppConfig.SettingSourcePath, AppConfig.ExportTsvPath, genParam, compilerParam);
            }

            var sb = new StringBuilder();

            foreach (var r in results)
            {
                sb.AppendLine(string.Format("Excel {0} -> {1}", r.ExcelFile, r.TabFileRelativePath));
            }
            Log.Info("TableML all Compile ok!\n{0}", sb.ToString());
            // make unity compile
            AssetDatabase.Refresh();
        }
Beispiel #3
0
        public Map(string name, int id, int variant, MapType type, MapFlags flags)
        {
            Name = name;
            MapID = id;
            VariantID = variant;
            Type = type;
            Flags = flags;
            Clients = new List<Client>();
            GenerationArgs = new GenParam();

            Objects = ObjectManager.Instance.GetObjectsForZone(Name);
            NPCs = ObjectManager.Instance.getNPCSForZone(Name);
        }
Beispiel #4
0
        public Map(string name, int id, int variant, MapType type, MapFlags flags)
        {
            Name           = name;
            MapID          = id;
            VariantID      = variant;
            Type           = type;
            Flags          = flags;
            Clients        = new List <Client>();
            GenerationArgs = new GenParam();

            Objects = ObjectManager.Instance.GetObjectsForZone(Name);
            NPCs    = ObjectManager.Instance.getNPCSForZone(Name);
        }
Beispiel #5
0
    protected void ImportParams(GenManager manager)
    {
        string path = EditorUtility.OpenFilePanel(
            "Save block parameters",
            "Export",
            "xml");

        if (path.Length != 0)
        {
            System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(GenParam));
            System.IO.FileStream fs    = new System.IO.FileStream(path, System.IO.FileMode.Open);
            GenParam             param = (GenParam)xs.Deserialize(fs);

            manager.param      = param;
            manager.genCount   = param.genCount;
            manager.importPath = path;
        }
    }
Beispiel #6
0
    protected void ExportParams(GenParam param)
    {
        string dateStr        = System.DateTime.Now.ToString("yyyyMMddhhmm");
        string defaultXmlFile = string.Format("Gen_{0}_{1}.xml",
                                              param.genCount, dateStr);

        string path = EditorUtility.SaveFilePanel(
            "Save block parameters",
            "Export",
            defaultXmlFile,
            "xml");

        if (path.Length != 0)
        {
            System.Xml.Serialization.XmlSerializer xs = new System.Xml.Serialization.XmlSerializer(typeof(GenParam));
            System.IO.FileStream fs = new System.IO.FileStream(path, System.IO.FileMode.Create);
            xs.Serialize(fs, param);
            fs.Close();
        }
    }
Beispiel #7
0
 public bool Equals(GenParam other) => TypeVariance == other.TypeVariance && Type == other.Type;