当前位置: 首页>>代码示例>>C#>>正文


C# Behavior类代码示例

本文整理汇总了C#中Behavior的典型用法代码示例。如果您正苦于以下问题:C# Behavior类的具体用法?C# Behavior怎么用?C# Behavior使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Behavior类属于命名空间,在下文中一共展示了Behavior类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnStart

        public override void OnStart()
        {
            var behaviorTrees = GetDefaultGameObject(behaviorGameObject.Value).GetComponents<Behavior>();
            if (behaviorTrees.Length == 1) {
                behavior = behaviorTrees[0];
            } else if (behaviorTrees.Length > 1) {
                for (int i = 0; i < behaviorTrees.Length; ++i) {
                    if (behaviorTrees[i].Group == group.Value) {
                        behavior = behaviorTrees[i];
                        break;
                    }
                }
                // If the group can't be found then use the first behavior tree
                if (behavior == null) {
                    behavior = behaviorTrees[0];
                }
            }

            if (behavior != null) {
                var variables = Owner.GetAllVariables();
                for (int i = 0; i < variables.Count; ++i) {
                    behavior.SetVariable(variables[i].Name, variables[i]);
                }

                behavior.EnableBehavior();

                if (waitForCompletion.Value) {
                    behaviorComplete = false;
                    behavior.OnBehaviorEnd += BehaviorEnded;
                }
            }
        }
开发者ID:wishes2018,项目名称:UnityGame,代码行数:32,代码来源:StartBehaviorTree.cs

示例2: Create

		public static object Create(this MocksRepository repository, Type type, object[] constructorArgs, Behavior? behavior,
			Type[] additionalMockedInterfaces, bool? mockConstructorCall, IEnumerable<CustomAttributeBuilder> additionalProxyTypeAttributes = null,
			List<IBehavior> supplementaryBehaviors = null, List<IBehavior> fallbackBehaviors = null, List<object> mixins = null, Expression<Predicate<MethodInfo>> interceptorFilter = null)
		{
			if (behavior == null)
				behavior = DefaultBehavior;

			if (supplementaryBehaviors == null)
				supplementaryBehaviors = new List<IBehavior>();
			if (fallbackBehaviors == null)
				fallbackBehaviors = new List<IBehavior>();
			if (mixins == null)
				mixins = new List<object>();

			DissectBehavior(behavior.Value, mixins, supplementaryBehaviors, fallbackBehaviors, constructorArgs, ref mockConstructorCall);

			return repository.Create(type,
				new MockCreationSettings
				{
					Args = constructorArgs,
					Mixins = mixins,
					SupplementaryBehaviors = supplementaryBehaviors,
					FallbackBehaviors = fallbackBehaviors,
					AdditionalMockedInterfaces = additionalMockedInterfaces,
					MockConstructorCall = mockConstructorCall.Value,
					AdditionalProxyTypeAttributes = additionalProxyTypeAttributes,
					InterceptorFilter = interceptorFilter,
				});
		}
开发者ID:BiBongNet,项目名称:JustMockLite,代码行数:29,代码来源:Behavior.cs

示例3: AI

        /// <summary>
        /// 
        /// </summary>
        /// <param name="world"></param>
        /// <param name="texture"></param>
        /// <param name="size"></param>
        /// <param name="startPosition"></param>
        /// <param name="mass"></param>
        /// <param name="wheelSize"></param>
        /// <param name="game"></param>
        /// <param name="behaviors"></param>
        /// <param name="userdata"></param>
        public AI(World world, Texture2D texture, Vector2 size, Vector2 startPosition, float mass, float wheelSize, Game1 game, Behavior behaviors, string userdata)
            : base(world, texture, size, mass, startPosition, game, userdata)
        {
            //Load(texture, 2, 11, 1,0);
            torso.body.CollisionCategories = Category.Cat2;
            speed = 0.5f;
            //jumpForce = new Vector2(0, -5f);

            Load(texture, 2, 5, 1, 1);
            direction = Direction.Right;
            lastCheck = DateTime.Now;

            //not used yet
            OnGround = true;

            //sets behavior for this AI
            switch (behaviors)
            {
                case Behavior.Patrol:
                    behaviorDel = Patrol;
                    damage = 34;
                    break;

                case Behavior.PatrolDistance:
                    behaviorDel = PatrolDistance;
                    damage = 40;
                    break;

                case Behavior.Turret:
                    fireRate = 0.08f;
                    enemyHP += 100;
                    behaviorDel = Turret;
                    damage = 45;
                    Load(texture, 1, 8, 1, 0);
                    break;

                case Behavior.Boss:
                    Load(texture, 2, 7, 60, 1);
                    fireRate = 0.5f;
                    enemyHP = 1512;
                    jumpForce = new Vector2(0, -21);
                    behaviorDel = Boss;
                    jumpInterval = 2f;
                    direction = Direction.Left;
                    damage = 70;
                    speed = 0.5f;
                    atSpawn = true;
                    break;

                case Behavior.None:
                    behaviorDel = None;
                    break;
            }

            this.behaviors = behaviors;

            //test (leave in peace)
            bossRay = game.Content.Load<Texture2D>("ProgressBar");
            bossRectRay = new Rectangle((int)wheel.Position.X, (int)wheel.Position.Y, 20, 20);
        }
开发者ID:settrbrg,项目名称:ethanolpunk,代码行数:72,代码来源:AI.cs

示例4: Add

 /// <summary>
 /// Adds a new Goal to the brain
 /// </summary>
 /// <param name="behavior"></param>
 public override void Add(Behavior behavior)
 {
     if(behavior is Goal)
         _root.Add(behavior as Goal);
     else
         base.Add(behavior);
 }
开发者ID:rc183,项目名称:igf,代码行数:11,代码来源:GoalBrain.cs

示例5: Camera

        /// <summary>
        /// Constructs a new instance of the camera class. The camera will
        /// have a flight behavior, and will be initially positioned at the
        /// world origin looking down the world negative z axis.
        /// </summary>
        public Camera()
        {
            behavior = Behavior.Flight;
            preferTargetYAxisOrbiting = true;

            fovx = DEFAULT_FOVX;
            znear = DEFAULT_ZNEAR;
            zfar = DEFAULT_ZFAR;

            accumPitchDegrees = 0.0f;
            orbitMinZoom = DEFAULT_ORBIT_MIN_ZOOM;
            orbitMaxZoom = DEFAULT_ORBIT_MAX_ZOOM;
            orbitOffsetLength = DEFAULT_ORBIT_OFFSET_LENGTH;
            firstPersonYOffset = 0.0f;

            eye = Vector3.Zero;
            target = Vector3.Zero;
            targetYAxis = Vector3.UnitY;
            xAxis = Vector3.UnitX;
            yAxis = Vector3.UnitY;
            zAxis = Vector3.UnitZ;

            orientation = Quaternion.Identity;
            viewMatrix = Matrix.Identity;

            savedEye = eye;
            savedOrientation = orientation;
            savedAccumPitchDegrees = 0.0f;
        }
开发者ID:aizotov,项目名称:CancerSimulation,代码行数:34,代码来源:Camera.cs

示例6: Start

 public void Start()
 {
     // cache for quick lookup
     behavior = GetComponent<Behavior>();
     health = GetComponent<Health>();
     health.onDeath += destroySelf;
 }
开发者ID:JohnnyVox,项目名称:schoolfire,代码行数:7,代码来源:Unit.cs

示例7: TheStudentIsLooking

 public void TheStudentIsLooking( Vector3 position)
 {
     if (curBehavior == Behavior.PayingAttention) {
         theStudentPos = position;
         curBehavior = pickOneBehavior();
     }
 }
开发者ID:speregil,项目名称:VRClassroom-GUI,代码行数:7,代码来源:StudentScript.cs

示例8: Remove

 /// <summary>
 /// Removes a Goal from the brain
 /// </summary>
 /// <param name="behavior"></param>
 public override void Remove(Behavior behavior)
 {
     if(behavior is Goal)
         _root.Remove(behavior as Goal);
     else
         base.Remove(behavior);
 }
开发者ID:rc183,项目名称:igf,代码行数:11,代码来源:GoalBrain.cs

示例9: Node_Affordance

 public static Node Node_Affordance(
     this SmartObject o,
     Behavior b,
     Val<string> affordance)
 {
     return new LeafInvoke(
         () => o.Affordance(b.Character, affordance.Value));
 }
开发者ID:alerdenisov,项目名称:ADAPT,代码行数:8,代码来源:SmartObjectNodes.cs

示例10: Level

 internal Level(string n, Behavior loadBehavior, Behavior updateBehavior, Behavior endBehavior, Condition winCondition)
 {
     mName = n;
     LoadBehavior = loadBehavior;
     UpdateBehavior = updateBehavior;
     EndBehavior = endBehavior;
     WinCondition = winCondition;
 }
开发者ID:vincentgarcia00,项目名称:frostbyte-entertainment,代码行数:8,代码来源:Level.cs

示例11: TestConstantBehavior

 public void TestConstantBehavior()
 {
   var b = new Behavior<int>(12);
   var @out = new List<int>();
   Listener l = b.Value().Listen(x => { @out.Add(x); });
   l.Unlisten();
   CollectionAssert.AreEqual(new[] { 12 }, @out);
 }
开发者ID:davideGiovannini,项目名称:sodium,代码行数:8,代码来源:BehaviorTester.cs

示例12: Accumulate

 private static Behavior<double> Accumulate(
         Event<int> ePulses, Behavior<double> calibration) {
     BehaviorLoop<int> total = new BehaviorLoop<int>();
     total.Loop(ePulses.Snapshot(total,(pulses_, total_) => pulses_ + total_).Hold(0));
     return Behavior<double>.Lift(
         (total_, calibration_) => total_ * calibration_,
         total, calibration);
 }
开发者ID:davideGiovannini,项目名称:sodium,代码行数:8,代码来源:AccumulatePulses.cs

示例13: Preset

 public Preset(
   Behavior<int> presetDollars,
   Fill fi,
   Behavior<Optional<Fuel>> fuelFlowing,
   Behavior<Boolean> fillActive)
 {
   Behavior<Speed> speed = Behavior<Speed>.Lift(
     (presetDollars_, price, dollarsDelivered, litersDelivered) =>
     {
       if (presetDollars_ == 0)
         return Speed.FAST;
       else
       {
         if (dollarsDelivered >= (double)presetDollars_)
           return Speed.STOPPED;
         double slowLiters =
           (double)presetDollars_ / price - 0.10;
         if (litersDelivered >= slowLiters)
           return Speed.SLOW;
         else
           return Speed.FAST;
       }
     },
     presetDollars,
     fi.Price,
     fi.DollarsDelivered,
     fi.LitersDelivered);
   Delivery = Behavior<Delivery>.Lift(
     (of, speed_) =>
       speed_ == Speed.FAST
         ? (
           of.Equals(Optional<Fuel>.Of(Fuel.ONE))
             ? Pump.Delivery.FAST1
             : of.Equals(Optional<Fuel>.Of(Fuel.TWO))
               ? Pump.Delivery.FAST2
               : of.Equals(Optional<Fuel>.Of(Fuel.THREE))
                 ? Pump.Delivery.FAST3
                 : Pump.Delivery.OFF
           )
         : speed_ == Speed.SLOW
           ? (
             of.Equals(Optional<Fuel>.Of(Fuel.ONE))
               ? Pump.Delivery.SLOW1
               : of.Equals(Optional<Fuel>.Of(Fuel.TWO))
                 ? Pump.Delivery.SLOW2
                 : of.Equals(Optional<Fuel>.Of(Fuel.THREE))
                   ? Pump.Delivery.SLOW3
                   : Pump.Delivery.OFF
             )
           : Pump.Delivery.OFF,
     fuelFlowing,
     speed);
   KeypadActive = Behavior<bool>.Lift(
     (of, speed_) =>
       !of.IsPresent || speed_ == Speed.FAST,
     fuelFlowing,
     speed);
 }
开发者ID:davideGiovannini,项目名称:sodium,代码行数:58,代码来源:Preset.cs

示例14: BuildTree

        private TreeBehaviorWrapper BuildTree(Behavior node)
        {
            var wrap = new TreeBehaviorWrapper(node);
            foreach (var child in node.GetChildren()) {
                wrap.Nodes.Add(BuildTree(child));
            }

            return wrap;
        }
开发者ID:fry,项目名称:refw,代码行数:9,代码来源:TreeEditor.cs

示例15: ShowAndWait

 // Show animation and loop until the user clicks
 static void ShowAndWait(Behavior<IDrawing> anim)
 {
     af.Animation = anim;
     waiting = true;
     while (waiting) {
         if (!af.Visible) throw new Exception();
         Application.DoEvents();
     }
 }
开发者ID:clp-takekawa,项目名称:codes-from-books,代码行数:10,代码来源:Program.cs


注:本文中的Behavior类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。