コード例 #1
0
        public ICharacterState Step()
        {
            behaviour.Idle();
            findTargetCooldown.Update();
            idleDoneCooldown.Update();

            // If there's target, attack
            if (findTargetCooldown.Ready())
            {
                var target = behaviour.FindTarget();

                if (target != null)
                {
                    return(new AttackState(behaviour, character, target));
                }
            }

            // If havn't done idling, idle
            if (!idleDoneCooldown.Ready())
            {
                return(this);
            }

            // Otherwise patrol
            return(new PatrolState(behaviour, character));
        }
コード例 #2
0
ファイル: PatrolState.cs プロジェクト: will3/Cubical-planet
        public ICharacterState Step()
        {
            findTargetCooldown.Update();

            // Attack if there is target
            if (findTargetCooldown.Ready())
            {
                var target = behaviour.FindTarget();

                if (target != null)
                {
                    return(new AttackState(behaviour, character, target));
                }
            }

            // Keep patrolling
            var finished = behaviour.Patrol();

            if (!finished)
            {
                return(this);
            }

            return(new IdleState(behaviour, character));
        }