當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。