/// <summary> /// Returns a hash code for this instance. /// </summary> /// <returns> /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. /// </returns> public override int GetHashCode() { unchecked { int result = Initiative.GetHashCode(); result = (result * 397) ^ SoftAttack.GetHashCode(); result = (result * 397) ^ HardAttack.GetHashCode(); result = (result * 397) ^ AirAttack.GetHashCode(); result = (result * 397) ^ NavalAttack.GetHashCode(); result = (result * 397) ^ GroundDefense.GetHashCode(); result = (result * 397) ^ AirDefense.GetHashCode(); result = (result * 397) ^ CloseDefense.GetHashCode(); result = (result * 397) ^ Range.GetHashCode(); result = (result * 397) ^ Movement.GetHashCode(); result = (result * 397) ^ Spotting.GetHashCode(); return(result); } }
protected void Awake() { anim = GetComponent <Animator>(); Shaker = GameObject.FindGameObjectWithTag("Shake"); maxGrip = fighter.weight; HP = fighter.HitPoints; jumpHeight = fighter.jumpHeight; moveSpeed = fighter.speed; maxJumpCount = fighter.jumpCount; rigidBody = GetComponent <Rigidbody2D>(); Target = GameObject.FindGameObjectWithTag("Floor").GetComponent <GravAttractor>(); Shield = GetComponentInChildren <Barrier>(true).gameObject; if (isPlayer) { player = ReInput.players.GetPlayer(playerID); //The player controlling this fighter } gameObject.name = fighter.name.ToString() + playerID; statemachine = new StateMachine(); var flinch = new Flinch(this); var walk = new Walk(this); var run = new Run(this); var idle = new Idle(this); var jump = new Jump(this); var groundattack = new GroundAttack(this, attack); var airattack = new AirAttack(this, attack); var stun = new Stun(this); var leapprep = new LeapPrep(this); var blocking = new Blocking(this); var dodge = new AirDodge(this); var leap = new Leaping(this); var prone = new Prone(this); At(dodge, idle, landed()); At(flinch, idle, stunless()); At(run, idle, stop()); At(walk, idle, stop()); At(idle, jump, jumping()); At(idle, jump, unground()); At(jump, jump, jumping()); At(walk, jump, unground()); At(run, jump, unground()); At(walk, jump, jumping()); At(run, jump, jumping()); At(walk, run, running()); At(run, walk, walking()); At(idle, walk, walking()); At(idle, run, running()); At(idle, groundattack, offensive()); At(walk, groundattack, offensive()); At(run, groundattack, offensive()); At(jump, airattack, offensive()); At(groundattack, idle, unoffensive()); At(airattack, jump, unoffensive()); At(airattack, idle, landed()); At(jump, airattack, offensive()); At(jump, idle, landed()); At(jump, dodge, guard()); At(blocking, stun, pierce()); At(idle, blocking, guard()); At(walk, blocking, guard()); At(run, blocking, guard()); At(leapprep, idle, cancelleap()); At(leapprep, leap, gravityChange()); At(blocking, idle, unguard()); At(leap, idle, landed()); At(prone, idle, stunless()); statemachine.AddAnyTransition(leapprep, () => LeapPrep && leapCooldown <= 0); statemachine.AddAnyTransition(stun, () => stunned); statemachine.AddAnyTransition(flinch, () => isDamaged); statemachine.AddAnyTransition(prone, () => slam); Func <bool> stunless() => () => doneStun == true; Func <bool> walking() => () => speed > 0.3 && speed < 0.7; Func <bool> running() => () => speed > 0.7; Func <bool> stop() => () => speed < 0.3; Func <bool> jumping() => () => (jumpTimer > Time.time) && (maxJumpCount > jumpCount) && !action && actionCooldown > 0; Func <bool> offensive() => () => attack != null && actionCooldown > 0; Func <bool> unoffensive() => () => attack == null; Func <bool> landed() => () => grounded; Func <bool> pierce() => () => Guard <= 0; Func <bool> guard() => () => isBlocking && actionCooldown > 0; Func <bool> unguard() => () => !isBlocking; Func <bool> gravityChange() => () => LeapRelease; Func <bool> cancelleap() => () => cancelled; Func <bool> unground() => () => !grounded; statemachine.SetState(idle); }