Пример #1
0
        public static int SelectFromMultiple(ISpawner spawnPoint, int optionCount, bool ignoreSelectionModifiers = false)
        {
            if (optionCount <= 0)
            {
                return(-1);
            }
            if (optionCount == 1)
            {
                return(0);
            }

            if (!ignoreSelectionModifiers && spawnPoint != null && spawnPoint.component != null)
            {
                using (var lst = TempCollection.GetList <ISpawnPointSelector>())
                {
                    spawnPoint.component.GetComponents <ISpawnPointSelector>(lst);
                    for (int i = 0; i < lst.Count; i++)
                    {
                        if (lst[i].enabled)
                        {
                            int index = lst[i].Select(spawnPoint, optionCount);
                            if (index >= 0)
                            {
                                return(index);
                            }
                        }
                    }
                }
            }

            return(RandomUtil.Standard.Range(optionCount));
        }
Пример #2
0
        private void Start()
        {
            _gameState.ResetData();
            _grid = new TetrisGrid(_gridHeight, _gridWidth);
            _grid.GridOverflowed += GridOnGridOverflowed;

            _soundManager = GetComponent <SoundManager>();
            _spawner      = GetComponent <RandomPrefabsSpawner>();
            _inputManager = new InputManagersWrapper(new List <IInputManager>()
            {
                GetComponent <InputManager>(),
                GetComponent <TouchInputManager>()
            });

            _scoreCalculator            = new ScoreCalculator(_gameState, _scoreData);
            _levelManager               = new LevelManager(_gameState, 10, _maxLevel);
            _preview                    = new GameObject("Preview", new Type[] { typeof(SpriteRenderer) });
            _preview.transform.position = _previewPosition;

            _currentTetromino = CreateTetromino();
            InitializeCurrentTetromino();

            _nextTetromino = CreateTetromino();
            SetUpPreview();
        }
Пример #3
0
        private void Run()
        {
            if (!_Display.HasFort())
            {
                _Fort = _FortFactory.CreateFort();
                _Display.BuildFort(_Fort);
                for (int i = 0; i < _SpawnerPool.Count; i++)
                {
                    ISpawner s  = GetSpawner(i);
                    Thread   th = new Thread(new ThreadStart(s.Run));
                    th.Start();
                }
            }
            while (_Running)
            {
                if (_Fort.isDead())
                {
                    foreach (var entry in _Livables)
                    {
                        entry.Key.Die();
                    }

                    //_Livables.Clear();
                    _AnimationQueue.Clear();

                    foreach (var entry in _SpawnerPool)
                    {
                        entry.Stop();
                    }
                    Display.End();
                    Display.Gameover();
                    _Running = false;
                }
            }
        }
Пример #4
0
 private void Awake()
 {
     Instance     = this;
     _dataManager = GetComponent <LevelDataManager>();
     Pool         = GetComponent <Pool>();
     _spawner     = GetComponent <Spawner>();
 }
Пример #5
0
    public ISpawner MoveNext()
    {
        ISpawner retval = spawners[spawnerIndex];

        spawnerIndex = (spawnerIndex + 1) % spawnerObjects.Length;
        return(retval);
    }
Пример #6
0
    public override void Init(int startNumber, int remainingNumber, ISpawner spawner, int startLevel = -1)
    {
        this.ballSpawner = spawner;

        //Setting Level for ball
        this.level = startLevel;
        if (startLevel < 0)
        {
            this.level = UnityEngine.Random.Range(Config.MinBallLevel, Config.MaxBallLevel);
        }

        float num = (startNumber - remainingNumber) / level;

        number = (int)num;
        if (num % 1 != 0)
        {
            number = (int)num + 1;
        }

        this.remainingNumber = startNumber - number;

        factor = (float)BallSpawner.MaxBallNumber / colors.Length;
        CheckColorChange();
        ChangeScale();
    }
Пример #7
0
    void OnScene(SceneView sceneView)
    {
        Handles.BeginGUI();

        GUILayout.Label("<b>Unit Spawn Information (Total count : " + spawnerList.Count + ")</b>", richStyle);

        npcDic.Clear();
        for (int i = 0; i < spawnerList.Count; i++)
        {
            ISpawner spawner = spawnerList[i];
            if (spawner is NPCSpawner)
            {
                NPCSpawner nSpawner = spawner as NPCSpawner;
                uint       npcID    = (uint)nSpawner.unitId;
                if (!npcDic.ContainsKey(npcID))
                {
                    npcDic.Add(npcID, new List <NPCSpawner>());
                }

                npcDic[npcID].Add(nSpawner);
            }
        }

        foreach (KeyValuePair <uint, List <NPCSpawner> > pair in npcDic)
        {
            GUILayout.Label("NPCID : " + pair.Key + " | Count : " + pair.Value.Count + (pair.Value[0].isBoss ? " [BOSS]" : string.Empty), txtColStyle);
        }

        Handles.EndGUI();
    }
Пример #8
0
        public void ParseSpawners(Room roomobj, XElement roomxml, XDocument doc)
        {
            XName spawnersName = XName.Get("spawners", doc.Root.Name.NamespaceName);

            List <XElement> spawners = roomxml.Elements(spawnersName).ToList();

            if (spawners.Count == 0)
            {
                return;
            }
            List <XElement> spawnerList = spawners[0].Elements("spawner").ToList();

            foreach (XElement spawner in spawnerList)
            {
                XElement typeName = spawner.Element("type");
                XElement count    = spawner.Element("count");
                XElement xloc     = spawner.Element("xloc");
                XElement yloc     = spawner.Element("yloc");

                float x = float.Parse(xloc.Value);
                float y = float.Parse(yloc.Value);

                int enemyCount = int.Parse(count.Value);

                // Use block center because spawners will just be invis blocks that spawn enemies
                Vector2 truePos = RoomUtilities.CalculateBlockCenter(roomobj.RoomPos, new Vector2(x, y));

                ISpawner spawnerAdd = CreateSpawner(typeName.Value, enemyCount, truePos);
                roomobj.AddSpawner(spawnerAdd);
            }
        }
Пример #9
0
    void FillSpawnerList()
    {
        SpawnController spawnCtlr = target as SpawnController;

        if (null == spawnCtlr)
        {
            return;
        }

        Transform[] gos = spawnCtlr.GetComponentsInChildren <Transform>() as Transform[];
        if (null == gos)
        {
            return;
        }

        spawnerList.Clear();

        for (int i = 0; i < gos.Length; i++)
        {
            ISpawner spawner = (ISpawner)gos[i].GetComponent("ISpawner");
            if (null != spawner)
            {
                spawnerList.Add(spawner);
                transList.Add(gos[i]);
            }
        }
    }
Пример #10
0
            protected override void OnTarget(Mobile from, object targ)
            {
                ISpawner spawner = null;

                if (targ is Item)
                {
                    spawner = ((Item)targ).Spawner;
                }
                else if (targ is Mobile)
                {
                    spawner = ((Mobile)targ).Spawner;
                }

                if (spawner is Spawner)
                {
                    Spawner spawnitem = (Spawner)spawner;
                    if (spawnitem.Map == null || spawnitem.Map == Map.Internal)
                    {
                        from.SendMessage("That spawner is in the internal map.");
                    }
                    else if (spawnitem.RootParent is Mobile)
                    {
                        from.MoveToWorld(spawnitem.GetWorldLocation(), spawnitem.Map);
                        from.SendMessage("The spawner is on a mobile.");
                    }
                    else
                    {
                        from.MoveToWorld(spawnitem.Location, spawnitem.Map);
                    }
                }
            }
Пример #11
0
        public static bool Replace(ISpawner spwner, string current, string replace, string check)
        {
            bool replaced = false;

            if (spwner is XmlSpawner)
            {
                XmlSpawner spawner = (XmlSpawner)spwner;

                foreach (var obj in spawner.SpawnObjects)
                {
                    if (obj == null || obj.TypeName == null)
                    {
                        continue;
                    }

                    string typeName   = obj.TypeName.ToLower();
                    string lookingFor = current.ToLower();

                    if (typeName != null && typeName.IndexOf(lookingFor) >= 0)
                    {
                        if (String.IsNullOrEmpty(check) || typeName.IndexOf(check) < 0)
                        {
                            obj.TypeName = typeName.Replace(lookingFor, replace);

                            if (!replaced)
                            {
                                replaced = true;
                            }
                        }
                    }
                }
            }
            else if (spwner is Spawner)
            {
                Spawner spawner = (Spawner)spwner;

                for (int i = 0; i < spawner.SpawnObjects.Count; i++)
                {
                    var so = spawner.SpawnObjects[i];

                    string typeName   = so.SpawnName.ToLower();
                    string lookingFor = current.ToLower();

                    if (typeName != null && typeName.IndexOf(lookingFor) >= 0)
                    {
                        if (String.IsNullOrEmpty(check) || typeName.IndexOf(check) < 0)
                        {
                            so.SpawnName = typeName.Replace(lookingFor, replace);

                            if (!replaced)
                            {
                                replaced = true;
                            }
                        }
                    }
                }
            }

            return(replaced);
        }
Пример #12
0
        public override void Delete()
        {
            if (_MutateTo != null)
            {
                ISpawner s = Spawner;

                if (s is XmlSpawner)
                {
                    XmlSpawner xml = (XmlSpawner)s;

                    if (xml.SpawnObjects == null)
                    {
                        return;
                    }

                    foreach (XmlSpawner.SpawnObject so in xml.SpawnObjects)
                    {
                        for (int i = 0; i < so.SpawnedObjects.Count; ++i)
                        {
                            if (so.SpawnedObjects[i] == this)
                            {
                                so.SpawnedObjects[i] = _MutateTo;

                                Spawner = null;
                                base.Delete();
                                return;
                            }
                        }
                    }
                }
            }

            base.Delete();
        }
Пример #13
0
        public static bool ActionOnSpawner(ISpawner spawner, Type typeCheck, string lineCheck, string exempt, Action <ISpawner> action, bool inherits)
        {
            string[] list = GetSpawnList(spawner);

            if (list == null)
            {
                return(false);
            }

            foreach (var str in list)
            {
                if (string.IsNullOrEmpty(str))
                {
                    continue;
                }

                string spawnObject = str.ToLower();

                if (typeCheck != null)
                {
                    Type t;

                    if (spawner is Spawner)
                    {
                        t = ScriptCompiler.FindTypeByName(spawnObject);
                    }
                    else
                    {
                        t = ScriptCompiler.FindTypeByName(BaseXmlSpawner.ParseObjectType(spawnObject));
                    }

                    if (t == typeCheck || (t != null && inherits && t.IsSubclassOf(typeCheck)))
                    {
                        if (action != null)
                        {
                            action(spawner);
                        }

                        return(true);
                    }
                }
                else
                {
                    string lookFor = lineCheck != null?lineCheck.ToLower() : null;

                    if ((lookFor == null || spawnObject.IndexOf(lookFor) >= 0) && (exempt == null || spawnObject.IndexOf(exempt.ToLower()) <= 0))
                    {
                        if (action != null)
                        {
                            action(spawner);
                        }

                        return(true);
                    }
                }
            }

            return(false);
        }
Пример #14
0
 public Spawnable(string path, SpawnOptions options, ISpawner spawner,
                  Func <ISpawnable <T>, IObserver <T>, IDisposable> subscriber)
 {
     ProgramPath = path ?? throw new ArgumentNullException(nameof(path));
     Options     = options ?? throw new ArgumentNullException(nameof(options));
     Spawner     = spawner ?? throw new ArgumentNullException(nameof(spawner));
     _subscriber = subscriber ?? throw new ArgumentNullException(nameof(subscriber));
 }
 private void Awake()
 {
     system = GetComponent <ParticleSystem>();
     if (spawner != null)
     {
         Spawner = spawner as ISpawner;
     }
 }
Пример #16
0
 /// <summary>
 ///   Adds a new spawner. Sets up the spawn radius, radius sqr,
 ///   and frequency fields based on the parameters of this
 ///   function.
 /// </summary>
 public void AddSpawnType(ISpawner spawner, float spawnDensity, int spawnRadius)
 {
     spawner.SpawnRadius    = spawnRadius;
     spawner.SpawnFrequency = 122;
     spawner.SpawnRadiusSqr = spawnRadius * spawnRadius;
     spawner.SetFrequencyFromDensity(spawnDensity);
     spawnTypes.Add(spawner);
 }
Пример #17
0
        public virtual Task <bool> RemoveSpawnerAsync(ISpawner spawner)
        {
            if (!_spawners.Contains(spawner))
            {
                return(Task.FromResult(false));
            }

            return(Task.FromResult(_spawners.Remove(spawner)));
        }
Пример #18
0
 public SpawnPointBeforeSpawnNotification(ISpawner spawnPoint, GameObject prefab)
 {
     if (spawnPoint == null)
     {
         throw new System.ArgumentNullException("spawnPoint");
     }
     _spawnPoint = spawnPoint;
     _prefab     = prefab;
 }
        public static void GetSpawnModifiers(ISpawner spawnPoint, List <ISpawnerModifier> modifiers)
        {
            if (spawnPoint == null)
            {
                throw new System.ArgumentNullException("spawnPoint");
            }

            spawnPoint.component.GetComponents <ISpawnerModifier>(modifiers);
            modifiers.Sort(SpawnPointHelper.ModiferSortMethod);
        }
Пример #20
0
 public void Init(IInput inputController, ISpawner spawner)
 {
     body         = GetComponent <IBody>();
     this.spawner = spawner;
     wayProcessor = new SnakeWayProcessor();
     InitTrackers(spawner);
     inputController.OnInputChange += WayProcessor.ProcessInput;
     wayProcessor.OnWayChanged     += body.SnapPosition;
     wayProcessor.OnWayChanged     += body.Refresh;
 }
Пример #21
0
    public ISpawner GetBreakApartMapping(ISpawner parent)
    {
        BreakApartMapping mapping = breakApartMappings.FirstOrDefault(m => m.parentSpawner == parent);

        if (mapping == null)
        {
            return(parent);
        }
        return(mapping.childSpawner);
    }
Пример #22
0
        private ISpawner InstantiateSpawner(int amount, float delay, IContentPrefab prefab)
        {
            GameObject newSpawner = Instantiate(NestedSpawner);
            ISpawner   spawner    = newSpawner.GetComponent <ISpawner>();

            spawner.OnSpawn    += OnSpawnerSpawn;
            spawner.OnFinished += OnSpawnerFinished;
            spawner.Spawn(amount, delay, prefab);
            return(spawner);
        }
Пример #23
0
        public override void Init()
        {
            Spawner = ScenePrivate.FindReflective <ISpawner>("Builder.Spawner").FirstOrDefault();
            if (Spawner == null)
            {
                Log.Write(LogLevel.Error, "Fetcher failed to find the Spawner :(");
            }

            ScenePrivate.Chat.Subscribe(Chat.DefaultChannel, OnChat, true);
        }
Пример #24
0
        public void Unlink()
        {
            ISpawner se = this.Spawner;

            if (se != null)
            {
                this.Spawner.Remove(this);
                this.Spawner = null;
            }
        }
Пример #25
0
    public DifficultySpawner(DifficultyConfig config, ISpawner spawner)
    {
        _difficultyConfig = config;

        _spawner = spawner;
        _spawner.Init(GetNewPattern);

        ResetObjects();
        Enable(true);
    }
Пример #26
0
 public SavannaFactory
     (CoordinateValidator validator, ISpawner spawn, Movement movement,
     PredatorEssentials predSpecial, PreyEssentials preySpecial)
 {
     _predSpecial      = predSpecial;
     _preySpecial      = preySpecial;
     _validator        = validator;
     _spawn            = spawn;
     _standardMovement = movement;
 }
Пример #27
0
 public ConsoleUserAddAnimals
     (Movement standardMovement, CoordinateValidator validator, PredatorEssentials predatorSpecial,
     PreyEssentials preySpecial, Spawner spawner)
 {
     _standardMovement = standardMovement;
     _validator        = validator;
     _predatorSpecial  = predatorSpecial;
     _preySpecial      = preySpecial;
     _spawner          = spawner;
 }
Пример #28
0
        public Task <bool> AddSpawnerAsync(ISpawner spawner)
        {
            if (_spawners.Contains(spawner))
            {
                return(Task.FromResult(false));
            }

            _spawners.Add(spawner);

            return(Task.FromResult(true));
        }
Пример #29
0
    public void RegisterSpawner(GameObject argSpawner)
    {
        ISpawner spawner = argSpawner.GetComponent <ISpawner>();

        if (null == spawner)
        {
            return;
        }

        m_levelSpawners.Add(spawner);
    }
Пример #30
0
 public void InitTrackers(ISpawner spawner)
 {
     trackers = GetComponentsInChildren <ITracker>();
     foreach (var tracker in trackers)
     {
         tracker.Target = spawner.LastSpawnedObject;
     }
     foreach (var tracker in trackers)
     {
         spawner.OnObjectSpawned += (Transform current) => tracker.Target = current;
     }
 }
Пример #31
0
 private List<ISpawner> GetAppropriateListForSpawner(ISpawner spawner) {
     return spawner.IsDefender ? defendersSpawners : attackersSpawners;
 }
Пример #32
0
 public SpawnerContext(ISpawner spawnerParam) {
     spawner = spawnerParam;
     Reset();
 }
Пример #33
0
 public void RegisterSpawner(ISpawner spawner) {
     GetAppropriateListForSpawner(spawner).Add(spawner);
 }
Пример #34
0
        public virtual void Delete()
        {
            if ( m_Deleted )
                return;
            else if ( !World.Instance.OnDelete( this ) )
                return;

            if ( m_Client != null )
                m_Client.CancelAllTrades();

            if ( m_Client != null )
                m_Client.Dispose();

            this.DropHolding();

            Region.OnRegionChange( this, m_Region, null );

            m_Region = null;
            //Is the above line REALLY needed?  The old Region system did NOT have said line
            //and worked fine, because of this a LOT of extra checks have to be done everywhere...
            //I guess this should be there for Garbage collection purposes, but, still, is it /really/ needed?

            if ( m_Spawner != null )
            {
                m_Spawner.Remove( this );
                m_Spawner = null;
            }

            OnDelete();

            for ( int i = m_EquippedItems.Count - 1; i >= 0; --i )
                if ( i < m_EquippedItems.Count )
                    m_EquippedItems[i].OnParentDeleted( this );

            this.SendRemovePacket();

            if ( m_Guild != null )
                m_Guild.OnDelete( this );

            m_Deleted = true;

            if ( m_Map != null )
            {
                m_Map.OnLeave( this );
                m_Map = null;
            }

            m_Hair = null;
            m_FacialHair = null;

            m_MountItem = null;

            World.Instance.RemoveMobile( this );

            EventSink.Instance.InvokeDeleted( new DeletedEventArgs( this ) );

            StopAggrExpire();

            CheckAggrExpire();

            if ( m_PoisonTimer != null )
                m_PoisonTimer.Stop();

            if ( m_HitsTimer != null )
                m_HitsTimer.Stop();

            if ( m_StamTimer != null )
                m_StamTimer.Stop();

            if ( m_ManaTimer != null )
                m_ManaTimer.Stop();

            if ( m_LogoutTimer != null )
                m_LogoutTimer.Stop();

            if ( m_ExpireCriminal != null )
                m_ExpireCriminal.Stop();

            if ( m_WarmodeTimer != null )
                m_WarmodeTimer.Stop();

            if ( m_ParaTimer != null )
                m_ParaTimer.Stop();

            if ( m_FrozenTimer != null )
                m_FrozenTimer.Stop();

            if ( m_AutoManifestTimer != null )
                m_AutoManifestTimer.Stop();

            OnAfterDelete();

            FreeCache();
        }
Пример #35
0
 /// <summary>
 /// Registers the despawn on process exit.
 /// </summary>
 /// <param name="spawner">The AdSenseSpawner.</param>
 private static void RegisterDespawnOnProcessExit(ISpawner spawner)
 {
     AppDomain.CurrentDomain.ProcessExit += spawner.CloseHandler;
 }
Пример #36
0
        public virtual void Delete()
        {
            if ( Deleted )
                return;
            else if ( !World.Instance.OnDelete( this ) )
                return;

            OnDelete();

            if ( m_Items != null )
            {
                for ( int i = m_Items.Count - 1; i >= 0; --i )
                {
                    if ( i < m_Items.Count )
                        ( (Item) m_Items[i] ).OnParentDeleted( this );
                }
            }

            SendRemovePacket();

            SetFlag( ImplFlag.Deleted, true );

            if ( Parent is Mobile )
                ( (Mobile) Parent ).RemoveItem( this );
            else if ( Parent is Item )
                ( (Item) Parent ).RemoveItem( this );

            ClearBounce();

            if ( m_Spawner != null )
            {
                m_Spawner.Remove( this );
                m_Spawner = null;
            }

            if ( m_Map != null )
            {
                m_Map.OnLeave( this );
                m_Map = null;
            }

            World.Instance.RemoveItem( this );

            OnAfterDelete();

            FreeCache();
        }