コード例 #1
0
    private void ResetBoard(bool complete = false)
    {
        _isEvenLeft = true;
        if (_board == null)
        {
            _board = new Ball[Rows, Columns];
        }

        PoolBoss.DespawnAllPrefabs();

        for (var y = 0; y < Rows; y++)
        {
            var offsetX = y.IsEven() && _isEvenLeft ? 0f : CellWidth / 2;
            for (var x = 0; x < Columns; x++)
            {
                var pos  = new Vector3(BoardLeft + x * CellWidth + offsetX, BoardTop + CellHeight - y * CellHeight, 0f);
                var ball = PoolBoss.SpawnInPool("ball", pos, Quaternion.identity).GetComponent <Ball>();
                ball.BoardX = x;
                ball.BoardY = y;
                ball.SetValue(RandomBallValue());
                ball.SetState(y > 4 || complete ? BallState.None : BallState.Active);

                _board[y, x] = ball;
            }
        }
    }
コード例 #2
0
        /// <summary>
        /// Рисовать крестик
        /// </summary>
        private void _drawXMark()
        {
            for (int i = 0; i < 2; i++)
            {
                Transform point = PoolBoss.Spawn(PointPrefab, Vector3.zero, FieldMarkTransforms[FieldMarkPlaceId].rotation, FieldMarkTransforms[FieldMarkPlaceId]);
                point.localPosition = _currentDrawModel.Pos;
                point.localScale    = Vector3.one;

                _currentDrawModel.Pos -= new Vector3((_currentDrawModel.FirstItem ? -2 : 2), 2);


                if (_currentDrawModel.FirstItem)
                {
                    if (_currentDrawModel.Pos == new Vector3(42f, -42f))
                    {
                        _currentDrawModel.Pos       = new Vector3(40f, 40f);
                        _currentDrawModel.FirstItem = false;
                    }
                }
                else
                {
                    if (_currentDrawModel.Pos == new Vector3(-42f, -42f))
                    {
                        // _endDrawMark();
                        StartCoroutine(_waitCoroutine(0.01f, _endDrawMark));// Для того, что бы мы увидели последнюю созданную точку, ставим задержку 0.01
                        return;
                    }
                }
            }

            StartCoroutine(_waitCoroutine(0.01f, _drawXMark));
        }
コード例 #3
0
    /// <summary>
    /// Releases bullet (back to pool or destroy).
    /// </summary>
    public void ReleaseBullet(UbhBullet bullet, bool destroy = false)
    {
        if (bullet == null || bullet.gameObject == null)
        {
            return;
        }

        bullet.OnFinishedShot();

        UbhBulletManager.instance.RemoveBullet(bullet);

#if USING_CORE_GAME_KIT
        // +++++ Replace PoolingSystem with DarkTonic's CoreGameKit. +++++
        InitializePoolBoss();
        PoolBoss.Despawn(bullet.transform);
#else
        if (destroy)
        {
            Destroy(bullet.gameObject);
            Destroy(bullet);
            bullet = null;
            return;
        }
        bullet.SetActive(false);
#endif
    }
コード例 #4
0
 // ReSharper disable once UnusedMember.Local
 void Update()
 {
     if (!_particles.IsAlive())
     {
         PoolBoss.Despawn(_trans);
     }
 }
コード例 #5
0
        public void ReceiveEvent(string customEventName, Vector3 eventOrigin)
        {
            switch (eventReceivedBehavior)
            {
            case EventReceivedBehavior.None:
                break;

            case EventReceivedBehavior.Despawn:
                PoolBoss.Despawn(Trans);
                break;

            case EventReceivedBehavior.DealXDamage:
                if (Kill == null)
                {
                    LogNoKillable();
                    break;
                }

                Kill.TakeDamage(1);

                break;

            case EventReceivedBehavior.Destroy:
                if (Kill == null)
                {
                    LogNoKillable();
                    break;
                }

                Kill.DestroyKillable();

                break;
            }
        }
コード例 #6
0
    // Update is called once per frame
    void Update()
    {
        var moveAmt = Input.GetAxis("Horizontal") * MOVE_SPEED * Time.deltaTime;

        if (moveAmt == 0)
        {
            this.rend.materials[0].mainTexture = stableShip;
        }
        else if (moveAmt > 0)
        {
            this.rend.materials[0].mainTexture = rightShip;
        }
        else
        {
            this.rend.materials[0].mainTexture = leftShip;
        }

        var pos = this.trans.position;

        pos.x += moveAmt;
        this.trans.position = pos;

        if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Space))
        {
            var spawnPos = this.trans.position;
            spawnPos.z += 15;

            if (!string.IsNullOrEmpty(customEventName) && LevelSettings.CustomEventExists(customEventName))
            {
                LevelSettings.FireCustomEvent(customEventName, this.trans);
            }
            PoolBoss.SpawnOutsidePool(ProjectilePrefab.transform, spawnPos, ProjectilePrefab.transform.rotation);
        }
    }
コード例 #7
0
    private IEnumerator PropegateWave(float force)
    {
        PoolBoss.Spawn(GameManager.Instance.TsunamiFX.transform, transform.position, Quaternion.identity, null, true);
        WaveManager.Instance.ResetRecedeTimer();
        yield return(new WaitForSeconds(0.8f));

        GridCell[] neighbours = GridManager.Instance.GetNeighbors(Coordinates);
        for (int i = 0; i < neighbours.Length; i++)
        {
            if (neighbours[i].IsOccupied)
            {
                if (neighbours[i].Occupant.Coordinates.y > Coordinates.y)
                {
                    neighbours[i].Occupant.Tsunami(force);
                }
                else
                {
                    if (neighbours[i].Occupant.Attachment == null)
                    {
                        neighbours[i].Occupant.Tsunami(force);
                    }
                    else
                    {
                        neighbours[i].Occupant.Tsunami(0.25f);
                    }
                }
            }
        }
    }
コード例 #8
0
    /// <summary>
    /// Releases all bullet (back to pool or destroy).
    /// </summary>
    public void ReleaseAllBullet(bool destroy = false)
    {
#if USING_CORE_GAME_KIT
        // +++++ Replace PoolingSystem with DarkTonic's CoreGameKit. +++++
        InitializePoolBoss();
        foreach (Transform transPrefab in m_poolPrefabTransformList)
        {
            if (transPrefab != null)
            {
                PoolBoss.DespawnAllOfPrefab(transPrefab);
            }
        }
        m_poolPrefabTransformList.Clear();
#else
        foreach (PoolingParam poolParam in m_pooledBulletDic.Values)
        {
            if (poolParam.m_bulletList != null)
            {
                for (int i = 0; i < poolParam.m_bulletList.Count; i++)
                {
                    UbhBullet bullet = poolParam.m_bulletList[i];
                    if (bullet != null && bullet.gameObject != null && bullet.isActive)
                    {
                        ReleaseBullet(bullet, destroy);
                    }
                }
            }
        }
#endif
    }
コード例 #9
0
    private IEnumerator ShowRoutine(Text messageLabel)
    {
        messageLabel.transform.localScale = Vector3.zero;

        Hashtable ht = new Hashtable();

        ht.Add("time", 0.25f);
        ht.Add("scale", Vector3.one);
        ht.Add("easetype", iTween.EaseType.easeOutBack);

        iTween.ScaleTo(messageLabel.gameObject, ht);

        yield return(new WaitForSeconds(2.0f));

        ht["time"]     = 0.1f;
        ht["scale"]    = Vector3.zero;
        ht["easetype"] = iTween.EaseType.easeInQuad;

        iTween.ScaleTo(messageLabel.gameObject, ht);

        yield return(new WaitForSeconds(0.3f));

        _messages.Remove(messageLabel);

        PoolBoss.Despawn(messageLabel.transform);
    }
コード例 #10
0
    /// <summary>
    /// Remove object pool.
    /// </summary>
    public void RemovePool(GameObject goPrefab)
    {
#if USING_CORE_GAME_KIT
        // +++++ Replace PoolingSystem with DarkTonic's CoreGameKit. +++++
        InitializePoolBoss();
        PoolBoss.DestroyPoolItem(goPrefab.transform);
        m_poolPrefabTransformList.Remove(goPrefab.transform);
#else
        int key = goPrefab.GetInstanceID();
        if (m_pooledBulletDic.ContainsKey(key) == false)
        {
            return;
        }

        PoolingParam poolParam = m_pooledBulletDic[key];
        poolParam.m_searchStartIndex = 0;

        for (int i = 0; i < poolParam.m_bulletList.Count; i++)
        {
            Destroy(poolParam.m_bulletList[i].gameObject);
            Destroy(poolParam.m_bulletList[i]);
            poolParam.m_bulletList[i] = null;
        }
        poolParam.m_bulletList.Clear();
#endif
    }
コード例 #11
0
    private IEnumerator DestroyBalls()
    {
        yield return(new WaitForEndOfFrame());

        var nextState = GameState.BallDrawNext;

        UpdateLinkedBalls2();

        foreach (var ball in _board)
        {
            if (!ball.IsActive() || ball.IsLinked)
            {
                continue;
            }

            nextState = GameState.BoardMovingDown;

            ball.SetState(BallState.None);

            var ballFall = PoolBoss.SpawnInPool("ball", ball.transform.position, Quaternion.identity).GetComponent <Ball>();
            ballFall.CopyFrom(ball);
            ballFall.SetState(BallState.Fall);
        }

        if (nextState == GameState.BoardMovingDown)
        {
            SoundManager.Instance.PlayFall();
        }

        State = nextState;
        // State = GameState.BallDrawNext;
    }
コード例 #12
0
    public T Spawn <T>(ConfigurableObject template, Transform parent = null, Vector3?position = null) where T : ConfigurableObject
    {
        T retObject = PoolBoss.Spawn(template.transform, Vector3.zero, Quaternion.identity, null, false).GetComponent <T>();

        if (retObject != null)
        {
            if (parent != null)
            {
                retObject.transform.SetParent(parent);
            }
            if (position.HasValue)
            {
                retObject.transform.position = position.Value;
            }

            retObject.gameObject.SetActive(true);

            ISpawnableObject[] spawnListeners = retObject.GetComponents <ISpawnableObject>();

            if (spawnListeners != null && spawnListeners.Length > 0)
            {
                for (int i = 0; i < spawnListeners.Length; ++i)
                {
                    spawnListeners[i].OnSpawned();
                }
            }

            return(retObject);
        }
        else
        {
            Debug.LogError("Could not spawn template!");
            return(null);
        }
    }
コード例 #13
0
    /// <summary>
    /// Get active bullets list.
    /// </summary>
    public List <UbhBullet> GetActiveBulletsList(GameObject goPrefab)
    {
        int key = goPrefab.GetInstanceID();
        List <UbhBullet> findList = null;

#if USING_CORE_GAME_KIT
        // +++++ Replace PoolingSystem with DarkTonic's CoreGameKit. +++++
        InitializePoolBoss();
        if (PoolBoss.Instance.poolItems != null && PoolBoss.Instance.poolItems.Count > 0)
        {
            for (int i = 0; i < PoolBoss.Instance.poolItems.Count; i++)
            {
                if (PoolBoss.Instance.poolItems[i].prefabTransform.gameObject.GetInstanceID() == key)
                {
                    var poolIteminfo = PoolBoss.PoolItemInfoByName(PoolBoss.Instance.poolItems[i].prefabTransform.gameObject.name);
                    if (poolIteminfo != null && poolIteminfo.SpawnedClones != null && poolIteminfo.SpawnedClones.Count > 0)
                    {
                        for (int k = 0; k < poolIteminfo.SpawnedClones.Count; k++)
                        {
                            if (poolIteminfo.SpawnedClones[k] == null)
                            {
                                continue;
                            }
                            var bullet = poolIteminfo.SpawnedClones[k].GetComponent <UbhBullet>();
                            if (bullet == null)
                            {
                                continue;
                            }
                            if (findList == null)
                            {
                                findList = new List <UbhBullet>(1024);
                            }
                            findList.Add(bullet);
                        }
                    }
                }
            }
        }
#else
        if (m_pooledBulletDic.ContainsKey(key))
        {
            PoolingParam poolParam = m_pooledBulletDic[key];

            for (int i = 0; i < poolParam.m_bulletList.Count; i++)
            {
                UbhBullet bullet = poolParam.m_bulletList[i];
                if (bullet != null && bullet.gameObject != null && bullet.isActive)
                {
                    if (findList == null)
                    {
                        findList = new List <UbhBullet>(1024);
                    }
                    findList.Add(poolParam.m_bulletList[i]);
                }
            }
        }
#endif
        return(findList);
    }
コード例 #14
0
        public void FindPoolItemName()
        {
            if (!string.IsNullOrEmpty(poolItemName))
            {
                return;
            }

            poolItemName = PoolBoss.GetPrefabShortName(name);
        }
コード例 #15
0
    private DanmakuBullet CreateBullet(BulletModel bulletModel)
    {
        // Core GameKit Integration

        Transform     bulletTransform = PoolBoss.Spawn(ProjectilePrefab.transform, new Vector3(0, 0, 0), new Quaternion(0, 0, 0, 0), PoolBoss.Instance.transform);
        DanmakuBullet bullet          = bulletTransform.GetComponentInChildren <DanmakuBullet>();

        return(bullet);
    }
コード例 #16
0
        private IEnumerator WaitUntilTimeUp()
        {
            yield return(_timerDelay);

            if (listener != null)
            {
                listener.Despawning(_trans);
            }
            PoolBoss.Despawn(_trans);
        }
コード例 #17
0
    public void Show(string message)
    {
        Text messageLabel = PoolBoss.Spawn(_messageLabelPrefab.transform, transform.position, Quaternion.identity, transform, false).GetComponent <Text>();

        messageLabel.rectTransform.localPosition = Vector3.zero;
        messageLabel.transform.localScale        = Vector3.one;

        messageLabel.text = message;
        _messages.Add(messageLabel);
        _animations.Add(Job.Create(ShowRoutine(messageLabel)));
    }
コード例 #18
0
        private void SpawnPlayer()
        {
            _player = PoolBoss.SpawnOutsidePool(PlayerPrefab, _playerPosition, PlayerPrefab.transform.rotation);

            var spawnPos = _playerPosition + RespawnParticleOffset;

            if (RespawnParticlePrefab != null)
            {
                PoolBoss.SpawnInPool(RespawnParticlePrefab, spawnPos, RespawnParticlePrefab.transform.rotation);
            }
        }
コード例 #19
0
    public void FlushMessages()
    {
        for (int i = 0; i < _animations.Count; ++i)
        {
            _animations[i].Kill();
        }

        for (int i = 0; i < _messages.Count; ++i)
        {
            PoolBoss.Despawn(_messages[i].transform);
        }
    }
コード例 #20
0
 protected override void OnDeselected()
 {
     if (_gridObject.HasBeenPlaced)
     {
         resetObject();
         base.OnDeselected();
     }
     else
     {
         PoolBoss.Despawn(_gridObject.transform);
     }
 }
コード例 #21
0
 /// <summary>
 /// Initialize CoreGameKit's PoolBoss
 /// </summary>
 private void InitializePoolBoss()
 {
     if (m_poolBoss == null)
     {
         // PoolBoss Initialize
         m_poolBoss = FindObjectOfType <PoolBoss>();
         if (m_poolBoss == null)
         {
             m_poolBoss = new GameObject(typeof(PoolBoss).Name).AddComponent <PoolBoss>();
         }
         m_poolBoss.autoAddMissingPoolItems = true;
     }
 }
コード例 #22
0
    /// <summary>
    /// Releases game object (back to pool or destroy).
    /// </summary>
    public void ReleaseGameObject(GameObject go, bool destroy = false)
    {
#if USING_CORE_GAME_KIT
        // +++++ Replace PoolingSystem with DarkTonic's CoreGameKit. +++++
        PoolBoss.Despawn(go.transform);
#else
        if (destroy)
        {
            Destroy(go);
            return;
        }
        go.SetActive(false);
#endif
    }
コード例 #23
0
        private void Despawn(TriggeredSpawner.EventType eType)
        {
            if (LevelSettings.AppIsShuttingDown || _isDespawning)
            {
                return;
            }

            _isDespawning = true;

            if (listener != null)
            {
                listener.Despawning(eType, _trans);
            }

            PoolBoss.Despawn(_trans);
        }
コード例 #24
0
    /// <summary>
    /// Remove object pool.
    /// </summary>
    public void RemovePool(GameObject goPrefab)
    {
#if USING_CORE_GAME_KIT
        // +++++ Replace PoolingSystem with DarkTonic's CoreGameKit. +++++
        InitializePoolBoss();
        Transform transPrefab = goPrefab.transform;
        PoolBoss.DestroyPoolItem(transPrefab);
        m_poolPrefabTransformList.Remove(transPrefab);
#else
        int key = goPrefab.GetInstanceID();
        if (m_pooledBulletDic.ContainsKey(key))
        {
            PoolingParam poolParam = m_pooledBulletDic[key];
            RemovePoolParam(poolParam);
        }
#endif
    }
コード例 #25
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        if (coll.gameObject.name.Contains("Pony"))
        {
            coll.enabled = false;
            _addNewPony(coll.transform);
        }

        if (coll.gameObject.name.Equals("SafeZone")) // Заходим в зону - оставляем овечек там
        {
            for (int i = 0; i < _ponyTransformList.Count; i++)
            {
                PonyCreation.PonyCatch();
                PoolBoss.Despawn(_ponyTransformList[i]);
            }
            _ponyTransformList = new List <Transform>();
        }
    }
コード例 #26
0
    private void ClearAllPeaks()
    {
        for (var i = 0; i < _pool.poolItems.Count; i++)
        {
            var poolItem = _pool.poolItems[i].prefabTransform;
            if (poolItem == null)
            {
                continue;
            }

            var item = PoolBoss.PoolItemInfoByName(poolItem.name);
            item.Peak     = Math.Max(0, item.SpawnedClones.Count);
            item.PeakTime = Time.realtimeSinceStartup;
        }

        _isDirty = true;
        _pool._changes++;
    }
コード例 #27
0
 /// <summary>
 /// Resets the object to its last valid coordinates, and clears the visualization for it.
 /// </summary>
 protected void resetObject()
 {
     if (_isPlacing)
     {
         GridManager.Instance.ClearVisualization(_gridObject);
         _gridObject.transform.position = GridManager.Instance.GetCell(_gridObject.Coordinates).transform.position;
         if (GridManager.Instance.CanBePlaced(_gridObject))
         {
             placeObject();
         }
         else
         {
             Debug.LogWarning("Could not find a valid placement to return object '" + _gridObject.name + "' to. Destroying.");
             PoolBoss.Despawn(_gridObject.transform);
         }
         _dragging  = false;
         _isPlacing = false;
     }
     setHighlight();
 }
コード例 #28
0
    /// <summary>
    /// Remove all object pool.
    /// </summary>
    public void RemoveAllPool()
    {
#if USING_CORE_GAME_KIT
        // +++++ Replace PoolingSystem with DarkTonic's CoreGameKit. +++++
        InitializePoolBoss();
        foreach (Transform transPrefab in m_poolPrefabTransformList)
        {
            if (transPrefab != null)
            {
                PoolBoss.DestroyPoolItem(transPrefab);
                m_poolPrefabTransformList.Remove(transPrefab);
            }
        }
        m_poolPrefabTransformList.Clear();
#else
        foreach (PoolingParam poolParam in m_pooledBulletDic.Values)
        {
            RemovePoolParam(poolParam);
        }
#endif
    }
コード例 #29
0
    /// <summary>
    /// Создаём понни, и рекурсию заодно, выходим по достижению 200 понни
    /// </summary>
    private void _createPony()
    {
        if (PonyCreated > 199)
        {
            _stopCreation = true;
            return;
        }

        PonyCreated++;
        Vector2 randPos = new Vector2(Random.Range(0, Screen.width), Random.Range(0, Screen.height));

        while (_safeRect.Contains(randPos))
        {
            randPos = new Vector2(Random.Range(0, Screen.width), Random.Range(0, Screen.height));
        }
        Transform spawned = PoolBoss.Spawn(PonyPrefab, randPos, new Quaternion(), PonyParent);

        spawned.GetComponent <Collider2D>().enabled = true;

        StartCoroutine(_waitCoroutine(0.5f, _createPony));
    }
コード例 #30
0
    void OnGUI()
    {
        GUI.Label(new Rect(10, 10, 760, 90), "Click the button below to spawn 10 Robot Kyles at a time until you have 50. There are 50 in the pool, so they will spawn instantly with no impact on performance! You can watch them become active under the Pool Boss game object. If you try to spawn more than 50, Pool Boss will refuse and log an error in the Console. There is an option to 'Allow Instantiate More' that you can turn on though. Select the Pool Boss game object for more information and functions on the pool items at runtime.");

        if (GUI.Button(new Rect(10, 80, 100, 30), "Spawn 10"))
        {
            for (var i = 0; i < 10; i++)
            {
                PoolBoss.SpawnInPool(robotKylePrefab, spawnPos, robotKylePrefab.rotation);
                spawnPos += new Vector3(40, 0, 0);
            }

            spawnPos.y  = 0;
            spawnPos.z -= 100;
            spawnPos.x  = -150;
        }

        if (GUI.Button(new Rect(10, 120, 100, 30), "Despawn All"))
        {
            PoolBoss.DespawnAllOfPrefab(robotKylePrefab);
            spawnPos = new Vector3(-150, 0, 150);
        }
    }