private void _OnShoot(Vector2 bornPos, Vector2 shootDic, Transform parent) //射击 { var born = _instancePool.GetInstance(_bornPrefab); born.GetComponent <BulletBornEffect>().OnFinish += () => { _ReturnInstance(born); }; born.transform.position = new Vector3(bornPos.x, bornPos.y, -1); born.transform.SetParent(parent); var bullet = _instancePool.GetInstance(_bulletPrefab); bullet.transform.position = _GetOffsetPos(bornPos); bullet.GetComponent <Bullet>().OnFinish += () => { _ReturnInstance(bullet); }; bullet.GetComponent <Bullet>().StartMove(shootDic, (int)BulletType.Normal); }
private GameObject _GetDustInstance(EffectType rType) //根据灰尘的种类获取对应的灰尘预制体 { switch (rType) { case EffectType.WalkDust: int index = Random.Range(0, 3); return(_instancePool.GetInstance(_dustPrefabList[index])); case EffectType.DashDust: return(_instancePool.GetInstance(_dashDustPrefab)); case EffectType.GroundDust: return(_instancePool.GetInstance(_groundDustPrefab)); case EffectType.ExplosionDust: return(_instancePool.GetInstance(_explosionDustPrefab)); case EffectType.ExplosionDustBornEffect: return(_instancePool.GetInstance(_explosionDustBornEffectPrefab)); case EffectType.PlayerHitEffect: return(_instancePool.GetInstance(_hitEffectPrefab)); case EffectType.DeathDust: return(_instancePool.GetInstance(_deathDustPrefab)); case EffectType.SoulFloatingEffect: return(_instancePool.GetInstance(_floatingSoulPrefab)); } return(null); }
public void GetCloudInstance(int num, GameObject go) { var startPos = _GetStartPos(num); var instanceToPool = _instancePool.GetInstance(go).GetComponent <Cloud>(); Vector3 newStartPos = new Vector3(startPos.x, startPos.y, go.transform.position.z); instanceToPool.ResetPos(newStartPos, instanceToPool.CurrentType, this); }
private void _OnShoot(int bulletType) //射击 { var ran = Random.Range(0, 2); var born = _instancePool.GetInstance(_bornDustPrefab); born.GetComponent <BulletBornEffect>().OnFinish += () => { _ReturnInstance(born); }; born.transform.position = _bulletDustPos.position; born.transform.SetParent(_instancePool.transform); if (ran == 1) { var scale = born.transform.localScale; scale.y *= -1; born.transform.localScale = scale; } var bullet = _GetCurrentInstance(bulletType); bullet.transform.position = _bulletPos.position; bullet.GetComponent <PotatoBullet>().OnFinish += () => { _ReturnInstance(bullet); }; bullet.GetComponent <PotatoBullet>().Init(); }