/// <summary> /// スキル攻撃の攻撃範囲を取得 /// </summary> /// <param name="skillAttackType"> スキル攻撃のタイプ</param> /// <returns> 攻撃範囲</returns> protected List <Vector2Int> GetSkillAttackRange(SkillAttackType skillAttackType) { List <Vector2Int> ret = new List <Vector2Int>(); switch (skillAttackType) { case SkillAttackType.HeavyAttack: ret = GetHeavyAttackRange(); break; case SkillAttackType.RotaryAttack: ret = GetRotaryAttackRange(); break; case SkillAttackType.ThrustAttack: ret = GetThrustAttackRange(); break; case SkillAttackType.MowDownAttack: ret = GetMowDownAttackRange(); break; default: Debug.LogError("攻撃範囲エラー" + skillAttackType); break; } return(ret); }
// Start is called before the first frame update new void Start() { StatusLoad(); base.Start(); _type = CharacterType.Player; _id = 0; _name = "<color=#ffff00>プレイヤー</color>"; _itemList = new List <Item>(); _skillAttackSlot = new SkillAttackType[4]; UIManager.instance.GetSkillMenu().SetSkill(0, (int)SkillAttackType.ThrustAttack); UIManager.instance.GetSkillMenu().SetSkill(1, (int)SkillAttackType.RotaryAttack); UIManager.instance.GetSkillMenu().SetSkill(2, (int)SkillAttackType.HeavyAttack); UIManager.instance.GetSkillMenu().SetSkill(3, (int)SkillAttackType.MowDownAttack); _skillAttackSlot[0] = SkillAttackType.ThrustAttack; _skillAttackSlot[1] = SkillAttackType.RotaryAttack; _skillAttackSlot[2] = SkillAttackType.HeavyAttack; _skillAttackSlot[3] = SkillAttackType.MowDownAttack; _visibleRect = new Rect(2, 2, 2, 2); _camera = Camera.main.GetComponent <FollowCamera>(); }
protected override int SkillAttack(SkillAttackType skillType) { var ret = base.SkillAttack(skillType); _dir = GetTargetDir(_player.transform.position); transform.rotation = Quaternion.Euler(0, (float)_dir, 0); return(ret); }
/// <summary> /// 攻击多个敌人 /// </summary> /// <param name="atk"></param> public virtual void MeleeMultiplayerAttack(SkillAttackType atk) { if (atk.SkillAttackJudgeAreaType == 3) { Vector3 center = new Vector3(0, 0, 0); float angleRadian = (float)(dir * 15f * Math.PI / 180.0f); float hudu = (float)(atk.AttackJudgeAreaAngle * Math.PI / 180.0f); //扇形中心 center.z = pos.z + (float)(atk.SkillAttackJudgeDistance * Math.Cos(angleRadian)); center.x = pos.x + (float)(atk.SkillAttackJudgeDistance * Math.Sin(angleRadian)); center.y = pos.y; //扇形正前方最远点 Vector3 centerTo = new Vector3(0, 0, 0); centerTo.z = center.z + (float)(atk.SkillAttackJudgeAreaRadius * Math.Cos(angleRadian)); centerTo.x = center.x + (float)(atk.SkillAttackJudgeAreaRadius * Math.Sin(angleRadian)); centerTo.y = center.y; foreach (var t in Logic.obinfmp) { var e = t.Value; if (tag == e.tag || e.curCreatureData.curHP <= 0) { continue; } if (Judge.IsCircleIntersectFan( e.pos.z, e.pos.x, e.curCreatureData.Radius, center.z, center.x, centerTo.z, centerTo.x, hudu)) { e.ToBeAttacked(atk.SkillAttackJudgeDamageRatio * curCreatureData.Attack, name, atk.AAF, pos); } } } else if (atk.SkillAttackJudgeAreaType == 2) { foreach (var t in Logic.obinfmp) { var e = t.Value; if (tag == e.tag || e.curCreatureData.curHP == 0) { continue; } if (Vector3.Distance(pos, e.pos) <= atk.SkillAttackJudgeAreaRadius + e.curCreatureData.Radius) { e.ToBeAttacked(atk.SkillAttackJudgeDamageRatio * curCreatureData.Attack, name, atk.AAF, pos); } } } }
/// <summary> /// スキル攻撃 /// </summary> /// <param name="skillType"> スキル攻撃のタイプ</param> /// <param name="attackPosList"> 攻撃範囲</param> /// <returns> 獲得経験値</returns> protected virtual int SkillAttack(SkillAttackType skillType) { //foreach (var trail in _trailRenderers) //{ // if (trail != null) // { // trail.emitting = true; // } //} transform.rotation = Quaternion.Euler(0, (float)_dir, 0); var data = _skillAttackData[(int)skillType]; UIManager.instance.AddText(_name + "の" + data.name); CpAdd(data.cost); var attackPosList = GetSkillAttackRange(skillType); int ret = 0; foreach (var attackPos in attackPosList) { var characterNo = _dungeonManager._floor.GetCharacterData(attackPos); if (characterNo != -1) { Character target; if (characterNo == 0) { target = _dungeonManager._player; } else { if (_id != 0) { continue; } target = _dungeonManager._floor._enemies[characterNo - 1]; } if (target.Damage(_atk + data.addAtk, target._def)) { ret += target._exp; } } } return(ret); }
/// <summary> /// このターンの行動をスキル攻撃に決定 /// </summary> /// <param name="skillAttackType"> セットするスキル攻撃のタイプ</param> protected void SetSkillAttackAction(SkillAttackType skillAttackType) { string animName = string.Empty; switch (skillAttackType) { case SkillAttackType.RotaryAttack: SkillAttackFunc = RotaryAttack; animName = "RotaryAttackTrigger"; break; case SkillAttackType.HeavyAttack: SkillAttackFunc = HeavyAttack; animName = "HeavyAttackTrigger"; break; case SkillAttackType.ThrustAttack: SkillAttackFunc = ThrustAttack; animName = "ThrustAttackTrigger"; break; case SkillAttackType.MowDownAttack: SkillAttackFunc = MowDownAttack; animName = "MowDownAttackTrigger"; break; default: Debug.LogError("技選択エラー" + skillAttackType); break; } Action action = () => { foreach (var trail in _trailRenderers) { if (trail != null) { trail.emitting = true; } } _animator.SetTrigger(animName); }; SetActFunc(action); _thinkEnd = true; }
private IEnumerator UseSkillRoutine( CharacterSkill characterSkill, Vector3 position, float triggerDuration, float totalDuration, SkillAttackType skillAttackType, CharacterItem weapon, DamageInfo damageInfo, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts) { // Update skill usage states var newSkillUsage = CharacterSkillUsage.Create(SkillUsageType.Skill, characterSkill.dataId); newSkillUsage.Use(this, characterSkill.level); skillUsages.Add(newSkillUsage); yield return(new WaitForSecondsRealtime(triggerDuration)); ApplySkill(characterSkill, position, skillAttackType, weapon, damageInfo, allDamageAmounts); yield return(new WaitForSecondsRealtime(totalDuration - triggerDuration)); }
protected override void ApplySkill(CharacterSkill characterSkill, Vector3 position, SkillAttackType skillAttackType, CharacterItem weapon, DamageInfo damageInfo, Dictionary <DamageElement, MinMaxFloat> allDamageAmounts) { base.ApplySkill(characterSkill, position, skillAttackType, weapon, damageInfo, allDamageAmounts); var skill = characterSkill.GetSkill(); switch (skill.skillType) { case SkillType.CraftItem: GameMessage.Type gameMessageType; if (!skill.itemCraft.CanCraft(this, out gameMessageType)) { GameManager.SendServerGameMessage(ConnectionId, gameMessageType); } else { skill.itemCraft.CraftItem(this); } break; } }
/// <summary> /// 攻击敌人 /// </summary> /// <param name="e"></param> public virtual void Attack(SkillAttackType atk) { }
// /// <summary> /// 使用技能 /// </summary> /// <param name="useSkillIdex">使用的技能在当前生物可用技能表中的下标</param> public virtual bool ToUseSkill(int useSID) { //技能冷却、MP判定 if (Logic.time - SkillLastFireTime[useSID] < curSkillDataList[useSID].CoolingTime) { return(false); //技能未冷却 } if (curCreatureData.curMP < curSkillDataList[useSID].CostMP) { return(false); //MP不足 } //询问状态机状态是否能够改变 if (!curFSM.ChangeState(curSkillDataList[useSID].StateName)) { return(false); //不可更改为当前技能; } //更改当前正在释放的技能为请求释放的技能 curSID = useSID; //技能进入冷却时间 SkillReset(curSID); curCreatureData.curMP -= curSkillDataList[useSID].CostMP; //--------------------------------攻击属性---------------------------------------------------------------- foreach (var t in curSkillDataList[useSID].ATKs) { SkillAttackType e = t; timer.Add((Logic.time + e.SkillAttackJudgeBeginTime, delegate() { MeleeMultiplayerAttack(e); })); } //--------------------------------BUFF属性---------------------------------------------------------------- foreach (var t in curSkillDataList[useSID].BUFFs) { SkillBUFFType e = t; timer.Add((Logic.time + e.BeginTime, delegate(){ for (int i = 0; i < e.RoleTimes; i++) { int j = i; BUFFtimer.Add((Logic.time + e.BeginTime + j * e.EachRoleTime, delegate() { if ((e.RoleAttribute & 1) != 0) { HPRecover(e.EffectValue); //curCreatureData.curHP += e.EffectValue; //if(curCreatureData.curHP>curCreatureData.maxMP) curCreatureData.curHP = curCreatureData.maxHP; } if ((e.RoleAttribute & 2) != 0) { MPRecover(e.EffectValue); //curCreatureData.curMP += e.EffectValue; //if(curCreatureData.curMP>curCreatureData.maxMP) curCreatureData.curMP = curCreatureData.maxMP; } if ((e.RoleAttribute & 4) != 0) { //curCreatureData.Speed *= e.EffectRatio>1?0:(1-e.EffectRatio); SpeedChange(e.EffectRatio); } if ((e.RoleAttribute & 8) != 0) { //curCreatureData.Defence *= e.EffectRatio>1?0:(1-e.EffectRatio); DefenceChange(e.EffectRatio); } if ((e.RoleAttribute & 16) != 0) { //curCreatureData.Attack *= e.EffectRatio>1?0:(1-e.EffectRatio); AttackChange(e.EffectRatio); } })); if (e.IfRecycle) { BUFFtimer.Add((Logic.time + e.BeginTime + e.RoleTimes * e.EachRoleTime, delegate() { if ((e.RoleAttribute & 1) != 0) { HPRecover(-e.EffectValue * e.RoleTimes); //curCreatureData.curHP -= e.EffectValue*e.RoleTimes; } if ((e.RoleAttribute & 2) != 0) { MPRecover(-e.EffectValue * e.RoleTimes); //curCreatureData.curMP -= e.EffectValue*e.RoleTimes; } if ((e.RoleAttribute & 4) != 0) { //curCreatureData.Speed *= e.EffectRatio>1?0:(1-e.EffectRatio); SpeedChange(-e.EffectRatio); } if ((e.RoleAttribute & 8) != 0) { //curCreatureData.Defence *= e.EffectRatio>1?0:(1-e.EffectRatio); DefenceChange(-e.EffectRatio); } if ((e.RoleAttribute & 16) != 0) { //curCreatureData.Attack *= e.EffectRatio>1?0:(1-e.EffectRatio); AttackChange(-e.EffectRatio); } })); } } })); } //--------------------------------子弹属性---------------------------------------------------------------- foreach (var t in curSkillDataList[useSID].Bullets) { SkillBulletType e = t; timer.Add((Logic.time + e.BulletFireTime, delegate() { BulletsManager.CreateBullet(name, e); })); } //--------------------------------位移属性---------------------------------------------------------------- foreach (var t in curSkillDataList[useSID].MOVEs) { SkillMoveType e = t; for (float i = 0; i < e.DuringTime; i += Logic.eachframtime) { timer.Add((Logic.time + e.BeginTime + i, delegate() { Move(e.Speed); //float angle = 15.0f * dir; //float f = (float)(angle*Math.PI/180.0f); //pos += (new Vector3((float)Math.Sin(f),0,(float)Math.Cos(f)))*((float)(e.Speed*Logic.eachframtime)); //rot = new Vector3(0,15.0f*dir,0); })); } } //curSkillStage = (0,0,0); //技能释放成功 //Debug.Log("use skill " + useSID); return(true); }