| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784 |
- using Sirenix.OdinInspector;
- using Spine.Unity;
- using System.Collections.Generic;
- using TMPro;
- using UnityEngine;
- using UnityEngine.InputSystem;
- using UnityEngine.UI;
- public enum PlayerAttackState
- {
- Idle = 0,
- WalkForward = 1,
- WalkBack = 2,
- }
- public class PlayerController : MoveCharacter
- {
- [Space(30)]
- [Title("PlayerController属性")]
- public int playerId;
- [LabelText("主角刷新位置")] public Vector2 refreshPos;
- public bool canJump;
- public Animator aniCollider;
-
- //
- [HideInInspector] public UIHP uiMp;
- [HideInInspector] public Transform uiRush;
- [FoldoutGroup("组件")] public Collider soulCollector;
- [FoldoutGroup("组件")] public SkeletonMecanim skeletonMecanim;
- [FoldoutGroup("组件")] public WallTrigger wallTrigger;
- [FoldoutGroup("组件")] public Collider bodyTrigger;
- private Spirits spirits;
- private SpiritSystem spiritSystem;
- private ScreenShake ss;
- private ConductController conductController;
- [HideInInspector] public GameManager gameManager;
- //
- [FoldoutGroup("召唤属性", order:-1)] public float totalSummonTime;
- [HideInInspector]
- public float summonTime;
- [FoldoutGroup("召唤属性")] public float onlySummonTime;
- [FoldoutGroup("召唤属性")] [DisplayOnly] public float restSummonTime;
- private SoldierLevelRecord slr;
- [HideInInspector]
- public float cacheDir; //召唤的时候按左右召唤结束不会响应手感不好,缓存一下,召唤后摇期间有左右响应的话会转向
- [HideInInspector]
- public bool cacheRush; //召唤的时候按冲刺结束不会响应手感不好,缓存一下,召唤后摇期间按下冲刺的话会冲刺
- [DisplayOnly] public float cacheSummonTime; //无法召唤时按下召唤键不会召唤,手感不好,缓存几帧,在这几帧内落地会立即召唤;
- [HideInInspector]
- public int cacheSummonId;
- [FoldoutGroup("召唤属性")] [DisplayOnly] public int nowAttackSummonID;
- [FoldoutGroup("召唤属性")] [LabelText("士兵起手式连段时间")] public float AttackSummonChangeTotalTime;
- [FoldoutGroup("召唤属性")] [DisplayOnly] public float AttackSummonChangeTime;
- [HideInInspector] public SoldierType lastSoldier;
- //
- [Header("蓝耗")]
- public float mp;
- public float totalMp;
- public float totalMp_2Players; //双人模式下总蓝量
- public bool isMpRepel = true;
- public bool isRapedReply;
- public float mpReplySpeed;
- public float mpReplySpeed_2Players; //双人模式下蓝量回复速度
- public float rapidReplySpeed;
- public float lostMp;
- public float addMp = 10;
- public GameObject soul;
- public GameObject rapidReplyEffect;
- [Tooltip("场上每多一个同种类兵种,召唤兵种蓝耗+x")] public float[] addCostMp;
- [Header("移动属性")]
- public Vector2 moveVec; //玩家不动时移动数据
- [HideInInspector]
- public Vector2 leftDir;
- //
- [FoldoutGroup("冲刺属性", order: -1)] public float rushSpeed = 100;
- //public float rushCostMp = 5;
- [FoldoutGroup("冲刺属性")] [LabelText("充能槽总数")]public int rushChargeTotalNums;
- [FoldoutGroup("冲刺属性")] [DisplayOnly] public int rushChargeNums;
- [FoldoutGroup("冲刺属性")] [LabelText("充能一次所需时间")] public float rushChargeAddTime;
- [FoldoutGroup("冲刺属性")] [DisplayOnly] public float rushChargeTime;
- [FoldoutGroup("冲刺属性")] public Vector3 rushDir;
- [FoldoutGroup("冲刺属性")] public float rushInvincibleTime = 0.2f;
- [HideInInspector] public float rushTime;
- [FoldoutGroup("冲刺属性")] public float totalRushTime = 0.5f;
- [HideInInspector] public float cacheRushTime; //无法Rush时按下Rush键不会Rush,手感不好,缓存几帧,在这几帧内落地会立即Rush;
- [FoldoutGroup("冲刺属性")] public float totalCacheRushTime = 0.1f;
- //
- [Header("跳跃属性")]
- public float jumpSpeed = 10;
- public float airJumpSpeed = 10;
- public int airJumped;
- public int airJumpNumber = 1; //最大跳跃次数
- public float canAirJumpSpeed = 5;//y轴速度大于这个值时不能进行空中跳跃
- [HideInInspector]
- public float canJumpTime; //离开平台后仍然可以跳跃的时间,用于提升手感
- public float leaveGroundCanJumpTime = 0.1f;
- [HideInInspector]
- public float cacheJumpTime; //即将落地时按下跳跃键不会跳跃,手感不好,缓存几帧,在这几帧内落地会立即跳跃;
- public float totalCacheJumpTime = 0.1f;
- [Header("飞行属性")]
- public float flySpeed = 5;
- public float playerMaxFlyHeight;
- [Header("召唤使魔")]
- public TextMeshProUGUI[] demonicNums;
- public GameObject[] cannotConductFXs;
- public List<GameObject> demonicPrefabs;
- public List<Vector3> demonicSummonPos;
- public Dictionary<int, List<Demonic>> demonicDic; //0:弓兵,1:胖子,2:棒子,3:融合后的弓兵,4:融合后的胖子,5:融合后的棒子
- public int nextSummonNum = 1;
- [LabelText("动作结束后无敌帧时间")] public float addSummonInvincibleTime = 0.1f;
- [Header("攻击")]
- public PlayerAttackState attackState;
- public float attackMoveSpeed = 5f;
- [HideInInspector]
- public float cacheAttackTime; //无法攻击时按下攻击键不会攻击,手感不好,缓存几帧,在这几帧内落地会立即攻击;
- public float totalCacheAttackTime = 0.1f;
- [Header("复活")]
- public float reviveTime; //复活时间
- public float totalReviveTime;
- [Header("锁魂塔")]
- public GameObject curSoulTower;
- //指挥功能
- private float conductTime; //指挥按键长按时间
- private int nowConductButton = -1; //现在按下的指挥键(0.J/1.K/2.L/-1.无)
- private int cacheConductId;
- [Header("召唤相应时间")] [Tooltip("在此时间内松手为召唤")] public float totalCacheSummonTime;
- [Header("融魂相应时间")] [Tooltip("在此时间以外松手为融魂")] public float[] canConductTime;
- public ConductReadyTip conductReadyTip; //指挥技就绪
- private bool isReadyConduct;
- [Header("时间倍率")] [Tooltip("时间速度放慢到正常的几倍")] public float timeSlowingMultiplier;
- [DisplayOnly]public float fixedDeltaTime;
- public float readyTipFxTime;
- public int dienum;
- //攻击力
- [Header("增加攻击力特效")]
- public GameObject attackEffect;
- [Header("攻击力献祭比例")]
- public float addRate;
- //泰山压顶
- [Header("泰山压顶")]
- public GameObject mountain;
- public Vector3 mountainOffset;
- public float largeX;
- //气功波
- public GameObject wavePowerObj;
- [Header("气功波伤害基数")] public int wavePowerDamage;
- //御剑术
- public GameObject flyingSwordsObj;
- //怨气弹
- public GameObject angryBulletObj;
- [Header("怨气弹数量基数")] public int angryBulletNum;
- public bool btnJumpPress
- {
- get
- {
- //return Input.GetKeyDown(KeyCode.Space) || isClickBtnJump;
- return isClickBtnJump;
- }
- }
- [HideInInspector]
- public bool isClickBtnJump;
- public bool btnRushPress
- {
- get
- {
- //return Input.GetKeyDown(KeyCode.LeftShift) || isClickBtnRush;
- return isClickBtnRush;
- }
- }
- [HideInInspector]
- public bool isClickBtnRush;
- public bool btnRushKeep
- {
- get
- {
- //return Input.GetKey(KeyCode.LeftShift) || isKeepBtnRush;
- return LBisHold || isKeepBtnRush;
- }
- }
- [HideInInspector]
- public bool isKeepBtnRush;
- public bool btnEastPress
- {
- get
- {
- return isClickBtnEast;
- }
- }
- [HideInInspector]
- public bool isClickBtnEast;
- public bool btnEastUp
- {
- get
- {
- return isBtnEastUp;
- }
- }
- [HideInInspector]
- public bool isBtnEastUp;
- public bool btnSouthPress
- {
- get
- {
- //return Input.GetKeyDown(KeyCode.K) || isClickBtnSouth;
- return isClickBtnSouth;
- }
- }
- [HideInInspector]
- public bool isClickBtnSouth;
- public bool btnSouthUp
- {
- get
- {
- //return Input.GetKeyDown(KeyCode.K) || isClickBtnSouth;
- return isBtnSouthUp;
- }
- }
- [HideInInspector]
- public bool isBtnSouthUp;
- public bool btnWestPress
- {
- get
- {
- return isClickBtnWest;
- }
- }
- [HideInInspector]
- public bool isClickBtnWest;
- public bool btnWestUp
- {
- get
- {
- return isBtnWestUp;
- }
- }
- [HideInInspector]
- public bool isBtnWestUp;
- public bool btnNorthPress
- {
- get
- {
- return isClickBtnNorth;
- }
- }
- [HideInInspector]
- public bool isClickBtnNorth;
- public bool btnNorthUp
- {
- get
- {
- return isBtnNorthUp;
- }
- }
- [HideInInspector]
- public bool isBtnNorthUp;
- public bool btnTransClick
- {
- get
- {
- return isClickBtnTrans;
- }
- }
- [HideInInspector]
- public bool isClickBtnTrans;
- public override void Init()
- {
- base.Init();
- uiHp = gameManager.p1uiHP;
- uiMp = gameManager.p1uiMP;
- uiRush = gameManager.p1uiRush;
- uiMp.pc = this;
- mp = totalMp;
- rushChargeNums = rushChargeTotalNums;
- uiMp.Show(mp, totalMp);
- for(int i = 0; i < rushChargeTotalNums; i++)
- {
- if (uiRush.childCount <= i)
- {
- Transform rushUIchid = Instantiate(uiRush.GetChild(0),uiRush);
- rushUIchid.localPosition = uiRush.GetChild(0).transform.localPosition + Vector3.right * 50 * i;
- }
- UIController.ChangeImageFill(uiRush.GetChild(i).GetComponent<Image>(), 1);
- }
-
- demonicNums = new TextMeshProUGUI[3];
- for (int i = 0; i < 3; i++)
- {
- demonicNums[i] = gameManager.demonicNum[i].GetComponentInChildren<TextMeshProUGUI>();
- }
- cannotConductFXs = new GameObject[3];
- for (int i = 0; i < 3; i++)
- {
- cannotConductFXs[i] = gameManager.demonicNum[i].transform.GetChild(3).gameObject;
- }
- }
- public override void Awake()
- {
- gameManager = GameManager.instance;
- gameManager.player = this;
- base.Awake();
- PlayerInput playerInput = transform.GetComponent<PlayerInput>();
- ss = Camera.main.GetComponentInParent<ScreenShake>();
- spirits = GetComponent<Spirits>();
- conductController = GetComponent<ConductController>();
- playerId = playerInput.playerIndex;
- Vector3 towerPos = TowerMap.myTowers[0].transform.position;
- transform.position = new Vector3(towerPos.x + refreshPos.x, towerPos.y + refreshPos.y, 0);
- switch (playerId)
- {
- case 0:
- PlayersInput.instance[0] = this;
- PlayersInput.instance[1] = this;
- SpiritSystem.isP1Out = true;
- SpiritSystem.isP1In = false;
- SpiritSystem.player1 = gameObject;
- SpiritSystem.p1Spirits = GetComponent<Spirits>();
- break;
- case 1:
- PlayersInput.instance[1] = this;
- SpiritSystem.isP2Out = true;
- SpiritSystem.isP2In = false;
- SpiritSystem.player2 = gameObject;
- SpiritSystem.p2Spirits = GetComponent<Spirits>();
- //切换为双人计算蓝量方式
- PlayerController p1 = PlayersInput.instance[0];
- mpReplySpeed = mpReplySpeed_2Players;
- p1.mpReplySpeed = mpReplySpeed_2Players;
- totalMp = totalMp_2Players;
- p1.totalMp = totalMp_2Players;
- if (mp > totalMp)
- {
- mp = totalMp;
- }
- if (p1.mp > totalMp)
- {
- p1.mp = totalMp;
- }
- uiMp.Show(mp, totalMp);
- p1.uiMp.Show(p1.mp, totalMp);
- break;
- default:
- break;
- }
- demonicDic = new Dictionary<int, List<Demonic>>();
- for (int i = 0; i < 5; i++)
- {
- demonicDic.Add(i, new List<Demonic>());
- }
- for (int i = 0; i < 3; i++)
- {
- PoolManager.Preloading(demonicPrefabs[i],50);
- }
- Init();
- spiritSystem = GameObject.Find("SpiritSystem").GetComponent<SpiritSystem>();
- fixedDeltaTime = Time.fixedDeltaTime;
- }
- private void Start()
- {
- slr = gameManager.GetComponent<SoldierLevelRecord>();
- }
- override public void Update()
- {
- if (LBisHold)
- {
- isKeepBtnRush = true;
- }
- if (foot.TrigGround)
- {
- //playerFX.
- }
- }
- void OnSprintingPress()
- {
- LBisHold = true;
- isClickBtnRush = true;
- isKeepBtnRush = true;
- }
- void OnSprintingRelease()
- {
- LBisHold = false;
- }
- //手柄按下LB
- [HideInInspector]
- public bool LBisHold;
- //读取手柄参数
- private void OnMove(InputValue value)
- {
- leftDir = value.Get<Vector2>();
- moveVec = value.Get<Vector2>();
- }
- void OnJump()
- {
- if (canJump)
- {
- isClickBtnJump = true;
- }
- }
- void OnSummon0()
- {
- if (nowConductButton == -1)
- {
- isClickBtnWest = true;
- nowConductButton = 0;
- conductTime = 0;
- }
- }
- void OnSummon0Up()
- {
- if (nowConductButton == 0)
- {
- isBtnWestUp = true;
- cacheConductId = nowConductButton;
- nowConductButton = -1;
- }
- }
- void OnSummon1()
- {
- if (nowConductButton == -1)
- {
- isClickBtnSouth = true;
- nowConductButton = 1;
- conductTime = 0;
- }
- }
- void OnSummon1Up()
- {
- if (nowConductButton == 1)
- {
- isBtnSouthUp = true;
- cacheConductId = nowConductButton;
- nowConductButton = -1;
- }
- }
- void OnSummon2()
- {
- if (nowConductButton == -1)
- {
- isClickBtnEast = true;
- nowConductButton = 2;
- conductTime = 0;
- }
- }
- void OnSummon2Up()
- {
- if (nowConductButton == 2)
- {
- isBtnEastUp = true;
- cacheConductId = nowConductButton;
- nowConductButton = -1;
- }
- }
- //选英灵 (手柄右扳机,键盘TAB)
- void OnChooseSpirit()
- {
- switch (playerId)
- {
- case 0:
- SpiritSystem.isP1CardChangeR = true;
- break;
- case 1:
- SpiritSystem.isP2CardChangeR = true;
- break;
- default:
- break;
- }
- }
- void OnTransfigurate()
- {
- isClickBtnTrans = true;
- }
- public void Jump()
- {
- SetUpSpeed(jumpSpeed);
- ani.Play("jump", 0, 0);
- }
- public void AirJump()
- {
- ChangeState(CharacterState.Rise);
- SetUpSpeed(airJumpSpeed);
- ani.Play("jump_air", 0, 0);
- }
- public void SetUpSpeed(float speed)
- {
- ChangeState(CharacterState.Rise);
- Vector3 velocity = rb.velocity;
- CheckTurn();
- velocity.y = speed;
- rb.velocity = velocity;
- //animalAni.SetInteger("state", (int)PlayerState.Rise);
- }
- public bool CheckSummon()
- {
- if (restSummonTime > 0)
- {
- return false;
- }
- if (state != CharacterState.Conduct
- && nowConductButton != -1
- && conductController.conductSkills[nowConductButton] != ConductSkills.Null
- && conductTime > totalCacheSummonTime
- && conductController.cd[nowConductButton] <= 0)
- {
- CheckTurn();
- ChangeState(CharacterState.Conduct);
- return true;
- }
- if (btnEastUp || btnWestUp || btnSouthUp || btnTransClick || cacheSummonTime > 0)
- {
- if(conductTime <= totalCacheSummonTime)
- {
- CheckTurn();
- if (!CheckCanSummon(cacheSummonId))
- {
- return false;
- }
- Summon(cacheSummonId);
- cacheSummonTime = 0;
- return true;
- }
- }
- return false;
- }
- public bool CheckConduct()
- {
- if (isBtnWestUp || isBtnSouthUp || isBtnEastUp)
- {
- if (isReadyConduct)
- {
- cacheSummonTime = 0;
- conductController.Conduct(cacheConductId, dienum);
- }
- isReadyConduct = false;
- return true;
- }
- if (!isReadyConduct && nowConductButton != -1)
- {
- int boostNum = demonicDic[nowConductButton].Count;
- if (conductController.bUseFixedSacrifice[nowConductButton])
- {
- dienum = conductController.sacrificeValue[nowConductButton];
- if (boostNum < dienum)
- {
- dienum = 0;
- }
-
- }
- else
- {
- dienum = (int)(boostNum * conductController.conversionRate[nowConductButton] / 100 + 0.5f);
- if (boostNum == 1)
- {
- dienum = 1;
- }
- }
-
- if (conductTime >= canConductTime[nowConductButton] * timeSlowingMultiplier)
- {
- isReadyConduct = true;
- if (!conductReadyTip.isShowing1 && !conductReadyTip.isShowingNoDemonic)
- {
- if (dienum > 0)
- {
- conductReadyTip.Show(1);
- }
- else
- {
- conductReadyTip.Show(3, nowConductButton);
- }
- }
- }
- else if (conductTime >= (canConductTime[nowConductButton] - readyTipFxTime) * timeSlowingMultiplier)
- {
- if (!conductReadyTip.isShowing0 && !conductReadyTip.isShowingNoDemonic)
- {
- if (dienum > 0)
- {
- conductReadyTip.Show(0);
- }
- else
- {
- conductReadyTip.Show(2, nowConductButton);
- }
- }
- }
- else
- {
- if (Time.timeScale == 1)
- {
- Time.timeScale = timeSlowingMultiplier;
- Time.fixedDeltaTime = fixedDeltaTime * Time.timeScale;
- if (dienum == 0)
- {
- conductReadyTip.Show(2, nowConductButton);
- CannotConductFX(nowConductButton);
- }
- }
- conductReadyTip.Init();
- }
- }
- return false;
- }
- private int cannotConductfx;
- private void CannotConductFX(int id)
- {
- cannotConductfx = id;
- cannotConductFXs[id].SetActive(true);
- Invoke("CannotConductFXFade", 0.2f);
- }
- private void CannotConductFXFade()
- {
- cannotConductFXs[cannotConductfx].SetActive(false);
- }
- //角色处于可自由活动状态时的通用切换状态逻辑,如Idle、Run状态,以及别的状态结束时准备回到Idle状态前
- public bool CheckPlayerChangeState(CharacterState excludeState = CharacterState.None)
- {
- if (btnRushPress || cacheRushTime > 0 || cacheRush)
- {
- if (excludeState != CharacterState.Rush)
- {
- //if(mp >= rushCostMp)
- if (rushChargeNums > 0)
- {
- restSummonTime = 0;
- summonTime = 0;
- cacheRush = false;
- ChangeState(CharacterState.Rush);
- return true;
- }
- }
- }
- if (!foot.TrigGround)
- {
- if (excludeState != CharacterState.Summon)
- {
- if (CheckSummon())
- {
- return true;
- }
- }
- if (rb.velocity.y > 0)
- {
- if (excludeState != CharacterState.Rise && restSummonTime <= 0)
- {
- summonTime = 0;
- ChangeState(CharacterState.Rise);
- return true;
- }
- }
- else
- {
- if (excludeState != CharacterState.Fall && restSummonTime <= 0)
- {
- summonTime = 0;
- ChangeState(CharacterState.Fall);
- return true;
- }
- }
- }
- else
- {
- airJumped = 0;
- if (CheckSummon())
- {
- if (excludeState == CharacterState.Summon)
- {
- if (foot.TrigGround)
- {
- ani.Play("summon", 0, 0);
- }
- else
- {
- ani.Play("summon_air", 0, 0);
- }
- }
- return true;
- }
- if (btnJumpPress || cacheJumpTime > 0)
- {
- if (excludeState != CharacterState.Rise && restSummonTime <= 0)
- {
- summonTime = 0;
- Jump();
- ChangeState(CharacterState.Rise);
- return true;
- }
- }
- if (leftDir.y < -0.5)
- {
- Platform platform = foot.trigGroundList[0].GetComponent<Platform>();
- if (platform != null && platform.canDown)
- {
- foot.trigGroundList.Remove(platform.gameObject);
- }
- }
- if (canFly)
- {
- if (leftDir.x > 0.3f || leftDir.x < -0.3f || leftDir.y > 0.3f || leftDir.y < -0.3f)
- {
- if (excludeState != CharacterState.Run && restSummonTime <= 0)
- {
- summonTime = 0;
- ChangeState(CharacterState.Run);
- return true;
- }
- }
- else
- {
- if (excludeState != CharacterState.Idle && summonTime <= 0)
- {
- ChangeState(CharacterState.Idle);
- return true;
- }
- }
- }
- else
- {
- if (leftDir.x > 0.3f || leftDir.x < -0.3f)
- {
- if (excludeState != CharacterState.Run && restSummonTime <= 0)
- {
- summonTime = 0;
- ChangeState(CharacterState.Run);
- return true;
- }
- }
- else
- {
- if (excludeState != CharacterState.Idle && summonTime <= 0)
- {
- ChangeState(CharacterState.Idle);
- return true;
- }
- }
- }
-
- }
- return false;
- }
- public override Vector3 GetMoveDir()
- {
- return leftDir;
- }
- public void CachedPlayerInput()
- {
- if (btnRushPress)
- {
- cacheRushTime = totalCacheRushTime;
- }
- if (btnJumpPress)
- {
- cacheJumpTime = totalCacheJumpTime;
- }
- if (btnNorthPress)
- {
- cacheAttackTime = totalCacheAttackTime;
- }
- if (btnWestPress)
- {
- cacheSummonId = 0;
- }
- if (btnWestUp)
- {
- cacheSummonTime = totalCacheSummonTime;
- }
- if (btnSouthPress)
- {
- cacheSummonId = 1;
- }
- if (btnSouthUp)
- {
- cacheSummonTime = totalCacheSummonTime;
- }
- if (btnEastPress)
- {
- cacheSummonId = 2;
- }
- if (btnEastUp)
- {
- cacheSummonTime = totalCacheSummonTime;
- }
- if (btnTransClick)
- {
- cacheSummonTime = totalCacheSummonTime;
- cacheSummonId = spirits.nowSpirit + 3;
- }
- }
- public override void OnState()
- {
- if(GameManager.instance.gameType == GameType.Shop)
- {
- return;
- }
- base.OnState();
- cacheJumpTime -= Time.deltaTime;
- cacheSummonTime -= Time.deltaTime;
- canJumpTime -= Time.deltaTime;
- invincibleTime -= Time.deltaTime;
- summonTime -= Time.deltaTime;
- restSummonTime -= Time.deltaTime;
- rushTime -= Time.deltaTime;
- cacheRushTime -= Time.deltaTime;
- dieKeepTime -= Time.deltaTime;
- if (nowConductButton != -1)
- {
- conductTime += Time.deltaTime;
- }
- if (AttackSummonChangeTime <= 0)
- {
- nowAttackSummonID = 0;
- }
- else
- {
- AttackSummonChangeTime -= Time.deltaTime;
- }
- if (rushChargeNums < rushChargeTotalNums && state != CharacterState.Rush && state != CharacterState.Sprint)
- {
- rushChargeTime += Time.deltaTime;
- UIController.ChangeImageFill(uiRush.GetChild(rushChargeNums).GetComponent<Image>(), rushChargeTime, rushChargeAddTime);
- if (rushChargeTime > rushChargeAddTime)
- {
- rushChargeNums++;
- rushChargeTime = 0;
- }
- }
- CachedPlayerInput();
- Vector3 velocity = rb.velocity;
- bool isToWall = false;
- //撞墙了
- if (wallTrigger.TrigWall)
- {
- if (bodyTrans.localScale.x > 0)
- {
- if (leftDir.x < 0)
- {
- isToWall = true;
- }
- }
- else
- {
- if (leftDir.x > 0)
- {
- isToWall = true;
- }
- }
- }
- switch (state)
- {
- case CharacterState.Idle:
- if (CheckPlayerChangeState(CharacterState.Idle))
- {
- break;
- }
- if(!foot.haveGravity)
- {
- transform.position = new Vector3(transform.position.x, platformPosY, transform.position.z);
- //transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, platformRotZ);
- }
-
- if (isToWall)
- {
- velocity.x = 0;
- }
- else
- {
- velocity.x = velocityAddition;
- }
- velocity.y = 0;
-
- rb.velocity = velocity;
- break;
- case CharacterState.Run:
- if (CheckPlayerChangeState(CharacterState.Run))
- {
- break;
- }
- CheckTurn();
- if (isToWall)
- {
- velocity.x = 0;
- }
- else
- {
- if (leftDir.x > 0.3f)
- {
- velocity.x = moveSpeed + velocityAddition;
- }
- else if (leftDir.x < -0.3f)
- {
- velocity.x = -moveSpeed + velocityAddition;
- }
- }
- velocity.y = 0;
- if (!foot.haveGravity)
- {
- transform.position = new Vector3(transform.position.x, platformPosY, transform.position.z);
- //transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles.x, transform.rotation.eulerAngles.y, platformRotZ);
- }
- rb.velocity = velocity;
- break;
- case CharacterState.Rise:
- if(CheckSummon())
- {
- break;
- }
- if (btnRushPress || cacheRushTime > 0 || cacheRush)
- {
- if (rushChargeNums > 0)
- {
- restSummonTime = 0;
- summonTime = 0;
- cacheRush = false;
- ChangeState(CharacterState.Rush);
- break;
- }
- }
- if (btnJumpPress || cacheJumpTime > 0)
- {
- if (airJumped < airJumpNumber && rb.velocity.y < canAirJumpSpeed)
- {
- airJumped++;
- AirJump();
- break;
- }
- }
- velocity = AirMove(velocity);
- if (isToWall)
- {
- velocity.x = 0;
- }
- rb.velocity = velocity;
- if (rb.velocity.y <= 0)
- {
- ChangeState(CharacterState.Fall);
- break;
- }
- break;
- case CharacterState.Fall:
- if(CheckSummon())
- {
- break;
- }
- if (btnRushPress || cacheRushTime > 0 || cacheRush)
- {
- if (rushChargeNums > 0)
- {
- restSummonTime = 0;
- summonTime = 0;
- cacheRush = false;
- ChangeState(CharacterState.Rush);
- break;
- }
- }
- if (foot.TrigGround)
- {
- if (CheckPlayerChangeState(CharacterState.Fall))
- {
- break;
- }
- }
- if (btnJumpPress || cacheJumpTime > 0)
- {
- if (canJumpTime > 0)
- {
- AirJump();
- break;
- }
- else
- {
- if (airJumped < airJumpNumber)
- {
- airJumped++;
- AirJump();
- break;
- }
- }
- }
- velocity = AirMove(velocity);
- if (isToWall)
- {
- velocity.x = 0;
- }
- rb.velocity = velocity;
- break;
- case CharacterState.Summon:
- if (leftDir.x > 0.3f || leftDir.x < -0.3f)
- {
- cacheDir = leftDir.x;
- }
- if (LBisHold)
- {
- cacheRush = true;
- }
- if (CheckPlayerChangeState(CharacterState.Summon))
- {
- break;
- }
- rb.velocity = Vector3.right * velocityAddition;
- break;
- case CharacterState.Rush:
- if (rushTime <= 0)
- {
- if (btnRushKeep)
- {
- ChangeState(CharacterState.Sprint);
- break;
- }
- if (CheckPlayerChangeState(CharacterState.Rush))
- {
- break;
- }
- }
- rb.velocity = rushDir * rushSpeed;
- break;
- case CharacterState.Sprint:
- if (!btnRushKeep)
- {
- if (CheckPlayerChangeState(CharacterState.Sprint))
- {
- break;
- }
- }
- uiMp.Show(mp, totalMp);
- rb.velocity = rushDir * rushSpeed;
- break;
- case CharacterState.Die:
- if (dieKeepTime <= 0)
- {
- if (isRevive)
- {
- reviveTime += Time.deltaTime;
- if (reviveTime >= totalReviveTime)
- {
- PlayerRevive();
- }
- }
- else
- {
- PlayerDie();
- }
- }
- break;
- case CharacterState.Conduct:
- if (CheckConduct())
- {
- 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;
- }
- isClickBtnRush = false;
- isKeepBtnRush = false;
- isClickBtnJump = false;
- isClickBtnSouth = false;
- isClickBtnEast = false;
- isClickBtnNorth = false;
- isClickBtnWest = false;
- isClickBtnTrans = false;
- isBtnSouthUp = false;
- isBtnEastUp = false;
- isBtnNorthUp = false;
- isBtnWestUp = false;
- if (foot.TrigGround)
- {
- canJumpTime = leaveGroundCanJumpTime;
- }
- //SearchTarget();
- //attackTarget = targetCharacter;
- if (isMpRepel)
- {
- if (mp < totalMp)
- {
- if (!isRapedReply)
- {
- mp += mpReplySpeed * Time.deltaTime;
- }
- else
- {
- mp += rapidReplySpeed * Time.deltaTime;
- }
- }
- }
- if (mp > totalMp)
- {
- mp = totalMp;
- }
- if (mp < 0)
- {
- mp = 0;
- }
- uiMp.Show(mp, totalMp);
- }
- public void PlayerDie()
- {
- switch (playerId)
- {
- case 0:
- SpiritSystem.isP1In = true;
- SpiritSystem.isP1Out = false;
- break;
- case 1:
- SpiritSystem.isP2In = true;
- SpiritSystem.isP2Out = false;
- break;
- default:
- break;
- }
- foot.trigGroundList.Clear();
- bodyTrans.gameObject.SetActive(false);
- uiHp.transform.parent.gameObject.SetActive(false);
- rb.constraints = RigidbodyConstraints.FreezeAll;
- isRevive = true;
- reviveTime = 0;
- }
- public void PlayerRevive()
- {
- isRevive = false;
- bodyTrans.gameObject.SetActive(true);
- uiHp.transform.parent.gameObject.SetActive(true);
- rb.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotation;
- Vector3 towerPos = TowerMap.myTowers[0].transform.position;
- transform.position = new Vector3(towerPos.x + refreshPos.x , towerPos.y+refreshPos.y, 0);
- switch (playerId)
- {
- case 0:
- SpiritSystem.isP1In = false;
- SpiritSystem.isP1Out = true;
- SpiritSystem.player1 = gameObject;
- SpiritSystem.p1Spirits = GetComponent<Spirits>();
- break;
- case 1:
- SpiritSystem.isP2In = false;
- SpiritSystem.isP2Out = true;
- SpiritSystem.player2 = gameObject;
- SpiritSystem.p2Spirits = GetComponent<Spirits>();
- break;
- default:
- break;
- }
- Init();
- GameUI.instance.HurtMask(1);
- }
- public void RapidReplyMp()
- {
- isRapedReply = true;
- rapidReplyEffect.SetActive(true);
- }
- public void NormalReplyMp()
- {
- isRapedReply = false;
- rapidReplyEffect.SetActive(false);
- }
- public override void ChangeState(CharacterState newState)
- {
- if (state == newState || newState == CharacterState.FramePause)
- {
- state = newState;
- return;
- }
- Vector3 velocity = rb.velocity;
- switch (state)
- {
- case CharacterState.Idle:
- break;
- case CharacterState.Run:
- velocity.x = 0;
- break;
- case CharacterState.Rise:
- //bodyCollider.SetActive(true);
- break;
- case CharacterState.Fall:
- break;
- case CharacterState.Attack:
- aniCollider.Play("NotAttack", 1, 0);
- break;
- case CharacterState.KeepAttack:
- aniCollider.Play("NotAttack", 1, 0);
- break;
- case CharacterState.Summon:
- rb.isKinematic = false;
- if (cacheDir != 0)
- {
- if (cacheDir > 0.3f && bodyTrans.localScale.x > 0)
- {
- Turn();
- }
- else if (cacheDir < -0.3f && bodyTrans.localScale.x < 0)
- {
- Turn();
- }
- cacheDir = 0;
- }
- break;
- case CharacterState.Rush:
- bodyTrigger.gameObject.SetActive(false);
- if(newState != CharacterState.Sprint)
- {
- invincibleTime = 0;
- }
- rb.useGravity = true;
- velocity = Vector3.zero;
- break;
- case CharacterState.Sprint:
- bodyTrigger.gameObject.SetActive(false);
- invincibleTime = 0;
- rb.useGravity = true;
- velocity = Vector3.zero;
- break;
- case CharacterState.Die:
- if (isRevive)
- {
- return;
- }
- isDie = false;
- rb.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotation;
- break;
- case CharacterState.Conduct:
- rb.isKinematic = false;
- Time.timeScale = 1;
- Time.fixedDeltaTime = fixedDeltaTime * Time.timeScale;
- conductReadyTip.activeFalse();
- break;
- default:
- break;
- }
- CharacterState oldState = state;
-
- state = newState;
- switch (newState)
- {
- case CharacterState.Idle:
- aniCollider.Play("Idle", 0, 0);
- if (oldState == CharacterState.Fall)
- {
- ani.Play("fall_end", 0, 0);
- }
- else
- {
- ani.Play("idle", 0, 0);
- }
- velocity = Vector3.right * velocityAddition;
- //animalAni.SetInteger("state", (int)PlayerState.Idle);
- break;
- case CharacterState.Run:
- aniCollider.Play("Run", 0, 0);
- ani.Play("run_start", 0, 0);
- //animalAni.SetInteger("state", (int)PlayerState.Walk);
- break;
- case CharacterState.Rise:
- //bodyCollider.SetActive(false);
- aniCollider.Play("Rise", 0, 0);
- canJumpTime = 0;
- break;
- case CharacterState.Fall:
- aniCollider.Play("Fall", 0, 0);
- ani.Play("fall", 0, 0);
- //animalAni.SetInteger("state", (int)PlayerState.Fall);
- break;
- case CharacterState.KeepAttack:
- aniCollider.Play("Attack_summonKeep", 1, 0);
- break;
- case CharacterState.Summon:
- aniCollider.Play("Summon", 0, 0);
- if (foot.TrigGround)
- {
- ani.Play("summon", 0, 0);
- }
- else
- {
- ani.Play("summon_air", 0, 0);
- }
- velocity = Vector3.right * velocityAddition;
- rb.isKinematic = true;
- cacheDir = 0;
- cacheRush = false;
- break;
- case CharacterState.Rush:
- if (GameManager.instance.isWindEnable || GameManager.instance.isThunderEnable) bodyTrigger.gameObject.SetActive(true);
- aniCollider.Play("Rush", 0, 0);
- ani.Play("rush_loop", 0, 0);
- rushTime = totalRushTime;
- invincibleTime = rushInvincibleTime;
- rb.useGravity = false;
- if (bodyTrans.localScale.x > 0)
- {
- rushDir = Vector3.left;
- }
- else
- {
- rushDir = Vector3.right;
- }
- velocity = rushDir * rushSpeed;
- //mp -= rushCostMp;
- rushChargeNums--;
- UIController.ChangeImageFill(uiRush.GetChild(rushChargeNums).GetComponent<Image>(), rushChargeTime, rushChargeAddTime);
- if (rushChargeNums != rushChargeTotalNums - 1)
- {
- UIController.ChangeImageFill(uiRush.GetChild(rushChargeNums + 1).GetComponent<Image>(), 0);
- }
- uiMp.Show(mp, totalMp);
- break;
- case CharacterState.Sprint:
- if(GameManager.instance.isWindEnable || GameManager.instance.isThunderEnable) bodyTrigger.gameObject.SetActive(true);
- aniCollider.Play("Sprint", 0, 0);
- rb.useGravity = false;
- velocity = rushDir * rushSpeed;
- break;
- case CharacterState.Die:
- rb.constraints = RigidbodyConstraints.FreezeAll;
- aniCollider.Play("Die", 0, 0);
- ani.Play("die", 0, 0);
- isDie = true;
- dieKeepTime = totalDieKeepTime;
- break;
- case CharacterState.Conduct:
- conductTime = 0;
- rb.velocity = Vector3.zero;
- rb.isKinematic = true;
- aniCollider.Play("Summon", 0, 0);
- if (foot.TrigGround)
- {
- ani.Play("summon", 0, 0);
- }
- else
- {
- ani.Play("summon_air", 0, 0);
- }
- break;
- default:
- break;
- }
- rb.velocity = velocity;
- }
- public void CheckTurn()
- {
- if (leftDir.x > 0.3f && bodyTrans.localScale.x > 0)
- {
- if (state == CharacterState.Run)
- {
- ani.Play("run_start", 0, 0);
- }
- Turn();
- }
- else if (leftDir.x < -0.3f && bodyTrans.localScale.x < 0)
- {
- if (state == CharacterState.Run)
- {
- ani.Play("run_start", 0, 0);
- }
- Turn();
- }
- }
- public Vector3 AirMove(Vector3 velocity)
- {
- CheckTurn();
- if (canFly)
- {
- velocity = leftDir.normalized * flySpeed;
- if (transform.position.y > playerMaxFlyHeight && velocity.y > 0)
- {
- velocity.y = 0;
- }
- }
- else
- {
- if (leftDir.x > 0.3f)
- {
- velocity = new Vector3(moveSpeed, velocity.y, velocity.z);
- }
- else if (leftDir.x < -0.3f)
- {
- velocity = new Vector3(-moveSpeed, velocity.y, velocity.z);
- }
- else
- {
- velocity = new Vector3(0, velocity.y, velocity.z);
- }
- if (velocity.y > 0)
- {
- velocity += Vector3.up * extraRiseGravity * Time.deltaTime;
- }
- else
- {
- velocity += Vector3.up * extraFallGravity * Time.deltaTime;
- }
- }
-
- return velocity;
- }
- public void Summon(int id)
- {
- ChangeState(CharacterState.Summon);
- summonTime = totalSummonTime;
- Demonic dem = demonicPrefabs[id].GetComponent<Demonic>();
- float costMp = dem.costMp;
- for (int i = 0; i < 3; i++)
- {
- if (GameManager.curSoldiers[i] == dem.soldierType)
- {
- costMp += slr.seb[i].mp;
- break;
- }
- }
- mp -= costMp;
- uiMp.Show(mp, totalMp);
- if (demonicPrefabs[id].GetComponent<Demonic>().canFly)
- {
- for (int i = 0; i < nextSummonNum; i++)
- {
- Demonic demonic = CreateDemonic(id);
- if (i > 0) demonic.transform.position += new Vector3(Random.Range(-2, 2), Random.Range(-2, 2), 0);
- if (!demonicDic.ContainsKey(id))
- {
- demonicDic.Add(id, new List<Demonic>());
- }
- demonicDic[id].Add(demonic);
- if (id <= 2)
- {
- demonicNums[id].text = demonicDic[id].Count.ToString();
- }
- int attackSummonId = nowAttackSummonID;
- if (lastSoldier != demonic.soldierType)
- {
- attackSummonId = 0;
- }
- demonic.attackController.attackSummonId = attackSummonId;
- onlySummonTime = demonic.attackController.summonTime[attackSummonId];
- invincibleTime = onlySummonTime + addSummonInvincibleTime;
- restSummonTime = onlySummonTime;
- demonic.Attack_summon();
- lastSoldier = demonic.soldierType;
- attackSummonId++;
- if (attackSummonId >= demonic.attackController.attackMethod_summon.Length)
- {
- attackSummonId = 0;
- AttackSummonChangeTime = 0;
- }
- else
- {
- AttackSummonChangeTime = AttackSummonChangeTotalTime;
- }
- nowAttackSummonID = attackSummonId;
- //id 3~6 为四个英灵
- if (id >= 3)
- {
- spirits.ultimateTimes[id - 3] -= spirits.summonCost;
- }
- spiritSystem.RefreshPlayerUI();
- if (isInSoulTower)
- {
- ls.AddDenomic(demonic);
- }
- }
- nextSummonNum = 1;
- }
- else
- {
- Demonic demonic = CreateDemonic(id);
- if (!demonicDic.ContainsKey(id))
- {
- demonicDic.Add(id, new List<Demonic>());
- }
- demonicDic[id].Add(demonic);
- if (id <= 2)
- {
- demonicNums[id].text = demonicDic[id].Count.ToString();
- }
- int attackSummonId = nowAttackSummonID;
- if (lastSoldier != demonic.soldierType)
- {
- attackSummonId = 0;
- }
- demonic.attackController.attackSummonId = attackSummonId;
- onlySummonTime = demonic.attackController.summonTime[attackSummonId];
- invincibleTime = onlySummonTime + addSummonInvincibleTime;
- restSummonTime = onlySummonTime;
- demonic.Attack_summon();
- lastSoldier = demonic.soldierType;
- attackSummonId++;
- if (attackSummonId >= demonic.attackController.attackMethod_summon.Length)
- {
- attackSummonId = 0;
- AttackSummonChangeTime = 0;
- }
- else
- {
- AttackSummonChangeTime = AttackSummonChangeTotalTime;
- }
- nowAttackSummonID = attackSummonId;
- //id 3~6 为四个英灵
- if (id >= 3)
- {
- spirits.ultimateTimes[id - 3] -= spirits.summonCost;
- }
- spiritSystem.RefreshPlayerUI();
- if (isInSoulTower)
- {
- ls.AddDenomic(demonic);
- }
- }
- }
- public Demonic CreateDemonic(int id)
- {
- GameObject demonicObj = PoolManager.Instantiate(demonicPrefabs[id]);
- Demonic demonic = demonicObj.GetComponent<Demonic>();
- slr.SoldierAddLevelBuff(demonic);
- AttackController attackController = demonic.attackController;
- for (int i = 0; i < attackController.attackMethod_summon.Length; i++)
- {
- AttackInfo attackInfo = attackController.attackMethod_summon[i].attackInfo;
- attackInfo.damage += gameManager.damage;
- attackInfo.criticalChance = gameManager.criticalChance;
- attackInfo.lifesteal = gameManager.lifesteal;
- }
- for (int i = 0; i < attackController.attackMethod_march.Length; i++)
- {
- AttackInfo attackInfo = attackController.attackMethod_march[i].attackInfo;
- attackInfo.damage += (int)(gameManager.damage * gameManager.damageRate);
- attackInfo.criticalChance = gameManager.criticalChance;
- attackInfo.lifesteal = gameManager.lifesteal;
- }
- if ((GameManager.instance.isSkyEnable && demonic.canFly))
- {
- for (int i = 0; i < attackController.attackMethod_summon.Length; i++)
- {
- AttackInfo attackInfo = attackController.attackMethod_summon[i].attackInfo;
- attackInfo.damage += (int)(attackInfo.damage * demonicDic[0].Count * GameManager.instance.attackRate);
- Debug.Log("飞行兵的数量是:" + demonicDic[0].Count + ",增加的伤害为" + (int)(demonicDic[0].Count * GameManager.instance.attackRate));
- }
- for (int i = 0; i < attackController.attackMethod_march.Length; i++)
- {
- AttackInfo attackInfo = attackController.attackMethod_march[i].attackInfo;
- attackInfo.damage += (int)(attackInfo.damage * demonicDic[0].Count * GameManager.instance.attackRate);
- }
- }
- else if (GameManager.instance.isGroundEnable && !demonic.canFly)
- {
- int num = demonicDic[1].Count + demonicDic[2].Count;
- demonic.totalHp += (int)(num * GameManager.instance.hpRate);
- demonic.hp = demonic.totalHp;
- demonic.uiHp.Show(demonic.hp, demonic.totalHp);
- Debug.Log("地面兵的数量是:" + num + ",增加的血量为" + (int)(num * GameManager.instance.hpRate));
- }
- demonic.attributeStatus.resistances.armor = gameManager.armor;
- demonic.attributeStatus.resistances.dodge = gameManager.dodge;
- demonic.regeneration = gameManager.regeneration;
- demonic.totalHp += gameManager.totalHp;
- demonic.id = id;
- demonic.playerID = playerId;
- demonicObj.transform.parent = null;
- demonicObj.transform.localEulerAngles = Vector3.zero;
- demonicObj.transform.localScale = new Vector3(1, 1, 1);
- Vector3 offset = demonicSummonPos[id];
- //demonic.CheckTurn(-bodyTrans.localScale.x);
- if (bodyTrans.localScale.x > 0)
- {
- if (demonic.bodyTrans.localScale.x < 0)
- {
- demonic.Turn();
- }
- }
- else
- {
- if (demonic.bodyTrans.localScale.x > 0)
- {
- demonic.Turn();
- }
- }
- demonicObj.transform.position = transform.position
- + new Vector3(bodyTrans.localScale.x > 0 ? offset.x : -offset.x, offset.y, offset.z);
- if (demonic.canFly)
- {
- demonic.flyHeight = demonic.transform.position.y;
- }
- demonic.player = this;
- demonic.Init();
- int order = demonicPrefabs[id].GetComponent<Demonic>().baseSortingOrder + demonicDic[demonic.id].Count;
- demonic.SetSortingOrder(order);
- return demonic;
- }
- public void OnDemonicRecycle(Demonic demonic)
- {
- if (!demonicDic.ContainsKey(demonic.id))
- {
- return;
- }
- demonicDic[demonic.id].Remove(demonic);
- if (demonic.id <= 2)
- {
- demonicNums[demonic.id].text = demonicDic[demonic.id].Count.ToString();
- }
- for (int i = 0; i < demonicDic[demonic.id].Count; i++)
- {
- int order = demonicDic[demonic.id][i].baseSortingOrder + i;
- demonicDic[demonic.id][i].SetSortingOrder(order);
- }
- }
- public bool CheckCanSummon(int id)
- {
- if(id < 3) //使魔
- {
- GameObject prefab;
- prefab = demonicPrefabs[id];
- Demonic dem = prefab.GetComponent<Demonic>();
- float costMp = dem.costMp;
- for (int i = 0; i < 3; i++)
- {
- if (GameManager.curSoldiers[i] == dem.soldierType)
- {
- costMp += slr.seb[i].mp;
- break;
- }
- }
- costMp += addCostMp[id] * demonicDic[id].Count;
- if (mp < costMp)
- {
- //Debug.Log("mp不足召唤失败, 还得加个动画或者音效啥的");
- return false;
- }
- }
- else
- {
- if(spirits.ultimateTimes[id -3 ] < spirits.summonCost)
- {
- return false;
- }
- }
- return true;
- }
- public void SetAttackState(PlayerAttackState value)
- {
- attackState = value;
- ani.SetInteger("attackState", (int)value);
- aniCollider.Play("Attack_summonKeep", 1, 0);
- }
- /*
- public void SearchTarget()
- {
- targetCharacter = searchTrigger.GetMinDisTarget(attackController.targetTypes, attackController.canHitFly);
- }*/
- public override void BeHit(int damage)
- {
- base.BeHit(damage);
- //屏幕红闪+抖动
- if (ss == null)
- {
- ss = Camera.main.GetComponentInParent<ScreenShake>();
- }
- ss.enabled = true;
- if (isSustainedInjury || damage >= heavyDamage)
- {
- ss.ShakeScreen(1);
- }
- }
- public override void BeHit(AttackController.AttackMethod attackMethod, Character attackFrom, int damage = -1)
- {
- Photosphere photosphere = conductController.photosphere;
- if (photosphere)
- {
- if(damage == -1)
- {
- photosphere.hp -= attackMethod.attackInfo.damage;
- }
- else
- {
- photosphere.hp -= damage;
- }
- return;
- }
- base.BeHit(attackMethod, attackFrom);
- //屏幕抖动
- if (ss == null)
- {
- ss = Camera.main.GetComponentInParent<ScreenShake>();
- }
- ss.enabled = true;
- if (isSustainedInjury || attackMethod.attackInfo.damage >= heavyDamage)
- {
- ss.ShakeScreen(1);
- }
- GameUI.instance.HurtMask((hp *1f)/totalHp);
- }
- }
|