Advertisement
Michael_smith

Entitymanager

Mar 31st, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 KB | None | 0 0
  1. using Microsoft.Xna.Framework;
  2. using Microsoft.Xna.Framework.Graphics;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace GameBase
  10. {
  11.     class EntityMgr
  12.     {
  13.         public void AddEntity(Entity entityToAdd)
  14.         {
  15.  
  16.             Entity stepEntity = firstentity;
  17.             if (firstentity != null)
  18.             {
  19.                 while (stepEntity.nextEntity != null)
  20.                 {
  21.                     stepEntity = stepEntity.nextEntity; // stepentity blir nรคsta entity
  22.                     {
  23.  
  24.                     }
  25.                     stepEntity.nextEntity = entityToAdd;
  26.                     {
  27.                         firstentity = entityToAdd; //lรคgger till en ny entity.
  28.                     }
  29.                 }
  30.             }
  31.         }
  32.                    
  33.         private Entity firstentity;
  34.         public EntityMgr()
  35.         {
  36.             firstentity = null;
  37.         }
  38.         public void Update(GameTime gameTime)
  39.         {
  40.            
  41.             Entity stepEntity = this.firstentity;
  42.             if (firstentity!= null)
  43.             {
  44.                 while(stepEntity!=null)
  45.                 {
  46.                     stepEntity.Update(gameTime);
  47.                     stepEntity = stepEntity.nextEntity;
  48.                    
  49.                 }
  50.             }
  51.  
  52.         }
  53.         public void Draw(SpriteBatch spriteBatch)
  54.         {
  55.             Entity stepentity = this.firstentity;
  56.  
  57.             if (firstentity != null)
  58.  
  59.             {
  60.                 while (stepentity != null)
  61.                 {
  62.                     stepentity.Draw(spriteBatch);
  63.                     stepentity = stepentity.nextEntity;
  64.  
  65.                 }
  66.             }
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement