當前位置: 首頁>>代碼示例>>C#>>正文


C# BaseEntity.addAttribute方法代碼示例

本文整理匯總了C#中BaseEntity.addAttribute方法的典型用法代碼示例。如果您正苦於以下問題:C# BaseEntity.addAttribute方法的具體用法?C# BaseEntity.addAttribute怎麽用?C# BaseEntity.addAttribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在BaseEntity的用法示例。


在下文中一共展示了BaseEntity.addAttribute方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: createBackground

 public static IEntity createBackground(EntitiesManager manager)
 {
     IEntity background = new BaseEntity(manager);
     background.addAttribute("color", Color.DarkGray);
     background.addAttribute("gameTime", new GameTime());
     background.addBehaviour(GameLoopPhase.Update, new RandomColorBehaviour());
     // menu.addBehaviour(GameLoopPhase.Update, new FadeColorBehaviour());
     background.addBehaviour(GameLoopPhase.Draw, new DrawBehaviour());
     background.addBehaviour(GameLoopPhase.Update, new GameStateChangingBehaviour(Keys.Escape, Buttons.Back, GameState.MainMenu));
     return background;
 }
開發者ID:TimeTourist,項目名稱:mancomb,代碼行數:11,代碼來源:EntityFactory.cs

示例2: createDebugScreen

        public static IEntity createDebugScreen(EntitiesManager manager)
        {
            IEntity debug = new BaseEntity(manager);
            SpriteFont font = manager.game.Content.Load<SpriteFont>("DebugFont");
            String prefix = "debug";
            debug.addAttribute(prefix + "Text", "Something");
            debug.addAttribute(prefix + "Color", Color.White);
            debug.addAttribute(prefix + "Scale", 1f);
            debug.addAttribute(prefix + "Rotation", 0f);
            debug.addAttribute(prefix + "Position", new Vector2(40, 40));
            debug.addBehaviour(GameLoopPhase.Draw, new DrawTextBehaviour(font, prefix));
            debug.addBehaviour(GameLoopPhase.Update, new DebugBehaviour());

            return debug;
        }
開發者ID:TimeTourist,項目名稱:mancomb,代碼行數:15,代碼來源:EntityFactory.cs

示例3: createShip

        public static IEntity createShip(EntitiesManager manager)
        {
            IEntity ship = new BaseEntity(manager);
            Vector2 Pos = new Vector2();
            Pos.X = manager.game.GraphicsDevice.Adapter.CurrentDisplayMode.Height / 8;
            Pos.Y = manager.game.GraphicsDevice.Adapter.CurrentDisplayMode.Width / 8;

            // for controlling behaviour
            ship.addAttribute("position", Pos);
            ship.addAttribute("velocity", new Vector2());
            ship.addAttribute("weight", 0.0076f);
            ship.addAttribute("direction", 0.0f);
            ship.addAttribute("scale", 1f);

            //for drawing
            Texture2D texture = manager.game.Content.Load<Texture2D>("ship");
            ship.addAttribute("texture", texture);

            //behaviours
            ship.addBehaviour(GameLoopPhase.Update, new GameControllingBehavior());
            ship.addBehaviour(GameLoopPhase.Update, new TemporaryGravityBehaviour());
            ship.addBehaviour(GameLoopPhase.Draw, new DrawTexture2DBehaviour());

            return ship;
        }
開發者ID:TimeTourist,項目名稱:mancomb,代碼行數:25,代碼來源:EntityFactory.cs

示例4: createMenu

        internal static IEntity createMenu(EntitiesManager menuEntitiesManager)
        {
            IEntity menu = new BaseEntity(menuEntitiesManager);

            Texture2D boxTexture = new Texture2D(menuEntitiesManager.game.GraphicsDevice, 1, 1);
            boxTexture.SetData(new Color[] { Color.White });

            menu.addAttribute("boxTexture", boxTexture);
            menu.addAttribute("boxColor", Color.DarkGoldenrod);
            menu.addAttribute("boxRectangle", new Rectangle(20, 30, 345, 200));
            menu.addBehaviour(GameLoopPhase.Draw, new DrawFilledRectangleBehaviour());

            SpriteFont MenuTitle = menuEntitiesManager.game.Content.Load<SpriteFont>("MenuTitle");
            SpriteFont MenuItem = menuEntitiesManager.game.Content.Load<SpriteFont>("MenuItem");

            String prefix = "menuTitle";
            menu.addAttribute(prefix + "Text", "Menu");
            menu.addAttribute(prefix + "Color", Color.White);
            menu.addAttribute(prefix + "Scale", 1f);
            menu.addAttribute(prefix + "Rotation", 0f);
            menu.addAttribute(prefix + "Position", new Vector2(40, 50));
            menu.addBehaviour(GameLoopPhase.Draw, new DrawTextBehaviour(MenuTitle, prefix));

            prefix = "menuItem1";
            menu.addAttribute(prefix + "Text", "Play (A) or (Enter)");
            menu.addAttribute(prefix + "Color", Color.Wheat);
            menu.addAttribute(prefix + "Scale", 1f);
            menu.addAttribute(prefix + "Rotation", 0.05f);
            menu.addAttribute(prefix + "Position", new Vector2(40, 90));
            menu.addBehaviour(GameLoopPhase.Draw, new DrawTextBehaviour(MenuItem, prefix));

            prefix = "menuItem2";
            menu.addAttribute(prefix + "Text", "Quit <BACK or (Esc)");
            menu.addAttribute(prefix + "Color", Color.Wheat);
            menu.addAttribute(prefix + "Scale", 1f);
            menu.addAttribute(prefix + "Rotation", 0f);
            menu.addAttribute(prefix + "Position", new Vector2(40, 120));
            menu.addBehaviour(GameLoopPhase.Draw, new DrawTextBehaviour(MenuItem, prefix));

            List<String> attributesToPulsate = new List<string>();
            //menu.addAttribute("attributeToPulsate", "menuItem1Scale");
            //menu.addBehaviour(GameLoopPhase.Update, new PulsatingFloatBehaviour(1f));
            menu.addAttribute("attributeToPulsate", "menuItem1Rotation");
            menu.addBehaviour(GameLoopPhase.Update, new PulsatingFloatBehaviour(0.03f, 0f));

            menu.addAttribute("color", Color.LightSteelBlue);
            menu.addBehaviour(GameLoopPhase.Draw, new DrawBehaviour());

            menu.addBehaviour(GameLoopPhase.Update, new GameStateChangingBehaviour(Keys.Enter, Buttons.A, GameState.Level1));
            menu.addBehaviour(GameLoopPhase.Update, new GameStateChangingBehaviour(Keys.Escape, Buttons.Back, GameState.Exit));

            return menu;
        }
開發者ID:TimeTourist,項目名稱:mancomb,代碼行數:53,代碼來源:EntityFactory.cs


注:本文中的BaseEntity.addAttribute方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。