コード例 #1
0
        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);
            }
        }
コード例 #2
0
    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;
        }
    }
コード例 #3
0
 /// <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;
 }
コード例 #4
0
ファイル: FighterControl.cs プロジェクト: gagip/GameDev
    // 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");
    }
コード例 #5
0
    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);
    }
コード例 #6
0
    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.");
        }
    }
コード例 #7
0
        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;
            }
        }
コード例 #8
0
 void ChangeState(FighterState s)
 {
     if (anim.GetInteger(animStateName) != (int)s)
     {
         anim.SetInteger(animStateName, (int)s);
     }
 }
コード例 #9
0
        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);
        }
コード例 #10
0
 /// <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;
 }
コード例 #11
0
ファイル: FighterControl.cs プロジェクト: gagip/GameDev
    /// <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;
        }
    }
コード例 #12
0
        //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();
            }
        }
コード例 #13
0
ファイル: FighterControl.cs プロジェクト: gagip/GameDev
    void OnSkillAnimFinished()
    {
        Vector3 position = transform.position;

        position += transform.forward * 2.0f;
        Instantiate(skillEffect, position, Quaternion.identity);
        myState = FighterState.Idle;
    }
コード例 #14
0
 void Start()
 {
     health      = MAX_HEALTH;
     animator    = GetComponent <Animator>();
     RigidBody   = GetComponent <Rigidbody> ();
     state       = FighterState.IDLE;
     audioSource = GetComponent <AudioSource>();
 }
コード例 #15
0
        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);
        }
コード例 #16
0
        public override bool ChangeState(FighterState state)
        {
            if (state == FighterState.Stored)
            {
                return(false);
            }

            return(base.ChangeState(state));
        }
コード例 #17
0
ファイル: FighterControl.cs プロジェクト: gagip/GameDev
    /// <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;
        }
    }
コード例 #18
0
        public virtual bool ChangeState(FighterState state)
        {
            if (state != FighterState.Stored && immovable)
            {
                return(false);
            }

            this.state = state;
            return(true);
        }
コード例 #19
0
        public void ChangeStateToDead()
        {
            currentState = FighterState.Dead;

            //Update Collision Box
            poseScript.StandUp();

            // Animation Set
            animationScript.ChangeAnimationState(currentState);
        }
コード例 #20
0
 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;
 }
コード例 #21
0
 private void addState <T>(FighterState fighterState)
 {
     States[typeof(T)] = fighterState;
     Animator.AddAnimation(
         fighterState.GetType().Name,
         new []
     {
         fighterState.Sprite.Sprite
     });
 }
コード例 #22
0
 public override void Execute(FighterCharacterController fighter, FighterState state)
 {
     if (relative)
     {
         fighter.velocity.x += newXValue;
     }
     else
     {
         fighter.velocity.x = newXValue;
     }
 }
コード例 #23
0
 public override void Execute(FighterCharacterController fighter, FighterState state)
 {
     if (relative)
     {
         fighter.targetVelocity.y += newYValue;
     }
     else
     {
         fighter.targetVelocity.y = newYValue;
     }
 }
コード例 #24
0
ファイル: FighterShip.cs プロジェクト: Hacksie/SS-Swansong
 public void Reset()
 {
     currentMissile = null;
     destination    = this.transform.position;
     state          = FighterState.PATROL;
     patrolIndex    = 0;
     exploded       = false;
     health         = 5;
     disabled       = false;
     missileCount   = 10;
 }
コード例 #25
0
 // handle block inputs and state
 public void Block(bool block)
 {
     if (block)
     {
         currentState = FighterState.BLOCK;
     }
     else
     {
         currentState = FighterState.DEFAULT;
     }
     animator.SetBool("blocking", block);
 }
コード例 #26
0
ファイル: FighterShip.cs プロジェクト: Hacksie/SS-Swansong
 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);
         }
     }
 }
コード例 #27
0
ファイル: Fighter.cs プロジェクト: XaferDev/Crystal
 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);
         }
     }
 }
コード例 #28
0
    void Start()
    {
        if (!TryGetComponent(out Motor))
        {
            Motor = gameObject.AddComponent <KinematicCharacterMotor>();
        }

        Motor.CharacterController = this;

        CurrentState = states["Idle"];
        CurrentState.OnStateEnter();
    }
コード例 #29
0
        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();
                    }
                }
            }
        }
コード例 #30
0
        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);
        }
コード例 #31
0
        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();
            }
        }
コード例 #32
0
ファイル: Fighter.cs プロジェクト: nightwolf93/Crystal
 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);
         }
     }
 }
コード例 #33
0
ファイル: AIController.cs プロジェクト: nthfloor/Nebulon12
        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;
        }