示例#1
0
 public void Enter(ICharacterable characterable)
 {
     if (null != OnStart)
     {
         OnStart(characterable);
     }
 }
示例#2
0
 public void Exit(ICharacterable characterable)
 {
     if (null != OnEnd)
     {
         OnEnd(characterable);
     }
 }
示例#3
0
        public bool Execute(ICharacterable executor)
        {
            if (executor.BattleCharacter.Stamina.Current < GetNeedToUseStamina())
            {
                return(false);
            }

            if (!executor.BattleCharacter.Stamina.Use(GetUsedStamina()))
            {
                return(false);
            }

            if (OnExecute != null)
            {
                OnExecute(executor, this);
            }

            float sinY = (float)Math.Sin(executor.CurrentRotation.y * Math.PI / 180.0f);
            float cosY = (float)Math.Cos(executor.CurrentRotation.y * Math.PI / 180.0f);

            Vector velocity = new Vector(movePosition.x * cosY + movePosition.z * sinY, movePosition.y, -movePosition.x * sinY + movePosition.z * cosY);

            velocity = velocity / executingTime;

            executor.SetVelocity(velocity.x, velocity.y, velocity.z);

            executor.CurrentState.OnEnd += onFinishExecute;

            return(true);
        }
示例#4
0
        public IState Update(IThinkable parent, ICharacterable own, float now, float deltaTime)
        {
            if (!own.CanMove())
            {
                return(this);
            }

            Vector direction = new Vector();

            if (GlobalRandom.Generator.Next() % 2 == 0)
            {
                direction.x = (float)(GlobalRandom.Generator.NextDouble() - 0.5);
            }
            if (GlobalRandom.Generator.Next() % 2 == 0)
            {
                direction.z = (float)(GlobalRandom.Generator.NextDouble() - 0.5);
            }

            if (direction.Magnitude() != 0.0f)
            {
                direction = direction / direction.Magnitude();
            }
            direction = direction * own.RunMaxSpeed;

            own.SetVelocity(direction.x, direction.y, direction.z);

            return(new state.Walking(0.5f));
        }
示例#5
0
        public void Exit(ICharacterable characterable)
        {
            characterable.SetVelocity(0.0f, 0.0f, 0.0f);

            characterable.SkillHolder.ResetCurrent();

            OnEnd(characterable);
        }
示例#6
0
        public bool Check(ICharacterable own)
        {
            var enemies = Grouping.SearchEnemyGroup(own);

            var target = utility.AttackableSearcher.SearchTarget(own, enemies);

            return(target != null);
        }
示例#7
0
        public BattleCharacter(ICharacterable owner, BattleStatus _status)
        {
            this.owner   = owner;
            BattleStatus = _status;
            //  現在HPを最大にしておく
            CurrentHitPoint = status.HitPoint;

            Stamina = new Stamina(BattleStatus.Stamina, BattleStatus.StaminaHealInterval, BattleStatus.StaminaHealValuePerInterval);
        }
示例#8
0
        public IState Update(IThinkable parent, ICharacterable own, float now, float deltaTime)
        {
            if (!own.Executioner.ExecuteNormal(now, own))
            {
                return(this);
            }

            return(new state.Attacking(own));
        }
示例#9
0
        public static void Dispatch(ActionEventTypes type, ICharacterable characterable)
        {
            Action <ICharacterable> result;

            if (actionEventHandlers.TryGetValue(type, out result))
            {
                if (null == result)
                {
                    return;
                }

                result(characterable);
            }
        }
示例#10
0
        public TurnRound(ICharacterable own, float _waitTime)
        {
            waitTime = _waitTime;

            elapsedTime = 0.0f;

            //  一番近い敵に向きを変える
            var enemies = Grouping.SearchEnemyGroup(own);

            if (enemies.Count != 0)
            {
                var target = enemies.First();

                var direction = target.CurrentPosition - own.CurrentPosition;
                own.SetRotation(0.0f, (float)(180.0f / Math.PI * Math.Atan2(direction.x, direction.z)), 0.0f);
            }
        }
示例#11
0
        public void Effect(ICharacterable executor, ICharacterable target, Vector hitPosition)
        {
            var damage = attack + executor.BattleCharacter.BattleStatus.Attack - target.BattleCharacter.BattleStatus.Defense;

            target.BattleCharacter.Damaged(damage);

            var knockBackDistance = knockBack + executor.BattleCharacter.BattleStatus.KnockBackAttack - target.BattleCharacter.BattleStatus.KnockBackRegist;

            if (knockBackDistance > 0.0f)
            {
                var direction = target.CurrentPosition - hitPosition;
                direction.y = 0.0f;

                direction = direction / direction.Magnitude();

                target.KnockBacked(direction * knockBackDistance);
            }
        }
示例#12
0
        public bool ExecuteNormal(float now, ICharacterable characterable)
        {
            var skill = characterable.SkillHolder.Current;

            if (null == skill)
            {
                return(false);
            }

            if (characterable.BattleCharacter.Stamina.Current < skill.GetNeedToUseStamina())
            {
                return(false);
            }

            var finishState = new SkillExecuteFinish();

            finishState.OnStart += delegate(ICharacterable dummy) { characterable.SkillHolder.ResetCurrent(); };

            if (!characterable.ChangeState(
                    new SkillExecuting(
                        now,
                        skill.GetExecutingTime() - skill.GetChainTime(),
                        new NextSkillChainChance(
                            now,
                            skill.GetExecutingTime() + skill.GetChainTime(),
                            new SkillRecasting(
                                now,
                                skill.GetExecutingTime() + skill.GetRecastingTime(),
                                finishState
                                )
                            )
                        )
                    ))
            {
                return(false);
            }

            //  実行
            skill.Execute(characterable);

            characterable.SkillHolder.MoveNextNormal();

            return(true);
        }