Exemplo n.º 1
0
        // PUBLIC METHODS: ----------------------------------------------------

        public void Count(GameStatics.BULLET_TYPE type)
        {
            if (!counter.ContainsKey(type))
            {
                counter[type] = 1;
            }
            else
            {
                counter[type] += 1;
            }

            UpdateCounter();
            UpdateRenderer();
        }
Exemplo n.º 2
0
        // PRIVATE METHODS: ----------------------------------------------------

        private void UpdateCounter()
        {
            var count = 0;

            foreach (var pair in counter)
            {
                if (count < pair.Value)
                {
                    count = pair.Value;
                    type  = pair.Key;
                }
            }

            onCounter.Invoke((int)type);
        }
Exemplo n.º 3
0
    public virtual void Fire(GameStatics.BULLET_TYPE bulletType, float radius, float speed, float acceleration, Vector3 direction)
    {
        this.bulletType   = bulletType;
        this.radius       = radius;
        this.speed        = speed;
        this.acceleration = acceleration;

        Vector3 lookAtPoint  = this.transform.position;
        Vector3 directionVec = Vector3.zero;

        directionVec = direction.normalized;

        if (ViewPointManager.Instance != null)
        {
            ViewPointManager.Instance.OnViewChangedStartTo2D  += OnViewChangedStartTo2D;
            ViewPointManager.Instance.OnViewChangedStartTo3D  += OnViewChangedStartTo3D;
            ViewPointManager.Instance.OnViewChangedMiddleTo2D += OnViewChangedMiddleTo2D;
            ViewPointManager.Instance.OnViewChangedMiddleTo3D += OnViewChangedMiddleTo3D;
            ViewPointManager.Instance.OnViewChangedEndTo2D    += OnViewChangedEndTo2D;
            ViewPointManager.Instance.OnViewChangedEndTo3D    += OnViewChangedEndTo3D;

            SetObjectDimensional();

            if (ViewPointManager.Instance.currentViewPoint == ViewPoint.twoDimensional)
            {
                directionVec.y = 0;
            }
        }

        lookAtPoint += directionVec;

        this.transform.LookAt(lookAtPoint);

        this.curVelocity  = this.transform.forward * speed;
        this.curTimer     = 0;
        this.initPosition = new Vector3(this.transform.position.x, this.transform.position.y, this.transform.position.z);

        this.isFire = true;

        object_2d.transform.position = new Vector3(this.transform.position.x, 1, this.transform.position.z);

        viewChange2dEffect.gameObject.SetActive(false);
        viewChange3dEffect.gameObject.SetActive(false);

        isCheckCollide = true;
    }
Exemplo n.º 4
0
    public void FireBullet(GameStatics.BULLET_TYPE bulletType, Vector3 startWorldPos, float radius, float speed, float acceleration, Vector3 direction)
    {
        if (bulletPool == null)
        {
            return;
        }

        if (bulletPool.ContainsKey(bulletType))
        {
            bool poolLimitOver = true;
            foreach (GameObject go in bulletPool[bulletType])
            {
                if (go.activeSelf == false)
                {
                    go.transform.position = startWorldPos;
                    go.SetActive(true);
                    BulletBase bullet = go.GetComponent <BulletBase>();
                    bullet.Fire(bulletType, radius, speed, acceleration, direction);

                    poolLimitOver = false;
                    break;
                }
            }

            if (poolLimitOver == true)
            {
                GameObject newGo = CreateNewBullet(bulletType);

                newGo.transform.parent = bulletRoot.transform;

                newGo.transform.position = startWorldPos;
                newGo.SetActive(true);

                BulletBase bullet = newGo.GetComponent <BulletBase>();
                bullet.Fire(bulletType, radius, speed, acceleration, direction);

                bulletPool[bulletType].Add(newGo);
            }
        }
    }
Exemplo n.º 5
0
    private GameObject CreateNewBullet(GameStatics.BULLET_TYPE bulletType)
    {
        if (bulletInfoList == null)
        {
            return(null);
        }

        foreach (BulletInfo item in bulletInfoList)
        {
            if (item.bulletType == bulletType)
            {
                GameObject go         = Instantiate(item.prefab);
                BulletBase bulletBase = go.GetComponent <BulletBase>();
                bulletBase.onDestroy   = OnDestroyBullet;
                bulletBase.onCollision = CollisionManager.Instance.OnCollideWithObject;

                return(go);
            }
        }

        return(null);
    }