• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Behavior类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: AddChildToNode

        bool AddChildToNode(Behavior node, Behavior child)
        {
            if (node.GetChildren().Count < node.GetMaxChildren()) {
                node.GetChildren().Add(child);
                return true;
            }

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


示例17: perFuel

 static Behavior<String> perFuel(
   Event<UpDown> eNozzle,
   Behavior<Double> price)
 {
   Behavior<Double> capPrice = eNozzle.Snapshot(price).Hold(0.0);
   Behavior<UpDown> nozzle = eNozzle.Hold(UpDown.DOWN);
   return Behavior<UpDown>.Lift(
     (u, price_) => u.Equals(UpDown.UP) ? Formatters.FormatPrice(price_) : "",
     nozzle,
     capPrice);
 }
开发者ID:davideGiovannini,项目名称:sodium,代码行数:11,代码来源:CapturePrice.cs


示例18: WhenSetDown

 private static Event<End> WhenSetDown(Event<UpDown> eNozzle,
             Fuel nozzleFuel,
             Behavior<Optional<Fuel>> fillActive) 
 {
     return Event<End>.FilterOptional(
         eNozzle.Snapshot(fillActive,
             (u,f) => u == UpDown.DOWN &&
                      f.Equals(Optional<Fuel>.Of(nozzleFuel))
                                    ? Optional<End>.Of(End.END)
                                    : Optional<End>.Empty()));
 }
开发者ID:davideGiovannini,项目名称:sodium,代码行数:11,代码来源:LifeCycle.cs


示例19: perFuel

 static Behavior<String> perFuel(
   Event<UpDown> eNozzle,
   Behavior<Double> price)
 {
   Event<StartFill> eStartFill = eNozzle.Filter(u => u == UpDown.UP) .Map(u => StartFill.START_FILL);
   Behavior<Double> capPrice = eStartFill.Snapshot(price).Hold(0.0);
   Behavior<UpDown> nozzle = eNozzle.Hold(UpDown.DOWN);
   return Behavior<UpDown>.Lift(
     (u, price_) => u.Equals(UpDown.UP) ? Formatters.FormatPrice(price_) : "",
     nozzle,
     capPrice);
 }
开发者ID:davideGiovannini,项目名称:sodium,代码行数:12,代码来源:CapturePriceFiltered.cs


示例20: Fill

 public Fill(
         Event<Unit> eClearAccumulator, Event<int> eFuelPulses,
         Behavior<Double> calibration, Behavior<Double> price1,
         Behavior<Double> price2, Behavior<Double> price3,
         Event<Fuel> eStart) 
 {
     Price = CapturePrice(eStart, price1, price2, price3);
     LitersDelivered = AccumulatePulsesPump.Accumulate(
             eClearAccumulator, eFuelPulses, calibration);
     DollarsDelivered = Behavior<double>.Lift(
             (liters, price_) => liters * price_,
             LitersDelivered, Price);
 }
开发者ID:davideGiovannini,项目名称:sodium,代码行数:13,代码来源:Fill.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BehaviorChain类代码示例发布时间:2022-05-24
下一篇:
C# Behaviac类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap