Exemplo n.º 1
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));
        }
Exemplo n.º 2
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);
        }
    }
Exemplo n.º 3
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);
                    }
                }
            }
        }
    }
Exemplo n.º 4
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);
    }
Exemplo n.º 5
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)));
    }
    /// <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));
    }
Exemplo n.º 7
0
    /// <summary>
    /// Get Bullet from object pool or instantiate.
    /// </summary>
    public UbhBullet GetBullet(GameObject goPrefab, Vector3 position, bool forceInstantiate = false)
    {
        if (goPrefab == null)
        {
            return(null);
        }

        UbhBullet bullet = null;

#if USING_CORE_GAME_KIT
        // +++++ Replace PoolingSystem with DarkTonic's CoreGameKit. +++++
        InitializePoolBoss();
        Transform trans = PoolBoss.Spawn(goPrefab.transform, position, UbhUtil.QUATERNION_IDENTITY, transform);
        if (trans == null)
        {
            return(null);
        }

        bullet = trans.gameObject.GetComponent <UbhBullet>();
        if (bullet == null)
        {
            bullet = trans.gameObject.AddComponent <UbhBullet>();
        }
#else
        int key = goPrefab.GetInstanceID();

        if (m_pooledBulletDic.ContainsKey(key) == false)
        {
            m_pooledBulletDic.Add(key, new PoolingParam());
        }

        PoolingParam poolParam = m_pooledBulletDic[key];

        if (forceInstantiate == false && poolParam.m_bulletList.Count > 0)
        {
            if (poolParam.m_searchStartIndex < 0 || poolParam.m_searchStartIndex >= poolParam.m_bulletList.Count)
            {
                poolParam.m_searchStartIndex = poolParam.m_bulletList.Count - 1;
            }

            for (int i = poolParam.m_searchStartIndex; i >= 0; i--)
            {
                if (poolParam.m_bulletList[i] == null || poolParam.m_bulletList[i].gameObject == null)
                {
                    poolParam.m_bulletList.RemoveAt(i);
                    continue;
                }
                if (poolParam.m_bulletList[i].isActive == false)
                {
                    poolParam.m_searchStartIndex = i - 1;
                    bullet = poolParam.m_bulletList[i];
                    bullet.SetActive(true);
                    break;
                }
            }
            if (bullet == null)
            {
                for (int i = poolParam.m_bulletList.Count - 1; i > poolParam.m_searchStartIndex; i--)
                {
                    if (poolParam.m_bulletList[i] == null || poolParam.m_bulletList[i].gameObject == null)
                    {
                        poolParam.m_bulletList.RemoveAt(i);
                        continue;
                    }
                    if (i < poolParam.m_bulletList.Count && poolParam.m_bulletList[i].isActive == false)
                    {
                        poolParam.m_searchStartIndex = i - 1;
                        bullet = poolParam.m_bulletList[i];
                        bullet.SetActive(true);
                        break;
                    }
                }
            }
        }

        if (bullet == null)
        {
            //edit by feng


            GameObject go = Instantiate(goPrefab, transform);
            bullet = go.GetComponent <UbhBullet>();
            if (bullet == null)
            {
                bullet = go.AddComponent <UbhBullet>();
            }
            poolParam.m_bulletList.Add(bullet);
            poolParam.m_searchStartIndex = poolParam.m_bulletList.Count - 1;
            bullet.SetActive(true);
        }

        bullet.transform.SetPositionAndRotation(position, UbhUtil.QUATERNION_IDENTITY);
#endif

        UbhBulletManager.instance.AddBullet(bullet);

        return(bullet);
    }
Exemplo n.º 8
0
    /// <summary>
    /// Get GameObject from object pool or instantiate.
    /// </summary>
    public GameObject GetGameObject(GameObject prefab, Vector3 position, Quaternion rotation, bool forceInstantiate = false)
    {
        if (prefab == null)
        {
            return(null);
        }

#if USING_CORE_GAME_KIT
        // +++++ Replace PoolingSystem with DarkTonic's CoreGameKit. +++++
        if (_PoolBoss == null)
        {
            // PoolBoss Initialize
            _PoolBoss = FindObjectOfType <PoolBoss>();
            if (_PoolBoss == null)
            {
                _PoolBoss = new GameObject(typeof(PoolBoss).Name).AddComponent <PoolBoss>();
            }
            _PoolBoss.autoAddMissingPoolItems = true;
        }
        return(PoolBoss.Spawn(prefab.transform, position, rotation, _Transform).gameObject);
#else
        int key = prefab.GetInstanceID();

        if (_PooledKeyList.Contains(key) == false && _PooledGoDic.ContainsKey(key) == false)
        {
            _PooledKeyList.Add(key);
            _PooledGoDic.Add(key, new List <GameObject>());
        }

        List <GameObject> goList = _PooledGoDic[key];
        GameObject        go     = null;

        if (forceInstantiate == false)
        {
            for (int i = goList.Count - 1; i >= 0; i--)
            {
                go = goList[i];
                if (go == null)
                {
                    goList.Remove(go);
                    continue;
                }
                if (go.activeSelf == false)
                {
                    // Found free GameObject in object pool.
                    Transform goTransform = go.transform;
                    goTransform.position = position;
                    goTransform.rotation = rotation;
                    go.SetActive(true);
                    return(go);
                }
            }
        }

        // Instantiate because there is no free GameObject in object pool.
        go = (GameObject)Instantiate(prefab, position, rotation);
        go.transform.parent = _Transform;
        goList.Add(go);

        return(go);
#endif
    }
Exemplo n.º 9
0
    void OnCollisionEnter(Collision collision)
    {
        m_playerShip.OnCollisionHitForAbilities(collision);
        MLandingAbility.MoverCollisionHitLogic(collision);
        LockOnCamera.Instance.PlayShakeEvent(m_collideEventData);

        for (int i = 0; i < collision.contacts.Length; ++i)
        {
            Vector3  vLoc   = collision.contacts[i].point;
            Collider hitCol = collision.contacts[i].thisCollider;

            if (hitCol == GetComponent <Collider>())
            {
                if (MLandingAbility.Landing || MLandingAbility.Landed)
                {
                    return;
                }

                bool bCollideDamageLayer = LayerMask.NameToLayer("Scenery") == collision.collider.gameObject.layer ||
                                           LayerMask.NameToLayer("Building") == collision.collider.gameObject.layer;
                //PlayEffect
                if (bCollideDamageLayer)
                {
                    m_collisionDamage.SetCollisionInfo(collision);
                    m_playerShip.HandleMod(m_collisionDamage);
                    m_playerShip.StealthMeter.ModifyCurrent(-Rigidbody.velocity.magnitude);
                    m_speedDamageMod.Amount = -m_playerShip.m_fSpeed;
                    LastCollisionVector     = collision.impulse / Time.fixedDeltaTime;
                    collision.gameObject.SendMessage("OnRammedByPlayer", m_speedDamageMod, SendMessageOptions.DontRequireReceiver);

                    MasterAudio.PlaySound(m_sOnRegularHit);
                }
                else if (LayerMask.NameToLayer("Water") == collision.collider.gameObject.layer)
                {
                    m_playerShip.StealthMeter.ModifyCurrent(-Rigidbody.velocity.magnitude);
                    Vector3 vAdded = m_playerShip.MTransform.forward;
                    vAdded.y = 0;
                    vAdded.Normalize();
                    vAdded *= 4f;
                    PoolBoss.Spawn(m_waterCollisionPrefab.transform, vLoc + vAdded, Quaternion.identity, null);
                }
                else if (LayerMask.NameToLayer("Actor") == collision.collider.gameObject.layer)
                {
                    m_playerShip.StealthMeter.ModifyCurrent((m_collisionDamage.Amount));
                }
                else if (LayerMask.NameToLayer("FlockingSpirits") == collision.collider.gameObject.layer)
                {
                    MasterAudio.PlaySound(m_sOnFlockingHit);

                    Transform mForm = PoolBoss.Spawn(m_impactEffect.transform, vLoc, Quaternion.identity, MTransform);
                    mForm.parent        = MTransform;
                    mForm.localPosition = MTransform.InverseTransformPoint(vLoc);
                }
                else if (LayerMask.NameToLayer("Vehicle") == collision.collider.gameObject.layer)
                {
                    MasterAudio.PlaySound(m_sOnVehicleHit);

                    Transform mForm = PoolBoss.Spawn(m_impactEffect.transform, vLoc, Quaternion.identity, MTransform);
                    mForm.parent        = MTransform;
                    mForm.localPosition = MTransform.InverseTransformPoint(vLoc);
                }
            }
        }
    }