| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917 |
- using Spine.Unity;
- using Spine;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Sirenix.OdinInspector;
- public class Demonic : MoveCharacter
- {
- [FoldoutGroup("组件")] [DisplayOnly]public SearchState searchState;
- [FoldoutGroup("组件")] public BigSoldier bigSoldier;
- [FoldoutGroup("组件")] public AttackTrigger dragonTrigger;
- [FoldoutGroup("角色信息")] public string myName;
- [FoldoutGroup("条件")] [LabelText("释放起手式后死亡")] public bool summonEndToDie;
- [FoldoutGroup("条件")] [LabelText("体型是否会变化")] public bool canSizeChange;
- [FoldoutGroup("条件")] [LabelText("是否无视OnState")] public bool ignoresOnState;
- [Space(30)]
- [Title("Demonic属性")]
- public SoldierType soldierType; //当前士兵属于什么兵种
- public PlayerController player; //召唤师
- public int playerID;
- public int id;
- public float costMp = 10;
- public bool isBack = false; //往反方向走
- public int baseSortingOrder;
- public float runSpeed;
- private bool isFreeze; //冻结rb
- public DemoicTag demoicTags;
- public int ownDamageScale;
- [Header("锁魂塔")]
- public bool isReturnSoulTower;
- public Vector3 origSoulPos;
- public bool isRecorded;
- [Header("攻击")]
- private float pastAttackTime;
- private bool isConAttack; //连续攻击,不切idle动画
- [Header("八卦")]
- public float adsorbSpeed; //八卦吸附的速度
- [HideInInspector] public Vector3 adsorbTarget; //八卦胖子吸附时目标位置的X
- private float adsorbTime; //八卦吸附中的时间
- public GameObject effectPrefab; //八卦卦象效果
- [Header("掉落魂")]
- public int dropSoulMax = 3;
- public int dropSoulMin = 1;
- public float dropSoulAngle = 60f;
- private AttackController initAc;
- private int initRegeneration;
- private int initArmor;
- private int initDodge;
- private BuffController buffControl;
- public override void FixedUpdate()
- {
- if (ignoresOnState) return;
- OnSearchState();
- OnState();
- }
- public bool SearchTarget()
- {
- targetCharacter = searchTrigger.GetMinDisTarget(attackController.targetTypes, attackController.curAttackMethod.canHitFly,attackController.curAttackMethod.searchMode);
- if (targetCharacter != null)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- public void ChangeSearchState(SearchState newState)
- {
- switch (searchState)
- {
- case SearchState.NoTarget:
- break;
- case SearchState.InSearchScope:
- break;
- case SearchState.InAttackScope:
- break;
- default:
- break;
- }
- searchState = newState;
- switch (searchState)
- {
- case SearchState.NoTarget:
- targetCharacter = null;
- break;
- case SearchState.InSearchScope:
- break;
- case SearchState.InAttackScope:
- break;
- default:
- break;
- }
- }
- public void OnSearchState()
- {
- switch (searchState)
- {
- case SearchState.NoTarget:
- if (SearchTarget())
- {
- ChangeSearchState(SearchState.InSearchScope);
- break;
- }
- //向玩家基地移动
- break;
- case SearchState.InSearchScope:
- if (!SearchTarget())
- {
- targetCharacter = null;
- ChangeSearchState(SearchState.NoTarget);
- break;
- }
- attackDis = attackController.curAttackMethod.attackDistance + targetCharacter.beHitDistance;
- if (targetCharacter != null && Mathf.Abs(targetCharacter.transform.position.x - transform.position.x) <= attackDis)
- {
- ChangeSearchState(SearchState.InAttackScope);
- break;
- }
- break;
- case SearchState.InAttackScope:
- if (targetCharacter != null)
- {
- //判断是否在射程夹角内
- AttackController.AttackMethod am = attackController.curAttackMethod;
- if (am.attackType == AttackController.AttackType.Shoot
- && attackController.curAttackMethod.attackInfo.attackMethod_Type == AttackMethod_Type.Attack_March)
- {
- Vector3 dir = targetCharacter.beSearchTrigger.transform.position - transform.position;
- float angle = Vector3.Angle(dir, Vector3.left * bodyTrans.localScale.x);
- if ((dir.y > 0 && angle > am.maxUpAngle) || (dir.y < 0 && angle > am.maxDownAngle))
- {
- ChangeSearchState(SearchState.NoTarget);
- break;
- }
- }
- attackDis = attackController.curAttackMethod.attackDistance + targetCharacter.beHitDistance;
- if (!targetCharacter.gameObject.activeInHierarchy || targetCharacter.isDie
- || Mathf.Abs(targetCharacter.transform.position.x - transform.position.x) > attackDis)
- {
- ChangeSearchState(SearchState.NoTarget);
- }
- }
- else
- {
- ChangeSearchState(SearchState.NoTarget);
- }
- break;
- default:
- break;
- }
- }
- public override Vector3 GetMoveDir()
- {
- Vector3 moveDir = Vector3.zero;
- switch (searchState)
- {
- case SearchState.NoTarget:
- if (TowerMap.enemyTowers.Count == 0)
- {
- moveDir = Vector3.left;
- break;
- }
- float minDistance = Mathf.Infinity;
- int id = -1;
- for (int i = 0; i < TowerMap.enemyTowers.Count; i++)
- {
- EnemyTower enemyTower = TowerMap.enemyTowers[i].GetComponent<EnemyTower>();
- if (transform.position.y >
- enemyTower.transform.position.y + enemyTower.height)
- {
- continue;
- }
- float distance = Vector3.Distance(transform.position,
- TowerMap.enemyTowers[i].transform.position);
- if (distance < minDistance)
- {
- minDistance = distance;
- id = i;
- }
- }
- if (id == -1)
- {
- moveDir = Vector3.left;
- break;
- }
- if (bodyTrans.position.x > TowerMap.enemyTowers[id].transform.position.x)
- {
- moveDir = Vector3.left;
- }
- else
- {
- moveDir = Vector3.right;
- }
- break;
- case SearchState.InSearchScope:
- if (targetCharacter)
- {
- if (targetCharacter.transform.position.x - transform.position.x < 0)
- {
- moveDir = Vector3.left;
- }
- else
- {
- moveDir = Vector3.right;
- }
- }
- else
- {
- moveDir = Vector3.zero;
- }
- break;
- case SearchState.InAttackScope:
- if (targetCharacter)
- {
- if (targetCharacter.transform.position.x - transform.position.x < 0)
- {
- moveDir = Vector3.left;
- }
- else
- {
- moveDir = Vector3.right;
- }
- }
- else
- {
- moveDir = Vector3.zero;
- }
- break;
- default:
- break;
- }
- if (!isBack)
- {
- return moveDir;
- }
- return -moveDir;
- }
- public bool GetAttack()
- {
- if (searchState == SearchState.InAttackScope)
- {
- return true;
- }
- return false;
- }
- public override void OnState()
- {
- base.OnState();
- if (state == CharacterState.FramePause)
- {
- return;
- }
- //hurtKeepTime -= Time.deltaTime;
- dieKeepTime -= Time.deltaTime;
- invincibleTime -= Time.deltaTime;
- pastAttackTime += Time.deltaTime;
- Vector3 leftDir = GetMoveDir();
- bool isAttack = GetAttack();
- Vector3 velocity = rb.velocity;
- Quaternion targetQt = Quaternion.Euler(Vector3.zero);
- switch (state)
- {
- case CharacterState.Idle:
- if (isAdjustHeight == 1)
- {
- ChangeState(CharacterState.Rise);
- break;
- }
- if (isAttack)
- {
- if (pastAttackTime * (1 + GameManager.instance.attackSpeed/100f) >= attackController.attackInterval)
- {
- Attack_march();
- }
- }
- else
- {
- if (!foot.TrigGround && !canFly)
- {
- if (rb.velocity.y > 0)
- {
- ChangeState(CharacterState.Rise);
- break;
- }
- else
- {
- ChangeState(CharacterState.Fall);
- break;
- }
- }
- if (leftDir.x > 0.3f || leftDir.x < -0.3f)
- {
- ChangeState(CharacterState.Run);
- break;
- }
- velocity.x = velocityAddition;
- velocity.y = 0;
- if (!foot.haveGravity)
- {
- transform.position = new Vector3(transform.position.x, platformPosY, transform.position.z);
- targetQt = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, platformRotZ);
- }
- if (RotLerpTime < 1)
- {
- RotLerpTime += RotLerpSpeed * Time.deltaTime;
- transform.rotation = Quaternion.Lerp(transform.rotation, targetQt, RotLerpTime);
- }
- else
- {
- transform.rotation = targetQt;
- }
- rb.velocity = velocity;
- }
- break;
- case CharacterState.Run:
- if (isAttack)
- {
- if (pastAttackTime * (1 + GameManager.instance.attackSpeed / 100f) >= attackController.attackInterval)
- {
- Attack_march();
- }
- else
- {
- ChangeState(CharacterState.Idle);
- }
- }
- else
- {
- if (!foot.TrigGround && !canFly)
- {
- if (rb.velocity.y > 0)
- {
- ChangeState(CharacterState.Rise);
- break;
- }
- else
- {
- ChangeState(CharacterState.Fall);
- break;
- }
- }
- if (leftDir.x < 0.3f && leftDir.x > -0.3f)
- {
- ChangeState(CharacterState.Idle);
- break;
- }
- if (leftDir.x > 0.3f)
- {
- velocity.x = (moveSpeed + velocityAddition) * moveSpeedScale;
- if (bodyTrans.localScale.x > 0)
- {
- Turn();
- }
- }
- else if (leftDir.x < -0.3f)
- {
- velocity.x = (-moveSpeed + velocityAddition) * moveSpeedScale;
-
- if (bodyTrans.localScale.x < 0)
- {
- Turn();
- }
- }
- velocity.y = 0;
- if (!foot.haveGravity)
- {
- transform.position = new Vector3(transform.position.x, platformPosY, transform.position.z);
- targetQt = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, platformRotZ);
- }
- if (RotLerpTime < 1)
- {
- RotLerpTime += RotLerpSpeed * Time.deltaTime;
- transform.rotation = Quaternion.Lerp(transform.rotation, targetQt, RotLerpTime);
- }
- else
- {
- transform.rotation = targetQt;
- }
- rb.velocity = velocity;
- AdjustHeight();
- }
- break;
- case CharacterState.Rush:
- if (isAttack)
- {
- if (pastAttackTime * (1 + GameManager.instance.attackSpeed / 100f) >= attackController.attackInterval)
- {
- Attack_march();
- }
- else
- {
- ChangeState(CharacterState.Idle);
- }
- }
- else
- {
- if (!foot.TrigGround && !canFly)
- {
- if (rb.velocity.y > 0)
- {
- ChangeState(CharacterState.Rise);
- break;
- }
- else
- {
- ChangeState(CharacterState.Fall);
- break;
- }
- }
- if (leftDir.x < 0.3f && leftDir.x > -0.3f)
- {
- ChangeState(CharacterState.Idle);
- break;
- }
- if (leftDir.x > 0.3f)
- {
- //rb.velocity += Vector3.right * moveAcc * Time.deltaTime;
- rb.velocity = Vector3.right * runSpeed;
- //if (rb.velocity.x > maxMoveSpeed)
- //{
- // rb.velocity = new Vector3(maxMoveSpeed, rb.velocity.y, rb.velocity.z);
- //}
- if (bodyTrans.localScale.x > 0)
- {
- Turn();
- }
- }
- else if (leftDir.x < -0.3f)
- {
- //rb.velocity -= Vector3.right * moveAcc * Time.deltaTime;
- rb.velocity = Vector3.left * runSpeed;
- //if (rb.velocity.x < -maxMoveSpeed)
- //{
- // rb.velocity = new Vector3(-maxMoveSpeed, rb.velocity.y, rb.velocity.z);
- //}
- if (bodyTrans.localScale.x < 0)
- {
- Turn();
- }
- }
- }
- break;
- case CharacterState.Rise:
- if (isAdjustHeight == 1)
- {
- AdjustHeight();
- }
- else if(isAdjustHeight == 2)
- {
- ChangeState(CharacterState.Idle);
- isAdjustHeight = 0;
- }
- else
- {
- if (rb.velocity.y <= 0)
- {
- ChangeState(CharacterState.Fall);
- break;
- }
- rb.velocity += Vector3.up * extraRiseGravity * Time.deltaTime;
- }
- break;
- case CharacterState.Fall:
- if (foot.TrigGround || (canFly && !isDie))
- {
- if (isDie)
- {
- ChangeState(CharacterState.Die);
- break;
- }
- ChangeState(CharacterState.Idle);
- break;
- }
- if (canFly && isDie)
- {
- velocity.y += extraFallGravity * Time.deltaTime;
- rb.velocity = velocity;
- }
- else
- {
- velocity.y += extraFallGravity * Time.deltaTime;
- if (leftDir.x > 0.3f)
- {
- velocity.x = moveSpeed * moveSpeedScale;
- if (bodyTrans.localScale.x > 0)
- {
- Turn();
- }
- }
- else if (leftDir.x < -0.3f)
- {
- velocity.x = -moveSpeed * moveSpeedScale;
- if (bodyTrans.localScale.x < 0)
- {
- Turn();
- }
- }
- rb.velocity = velocity;
- }
- break;
- case CharacterState.Attack:
- attackController.JudgeTriggerOnOff();
- if (attackController.attackTime <= 0)
- {
- if (summonEndToDie)
- {
- ChangeState(CharacterState.Die);
- break;
- }
- if (isInSoulTower)
- {
- ChangeState(CharacterState.LockSoul);
- }
- else
- {
- isAttack = GetAttack();
- if (isAttack)
- {
- isConAttack = true;
- }
- ChangeState(CharacterState.Idle);
- }
- break;
- }
- if (!foot.haveGravity)
- {
- targetQt = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, platformRotZ);
- }
- if (RotLerpTime < 1)
- {
- RotLerpTime += RotLerpSpeed * Time.deltaTime;
- transform.rotation = Quaternion.Lerp(transform.rotation, targetQt, RotLerpTime);
- }
- else
- {
- transform.rotation = targetQt;
- }
- rb.velocity = new Vector3(velocityAddition, rb.velocity.y, rb.velocity.z);
- break;
- case CharacterState.Die:
- if (dieKeepTime <= 0)
- {
- gameObject.SetActive(false);
- break;
- }
- break;
- case CharacterState.LockSoul:
- if (!isReturnSoulTower)
- {
- if (targetCharacter != null && targetCharacter.gameObject.layer == 8 && targetCharacter.isInSoulTower)
- {
- ChangeState(CharacterState.Idle);
- }
- else
- {
- isReturnSoulTower = true;
- }
- }
- else
- {
- if (transform.position.x - origSoulPos.x >= 0.2f)
- {
- rb.velocity = Vector3.right * (-moveSpeed + velocityAddition) * moveSpeedScale;
- if (bodyTrans.localScale.x < 0)
- {
- Turn();
- }
- }
- else if (origSoulPos.x - transform.position.x >= 0.2f)
- {
- rb.velocity = Vector3.right * (moveSpeed + velocityAddition) * moveSpeedScale;
- if (bodyTrans.localScale.x > 0)
- {
- Turn();
- }
- }
- else
- {
- ani.CrossFade(AnimatorHash.ANIMATOR_idle, 0.2f);
- rb.velocity = Vector3.zero;
- transform.position = origSoulPos;
- isReturnSoulTower = false;
- targetCharacter = null;
- FaceToEneTower();
- }
- //锁魂塔内使魔返回原地过程中扫描到敌人时,停止返回并索敌攻击
- if (targetCharacter != null && targetCharacter.gameObject.layer == 8 && targetCharacter.isInSoulTower)
- {
- ChangeState(CharacterState.Idle);
- }
- }
- break;
- case CharacterState.HitStun:
- hitFeedbackSystem.HitStunUpdate();
- break;
- case CharacterState.SpecialStatus_Float:
- attributeStatus.SpecialStateEffect(SpecialState.FloatState);
- break;
- case CharacterState.SpecialStatus_BlowUp:
- attributeStatus.SpecialStateEffect(SpecialState.BlownUp);
- break;
- case CharacterState.SpecialStatus_ShotDown:
- attributeStatus.SpecialStateEffect(SpecialState.ShotDown);
- break;
- case CharacterState.SpecialStatus_Weak:
- attributeStatus.SpecialStateEffect(SpecialState.Weak);
- break;
- default:
- break;
- }
- }
- private void FaceToEneTower()
- {
- float dis = 1000000;
- GameObject to = null;
- foreach (GameObject g in TowerMap.enemyTowers)
- {
- float k = Vector3.Distance(g.transform.position, transform.position);
- if (k < dis)
- {
- dis = k;
- to = g;
- }
- }
- if (to != null && to.transform.position.x < transform.position.x)
- {
- if (bodyTrans.localScale.x < 0)
- {
- Turn();
- }
- }
- else
- {
- if (bodyTrans.localScale.x > 0)
- {
- Turn();
- }
- }
- }
- public override void ChangeState(CharacterState newState)
- {
- if (state == newState || newState == CharacterState.FramePause)
- {
- state = newState;
- return;
- }
- AnimatorStateInfo currentStateInfo = ani.GetCurrentAnimatorStateInfo(0);
- switch (state)
- {
- case CharacterState.Idle:
- //transform.rotation = Quaternion.Euler(Vector3.zero);
- break;
- case CharacterState.Run:
- //transform.rotation = Quaternion.Euler(Vector3.zero);
- rb.velocity = Vector3.zero;
- break;
- case CharacterState.Rush:
- rb.velocity = Vector3.zero;
- break;
- case CharacterState.Rise:
- if (!canFly)
- {
- bodyCollider.SetActive(true);
- }
- break;
- case CharacterState.Fall:
- rb.velocity = Vector3.zero;
- break;
- case CharacterState.Attack:
- if (isFreeze)
- {
- rb.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotation;
- }
- attackController.isAttackTriggerOn = false;
- attackController.curAttackMethod.attackTrigger.gameObject.SetActive(false);
- ani.speed = 1;
- break;
- case CharacterState.Die:
- isDie = false;
- break;
- case CharacterState.LockSoul:
- //isReturnSoulTower = true;
- break;
- case CharacterState.FramePause:
- state = hitFeedbackSystem.curCharacterState;
- ChangeState(newState);
- return;
- default:
- break;
- }
- //Debug.Log("士兵由" + state + "切换到" + newState);
- state = newState;
- switch (newState)
- {
- case CharacterState.Idle:
- if (!isConAttack || attackController.attackInterval > 0)
- {
- ani.CrossFade(AnimatorHash.ANIMATOR_idle, 1);
- }
- rb.velocity = Vector3.zero;
- isConAttack = false;
- //animalAni.SetInteger("state", (int)PlayerState.Idle);
- break;
- case CharacterState.Run:
- if(currentStateInfo.shortNameHash == AnimatorHash.ANIMATOR_weak)
- {
- ani.Play(AnimatorHash.ANIMATOR_walk, 0, 0);
- }
- else
- {
- ani.CrossFade(AnimatorHash.ANIMATOR_walk, 0.5f);
- }
- break;
- case CharacterState.Rush:
- ani.Play(AnimatorHash.ANIMATOR_rush, 0, 0);
- break;
- case CharacterState.Fall:
- ani.Play(AnimatorHash.ANIMATOR_fall, 0, 0);
- //animalAni.SetInteger("state", (int)PlayerState.Fall);
- break;
- case CharacterState.Attack:
- break;
- case CharacterState.Die:
- if (canFly)
- {
- if (isDie)
- {
- return;
- }
- rb.constraints = RigidbodyConstraints.FreezeRotation | RigidbodyConstraints.FreezePositionZ;
- rb.velocity = Vector3.zero;
- ChangeState(CharacterState.Fall);
- isDie = true;
- PlayersInput.instance[playerID].OnDemonicRecycle(this);
- //if (GameManager.instance.isGroundEnable && !canFly)
- //{
- // int randomInt = Random.Range(0, 100);
- // if (randomInt < GameManager.instance.groundProbability)
- // {
- // SoulDead soulDead = PoolManager.Instantiate(Resources.Load<GameObject>("Prefab/SoulDead"),transform.position).GetComponent<SoulDead>();
- // soulDead.Init(player, id);
- // soulDead.transform.position = transform.position;
- // }
- //}
- }
- else
- {
- isDie = true;
- ani.Play(AnimatorHash.ANIMATOR_die, 0, 0);
- dieKeepTime = totalDieKeepTime;
- PlayersInput.instance[playerID].OnDemonicRecycle(this);
- //if (GameManager.instance.isGroundEnable && !canFly)
- //{
- // int randomInt = Random.Range(0, 100);
- // if (randomInt < GameManager.instance.groundProbability)
- // {
- // SoulDead soulDead = PoolManager.Instantiate(Resources.Load<GameObject>("Prefab/SoulDead"), transform.position).GetComponent<SoulDead>();
- // soulDead.Init(player, id);
- // soulDead.transform.position = transform.position;
- // }
- //}
- }
- if (GameManager.instance.isSkyGroundIceEnable)
- {
- int randomInt = Random.Range(0, 100);
- if (randomInt < GameManager.instance.skyGroundProbability + (int)(GameManager.instance.skyGroundLabelEffectRatio * (GameManager.instance.myTreasuresTag[0] + GameManager.instance.myTreasuresTag[4])))
- {
- player.nextSummonNum++;
- GameUI.instance.summonNum.text = player.nextSummonNum.ToString();
- }
- }
- summonEndToDie = false;
- canSizeChange = false;
- bigSoldier.enabled = false;
- break;
- case CharacterState.LockSoul:
- rb.velocity = Vector3.zero;
- ani.Play(AnimatorHash.ANIMATOR_walk, 0, 0);
- //FaceToEneTower();
- break;
- default:
- break;
- }
- }
- public virtual void Attack_summon()
- {
- ani.speed = 1 * (1 + GameManager.instance.attackSpeed / 100f);
- if (needToAdjustFlyHeight && canFly)
- {
- flyHeight = Random.Range(minFlyHeight, maxFlyHeight);
- isAdjustHeight = 1;
- }
- if (!canFly)
- {
- rb.constraints = RigidbodyConstraints.FreezeAll;
- isFreeze = true;
- }
- CheckTurn(-PlayersInput.instance[playerID].bodyTrans.localScale.x);
- attackController.Attack_summon();
- invincibleTime = attackController.attackTime;
- attackTarget = targetCharacter;
- }
- public virtual void Attack_march()
- {
- ani.speed = 1 * (1 + GameManager.instance.attackSpeed / 100f);
- CheckTurn(GetMoveDir().x);
- attackController.Attack_march();
- if (attackController.attackMarchId + 1 < attackController.attackMethod_march.Length)
- {
- attackController.attackMarchId += 1;
- }
- else
- {
- attackController.attackMarchId = 0;
- }
- attackTarget = targetCharacter;
- pastAttackTime = 0;
- }
- public void DropSouls()
- {
- int dropSoulNum = Random.Range(dropSoulMin, dropSoulMax + 1);
- if (dropSoulNum > 1)
- {
- for (int i = 0; i < dropSoulNum; i++)
- {
- float angleInterval = dropSoulAngle / (float)(dropSoulNum - 1);
- float angle = 90 + ((float)i - (float)(dropSoulNum - 1) / 2) * angleInterval;
- angle = angle / 180 * Mathf.PI;
- GameObject soulObj = PoolManager.Instantiate(soulPrefab, transform.position);
- Vector3 dir = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle), 0);
- Soul soul = soulObj.GetComponent<Soul>();
- soul.Burst(dir * soulStartSpeed);
- }
- }
- else
- {
- GameObject soulObj = PoolManager.Instantiate(soulPrefab, transform.position);
- Vector3 dir = Vector3.up;
- Soul soul = soulObj.GetComponent<Soul>();
- soul.Burst(dir * soulStartSpeed);
- }
- }
- public override void Init()
- {
- base.Init();
- attackController = initAc;
- regeneration = initRegeneration;
- attributeStatus.resistances.dodge = initDodge;
- attributeStatus.resistances.armor = initArmor;
- }
- public override void Awake()
- {
- base.Awake();
- initAc = attackController;
- initRegeneration = regeneration;
- initDodge = attributeStatus.resistances.dodge;
- initArmor = attributeStatus.resistances.armor;
- bc = GetComponent<BuffController>();
- }
- protected override void OnDisable()
- {
- base.OnDisable();
- ownDamageScale = 0;
- }
- /// <summary>
- /// 在子类具体实现,用于处理每种士兵单独的逻辑
- /// </summary>
- public virtual void AfterInit()
- {
- for (int i = 0; i < attackController.attackMethod_march.Length; i++)
- {
- AttackInfo attackInfo = attackController.attackMethod_march[i].attackInfo;
- attackInfo.damage = (int)(attackController.attackMethod_summon[i].attackInfo.damage/5f);
- if (attackInfo.damage < 1) attackInfo.damage = 1;
- }
- }
- }
- [System.Flags]
- public enum DemoicTag
- {
- None = 0,
- Sky = 1 << 0,
- Ground = 1 << 1,
- Remote = 1 << 2,
- Melee = 1 << 3,
- }
|