Ejemplo n.º 1
0
        private void categoriseComponents(UnitEntity e)
        {
            foreach (BaseUnitComponent buc in e.Components)
            {
                switch (buc.Category)
                {
                case ComponentCategory.Graphic:
                    BaseDrawableUnitComponent comp = buc as BaseDrawableUnitComponent;
                    if (comp == null)
                    {
                        throw new Exception("GraphicCategory Component is not a DrawableUnitComponent!");
                    }
                    this.graphicComponents.Add(comp);
                    break;

                case ComponentCategory.Movement:
                    this.movementComponents.Add(buc);
                    break;

                case ComponentCategory.Misc:
                    this.miscComponents.Add(buc);
                    break;

                default: throw new Exception("Unknown category!");
                }
            }

            // just to make sure, clear all components in unitentity
            e.Components.Clear();
        }
Ejemplo n.º 2
0
        public UnitEntity CreateUnitEntity(UnitEntityType type)
        {
            UnitEntity e = null;

            switch (type)
            {
            case UnitEntityType.Cube: e = buildCube(); break;

            default: throw new ArgumentException("Unknown unit entity.");
            }

            return(e);
        }
Ejemplo n.º 3
0
        public override void Initialize()
        {
            // testing
            UnitEntity e = unitBuilder.CreateUnitEntity(UnitEntityType.Cube);

            categoriseComponents(e);

            vpService = (IViewportService)this.Game.Services.GetService(typeof(IViewportService));
            vpService.MainViewChanged += new ViewportService.ViewportChangedHandler(vpService_MainViewChanged);
            this.mapViewport           = vpService.MainView;

            base.Initialize();
        }
Ejemplo n.º 4
0
        protected UnitEntity buildCube()
        {
            UnitEntity e = new UnitEntity();
            UnitServices unitservices = new UnitServices();
            unitservices.AddService(typeof(IUnitEntityType), e);

            GraphicComponent graphic = new GraphicComponent(); // get provided services

            // init each component
            initializeComponent(graphic, unitservices);
            graphic.LoadContent();

            e.Components.Add(graphic);
            return e;
        }
Ejemplo n.º 5
0
        protected UnitEntity buildCube()
        {
            UnitEntity   e            = new UnitEntity();
            UnitServices unitservices = new UnitServices();

            unitservices.AddService(typeof(IUnitEntityType), e);

            GraphicComponent graphic = new GraphicComponent(); // get provided services

            // init each component
            initializeComponent(graphic, unitservices);
            graphic.LoadContent();

            e.Components.Add(graphic);
            return(e);
        }
Ejemplo n.º 6
0
        private void categoriseComponents(UnitEntity e)
        {
            foreach (BaseUnitComponent buc in e.Components)
            {
                switch (buc.Category)
                {
                    case ComponentCategory.Graphic:
                        BaseDrawableUnitComponent comp = buc as BaseDrawableUnitComponent;
                        if (comp == null)
                        {
                            throw new Exception("GraphicCategory Component is not a DrawableUnitComponent!");
                        }
                        this.graphicComponents.Add(comp);
                        break;
                    case ComponentCategory.Movement:
                        this.movementComponents.Add(buc);
                        break;
                    case ComponentCategory.Misc:
                        this.miscComponents.Add(buc);
                        break;
                    default: throw new Exception("Unknown category!");

                }
            }

            // just to make sure, clear all components in unitentity
            e.Components.Clear();
        }