public override void Initialize() { temp = new GameObject().transform; _target = _caster.lockedTarget; // 求2支箭之间的角度 int angleNum = _skillBulletCfg.SplitNum - 1; float angle = _skillBulletCfg.SplitAngle / angleNum; temp.position = _target.transform.position; temp.RotateAround(_caster.position, temp.up, angle * -angleNum / 2); // 创建每支箭 for (int i = 0; i <= angleNum; i++) { Vector3 dir = (temp.position - _caster.position).normalized; temp.RotateAround(_caster.position, temp.up, angle); // 创建一支非指向型箭 SpellBulletNormal bullet = new SpellBulletNormal(_caster); bullet.SkillBasicCfg = _skillBasicCfg; bullet.SkillBulletCfg = _skillBulletCfg; //bullet.target = _target; bullet.Initialize(); bullet.SetDirection(dir); SkillManager.instance.AddSpell(_caster.GlobalID, bullet); } GameObject.Destroy(temp.gameObject); }
/// <summary> /// 创建子弹类技能 /// </summary> /// <param name="cfg"></param> /// <returns></returns> private Spell CreateBullet(SkillBulletCfg cfg) { Spell spell = null; switch (cfg.BulletType) { case BulletType.Cast: if (cfg.FlyTrack) { spell = new SpellBulletTrack(_caster); } else { spell = new SpellBulletNormal(_caster); } break; case BulletType.Multiple: spell = new SpellBulletMulti(_caster); break; case BulletType.Split: spell = new SpellBulletSplit(_caster); break; case BulletType.Bounce: break; case BulletType.Boomerang: spell = new SpellBulletBoomerang(_caster); break; } return(spell); }
public override void Initialize() { //// 求2支箭之间的角度 //int angleNum = _skillBulletCfg.SplitNum - 1; //float angle = _skillBulletCfg.SplitAngle / angleNum; //// 求中间一支箭的目标点 //Vector3 forwardPos = _caster.position + _caster.forward * _skillBulletCfg.FlyRange; //// 创建每支箭 //for (int i = 0; i <= angleNum; i++) //{ // // 求每支箭的朝向 // float radius = _skillBulletCfg.FlyRange; // float x = forwardPos.x + radius * Mathf.Sin((angle * i * Mathf.Deg2Rad)); // float z = forwardPos.z + radius * Mathf.Cos((angle * i * Mathf.Deg2Rad)); // Vector3 targetpos = new Vector3(x, _caster.position.y + 1f, z); // Vector3 dir = (targetpos - _caster.position).normalized; // // 创建一支非指向型箭 // SpellBulletNormal bullet = new SpellBulletNormal(_caster); // bullet.SkillBasicCfg = _skillBasicCfg; // bullet.SkillBulletCfg = _skillBulletCfg; // bullet.target = _target; // bullet.Initialize(); // bullet.SetDirection(dir); // Battle.instance.AddSpell(_caster.GlobalID, bullet); //} //_hited = true; temp = new GameObject().transform; _target = _caster.lockedTarget; // 求2支箭之间的角度 int angleNum = _skillBulletCfg.SplitNum - 1; float angle = _skillBulletCfg.SplitAngle / angleNum; temp.position = _target.transform.position; temp.RotateAround(_caster.position, temp.up, angle * -angleNum / 2); // 创建每支箭 for (int i = 0; i <= angleNum; i++) { Vector3 dir = (temp.position - _caster.position).normalized; temp.RotateAround(_caster.position, temp.up, angle); // 创建一支非指向型箭 SpellBulletNormal bullet = new SpellBulletNormal(_caster); bullet.SkillBasicCfg = _skillBasicCfg; bullet.SkillBulletCfg = _skillBulletCfg; //bullet.target = _target; bullet.Initialize(); bullet.SetDirection(dir); SkillManager.instance.AddSpell(_caster.GlobalID, bullet); } GameObject.Destroy(temp.gameObject); }