public void UnitStatisticsMakeDefault()
        {
            UnitStatistics = new UnitSettings();
            UnitStatistics.SetToDefault();

            UnitStatisticsSave();
        }
예제 #2
0
        private IEnumerator InitiateWave(Wave wave)
        {
            Vector3 spawnPosition = wavePath.points[0].position;

            for (int i = 0; i < wave.waveUnits.Length; i++)
            {
                WavePart waveUnit = wave.waveUnits[i];
                UnitType unitType = waveUnit.unitType;
                if (unitType == UnitType.Enemy)
                {
                    UnitSettings settings = waveUnit.unitSettings;
                    for (int j = 0; j < waveUnit.unitCount; j++)
                    {
                        Unit unit = Instantiate(unitPrefab, spawnPosition, Quaternion.identity).GetComponent <Unit>();
                        unit.path        = wavePath;
                        unit.waveSpawner = this;

                        unit.Initialize(settings);

                        spawnedUnits.Add(unit);

                        yield return(new WaitForSeconds(1f / waveUnit.spawnRate));
                    }
                }
                else if (unitType == UnitType.Wait)
                {
                    yield return(new WaitForSeconds(waveUnit.waitTime));
                }
            }
        }
예제 #3
0
 public PlayerCamMotor(ICamInput input, Transform player, Camera cam, UnitSettings settings)
 {
     this.input    = input;
     this.player   = player;
     this.cam      = cam;
     this.settings = settings;
 }
예제 #4
0
    public void SpawnUnit()
    {
        UnitSettings newUnitCache = currentUnit;

        GameConfig.Instance.StartCoroutine(SpawnUnitLogic(newUnitCache));
        // unit spawn logic
    }
예제 #5
0
 public UnitMotor(IUnitInput input, JumpSystem jumpSystem, Rigidbody rb, UnitSettings settings)
 {
     this.input      = input;
     this.jumpSystem = jumpSystem;
     this.rb         = rb;
     this.settings   = settings;
 }
예제 #6
0
    void DrawProperty(UnitSettings setting)
    {
        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("-", GUILayout.Width(25)))
        {
            removeList.Add(setting.id);
        }

        setting.id           = EditorGUILayout.TextField(setting.id, GUILayout.Width(150));
        setting.displayName  = EditorGUILayout.TextField(setting.displayName, GUILayout.Width(150));
        setting.appearanceId = EditorGUILayout.TextField(setting.appearanceId, GUILayout.Width(100));
        setting.isTower      = EditorGUILayout.Toggle(setting.isTower, GUILayout.Width(50));

        setting.cost     = EditorGUILayout.IntField(setting.cost, GUILayout.Width(50));
        setting.hitPoint = EditorGUILayout.IntField(setting.hitPoint, GUILayout.Width(50));

        setting.attackPower = EditorGUILayout.IntField(setting.attackPower, GUILayout.Width(50));
        setting.attackSpeed = EditorGUILayout.FloatField(setting.attackSpeed, GUILayout.Width(50));
        setting.moveSpeed   = EditorGUILayout.FloatField(setting.moveSpeed, GUILayout.Width(50));

        setting.effectiveRange = EditorGUILayout.FloatField(setting.effectiveRange, GUILayout.Width(50));
        setting.sensingRange   = EditorGUILayout.FloatField(setting.sensingRange, GUILayout.Width(50));

        setting.attackTarget         = EditorGUILayout.IntField(setting.attackTarget, GUILayout.Width(100));
        setting.attackPriority       = EditorGUILayout.IntField(setting.attackPriority, GUILayout.Width(100));
        setting.characterAttackRatio = EditorGUILayout.FloatField(setting.characterAttackRatio, GUILayout.Width(100));
        setting.towerAttackRatio     = EditorGUILayout.FloatField(setting.towerAttackRatio, GUILayout.Width(100));

        setting.summonId = EditorGUILayout.TextField(setting.summonId, GUILayout.Width(100));

        EditorGUILayout.EndHorizontal();
    }
    protected int _speed;             // Speed property is used to set NavMeshUnit's speed

    void Awake()
    {
        // If there is no UnitSettings assigned, try to find them. If there are still none, throw an error
        if (!settings)
        {
            settings = this.gameObject.GetComponent <BaseUnit>().settings;
            if (!settings)
            {
                Debug.LogError("ERROR: This Unit does not have UnitSettings!");
            }
            else    // If there are UnitSettings, initalize this Unit's variables with UnitSettings values
            {
                this._speed = settings.speed;
            }
        }

        if (!agent)
        {
            // Normally, I would implement error handling for the following property assignment. For this test, I'm doin' it dirty!
            agent = this.gameObject.GetComponent <NavMeshAgent>();

            if (!agent)
            {
                Debug.LogError("ERROR: This Unit does not have a NavMeshUnit!");
            }
        }

        // If there's UnitSettings and a NavMeshAgent, initialize the NavMeshAgent's speed property
        if (agent && settings)
        {
            agent.speed = this._speed;
        }
    }
예제 #8
0
    public static UnitManager Setup(UnitSettings settings, ref UnitSetupData setupData)
    {
        instance = new GameObject("UnitManager").AddComponent <UnitManager>();

        instance.SetupInternal(settings, ref setupData);

        return(instance);
    }
예제 #9
0
    void SetupInternal(UnitSettings settings, ref UnitSetupData setupData)
    {
        this.settings = settings;

        allUnits = new List <Unit>();
        idToUnit = new Dictionary <int, Unit>();

        instance.AtSetup(settings, ref setupData);
    }
    private DefaultUnitModel GetModelForWave(int currentWaveIndex, UnitSettings unitUpgradeSettings)
    {
        var model = new DefaultUnitModel(_unitSettings.Health + unitUpgradeSettings.Health * currentWaveIndex,
                                         _unitSettings.Damage + unitUpgradeSettings.Damage * currentWaveIndex,
                                         _unitSettings.Gold + unitUpgradeSettings.Gold * currentWaveIndex,
                                         _unitSettings.Speed + unitUpgradeSettings.Speed * currentWaveIndex);

        return(model);
    }
    public DefaultSpawnUnitWaveBehaviour(DefaultUnitSpawner spawner, UnitSettings unitSettings, UnitSettings unitUpgradeSettings, UnitPath[] paths, Transform parent)
    {
        _paths  = paths;
        _parent = parent;

        _unitSettings        = unitSettings;
        _unitUpgradeSettings = unitUpgradeSettings;

        _defaultUnitSpawner = spawner;
    }
예제 #12
0
        public void ConvertSlidesFromDirectory()
        {
            var slidesDirectory = new DirectoryInfo(@"Your path to slides");
            var unit            = new Unit(UnitSettings.CreateByTitle("u1", CourseSettings.DefaultSettings), slidesDirectory.GetSubdir("u1"));

            foreach (var slideFile in slidesDirectory.GetFiles("S*.cs"))
            {
                var slide = new CSharpSlideLoader().Load(slideFile, unit, 0, CourseSettings.DefaultSettings);
                ConvertSlide(slide);
            }
        }
예제 #13
0
        public void OneTimeSetUp()
        {
            Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory);

            loader         = new XmlSlideLoader();
            courseSettings = new CourseSettings(CourseSettings.DefaultSettings);
            courseSettings.Scoring.Groups.Add("ScoringGroup1", new ScoringGroup {
                Id = "ScoringGroup1"
            });
            unit = new Unit(UnitSettings.CreateByTitle("Unit title", courseSettings), new DirectoryInfo(testDataDirectory));
        }
예제 #14
0
 public virtual void Init(UnitSettings settings)
 {
     this.lifes          = settings.lifes;
     this.moveSpeed      = settings.moveSpeed;
     this.rotationSpeed  = settings.rotationSpeed;
     this.attackDistance = settings.attackDistance;
     this.attackDamage   = settings.attackDamage;
     this.attackDelay    = settings.attackDelay;
     this.myTeam         = settings.team == "People" ? UnitTeams.people : UnitTeams.zombie;
     AddToList();
 }
예제 #15
0
        public bool SetMode(UnitID Axis, UnitSettings mode)
        {
            int AxisNo = (int)Axis - (int)UnitID.U1;

            if (!IsAxisInRange(AxisNo))
            {
                return(false);
            }
            _controller.SetMode(Axis, mode);
            return(true);
        }
 public EditCartridgeViewModel(ConfigurationModel configurationModel,
                               AmmoModel cartridgesModel,
                               Cartridge cartridgeToEdit = null)
 {
     Cartridge = cartridgeToEdit ?? new Cartridge();
     isNew     = cartridgeToEdit == null;
     configurationModel.Initialize();
     units                = configurationModel.Units;
     DisplayName          = "Cartridge Data";
     this.cartridgesModel = cartridgesModel;
 }
예제 #17
0
 public void OneTimeSetUp()
 {
     Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory);
     videoAnnotationsClient = Mock.Of <IUlearnVideoAnnotationsClient>();
     slideRenderer          = new SlideRenderer(videoAnnotationsClient, null, null, null);
     loader         = new XmlSlideLoader();
     courseSettings = new CourseSettings(CourseSettings.DefaultSettings);
     courseSettings.Scoring.Groups.Add("ScoringGroup1", new ScoringGroup {
         Id = "ScoringGroup1"
     });
     unit = new Unit(UnitSettings.CreateByTitle("Unit title", courseSettings), new DirectoryInfo(testDataDirectory));
 }
예제 #18
0
    public void SetParameter(string id)
    {
        UnitButtonID = id;

        UnitSettings setting = UnitSettingLoader.GetSetting(UnitButtonID);

        CoinCostText.text = setting.cost.ToString();

        var sprite = Resources.Load <Sprite> ("Textures/" + setting.appearanceId);

        transform.Find("Image").GetComponent <UnityEngine.UI.Image>().sprite = sprite;
    }
        // Gets the first UnitSettings whose startingHealth is greater than or equal to the health parameter. allUnitSettings is sorted to an increasing order
        public UnitSettings GetUnitSettingsByHealth(int health)
        {
            for (int i = 0; i < allUnitSettings.Length; i++)
            {
                UnitSettings item = allUnitSettings[i];
                if (item.startingHealth >= health)
                {
                    return(item);
                }
            }

            return(null);
        }
 public void writeData(UnitSettings data)
 {
     this.writeArray(data.used);
     this.writeArray(data.hp);
     this.writeArray(data.shield);
     this.writeArray(data.armor);
     this.writeArray(data.build_time);
     this.writeArray(data.mineral_cost);
     this.writeArray(data.gas_cost);
     this.writeArray(data.str_unit_name);
     this.writeArray(data.weapon_damage);
     this.writeArray(data.upgrade_bonus);
 }
예제 #21
0
        private void DisplayUnit(UnitStackRepresentation unit, int position)
        {
            UnitSettings settings = unitSettingsMap[unit.type];

            uintSlots[position].gameObject.SetActive(true);
            uintSlots[position].SetInformation(
                "Имя   " + settings.baseData.unitName,
                "Количество " + unit.numberOfUnits,
                "Здоровье " + settings.baseData.maxHealth,
                "Урон " + settings.baseData.damage,
                "Инициатива " + settings.baseData.initiative
                );
        }
예제 #22
0
        /// <summary>
        /// 加载单元
        /// </summary>
        /// <param name="unitKey"></param>
        /// <returns></returns>
        public UnitSettings LoadUnit(String unitKey)
        {
            if (!this.Useable)
            {
                return(null);
            }
            /*特殊处理*/ if (unitKey == "self" || unitKey == "wind" || unitKey == "daemon")
            {
                return(null);
            }                                                                                /*特殊处理*/
            LoggerModuleHelper.TryLog("Modules.UnitManageModule.LoadUnit", "开始加载单元配置文件");
            //读取文件
            String unitFilePath = String.Concat(this.UnitsDirectory, Path.DirectorySeparatorChar, unitKey, ".json");

            if (!File.Exists(unitFilePath))
            {
                LoggerModuleHelper.TryLog("Modules.UnitManageModule.LoadUnit[Error]", $"单元配置文件 {unitFilePath} 不存在");
                return(null);
            }
            FileInfo fileInfo;

            try {
                fileInfo = new FileInfo(unitFilePath);
            }catch (Exception exception) {
                LoggerModuleHelper.TryLog(
                    "Modules.UnitManageModule.LoadUnit[Error]",
                    $"单元配置文件 {unitFilePath} 文件信息异常,: {exception.Message}\n异常堆栈: {exception.StackTrace}");
                return(null);
            }
            //setting
            UnitSettings unitSettings = UnitManageModuleHelper.ParseUnitSettingsFile(fileInfo);

            if (unitSettings == null)
            {
                LoggerModuleHelper.TryLog("Modules.UnitManageModule.LoadUnit[Warning]", $"单元文件\"{unitFilePath}\"读取失败");
                return(null);
            }
            //检查是新增或更新
            if (this.UnitDictionary.ContainsKey(unitKey))
            {
                this.UnitDictionary[unitKey].Settings = unitSettings;
            }
            else
            {
                _ = this.UnitDictionary.TryAdd(unitKey, new Unit {
                    Key = unitKey, Settings = unitSettings
                });
            }
            LoggerModuleHelper.TryLog("Modules.UnitManageModule.LoadUnit", $"单元\"{unitKey}\"读取成功,已加入单元列表");
            return(unitSettings);
        }
예제 #23
0
 /// <summary>
 /// Set the mode of the specified channel.
 /// </summary>
 /// <param name="unitId"></param>
 /// <param name="settings"></param>
 public void ChangeUnitSettings(UnitID unitId, UnitSettings settings)
 {
     if (settings != null)
     {
         lock (_lockController)
         {
             Send(new CommandSetMode(unitId, settings));
         }
     }
     else
     {
         throw new ArgumentOutOfRangeException(nameof(settings), "the settings object can not be null.");
     }
 }
예제 #24
0
        /// <summary>
        /// Get the settings of the specified channel including Mode, IsFlipDir, etc.
        /// </summary>
        /// <param name="unitId"></param>
        /// <returns></returns>
        public UnitSettings GetUnitSettings(UnitID unitId)
        {
            RxPackage package;

            lock (_lockController)
            {
                Send(new CommandGetUnitSettings(unitId));
                Read(out package, CancellationToken.None);
            }

            var settings = new UnitSettings(package.Payload);

            return(settings);
        }
예제 #25
0
 /// <summary>
 /// Set the mode of the specified channel.
 /// </summary>
 /// <param name="UnitID"></param>
 /// <param name="Settings"></param>
 public void SetMode(UnitID UnitID, UnitSettings Mode)
 {
     if (Mode != null)
     {
         lock (lockController)
         {
             Send(new CommandSetMode(UnitID, Mode));
         }
     }
     else
     {
         throw new ArgumentOutOfRangeException("the settings object can not be null.");
     }
 }
예제 #26
0
 private void LoadUnits()
 {
     try
     {
         Units = JsonConvert.DeserializeObject <UnitSettings>(Preferences.Get(SETTINGS_KEY, ""));
         if (Units is null)
         {
             Units = new UnitSettings();
         }
     }
     catch (Exception)
     {
         Units = new UnitSettings();
     }
 }
 /// <summary>
 /// Initializes a new instance of the MainViewModel class.
 /// </summary>
 public MainWindowViewModel()
 {
     if (IsInDesignMode)
     {
         // Code runs in Blend --> create design time data.
         UnitStatistics = new UnitSettings();
         UnitStatistics.SetToDefault();
     }
     else
     {
         // Code runs "for real"
         UnitStatistics = App.UnitStatisticsSettings;
     }
     
 }
예제 #28
0
        public void Not_Report_Indentation_Warning_On_Ethalon_Solution_Of_SingleFileExercise()
        {
            var exerciseXmlFile = TestsHelper.ProjSlideFolder.GetFile("S055 - Упражнение на параметры по умолчанию.lesson.xml");

            var courseSettings = new CourseSettings(CourseSettings.DefaultSettings)
            {
                Preludes = new[] { new PreludeFile(Language.CSharp, TestsHelper.ProjSlideFolder.GetFile("Prelude.cs").FullName) }
            };

            var unit = new Unit(UnitSettings.CreateByTitle("Unit title", courseSettings), TestsHelper.ProjSlideFolder);
            var slideLoadingContext = new SlideLoadingContext("Test", unit, courseSettings, TestsHelper.ProjSlideFolder, exerciseXmlFile, 1);
            var exerciseSlide       = (ExerciseSlide) new XmlSlideLoader().Load(slideLoadingContext);

            var validatorOut = TestsHelper.ValidateExerciseSlide(exerciseSlide);

            validatorOut.Should().BeNullOrEmpty();
        }
예제 #29
0
파일: Unit.cs 프로젝트: koppepan/ggj2018
    //! パラメータの設定 生成時にGameManagerから呼ばれる
    public void SetParameter(UnitSettings unitSetting, Vector2 destPosition,
                             Func <Unit, Unit> getNearEnemy,
                             Func <Unit, Unit> getNearTower,
                             Action <string, Unit> summon)
    {
        parameter       = unitSetting;
        currentHitPoint = parameter.hitPoint;

        endposition = destPosition;

        this.getNearEnemy = getNearEnemy;
        this.getNearTower = getNearTower;
        this.summon       = summon;

        this.ObserveEveryValueChanged(x => x.currentHitPoint).Subscribe(hp => {
            hpBar.value = (float)hp / (float)parameter.hitPoint;
        }).AddTo(gameObject);
    }
예제 #30
0
    private Transform GetUnit(UnitSettings newUnit)
    {
        Transform retunit = null;

        if (newUnit.unitPrefab.GetComponent <AircraftThatWorksWithWeapon>())
        {
            retunit = Poolable.Get <AircraftThatWorksWithWeapon>(() => Poolable.CreateObj <AircraftThatWorksWithWeapon>(newUnit.unitPrefab.gameObject), playerBaseSpawn.position, newUnit.unitPrefab.rotation).transform;
        }
        else if (newUnit.unitPrefab.GetComponent <StrikeFighterThatWorksWithWeapon>())
        {
            retunit = Poolable.Get <StrikeFighterThatWorksWithWeapon>(() => Poolable.CreateObj <StrikeFighterThatWorksWithWeapon>(newUnit.unitPrefab.gameObject), playerBaseSpawn.position, newUnit.unitPrefab.rotation).transform;
        }
        else if (newUnit.unitPrefab.GetComponent <StrategicBomberThatWorksWithWeapon>())
        {
            retunit = Poolable.Get <StrategicBomberThatWorksWithWeapon>(() => Poolable.CreateObj <StrategicBomberThatWorksWithWeapon>(newUnit.unitPrefab.gameObject), playerBaseSpawn.position, newUnit.unitPrefab.rotation).transform;
        }
        else if (newUnit.unitPrefab.GetComponent <CarrierModule>())
        {
            retunit = Poolable.Get <FrigateThatWorksWithWeapon>(() => Poolable.CreateObj <FrigateThatWorksWithWeapon>(newUnit.unitPrefab.gameObject), playerBaseSpawn.position, newUnit.unitPrefab.rotation).transform;
        }
        else if (newUnit.unitPrefab.GetComponent <FrigateThatWorksWithWeapon>())
        {
            retunit = Poolable.Get <FrigateThatWorksWithWeapon>(() => Poolable.CreateObj <FrigateThatWorksWithWeapon>(newUnit.unitPrefab.gameObject), playerBaseSpawn.position, newUnit.unitPrefab.rotation).transform;
        }
        else if (newUnit.unitPrefab.GetComponent <SubmarineThatWorksWithWeapon>())
        {
            retunit = Poolable.Get <SubmarineThatWorksWithWeapon>(() => Poolable.CreateObj <SubmarineThatWorksWithWeapon>(newUnit.unitPrefab.gameObject), playerBaseSpawn.position, newUnit.unitPrefab.rotation).transform;
        }
        else if (newUnit.unitPrefab.GetComponent <BallisticSubmarineThatWorksWithWeapon>())
        {
            retunit = Poolable.Get <BallisticSubmarineThatWorksWithWeapon>(() => Poolable.CreateObj <BallisticSubmarineThatWorksWithWeapon>(newUnit.unitPrefab.gameObject), playerBaseSpawn.position, newUnit.unitPrefab.rotation).transform;
        }
        else if (newUnit.unitPrefab.GetComponent <DestroyerThatWorksWithWeapon>())
        {
            retunit = Poolable.Get <DestroyerThatWorksWithWeapon>(() => Poolable.CreateObj <DestroyerThatWorksWithWeapon>(newUnit.unitPrefab.gameObject), playerBaseSpawn.position, newUnit.unitPrefab.rotation).transform;
        }
        else if (newUnit.unitPrefab.GetComponent <PatrolBoatThatWorksWithWeapon>())
        {
            retunit = Poolable.Get <PatrolBoatThatWorksWithWeapon>(() => Poolable.CreateObj <PatrolBoatThatWorksWithWeapon>(newUnit.unitPrefab.gameObject), playerBaseSpawn.position, newUnit.unitPrefab.rotation).transform;
        }

        return(retunit);
    }
예제 #31
0
 public override void Init(UnitSettings settings)
 {
     base.Init(settings);
     this.bulletSpeed = settings.bulletSpeed;
 }
 public void UnitStatisticsLoad()
 {
     UnitStatistics = UnitSettings.Load();
     App.UnitStatisticsSettings = UnitStatistics;
 }
예제 #33
0
        /// <summary>
        ///     Stop (deactivate) unit.
        /// </summary>
        /// <param name="settings">The settings of unit to stop.</param>
        public void StopUnit(UnitSettings settings)
        {
            var runner = new StopUnitRunner(Context);

            runner.Run(settings);
        }
 private void Application_Startup(object sender, StartupEventArgs e)
 {
     UnitStatisticsSettings = UnitSettings.Load();
 }