예제 #1
0
파일: TreeCutter.cs 프로젝트: MK4H/MHUrho
        public static TreeCutter CreateNew(ILevelManager level, IBuilding building, TreeCutterType type)
        {
            TreeCutter newCutter = null;

            try {
                newCutter           = new TreeCutter(level, building, type);
                newCutter.healthBar =
                    new HealthBarControl(level, building, 100, new Vector3(0, 3, 0), new Vector2(0.5f, 0.1f), false);
                StaticRangeTarget.CreateNew(newCutter, level, building.Center);

                using (var spawnPoints = building.Tiles[0].GetNeighbours().GetEnumerator()) {
                    for (int i = 0; i < numberOfWorkers; i++)
                    {
                        IUnit workerUnit1 = level.EditorMode ? null : newCutter.SpawnWorkerUnit(spawnPoints);
                        newCutter.workers[i] = new Worker(newCutter, workerUnit1, workerRespawnTime)
                        {
                            DoRespawn = !level.EditorMode
                        };
                    }
                }

                return(newCutter);
            }
            catch (Exception e) {
                newCutter?.Dispose();
                throw;
            }
        }
예제 #2
0
파일: TreeCutter.cs 프로젝트: MK4H/MHUrho
            public static Worker Load(SequentialPluginDataReader reader, TreeCutter cutter, bool doRespawn)
            {
                reader.GetNext(out int ID);
                reader.GetNext(out double duration);
                reader.GetNext(out double remaining);

                IUnit unit = ID != 0 ? cutter.Level.GetUnit(ID) : null;


                return(new Worker(cutter, unit, duration, remaining)
                {
                    DoRespawn = doRespawn
                });
            }
예제 #3
0
파일: TreeCutter.cs 프로젝트: MK4H/MHUrho
            Worker(TreeCutter cutter, IUnit unit, double respawnTime, double remainingTime)
            {
                this.DoRespawn = true;
                this.Unit      = unit;
                if (unit != null)
                {
                    ((Dog)unit.UnitPlugin).Cutter = cutter;
                    unit.OnRemoval += OnWorkerDeath;
                }

                this.cutter = cutter;

                timeout = new Timeout(respawnTime, remainingTime);
            }
예제 #4
0
파일: TreeCutter.cs 프로젝트: MK4H/MHUrho
 public override BuildingInstancePlugin GetInstanceForLoading(ILevelManager level, IBuilding building)
 {
     return(TreeCutter.CreateForLoading(level, building, this));
 }
예제 #5
0
파일: TreeCutter.cs 프로젝트: MK4H/MHUrho
 public override BuildingInstancePlugin CreateNewInstance(ILevelManager level, IBuilding building)
 {
     return(TreeCutter.CreateNew(level, building, this));
 }
예제 #6
0
파일: TreeCutter.cs 프로젝트: MK4H/MHUrho
 public Worker(TreeCutter cutter, IUnit unit, double respawnTime)
     : this(cutter, unit, respawnTime, respawnTime)
 {
 }