public void AddToTargetList(Character target) { if (target == null) throw new ArgumentNullException("target"); if (target == m_character) throw new ArgumentOutOfRangeException("target"); if (TargetList.Contains(target) == false) TargetList.Add(target); }
public Helper(FightEngine engine, Character parent, HelperData data) : base(engine) { if (parent == null) throw new ArgumentNullException("parent"); if (data == null) throw new ArgumentNullException("data"); m_parent = parent; m_baseplayer = m_parent.BasePlayer; m_team = m_baseplayer.Team; m_offsetcharacter = (data.PositionType == PositionType.P2) ? parent.GetOpponent() : parent; m_remove = false; m_data = data; m_firsttick = true; m_statemanager = Parent.StateManager.Clone(this); m_spritemanager = Parent.SpriteManager.Clone(); m_animationmanager = Parent.AnimationManager.Clone(); m_commandmanager = Parent.CommandManager.Clone(); m_soundmanager = Parent.SoundManager.Clone(); m_dimensions = new CharacterDimensions(Data.GroundFront, Data.GroundBack, Data.AirFront, Data.AirBack, Data.Height); m_palfx = (Data.OwnPaletteFx == true) ? new PaletteFx() : Parent.PaletteFx; CurrentPalette = Parent.CurrentPalette; CurrentFacing = GetFacing(Data.PositionType, m_offsetcharacter.CurrentFacing, Data.FacingFlag < 0); CurrentLocation = GetStartLocation(); CurrentScale = Data.Scale; SetLocalAnimation(0, 0); StateManager.ChangeState(Data.InitialStateNumber); }
public void OnHit(HitDefinition hitdef, Character target, Boolean blocked) { if (hitdef == null) throw new ArgumentNullException("hitdef"); if (target == null) throw new ArgumentNullException("target"); m_character.DrawOrder = hitdef.P1SpritePriority; AddToTargetList(target); if (blocked == true) { m_character.BasePlayer.Power += hitdef.P1GuardPowerAdjustment; HitPauseTime = hitdef.GuardPauseTime; MoveContact = 1; MoveGuarded = 1; MoveHit = 0; MoveReversed = 0; } else { m_character.BasePlayer.Power += hitdef.P1HitPowerAdjustment; HitPauseTime = hitdef.PauseTime; MoveContact = 1; MoveGuarded = 0; MoveHit = 1; MoveReversed = 0; } }
public Projectile(FightEngine fightengine, Character creator, ProjectileData data) : base(fightengine) { if (creator == null) throw new ArgumentNullException("creator"); if (data == null) throw new ArgumentNullException("data"); m_creator = creator; m_offsetcharacter = (data.PositionType == PositionType.P2) ? creator.GetOpponent() : creator; m_data = data; m_animationmanager = Creator.AnimationManager.Clone(); m_spritemanager = Creator.SpriteManager.Clone(); m_gameticks = 0; m_hitcountdown = 0; m_state = ProjectileState.Normal; m_totalhits = 0; m_hitpausecountdown = 0; m_currentpriority = Data.Priority; m_palfx = new PaletteFx(); CurrentPalette = Creator.CurrentPalette; CurrentFacing = Creator.CurrentFacing; CurrentLocation = GetStartLocation(); CurrentVelocity = Data.InitialVelocity; CurrentAcceleration = Data.Acceleration; CurrentFlip = SpriteEffects.None; CurrentScale = Data.Scale; DrawOrder = Data.SpritePriority; SetLocalAnimation(Data.AnimationNumber, 0); }
public void Set(Character bindcharacter, Vector2 offset, Int32 time, Int32 facingflag, Boolean targetbind) { if (bindcharacter == null) throw new ArgumentNullException("bindcharacter"); m_bindcharacter = bindcharacter; m_time = time; m_offset = offset; m_facingflag = facingflag; m_istargetbind = targetbind; m_isactive = true; }
public Contact(Character attacker, Character target, HitDefinition hitdef, ContactType type) { if (attacker == null) throw new ArgumentNullException("attacker"); if (target == null) throw new ArgumentNullException("target"); if (hitdef == null) throw new ArgumentNullException("hitdef"); if (type == ContactType.None) throw new ArgumentOutOfRangeException("type"); m_attacker = attacker; m_target = target; m_hitdef = hitdef; m_type = type; }
public CharacterBind(Character character) { if (character == null) throw new ArgumentNullException("character"); m_character = character; m_bindcharacter = null; m_time = 0; m_offset = new Vector2(0, 0); m_facingflag = 0; m_isactive = false; m_istargetbind = false; }
public void Set(Character creator, Int32 time, Int32 buffertime, Int32 movetime, Boolean hitpause, Boolean pausebackgrounds) { if (creator == null) throw new ArgumentNullException("creator"); Reset(); m_creator = creator; m_totaltime = time; m_elapsedtime = 0; m_commandbuffertime = buffertime; m_movetime = movetime; m_hitpause = hitpause; m_pausebackgrounds = pausebackgrounds; foreach (Entity entity in Engine.Entities) m_pausedentities.Add(entity); }
public void OnHit(HitDefinition hitdef, Character attacker, Boolean blocked) { if (hitdef == null) throw new ArgumentNullException("hitdef"); if (attacker == null) throw new ArgumentNullException("attacker"); Boolean alreadyfalling = IsFalling; HitDef.Set(hitdef); Attacker = attacker; Blocked = blocked; if (alreadyfalling == true) { HitDef.Fall = true; } else { m_character.JugglePoints = m_character.BasePlayer.Constants.AirJuggle; } HitCount = (m_character.MoveType == MoveType.BeingHit) ? HitCount + 1 : 1; HitStateType = m_character.StateType; m_character.DrawOrder = HitDef.P2SpritePriority; m_character.PlayerControl = PlayerControl.NoControl; m_character.MoveType = MoveType.BeingHit; if (blocked == true) { HitShakeTime = HitDef.GuardShakeTime; m_character.BasePlayer.Power += HitDef.P2GuardPowerAdjustment; } else { HitShakeTime = HitDef.ShakeTime; m_character.BasePlayer.Power += HitDef.P2HitPowerAdjustment; m_character.PaletteFx.Set(HitDef.PalFxTime, HitDef.PalFxAdd, HitDef.PalFxMul, HitDef.PalFxSinAdd, HitDef.PalFxInvert, HitDef.PalFxBaseColor); if (IsFalling == true) { Int32 neededjugglepoints = EvaluationHelper.AsInt32(Attacker, Attacker.StateManager.CurrentState.JugglePoints, 0); m_character.JugglePoints -= neededjugglepoints; } } }
public OffensiveInfo(Character character) { if (character == null) throw new ArgumentNullException("character"); m_character = character; m_hitdef = new HitDefinition(); m_hitpausetime = 0; m_isactive = false; m_movecontact = 0; m_moveguarded = 0; m_movehit = 0; m_movereversed = 0; m_attackmultiplier = 1; m_hitcount = 0; m_uniquehitcount = 0; m_projectileinfo = new ProjectileInfo(); m_targetlist = new List<Character>(); }
public DefensiveInfo(Character character) { if (character == null) throw new ArgumentNullException("character"); m_character = character; m_hitdef = new HitDefinition(); m_blocked = false; m_killed = false; m_hitstatetype = StateType.None; m_hitshaketime = 0; m_defensemultiplier = 1; m_attacker = null; m_hittime = 0; m_hitby1 = new HitBy(); m_hitby2 = new HitBy(); m_isfalling = false; m_hitoverrides = new List<HitOverride>(); for (Int32 i = 0; i != 8; ++i) m_hitoverrides.Add(new HitOverride()); m_hitcount = 0; }
void OnAttackHit(Character attacker, Character target, HitDefinition hitdef) { if (attacker == null) throw new ArgumentNullException("attacker"); if (target == null) throw new ArgumentNullException("target"); if (hitdef == null) throw new ArgumentNullException("hitdef"); ApplyDamage(attacker, target, hitdef.HitDamage, hitdef.CanKill); if (target.Life == 0) { target.DefensiveInfo.Killed = true; hitdef.Fall = true; } switch (target.DefensiveInfo.HitStateType) { case StateType.Standing: case StateType.Crouching: case StateType.Prone: target.DefensiveInfo.HitTime = hitdef.GroundHitTime; break; case StateType.Airborne: target.DefensiveInfo.HitTime = hitdef.AirHitTime; break; default: throw new ArgumentOutOfRangeException("target.DefensiveInfo.HitStateType"); } if (hitdef.P1NewState != null) { attacker.StateManager.ChangeState(hitdef.P1NewState.Value); } if (hitdef.P2NewState != null) { if (hitdef.P2UseP1State == true) { target.StateManager.ForeignManager = attacker.StateManager; target.StateManager.ChangeState(hitdef.P2NewState.Value); } else { target.StateManager.ForeignManager = null; target.StateManager.ChangeState(hitdef.P2NewState.Value); } } else { target.StateManager.ForeignManager = null; if (hitdef.GroundAttackEffect == AttackEffect.Trip) { target.StateManager.ChangeState(StateMachine.StateNumber.HitTrip); } else { switch (target.DefensiveInfo.HitStateType) { case StateType.Standing: target.StateManager.ChangeState(StateMachine.StateNumber.StandingHitShaking); break; case StateType.Crouching: target.StateManager.ChangeState(StateMachine.StateNumber.CrouchingHitShaking); break; case StateType.Airborne: target.StateManager.ChangeState(StateMachine.StateNumber.AirHitShaking); break; case StateType.Prone: target.StateManager.ChangeState(StateMachine.StateNumber.HitProneShaking); break; default: throw new ArgumentOutOfRangeException("target.DefensiveInfo.HitStateType"); } } } }
void ApplyDamage(Character attacker, Character target, Int32 amount, Boolean cankill) { if (attacker == null) throw new ArgumentNullException("attacker"); if (target == null) throw new ArgumentNullException("target"); Single offensive_multiplier = attacker.OffensiveInfo.AttackMultiplier * (attacker.BasePlayer.Constants.AttackPower / 100.0f); Single defensive_multiplier = target.DefensiveInfo.DefenseMultiplier * (target.BasePlayer.Constants.DefensivePower / 100.0f); amount = (Int32)(amount * offensive_multiplier / defensive_multiplier); target.Life -= amount; if (target.Life == 0 && cankill == false) target.Life = 1; }
Boolean HelperCheck(Character character) { if (character == null) throw new ArgumentNullException("character"); Helper helper = character as Helper; if (helper == null) return false; return helper.Data.Type == HelperType.Normal; }
void ProjectileAttack(Projectile projectile, Character target) { if (projectile == null) throw new ArgumentNullException("projectile"); if (target == null) throw new ArgumentNullException("target"); if (CanBlock(projectile, target, projectile.Data.HitDef, true) == true) { OnAttack(projectile, target, projectile.Data.HitDef, true); } else if (CanHit(projectile, target, projectile.Data.HitDef) == true) { OnAttack(projectile, target, projectile.Data.HitDef, false); } else if (CanBlock(projectile, target, projectile.Data.HitDef, false) == true) { OutOfRangeBlock(target); } }
void HitCheck(Character attacker) { if (attacker == null) throw new ArgumentNullException("attacker"); if (attacker.InHitPause == true || attacker.OffensiveInfo.ActiveHitDef == false) return; foreach (Entity entity in Engine.Entities) { Character target = entity as Character; if (target == null) continue; if (CanBlock(attacker, target, attacker.OffensiveInfo.HitDef, true) == true) { m_attacks.Add(new Contact(attacker, target, attacker.OffensiveInfo.HitDef, ContactType.Block)); } else if (CanHit(attacker, target, attacker.OffensiveInfo.HitDef) == true) { m_attacks.Add(new Contact(attacker, target, attacker.OffensiveInfo.HitDef, ContactType.Hit)); } else if (CanBlock(attacker, target, attacker.OffensiveInfo.HitDef, false) == true) { m_attacks.Add(new Contact(attacker, target, attacker.OffensiveInfo.HitDef, ContactType.MissBlock)); } } }
void OutOfRangeBlock(Character character) { if (character == null) throw new ArgumentNullException("character"); Int32 currentstatenumber = character.StateManager.CurrentState.Number; if (currentstatenumber < StateMachine.StateNumber.GuardStart || currentstatenumber > StateMachine.StateNumber.GuardEnd) { character.StateManager.ChangeState(StateMachine.StateNumber.GuardStart); } }
Vector2 GetSparkLocation(Character attacker, Character target, Vector2 baselocation) { if (attacker == null) throw new ArgumentNullException("attacker"); if (target == null) throw new ArgumentNullException("target"); Vector2 offset = new Vector2(0, attacker.CurrentLocation.Y - target.CurrentLocation.Y); switch (target.CurrentFacing) { case Facing.Left: offset.X = target.CurrentLocation.X - target.GetFrontLocation(); break; case Facing.Right: offset.X = target.GetFrontLocation() - target.CurrentLocation.X; break; } return baselocation + offset; }
void MakeSpark(Character attacker, Character target, Int32 animationnumber, Vector2 sparklocation, Boolean playeranimation) { if (attacker == null) throw new ArgumentNullException("attacker"); if (target == null) throw new ArgumentNullException("target"); ExplodData data = new ExplodData(); data.IsHitSpark = true; data.CommonAnimation = playeranimation == false; data.PositionType = PositionType.P1; data.AnimationNumber = animationnumber; data.SpritePriority = attacker.DrawOrder + 1; data.RemoveTime = -2; data.OwnPalFx = false; data.Scale = Vector2.One; data.Location = GetSparkLocation(attacker, target, sparklocation); data.Creator = attacker; data.Offseter = target; Explod explod = new Explod(attacker.Engine, data); if (explod.IsValid == true) explod.Engine.Entities.Add(explod); }
void PlaySound(Character attacker, Character target, SoundId soundid, Boolean playersound) { if (attacker == null) throw new ArgumentNullException("attacker"); if (target == null) throw new ArgumentNullException("target"); Audio.SoundManager snd = (playersound == true) ? attacker.SoundManager : attacker.Engine.CommonSounds; snd.Play(-1, soundid, false, 0, 1.0f, false); }
void OnAttackBlock(Character attacker, Character target, HitDefinition hitdef) { if (attacker == null) throw new ArgumentNullException("attacker"); if (target == null) throw new ArgumentNullException("target"); if (hitdef == null) throw new ArgumentNullException("hitdef"); target.DefensiveInfo.HitTime = hitdef.GuardHitTime; ApplyDamage(attacker, target, hitdef.GuardDamage, hitdef.CanGuardKill); switch (target.DefensiveInfo.HitStateType) { case StateType.Standing: target.StateManager.ChangeState(StateMachine.StateNumber.StandingGuardHitShaking); break; case StateType.Airborne: target.StateManager.ChangeState(StateMachine.StateNumber.AirGuardHitShaking); break; case StateType.Crouching: target.StateManager.ChangeState(StateMachine.StateNumber.CrouchingGuardHitShaking); break; default: throw new ArgumentOutOfRangeException("target.DefensiveInfo.HitStateType"); } }
void OnAttack(Character attacker, Character target, HitDefinition hitdef, Boolean blocked) { if (attacker == null) throw new ArgumentNullException("attacker"); if (target == null) throw new ArgumentNullException("target"); if (hitdef == null) throw new ArgumentNullException("hitdef"); target.DefensiveInfo.OnHit(hitdef, attacker, blocked); HitDefinition myhitdef = target.DefensiveInfo.HitDef; attacker.OffensiveInfo.OnHit(myhitdef, target, blocked); SetFacing(attacker, target, myhitdef); if (blocked == false) { DoEnvShake(myhitdef, attacker.Engine.EnvironmentShake); PlaySound(attacker, target, myhitdef.HitSoundId, myhitdef.PlayerSound); MakeSpark(attacker, target, myhitdef.SparkAnimation, myhitdef.SparkStartPosition, myhitdef.PlayerSpark); } else { PlaySound(attacker, target, myhitdef.GuardSoundId, myhitdef.GuardPlayerSound); MakeSpark(attacker, target, myhitdef.GuardSparkAnimation, myhitdef.SparkStartPosition, myhitdef.GuardPlayerSpark); } HitOverride hitoverride = target.DefensiveInfo.GetOverride(myhitdef); if (hitoverride != null) { if (hitoverride.ForceAir == true) myhitdef.Fall = true; target.StateManager.ForeignManager = null; target.StateManager.ChangeState(hitoverride.StateNumber); } else { if (blocked == false) { OnAttackHit(attacker, target, myhitdef); } else { OnAttackBlock(attacker, target, myhitdef); } } }
Boolean CanBlock(Entity attacker, Character target, HitDefinition hitdef, Boolean rangecheck) { if (attacker == null) throw new ArgumentNullException("attacker"); if (target == null) throw new ArgumentNullException("target"); if (hitdef == null) throw new ArgumentNullException("hitdef"); if (rangecheck == true && Collision.HasCollision(attacker, ClsnType.Type1Attack, target, ClsnType.Type2Normal) == false) return false; if (hitdef.Targeting == AffectTeam.None) return false; if (((hitdef.Targeting & AffectTeam.Enemy) != AffectTeam.Enemy) && (attacker.Team != target.Team)) return false; if (((hitdef.Targeting & AffectTeam.Friendly) != AffectTeam.Friendly) && (attacker.Team == target.Team)) return false; if (target.CommandManager.IsActive("holdback") == false) return false; if (InGuardDistance(attacker, target, hitdef) == false) return false; if (target.StateType == StateType.Airborne && (hitdef.GuardFlag.HitAir == false || target.Assertions.NoAirGuard == true)) return false; if (target.StateType == StateType.Standing && (hitdef.GuardFlag.HitHigh == false || target.Assertions.NoStandingGuard == true)) return false; if (target.StateType == StateType.Crouching && (hitdef.GuardFlag.HitLow == false || target.Assertions.NoCrouchingGuard == true)) return false; if (target.StateType == StateType.Prone) return false; if (target.Life <= hitdef.GuardDamage && hitdef.CanGuardKill == true) return false; return true; }
void OnAttack(Projectile projectile, Character target, HitDefinition hitdef, Boolean blocked) { if (projectile == null) throw new ArgumentNullException("projectile"); if (target == null) throw new ArgumentNullException("target"); if (hitdef == null) throw new ArgumentNullException("hitdef"); Character attacker = projectile.Creator; target.DefensiveInfo.OnHit(hitdef, projectile.Creator, blocked); hitdef = target.DefensiveInfo.HitDef; projectile.TotalHits += 1; projectile.HitCountdown = projectile.Data.TimeBetweenHits; if (blocked == true) { attacker.BasePlayer.Power += hitdef.P1GuardPowerAdjustment; attacker.BasePlayer.OffensiveInfo.ProjectileInfo.Set(projectile.Data.ProjectileId, ProjectileDataType.Guarded); projectile.HitPauseCountdown = hitdef.GuardPauseTime; PlaySound(attacker, target, hitdef.GuardSoundId, hitdef.GuardPlayerSound); MakeSpark(projectile, target, hitdef.GuardSparkAnimation, hitdef.SparkStartPosition, hitdef.GuardPlayerSpark); } else { attacker.BasePlayer.Power += hitdef.P1HitPowerAdjustment; attacker.BasePlayer.OffensiveInfo.ProjectileInfo.Set(projectile.Data.ProjectileId, ProjectileDataType.Hit); projectile.HitPauseCountdown = hitdef.PauseTime; DoEnvShake(hitdef, attacker.Engine.EnvironmentShake); PlaySound(attacker, target, hitdef.HitSoundId, hitdef.PlayerSound); MakeSpark(projectile, target, hitdef.SparkAnimation, hitdef.SparkStartPosition, hitdef.PlayerSpark); } HitOverride hitoverride = target.DefensiveInfo.GetOverride(hitdef); if (hitoverride != null) { if (hitoverride.ForceAir == true) hitdef.Fall = true; target.StateManager.ForeignManager = null; target.StateManager.ChangeState(hitoverride.StateNumber); } else { if (blocked == false) { OnAttackHit(attacker, target, hitdef); } else { OnAttackBlock(attacker, target, hitdef); } } }
Boolean InGuardDistance(Entity attacker, Character target, HitDefinition hitdef) { if (attacker == null) throw new ArgumentNullException("attacker"); if (target == null) throw new ArgumentNullException("target"); if (hitdef == null) throw new ArgumentNullException("hitdef"); Single distance = Math.Abs(attacker.CurrentLocation.X - target.CurrentLocation.X); return distance <= hitdef.GuardDistance; }
Boolean CanHit(Entity attacker, Character target, HitDefinition hitdef) { if (attacker == null) throw new ArgumentNullException("attacker"); if (target == null) throw new ArgumentNullException("target"); if (hitdef == null) throw new ArgumentNullException("hitdef"); if (Collision.HasCollision(attacker, ClsnType.Type1Attack, target, ClsnType.Type2Normal) == false) return false; if (hitdef.Targeting == AffectTeam.None) return false; if (((hitdef.Targeting & AffectTeam.Enemy) != AffectTeam.Enemy) && (attacker.Team != target.Team)) return false; if (((hitdef.Targeting & AffectTeam.Friendly) != AffectTeam.Friendly) && (attacker.Team == target.Team)) return false; if (target.StateType == StateType.Standing && hitdef.HitFlag.HitHigh == false) return false; if (target.StateType == StateType.Crouching && hitdef.HitFlag.HitLow == false) return false; if (target.StateType == StateType.Airborne && hitdef.HitFlag.HitAir == false) return false; if (target.StateType == StateType.Prone && hitdef.HitFlag.HitDown == false) return false; if (target.MoveType == MoveType.BeingHit && hitdef.HitFlag.ComboFlag == HitFlagCombo.No) return false; if (target.MoveType != MoveType.BeingHit && hitdef.HitFlag.ComboFlag == HitFlagCombo.Yes) return false; if (target.DefensiveInfo.HitBy1.CanHit(hitdef.HitAttribute) == false) return false; if (target.DefensiveInfo.HitBy2.CanHit(hitdef.HitAttribute) == false) return false; if (target.DefensiveInfo.IsFalling == true) { if (attacker is Player) { Player player = attacker as Player; #warning Juggling system is weird Int32 neededjugglepoints = EvaluationHelper.AsInt32(player, player.StateManager.CurrentState.JugglePoints, 0); //if (neededjugglepoints > target.JugglePoints) return false; } } return true; }
void SetFacing(Character attacker, Character target, HitDefinition hitdef) { if (attacker == null) throw new ArgumentNullException("attacker"); if (target == null) throw new ArgumentNullException("target"); if (hitdef == null) throw new ArgumentNullException("hitdef"); if (hitdef.P1Facing == -1) attacker.CurrentFacing = Misc.FlipFacing(attacker.CurrentFacing); if (hitdef.P1GetP2Facing == -1) attacker.CurrentFacing = Misc.FlipFacing(target.CurrentFacing); if (hitdef.P1GetP2Facing == 1) attacker.CurrentFacing = target.CurrentFacing; if (hitdef.P2Facing == 1) target.CurrentFacing = Misc.FlipFacing(attacker.CurrentFacing); if (hitdef.P2Facing == -1) target.CurrentFacing = attacker.CurrentFacing; }