private EffectRenderer(EOGame game, DrawableGameComponent target, Action cleanupAction)
			: base(game)
		{
			_target = target;
			_cleanupAction = cleanupAction;
			_effectSpriteManager = new EffectSpriteManager(game.GFXManager);
			_sb = new SpriteBatch(game.GraphicsDevice);

			SetEffectInfoTypeAndID(EffectType.Invalid, -1);
		}
 public RippleEffect(DrawableGameComponent component)
     : base(component.Game)
 {
     m_component = component;
     m_device = m_component.Game.GraphicsDevice;
     m_contentManager = m_component.Game.Content;
 }
        public bool IntersectsAny(DrawableGameComponent component, Vector3 offset)
        {
            BoundingCylinder cylinder = component.GetBoundingCylinder();
            cylinder.Point += offset;

            return vegetationList.Any(v => cylinder.Intersects(v.GetBoundingCylinder()));
        }
        public VegetationManager(Terrain terrain)
        {
            vegetationList = new List<DrawableGameComponent>();

            var doc = new XmlDocument();
            doc.Load(Config.VegetationConfigPath);

            foreach (XmlElement objectElement in doc.GetElementsByTagName("Object"))
            {
                float radius = float.Parse(objectElement.GetAttribute("boundingCylinderRadius").Replace('.',','));
                float height = float.Parse(objectElement.GetAttribute("boundingCylinderHeight").Replace('.', ','));

                foreach (XmlElement transformElement in objectElement.GetElementsByTagName("Transform"))
                {
                    var vegetationObj = new DrawableGameComponent(radius, height);

                    float x = float.Parse(transformElement.GetAttribute("translateX").Replace('.', ','));
                    float z = float.Parse(transformElement.GetAttribute("translateZ").Replace('.', ','));
                    float y = terrain.GetHeight(x, z);
                    vegetationObj.Position = new Vector3(x, y, z);

                    vegetationObj.Scale = new Vector3(float.Parse(transformElement.GetAttribute("scale").Replace('.', ',')));

                    vegetationList.Add(vegetationObj);
                }
            }
        }
示例#5
0
 /// <summary>
 /// This adds the alien's opponent.
 /// </summary>
 /// <param name="component">The player</param>
 /// <exception cref="ArgumentException">Thrown if the component is not a
 /// PlayerSprite.</exception>
 public override void AddOpponent(DrawableGameComponent component)
 {
     if (component is PlayerSprite)
         opponent = component as PlayerSprite;
     else
         throw new ArgumentException
             ("The opponent must be of PlayerSprite type.");
 }
        public DisposableDrawableGameComponent(Game game, DrawableGameComponent component, float timeToLive)
            : base(game)
        {
            this.component = component;

            this.timeToLive = timeToLive;
            this.time = System.Environment.TickCount;
        }
示例#7
0
文件: Game1.cs 项目: bam6470/stealth
 protected void changeScreen(object sender, ChangeScreenEventArgs args)
 {
     if (args.screenType == ScreenType.InGame)
     {
         Components.Remove(screen);
         screen = new PlayGame(this);
         Components.Add(screen);
         ((PlayGame)screen).Initialize(this);
     }
 }
		public EOChatBubble(CharacterRenderer following)
			: base(EOGame.Instance)
		{
			m_ref = following;
			m_isChar = true;
			DrawOrder = following.Character.ID + (int)ControlDrawLayer.BaseLayer + 1; //use ID for draw order
			_initLabel();
			Visible = false;
			EOGame.Instance.Components.Add(this);
		}
		public EOChatBubble(NPC following)
			: base(EOGame.Instance)
		{
			m_ref = following;
			m_isChar = false;
			DrawOrder = following.Index + (int)ControlDrawLayer.BaseLayer + 1; //use index for draw order
			_initLabel();
			Visible = false;
			EOGame.Instance.Components.Add(this);
		}
示例#10
0
 /// <summary>
 /// This adds the player's opponents.
 /// </summary>
 /// <param name="component">The opponent to be added.</param>
 public override void AddOpponent(DrawableGameComponent component)
 {
     if (component is AlienSquad)
         opponent = component as AlienSquad;
     else if (component is MotherShipSprite)
         motherShip = component as MotherShipSprite;
     else
         throw new ArgumentException
             ("The opponent must be of AlienSquad or MotherShipSprite type.");
 }
示例#11
0
		private EffectRenderer(INativeGraphicsManager gfxManager,
							   DrawableGameComponent target,
							   Action cleanupAction)
		{
			_target = target;
			_cleanupAction = cleanupAction;
			_effectSpriteManager = new EffectSpriteManager(gfxManager);
			_effectSoundManager = new EffectSoundManager(new SoundManager());

			SetEffectInfoTypeAndID(EffectType.Invalid, -1);
		}
 public ProjectileHandler GetNewHandler(DrawableGameComponent emitter)
 {
     if (projectileHandlers.ContainsKey(emitter))
         return projectileHandlers[emitter];
     else
     {
         ProjectileHandler t = new ProjectileHandler(Game, spriteBatch);
         t.Initialize();
         projectileHandlers.Add(emitter, t);
         return t;
     }
 }
        public void CreateItem(byte id)
        {
            var item = new DrawableGameComponent(Config.ItemsCylinderRadius, Config.ItemsCylinderHeight);

            item.Scale = new Vector3(Config.ItemsScale);

            do
            {
                item.Position = Server.Terrain.GetRandomPositionOnTerrain();
            }
            while (Server.VegetationManager.IntersectsAny(item));

            items[id] = item;

            Server.Send(new NetworkPacketAddItem(id, item));
        }
		/// <summary>
		/// This constructor makes the DamageCounter follow 'actor' on the screen.
		/// </summary>
		/// <param name="actor">CharacterRenderer or NPCRenderer</param>
		public DamageCounter(DrawableGameComponent actor)
		{
			m_ref = actor;
			if (m_ref is NPCRenderer)
			{
				m_isCharacter = false;
			}
			else if (m_ref is CharacterRenderer)
			{
				m_isCharacter = true;
			}
			else
			{
				throw new ArgumentException("Invalid actor type. Use Character or NPCRenderer", "actor");
			}

			lock (gfx_init_lock)
			{
				Texture2D wholeSheet = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 58, true);
				//lazy init of spritesheet - static so same texture in use for all damage counters
				//this sheet is a subsheet of GFX002/158 that has only the numbers and 'miss' text
				if (s_NumberSprites == null)
				{
					Color[] data = new Color[123*24];
					wholeSheet.GetData(0, new Rectangle(40, 28, 123, 24), data, 0, data.Length);

					s_NumberSprites = new Texture2D(Game.GraphicsDevice, 123, 24);
					s_NumberSprites.SetData(data);
				}

				//same with health bars - subsheet of GFX002/158 that has only the health bars
				if (s_HealthBarSprites == null)
				{
					Color[] data = new Color[40*35];
					wholeSheet.GetData(0, new Rectangle(0, 28, 40, 35), data, 0, data.Length);

					s_HealthBarSprites = new Texture2D(Game.GraphicsDevice, 40, 35);
					s_HealthBarSprites.SetData(data);
				}
			}

			m_numbersToDraw = new List<Rectangle>();
			Visible = false;
			if(!Game.Components.Contains(this))
				Game.Components.Add(this);
		}
示例#15
0
 protected virtual void Draw(GameTime gameTime)
 {
     if (!_playingVideo)
     {
         foreach (GameComponent gc in _gameComponentCollection)
         {
             if (gc.Enabled && gc is DrawableGameComponent)
             {
                 DrawableGameComponent dc = gc as DrawableGameComponent;
                 if (dc.Visible)
                 {
                     dc.Draw(gameTime);
                 }
             }
         }
     }
 }
示例#16
0
        protected virtual void Draw(GameTime gameTime)
        {
            if (_initializing)
            {
                if (spriteBatch != null)
                {
                    spriteBatch.Begin();

                    // We need to turn this into a progress bar or animation to give better user feedback
                    spriteBatch.Draw(splashScreen, new Vector2(0, 0), Color.White);
                    spriteBatch.End();
                }
            }
            else
            {
                if (!_playingVideo)
                {
                    // Changed from foreach to for loop in case the GameComponents's Update method
                    //   modifies the component collection.  With a foreach it causes an error:
                    //  "Collection was modified; enumeration operation may not execute."
                    //  .Net 4.0 I thought got around this but in Mono 2.10.2 we still get this error.
                    for (int x = 0; x < _gameComponentCollection.Count; x++)
                    {
                        var gc = (GameComponent)_gameComponentCollection[x];
                        if (gc.Enabled && gc is DrawableGameComponent)
                        {
                            DrawableGameComponent dc = gc as DrawableGameComponent;
                            if (dc.Visible)
                            {
                                dc.Draw(gameTime);
                            }
                        }
                    }
                }
            }
        }
 public void RequestDestroyHandler(DrawableGameComponent emitter)
 {
     cleanupList.AddLast(emitter);
 }
 private void EnableDisableDrawable(DrawableGameComponent dgc, bool enabled)
 {
     if (dgc != null)
     {
         dgc.Visible = enabled;
         dgc.Enabled = enabled;
     }
 }
示例#19
0
		public void MakeSpeechBubble(DrawableGameComponent follow, string message, bool groupChat)
		{
			if (!World.Instance.ShowChatBubbles)
				return;

			if (follow == null)
				follow = World.Instance.ActiveCharacterRenderer; /* Calling with null assumes Active Character */

			//show just the speech bubble, since this should be called from the HUD and rendered there already

// ReSharper disable CanBeReplacedWithTryCastAndCheckForNull
			if (follow is CharacterRenderer)
				((CharacterRenderer)follow).SetChatBubbleText(message, groupChat);
			else if (follow is NPC)
				((NPC)follow).SetChatBubbleText(message, groupChat);
// ReSharper restore CanBeReplacedWithTryCastAndCheckForNull
		}
示例#20
0
 internal void setRooms(DrawableGameComponent room1,
     DrawableGameComponent room2,
     DrawableGameComponent room3,
     DrawableGameComponent room4,
     DrawableGameComponent room5,
     DrawableGameComponent room6,
     DrawableGameComponent room7,
     DrawableGameComponent room8)
 {
     rooms.Add(room1);
     rooms.Add(room2);
     rooms.Add(room3);
     rooms.Add(room4);
     rooms.Add(room5);
     rooms.Add(room6);
     rooms.Add(room7);
     rooms.Add(room8);
 }
示例#21
0
 public void Disable(DrawableGameComponent d)
 {
     if (d!=null)
     {
         d.Enabled = false;
         d.Visible = false;
     }
 }
示例#22
0
 public void Enable(DrawableGameComponent d)
 {
     if(d!=null)
     {
         d.Enabled = true;
         d.Visible = true;
     }
 }
示例#23
0
文件: Game1.cs 项目: bam6470/stealth
        protected override void Initialize()
        {
            // Initialize screen slect
            screenSelect = ScreenType.MainMenu;
            screen = new MainMenu(this);
            Components.Add(screen);
            //((MainMenu)screen).Initialize();
            //((MainMenu)screen).LoadContent();
            ((MainMenu)screen).moveToPlayGame += changeScreen;

            // Initialize the pointer
            pointer = new Pointer(this);
            Components.Add(pointer);
            base.Initialize();
        }
示例#24
0
 /// <summary>
 /// Removes the child.
 /// </summary>
 /// <returns>
 /// True if removed successful.
 /// </returns>
 /// <param name='item'>
 /// The <see cref="DrawableGameComponent"/> to remove.
 /// </param>
 public static bool removeChild(DrawableGameComponent item)
 {
     return children.Remove (item);
 }
 public void Setup()
 {
     component = new DrawableGameComponent(new Game());
 }
		public void SetSpellTarget(DrawableGameComponent target)
		{
			Character.SetSpellTarget(target);
			_prepareSpell();
		}
示例#27
0
        private void convertMapNodes(DrawableGameComponent [,] mapNodes, Node[,] tempMap)
        {
            //mapNodes = new DrawableGameComponent[this.internalMap.MapNodeHeight, this.internalMap.MapNodeWidth];
            //Node[,] tempMap = this.internalMap.InternalMapStruct;

            Vector3 startPosition = new Vector3(-(this.internalMap.MapPixelWidth / 2) + (InternalMap.GridSize / 2),
                                                 (this.internalMap.MapPixelHeight / 2 - InternalMap.GridSize / 2),
                                                 InternalMap.GridSize / 2);
            //Console.WriteLine(startPosition);
            Node tempNode = tempMap[0, 0];
            for (int row = 0; row < this.internalMap.MapNodeHeight; row++)
            {
                float x = startPosition.X;
                for (int col = 0; col < this.internalMap.MapNodeWidth; col++)
                {
                    tempNode = tempMap[row, col];

                    if (tempNode is RoomNode)
                    {
                        Room room = new Room(this.game, (RoomNode)tempNode,
                                             new Vector3(startPosition.X, startPosition.Y, startPosition.Z));
                        mapNodes[row, col] = room;
                    }
                    else if (tempNode is WallNode)
                    {
                        Wall wall = new Wall(this.game, (WallNode)tempNode,
                                             new Vector3(startPosition.X, startPosition.Y, startPosition.Z));
                        mapNodes[row, col] = wall;
                    }
                    if (tempNode is EmptyNode)
                    {
                        EmptySpace empty = new EmptySpace(this.game);
                        mapNodes[row, col] = empty;
                    }
                    startPosition.X = startPosition.X + tempNode.Width * InternalMap.GridSize;
                }
                startPosition.X = x;
                startPosition.Y = startPosition.Y - tempNode.Width * InternalMap.GridSize;
            }
        }
示例#28
0
 private static void EnableScene(DrawableGameComponent scene)
 {
     scene.Enabled = true;
     scene.Visible = true;
 }
示例#29
0
 /// <summary>
 /// Abstract method for adding an opponent.
 /// </summary>
 /// <param name="component"></param>
 public abstract void AddOpponent(DrawableGameComponent component);
示例#30
0
 /// <summary>
 /// Adds the child.
 /// </summary>
 /// <param name='item'>
 /// Item.
 /// </param>
 public static void addChild(DrawableGameComponent item)
 {
     children.Add (item);
 }
示例#31
0
 private static void DisableScene(DrawableGameComponent scene)
 {
     scene.Enabled = false;
     scene.Visible = false;
 }
示例#32
0
 public DrawableGameComponentWrapper(DrawableGameComponent component, IScreen screen, DisplayLayer index)
     : base(screen, index)
 {
     Wrapped = component;
 }