Example #1
0
    void OnSimulationSettingChange(SimulationSetting simulationSetting, float value)
    {
        int index = (int)simulationSetting;

        switch (simulationSetting)
        {
        case SimulationSetting.GenerationDuration:
            SimulationManager.Instance.GenerationDuration = value;
            break;

        case SimulationSetting.MutationIntensity:
            SimulationManager.Instance.MutationIntensity = value;
            break;

        case SimulationSetting.MutationProbability:
            SimulationManager.Instance.MutationProbability = value;
            break;

        case SimulationSetting.PercentageOfElites:
            SimulationManager.Instance.PercentageOfElites = value;
            break;

        case SimulationSetting.PopulationAmount:
            SimulationManager.Instance.PopulationAmount = (int)value;
            break;
        }

        string format = GetValueFormat(value);

        simulationSettingsTexts[index].text = String.Format(simulationSettingsStrings[index], value.ToString(format));
    }
Example #2
0
 /// <summary>
 /// Setting UI에서 설정한 값을 파일에 반영하는 함수
 /// </summary>
 /// <param name="simulationData">Setting UI에 설정된 시뮬레이션 설정 값</param>
 /// <param name="playerData">PlayerSetting에 설정된 플레이어 설정 값</param>
 public void SetFileData(SimulationSetting simulationData, PlayerSetting playerData)
 {
     File.WriteAllText(simulationSettingPath,
                       JsonUtility.ToJson(simulationData),
                       Encoding.Default);
     File.WriteAllText(playerSettingPath,
                       JsonUtility.ToJson(playerData),
                       Encoding.Default);
 }
        private void SpreaderData()
        {
            // 데이터 읽어오기
            var simulationData = new SimulationSetting();
            var playerData     = new PlayerSetting();

            manager.FileManager.GetFileData(ref simulationData, ref playerData);

            // 데이터 뿌려주기
            manager.GPUBoids?.GetSettingData(simulationData);
            manager.SharkManager.GetSettingData(simulationData);
            manager.CameraOperate.GetSettingData(playerData);
        }
        /// <summary>
        /// 실행파일이 처음 실행된경우
        /// 셋팅 json파일의 값을 읽고 UI에 뿌려줌
        /// </summary>
        void Start()
        {
            // 데이터 받아오기
            var fileMgr = LobbyManager.instance.FileManager;

            var simulationData = new SimulationSetting();
            var playerData     = new PlayerSetting();

            fileMgr.GetFileData(ref simulationData, ref playerData);

            // 데이터 뿌려주기
            UIDataChange(simulationData, playerData);
        }
        /// <summary>
        /// 초기화 버튼을 눌렀을 경우 모든 설정값을 초기화하는 함수
        /// </summary>
        public void InitSettingFields()
        {
            // json 초기화
            var fileMgr = LobbyManager.instance.FileManager;

            fileMgr.InitFileData();

            // UI값 초기화
            var simulationData = new SimulationSetting();
            var playerData     = new PlayerSetting();

            UIDataChange(simulationData, playerData);
        }
Example #6
0
        /// <summary>
        /// Simuation Scene에서 설정용 Json파일을 읽기 위한 함수
        /// </summary>
        public void GetFileData(ref SimulationSetting simulationData, ref PlayerSetting playerData)
        {
            var simulFI  = new FileInfo(simulationSettingPath);
            var playerFI = new FileInfo(playerSettingPath);

            if (!simulFI.Exists || !playerFI.Exists)
            {
                Debug.Log("no exists file");
                InitFileData();
            }

            simulationData = JsonUtility.FromJson <SimulationSetting>(File.ReadAllText(simulationSettingPath));
            playerData     = JsonUtility.FromJson <PlayerSetting>(File.ReadAllText(playerSettingPath));
        }
Example #7
0
        /// <summary>
        /// Setting 데이터를 모두 초기화하는 함수
        /// 초기값은 'SettingData.md' 파일 참조
        /// </summary>
        public void InitFileData()
        {
            var simulationData = new SimulationSetting();

            File.WriteAllText(simulationSettingPath,
                              JsonUtility.ToJson(simulationData),
                              Encoding.Default);

            var playerData = new PlayerSetting();

            File.WriteAllText(playerSettingPath,
                              JsonUtility.ToJson(playerData),
                              Encoding.Default);
        }
        public void GetSettingData(SimulationSetting data)
        {
            MaxObjectNum = data.numOfFish;

            CohesionNeighborhoodRadius = data.cohesionRadius;
            AlignmentNeighborhoodRadius = data.alignmentRadius;
            SeparateNeighborhoodRadius = data.separateRadius;

            CohesionWeight = data.cohesionWeight;
            AlignmentWeight = data.alignmentWeight;
            SeparateWeight = data.separateWeight;

            MaxSpeed = data.maxSpeed;
            MaxSteerForce = data.maxSteer;

            AvoidObstacleDistance = data.avoidObstacleDistance;
            AvoidObstacleWeight = data.avoidObstacleWeight;
        }
        /// <summary>
        /// json 설정파일을 수정하기 위해 SettingUI의 Simulation 데이터를 읽어들이는 함수
        /// </summary>
        public SimulationSetting GatheringSimulationSetting()
        {
            var simulationData = new SimulationSetting();

            simulationData.numOfFish             = (int)numOfFish.value;
            simulationData.numOfShark            = (int)numOfShark.value;
            simulationData.cohesionRadius        = float.Parse(cohesionRadius.text);
            simulationData.alignmentRadius       = float.Parse(alignmentRadius.text);
            simulationData.separateRadius        = float.Parse(separateRadius.text);
            simulationData.avoidObstacleDistance = float.Parse(avoidObstacleDistance.text);
            simulationData.cohesionWeight        = float.Parse(cohesionWeight.text);
            simulationData.alignmentWeight       = float.Parse(alignmentWeight.text);
            simulationData.separateWeight        = float.Parse(separateWeight.text);
            simulationData.avoidObstacleWeight   = float.Parse(avoidObstacleWeight.text);
            simulationData.maxSpeed = float.Parse(maxSpeed.text);
            simulationData.maxSteer = float.Parse(maxSteer.text);

            return(simulationData);
        }
Example #10
0
    protected virtual void OnStart()
    {
        for (int i = 0; i < (int)NeuralNetworkSetting.Count; i++)
        {
            NeuralNetworkSetting neuralNetworkSetting = (NeuralNetworkSetting)i;

            neuralNetworkSettingsStrings[i] = neuralNetworkSettingsTexts[i].text;
            neuralNetworkSettingsSliders[i].onValueChanged.AddListener((value) => OnNeuralNetworkSettingChange(neuralNetworkSetting, value));
            OnNeuralNetworkSettingChange(neuralNetworkSetting, neuralNetworkSettingsSliders[i].value);
        }

        for (int i = 0; i < (int)SimulationSetting.Count; i++)
        {
            SimulationSetting simulationSetting = (SimulationSetting)i;

            simulationSettingsStrings[i] = simulationSettingsTexts[i].text;
            simulationSettingsSliders[i].onValueChanged.AddListener((value) => OnSimulationSettingChange(simulationSetting, value));
            OnSimulationSettingChange(simulationSetting, simulationSettingsSliders[i].value);
        }
    }
        /// <summary>
        /// UI에 클래스 데이터를 뿌려주는 함수
        /// </summary>
        /// <param name="simulationData">simulationData</param>
        /// <param name="playerData">playerData</param>
        private void UIDataChange(SimulationSetting simulationData, PlayerSetting playerData)
        {
            // 시뮬레이션
            numOfFish.value            = simulationData.numOfFish;
            numOfShark.value           = simulationData.numOfShark;
            cohesionRadius.text        = simulationData.cohesionRadius.ToString();
            alignmentRadius.text       = simulationData.alignmentRadius.ToString();
            separateRadius.text        = simulationData.separateRadius.ToString();
            avoidObstacleDistance.text = simulationData.avoidObstacleDistance.ToString();
            cohesionWeight.text        = simulationData.cohesionWeight.ToString();
            alignmentWeight.text       = simulationData.alignmentWeight.ToString();
            separateWeight.text        = simulationData.separateWeight.ToString();
            avoidObstacleWeight.text   = simulationData.avoidObstacleWeight.ToString();
            maxSpeed.text = simulationData.maxSpeed.ToString();
            maxSteer.text = simulationData.maxSteer.ToString();

            // 플레이어
            scrollSpeed.value  = playerData.scrollSpeed;
            rotateXSpeed.value = playerData.rotateXSpeed;
            rotateYspeed.value = playerData.rotateYspeed;
            moveSpeed.value    = playerData.moveSpeed;
            keyMoveSpeed.value = playerData.keyMoveSpeed;
        }
 public void GetSettingData(SimulationSetting data)
 {
     numOfShark = data.numOfShark;
 }