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


C# IEntity.addAttribute方法代码示例

本文整理汇总了C#中IEntity.addAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# IEntity.addAttribute方法的具体用法?C# IEntity.addAttribute怎么用?C# IEntity.addAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEntity的用法示例。


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

示例1: doBehaviour

 public override void doBehaviour(IEntity parent)
 {
     Vector2 velocity = parent.getAttribute<Vector2>("velocity");
     Vector2 position = parent.getAttribute<Vector2>("position");
     float weight = parent.getAttribute<float>("weight");
     // float timeSeconds = parent.getManager().game.gameTime.ElapsedGameTime.Milliseconds * 0.0001f;
     velocity = new Vector2(velocity.X, velocity.Y + (weight));
     position += velocity;
     parent.addAttribute("velocity", velocity);
     parent.addAttribute("position", position);
     parent.addAttribute("weight", weight);
 }
开发者ID:TimeTourist,项目名称:mancomb,代码行数:12,代码来源:TemporaryGravityBehaviour.cs

示例2: doBehaviour

        public override void doBehaviour(IEntity parent)
        {
            KeyboardState keyboardState = Keyboard.GetState(0);
            StringBuilder ds = new StringBuilder();

            if (keyboardState.GetPressedKeys().Contains(Keys.Q))
            {
                parent.getManager().game.IsFixedTimeStep = !parent.getManager().game.IsFixedTimeStep;
            }
            if (keyboardState.GetPressedKeys().Contains(Keys.W))
            {
                parent.getManager().game.graphics.SynchronizeWithVerticalRetrace = !parent.getManager().game.graphics.SynchronizeWithVerticalRetrace;
            }
            if (keyboardState.GetPressedKeys().Contains(Keys.F))
            {
                parent.getManager().game.graphics.ToggleFullScreen();
            }
            ds.Append("IsFixedTimeStep (Q to toggle): ");
            ds.Append(parent.getManager().game.IsFixedTimeStep);
            ds.AppendLine();
            ds.Append("ElapsedGameTime:");
            ds.Append(parent.getManager().game.gameTime.ElapsedGameTime);
            ds.AppendLine();
            ds.Append("TargetElapsedTime: ");
            ds.Append(parent.getManager().game.TargetElapsedTime);
            ds.AppendLine();
            ds.Append("SynchronizeWithVerticalRetrace (W to toggle): ");
            ds.Append(parent.getManager().game.graphics.SynchronizeWithVerticalRetrace);
            ds.AppendLine();
            ds.Append("Toggle fullscreen (F to toggle): ");

            parent.addAttribute("debugText", ds.ToString());
        }
开发者ID:TimeTourist,项目名称:mancomb,代码行数:33,代码来源:DebugBehaviour.cs

示例3: doBehaviour

        public override void doBehaviour(IEntity parent)
        {
            GameTime gameTime = parent.getAttribute<GameTime>("gameTime");

            fadeDelay -= gameTime.ElapsedGameTime.TotalSeconds;

            if (fadeDelay <= 0)
            {
                //Reset the Fade delay
                fadeDelay = .035;
                //Increment/Decrement the fade value for the image
                alphaValue += fadeIncrement;
                //If the AlphaValue is equal or above the max Alpha value or
                //has dropped below or equal to the min Alpha value, then
                //reverse the fade
                if (alphaValue > 1f)
                {
                    alphaValue = 0f;

                }

                Color color = Color.Lerp(parent.getAttribute<Color>("color"), goalColor, alphaValue);
                parent.addAttribute("color", color);

            }
        }
开发者ID:TimeTourist,项目名称:mancomb,代码行数:26,代码来源:FadeColorBehaviour.cs

示例4: doBehaviour

        public override void doBehaviour(IEntity parent)
        {
            // probably not a good place to have Textures... They get big, and are copied here,
            // better have them stored somewhare for direct access.
            float direction = parent.getAttribute<float>("direction");
            Vector2 position = parent.getAttribute<Vector2>("position");
            Vector2 velocity = parent.getAttribute<Vector2>("velocity");
            GamePadState gamePadState = GamePad.GetState(0);
            KeyboardState keyboardState = Keyboard.GetState(0);

            if (gamePadState.ThumbSticks.Left.X > 0.2f || gamePadState.ThumbSticks.Left.X < -0.2f)
            {
                direction += gamePadState.ThumbSticks.Left.X * 0.1f;
                float circle = MathHelper.Pi * 2;
                direction = direction % circle;
            }
            if (gamePadState.IsButtonDown(Buttons.A) || keyboardState.IsKeyDown(Keys.Up))
            {
                //Velocity += AngleToVector(Direction) * new Vector2(0.3f, 0.3f);
                //Pos += AngleToVector(Direction) * new Vector2(12.3f, 12.3f);
                velocity += AngleToVector(direction) * new Vector2(0.3f, 0.3f);
            }
            if (gamePadState.IsButtonDown(Buttons.Y) || keyboardState.IsKeyDown(Keys.Space))
            {
                position = new Vector2(100, 100);
                velocity = new Vector2();
                direction = 0;
            }

            if (keyboardState.IsKeyDown(Keys.Left) == true)
            {
                direction -= 0.05f;
                float circle = MathHelper.Pi * 2;
                direction = direction % circle;
            }
            else if (keyboardState.IsKeyDown(Keys.Right) == true)
            {
                direction += 0.05f;
                float circle = MathHelper.Pi * 2;
                direction = direction % circle;
            }
            parent.addAttribute("direction", direction);
            parent.addAttribute("position", position);
            parent.addAttribute("velocity", velocity);
        }
开发者ID:TimeTourist,项目名称:mancomb,代码行数:45,代码来源:GameControllingBehavior.cs

示例5: doBehaviour

        public override void doBehaviour(IEntity parent)
        {
            string attributeToPulsate = parent.getAttribute<string>("attributeToPulsate");
            float attribute = parent.getAttribute<float>(attributeToPulsate);
            double time = parent.getManager().game.gameTime.TotalGameTime.TotalSeconds;

            float pulsate = (float)Math.Sin(time * 4);
            attribute = multiplier + pulsate * offset;
            parent.addAttribute(attributeToPulsate, attribute);
        }
开发者ID:TimeTourist,项目名称:mancomb,代码行数:10,代码来源:PulsatingFloatBehaviour.cs

示例6: doBehaviour

 public override void doBehaviour(IEntity parent)
 {
     if (r.Next(0, 100) < 1)
     {
         Color c = new Color(
             (byte)r.Next(0, 255),
             (byte)r.Next(0, 255),
             (byte)r.Next(0, 255));
         parent.addAttribute("color", c);
     }
 }
开发者ID:TimeTourist,项目名称:mancomb,代码行数:11,代码来源:RandomColorBehaviour.cs


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