예제 #1
0
        public void OnTick()
        {
            if (_CheckSpawn)
            {
                if (BaseCreature.IsSoulboundEnemies && Spawn != null)
                {
                    foreach (BaseCreature bc in Spawn.Keys)
                    {
                        if (!bc.Deleted)
                        {
                            bc.IsSoulBound = true;
                        }
                    }
                }

                _CheckSpawn = false;
            }

            Map map = Map;

            if (map == null)
            {
                return;
            }

            if (!InitialSpawn)
            {
                for (int i = 0; i < MaxSpawn; i++)
                {
                    SpawnHelper(true);
                    InitialSpawn = true;
                }
            }
            else if (CannonsOperational && NextShoot < DateTime.UtcNow)
            {
                for (var index = 0; index < Cannons.Count; index++)
                {
                    MannedCannon c = Cannons[index];

                    if (c != null && !c.Deleted && (c.CanFireUnmanned || c.Operator != null && !c.Operator.Deleted && c.Operator.Alive))
                    {
                        c.Scan(true);
                    }
                }

                NextShoot = DateTime.UtcNow + TimeSpan.FromSeconds(2);
            }

            if (NextSpawn < DateTime.UtcNow)
            {
                Timer.DelayCall(TimeSpan.FromSeconds(1), () =>
                {
                    if (SpawnCount() < MaxSpawn)
                    {
                        SpawnHelper(false);
                    }
                });
            }
        }