public bool Fight(Fighter fighter) { if (fighter.Weapon >= this.Health) { fighter.Health -= this.Weapon; this.Health = 0; this.FighterState = FighterState.Dead; if (fighter.Health <= 0) { fighter.FighterState = FighterState.Dead; return(true); } return(false); } else if (fighter.Health <= this.Weapon) { this.Health -= fighter.Weapon; fighter.Health = 0; fighter.FighterState = FighterState.Dead; return(true); } else { this.Health -= fighter.Weapon; fighter.Health -= this.Weapon; if (fighter.Health <= 0) { fighter.FighterState = FighterState.Dead; } return(false); } }
private void UpdateFleeState() { //get all objects within range of me Collider[] hitColliders = Physics.OverlapSphere(transform.position, crystalRange); //if any //if crystal //invoke retreat //else //invoke seek foreach (Collider c in hitColliders) { if (c.gameObject.tag == "Crystal") { state = FighterState.RETREAT; break; } } if (state != FighterState.RETREAT && Vector3.Distance(transform.position, flee.targetGameObject.transform.position) > range) { state = FighterState.SEEK; seek.enabled = true; flee.enabled = false; } }
/// <summary> /// Instantiate a new fighter controller /// </summary> /// <param name="state">The fighter state (enemy, player, wingman...)</param> /// <param name="trailPositions">List of trails position</param> /// <param name="engineAudio">Engine audio type</param> /// <param name="shootAudio">Gun shoot audio type</param> public FighterController(FighterState state, List <Vector3> trailPositions, SoundType engineAudio, SoundType shootAudio) { this.state = state; this.trailPositions = trailPositions; this.engineAudio = engineAudio; this.shootAudio = shootAudio; }
// Use this for initialization void Start() { characterController = GetComponent <CharacterController>(); myAnimation = GetComponent <Animation>(); myAnimation.playAutomatically = false; // 자동 재생 끄고 myAnimation.Stop(); // 애니메이션 정지 myState = FighterState.Idle; myAnimation[idleAnimClip.name].wrapMode = WrapMode.Loop; // 대기 애니메이션은 반복모드 myAnimation[walkAnimClip.name].wrapMode = WrapMode.Loop; myAnimation[runAnimClip.name].wrapMode = WrapMode.Loop; myAnimation[attack1AnimClip.name].wrapMode = WrapMode.Once; myAnimation[attack2AnimClip.name].wrapMode = WrapMode.Once; myAnimation[attack3AnimClip.name].wrapMode = WrapMode.Once; myAnimation[attack4AnimClip.name].wrapMode = WrapMode.Once; myAnimation[skillAnimClip.name].wrapMode = WrapMode.Once; AddAnimationEvent(attack1AnimClip, "OnAttackAnimFinished"); AddAnimationEvent(attack2AnimClip, "OnAttackAnimFinished"); AddAnimationEvent(attack3AnimClip, "OnAttackAnimFinished"); AddAnimationEvent(attack4AnimClip, "OnAttackAnimFinished"); AddAnimationEvent(skillAnimClip, "OnSkillAnimFinished"); }
private void hardCodeFightersAndSkills() { // Create the player. addFighter(isPlayer: true, maxHealth: playerMaxHealth); player.addSkill( new SkillState( "Fireball", "icon_69", actionCost: 2, cooldown: 2, damage: 10 ) ); player.addSkill(new SkillState("Punch", "icon_126", damage: 3)); player.addSkill( new SkillState( "Enchanted Shield", "icon_70", canTargetEnemy: false, canTargetSelf: true ) ); // Create the enemies. addFighter(isPlayer: false, maxHealth: enemyMaxHealth); FighterState enemy = enemies.ToList()[0].Value; enemy.addSkill( new SkillState("Kick", "icon_16", actionCost: 2, cooldown: 0, damage: 3) ); // Set the turn order. fighterTurnOrder.Add(playerFighterId); fighterTurnOrder.Add(enemy.fighterId); }
public void ReceiveDamage(int damage) { if (currentState == FighterState.dead) { Debug.LogWarning("Fighter is already dead and can no longer receive any damage!"); return; } if (damage > 0) { currentHealth -= damage; if (currentHealth <= 0) { HandleDeath(); } else if (currentHealth <= MaxHealth * LastBreathThreshold) { currentState = FighterState.lastBreath; } } else { Debug.LogWarning("Fighter cannot receive negative damage. Health will not be modified."); } }
public void DrinkPotion(IPotion potion) { if (Health == 0) { Health = 0; } if (Health + potion.Healing > 10) { Health = 10; } if (Health != 0 && (Health + potion.Healing) <= 10) { Health += potion.Healing; } if (Health == 10) { State = FighterState.Healthy; } if (Health < 10) { State = FighterState.Hurt; } if (Health == 0) { State = FighterState.Dead; } }
void ChangeState(FighterState s) { if (anim.GetInteger(animStateName) != (int)s) { anim.SetInteger(animStateName, (int)s); } }
public void ChangeAnimationState(FighterState newState) { // Redundent if (currentAnimation == newState) { return; } // Return if (!animator.isActiveAndEnabled) { return; } //Expeceptions if (!canChangeAnimation) { return; } // Update animator currentAnimation = newState; PlayAnimation(currentAnimation); }
/// <summary> /// Instantiate a new fighter controller /// </summary> /// <param name="state">The fighter state (enemy, player, wingman...)</param> /// <param name="trailPositions">List of trails position</param> /// <param name="engineAudio">Engine audio type</param> /// <param name="shootAudio">Gun shoot audio type</param> public FighterController(FighterState state, List<Vector3> trailPositions, SoundType engineAudio, SoundType shootAudio) { this.state = state; this.trailPositions = trailPositions; this.engineAudio = engineAudio; this.shootAudio = shootAudio; }
/// <summary> /// 공격 애니메이션 재생이 끝나면 호출되는 애니메이션 이벤트 함수 /// </summary> void OnAttackAnimFinished() { if (nextAttack == true) { nextAttack = false; switch (attackState) { case FighterAttackState.Attack1: attackState = FighterAttackState.Attack2; break; case FighterAttackState.Attack2: attackState = FighterAttackState.Attack3; break; case FighterAttackState.Attack3: attackState = FighterAttackState.Attack4; break; case FighterAttackState.Attack4: attackState = FighterAttackState.Attack1; break; } } else { cannotMove = false; myState = FighterState.Idle; attackState = FighterAttackState.Attack1; } }
//IntPtr handle = static void Main(string[] args) { BotLoader.AddSearchPath("../../../UltraBot/Bots/"); var KenBot = BotLoader.LoadBotFromFile("KenBot"); KenBot.Init(0); Util.Init(); DX9Overlay.SetParam("process", "SSFIV.exe"); DX9Overlay.DestroyAllVisual(); TextLabel roundTimer = new TextLabel("Consolas", 10, TypeFace.NONE, new Point(390, 0), Color.White, "", true, true); TextLabel player1 = new TextLabel("Consolas", 10, TypeFace.NONE, new Point(90, 0), Color.White, "", true, true); TextLabel player2 = new TextLabel("Consolas", 10, TypeFace.NONE, new Point(480, 0), Color.White, "", true, true); //Stopwatch sw = new Stopwatch(); // Do something you want to time var ms = MatchState.getInstance(); var f1 = FighterState.getFighter(0); var f2 = FighterState.getFighter(1); KenBot.Init(0); while (true) { ms.Update(); roundTimer.Text = String.Format("Frame:{0}", ms.FrameCounter); UpdateOverlay(player1, f1); UpdateOverlay(player2, f2); KenBot.Run(); } }
void OnSkillAnimFinished() { Vector3 position = transform.position; position += transform.forward * 2.0f; Instantiate(skillEffect, position, Quaternion.identity); myState = FighterState.Idle; }
void Start() { health = MAX_HEALTH; animator = GetComponent <Animator>(); RigidBody = GetComponent <Rigidbody> (); state = FighterState.IDLE; audioSource = GetComponent <AudioSource>(); }
public float GetAnimationLenght(FighterState state) { // Get All Information AnimationClip[] clips = animator.runtimeAnimatorController.animationClips; // Anim Info string animName = ""; float animLength = -1f; foreach (AnimationClip clip in clips) { switch (state) { case FighterState.Idle: animName = ("Idle"); break; case FighterState.WalkLeft: animName = ("Walk Left"); break; case FighterState.WalkRight: animName = ("Walk Right"); break; case FighterState.Attacking: animName = ("Attack"); break; case FighterState.Blocking: animName = ("Block"); break; case FighterState.Crouching: animName = ("Crouch Idle"); break; case FighterState.Damaged: animName = ("Get Damaged"); break; case FighterState.Dying: animName = ("Dying"); break; } } foreach (AnimationClip clip in clips) { //print(clip.name); if (clip.name.Contains(animName)) { animLength = clip.length; } } return(animLength); }
public override bool ChangeState(FighterState state) { if (state == FighterState.Stored) { return(false); } return(base.ChangeState(state)); }
/// <summary> /// 마우스 왼쪽 버튼으로 공격을 합니다 /// </summary> void InputControl() { // 0 마우스 왼쪽, 1 오른쪽, 2 휠 if (Input.GetMouseButtonDown(0) == true) { // 내가 공격중이 아니라면 공격 시작 if (myState != FighterState.Attack) { myState = FighterState.Attack; attackState = FighterAttackState.Attack1; } else { // 공격 중이라면 애니메이션이 일정 이상 재생이 되었다면 다음 공격 활성화 switch (attackState) { case FighterAttackState.Attack1: if (myAnimation[attack1AnimClip.name].normalizedTime > 0.1f) { nextAttack = true; } break; case FighterAttackState.Attack2: if (myAnimation[attack2AnimClip.name].normalizedTime > 0.1f) { nextAttack = true; } break; case FighterAttackState.Attack3: if (myAnimation[attack3AnimClip.name].normalizedTime > 0.1f) { nextAttack = true; } break; case FighterAttackState.Attack4: if (myAnimation[attack4AnimClip.name].normalizedTime > 0.1f) { nextAttack = true; } break; } } } if (Input.GetMouseButtonDown(1) == true) { if (myState == FighterState.Attack) { attackState = FighterAttackState.Attack1; nextAttack = false; } myState = FighterState.Skill; } }
public virtual bool ChangeState(FighterState state) { if (state != FighterState.Stored && immovable) { return(false); } this.state = state; return(true); }
public void ChangeStateToDead() { currentState = FighterState.Dead; //Update Collision Box poseScript.StandUp(); // Animation Set animationScript.ChangeAnimationState(currentState); }
public Attack(InputManager input, Transform parentTransform, PlayerMovement playerMovement, FighterState newState, int totalSteps) { hitboxColor = new Color(Color.Red, .5f); actionFrames = new Dictionary <int, ActionFrame>(); this.parentTransform = parentTransform; this.totalSteps = totalSteps; this.playerMovement = playerMovement; state = newState; isJumpingAttack = false; }
private void addState <T>(FighterState fighterState) { States[typeof(T)] = fighterState; Animator.AddAnimation( fighterState.GetType().Name, new [] { fighterState.Sprite.Sprite }); }
public override void Execute(FighterCharacterController fighter, FighterState state) { if (relative) { fighter.velocity.x += newXValue; } else { fighter.velocity.x = newXValue; } }
public override void Execute(FighterCharacterController fighter, FighterState state) { if (relative) { fighter.targetVelocity.y += newYValue; } else { fighter.targetVelocity.y = newYValue; } }
public void Reset() { currentMissile = null; destination = this.transform.position; state = FighterState.PATROL; patrolIndex = 0; exploded = false; health = 5; disabled = false; missileCount = 10; }
// handle block inputs and state public void Block(bool block) { if (block) { currentState = FighterState.BLOCK; } else { currentState = FighterState.DEFAULT; } animator.SetBool("blocking", block); }
void OnTriggerStay2D(Collider2D other) { if (other.tag == "Player") { state = FighterState.FIGHT; if (missileCount > 0 && (currentMissile == null || !currentMissile.gameObject.activeInHierarchy || currentMissile.source != this.gameObject)) { //missileCount--; currentMissile = Game.Instance.FireMissile(this.transform.position + this.transform.up, this.transform.up, this.gameObject, Game.Instance.player.gameObject, "AS-39 Gyrfalcon", true); } } }
public void RemoveState(FighterState state) { States.Remove(state); foreach (Engines.Spells.SpellBuff buff in this.Buffs.ToArray()) { if (buff.StateType == state) { buff.BuffRemoved(); this.Buffs.Remove(buff); } } }
void Start() { if (!TryGetComponent(out Motor)) { Motor = gameObject.AddComponent <KinematicCharacterMotor>(); } Motor.CharacterController = this; CurrentState = states["Idle"]; CurrentState.OnStateEnter(); }
private void InputControl() { // 0은 왼쪽 버튼, 1은 오른쪽버튼, 2는 휠버튼 if (Input.GetMouseButtonDown(0) == true) { if (_state != FighterState.Attack) { _state = FighterState.Attack; attackState = FighterAttackState.Attack1; } else { switch (attackState) { case FighterAttackState.Attack1: // 10%이상 진행되었다면 if (_animation[attack1AnimClip.name].normalizedTime > 0.1f) { nextAttack = true; } break; case FighterAttackState.Attack2: if (_animation[attack2AnimClip.name].normalizedTime > 0.1f) { nextAttack = true; } break; case FighterAttackState.Attack3: if (_animation[attack3AnimClip.name].normalizedTime > 0.1f) { nextAttack = true; } break; case FighterAttackState.Attack4: if (_animation[attack4AnimClip.name].normalizedTime > 0.1f) { nextAttack = true; } break; default: throw new ArgumentOutOfRangeException(); } } } }
int CheckForStateFighter(FighterState targetState) /// Return fighter in current state; -1 if no one is found /// { if (fighter1.currentState == targetState) { return(1); } if (fighter2.currentState == targetState) { return(2); } /// No Victor /// return(-1); }
protected void ProcessAction(FighterState action) { //Crouch if (action == FighterState.Crouching) { fighterScript.Crouch(true); return; } else { fighterScript.Crouch(false); } if (action == FighterState.Attacking) { //Try to Attack fighterScript.AttackBasic(); } else if (action == FighterState.WalkLeft) { // Try to walk fighterScript.Walk(-1f); } else if (action == FighterState.WalkRight) { // Try to walk fighterScript.Walk(1f); } else if (action == FighterState.Blocking) { // Try to walk fighterScript.Block(); } else if (action == FighterState.Crouching) { fighterScript.Crouch(true); } else { // Try to walk SetCharacterToStandStill(); } }
public void RemoveState(FighterState state) { States.Remove(state); foreach (Engines.Spells.SpellBuff buff in this.Buffs.ToArray()) { if (buff.StateType == state) { buff.BuffRemoved(); this.Buffs.Remove(buff); } } }
private PowerDataStructures.PriorityQueue<float, Fighter> getHealthiestFighters(TeamInformation ti, FighterState requiredFighterState) { PowerDataStructures.PriorityQueue<float, Fighter> healthiestFighters = new PowerDataStructures.PriorityQueue<float,Fighter>(true); foreach (Fighter fi in ti.teamFighters) if (requiredFighterState == FighterState.FS_IDLE) { if (!isFighterEngagedInBattle(ti,fi)) healthiestFighters.Add(new KeyValuePair<float,Fighter>(fi.getHealth,fi)); } else if (requiredFighterState == FighterState.FS_ENGAGED) { if (!isFighterEngagedInBattle(ti, fi)) healthiestFighters.Add(new KeyValuePair<float, Fighter>(fi.getHealth, fi)); } else if (requiredFighterState == FighterState.FS_DONTCARE) healthiestFighters.Add(new KeyValuePair<float, Fighter>(fi.getHealth, fi)); return healthiestFighters; }