コード例 #1
0
        public BulletView Create(uint bulletid, Vector3 startPos, Vector3 destPos, float duration)
        {
            Vector3 v = destPos - startPos;

            v.z = 0;
            var rotation = Quaternion.FromToRotation(Vector3.right, v);

            var data      = configMgr.GetBulletData(bulletid.ToString());
            var bulletObj = objMgr.Get(PoolNames.BULLET);

            if (bulletObj != null)
            {
                var bullet = new BulletView();
                bullet.Initialize(data, ++objId, destPos, rotation, duration);

                bulletObj.transform.SetParent(battleScene.transform);
                bulletObj.transform.SetLayer(Layers.Default);
                bulletObj.transform.position = startPos;
                bulletObj.AddComponent <ViewObject>().BindView(bullet);
                bulletObj.SetActive(true);

                mBullets.Add(objId, bullet);
                return(bullet);
            }
            return(null);
        }
コード例 #2
0
        public BulletView Create(string bulletName, long objId)
        {
            var data      = cfgMgr.GetBulletData(bulletName);
            var bulletObj = objMgr.Get(PoolNames.BULLET);

            if (bulletObj != null)
            {
                bulletObj.transform.SetParent(io.battleObject);
                bulletObj.transform.SetLayer(AppConst.GameplayLayer);

                var bullet = new BulletView();
                bullet.Initialize(data, objId);

                bulletObj.AddComponent <ViewObject>().BindView(bullet);

                mBullets.Add(objId, bullet);
                return(bullet);
            }
            return(null);
        }