public TileUI(MapEditorController controller, CellComponent observable)
        {
            InitializeComponent();
            this.controller = controller;
            this.cell = observable;

            // Initialize Image
            if (observable != null)
            {
                // Register for TileChange event.
                observable.TileChangedEvent += this.ChangeTile;
                observable.UnitAddedEvent += this.UnitAddedToCell;
                observable.UnitRemovedEvent += this.UnitRemovedFromCell;

                TileFactory tf = TileFactory.Instance;
                this.Image = tf.getBitmapImproved(observable.GetTile());

                foreach (ModelComponent m in observable.EntitiesContainedWithin)
                {
                    if (m is UnitComponent)
                    {
                        UnitUI unitUI = new UnitUI(controller, m as UnitComponent);
                        Controls.Add(unitUI);
                        unitUI.MouseClick += TileUI_MouseDown;
                    }
                }
            }

            AllowDrop = true;
        }
Example #2
0
        public TileUI(MapEditorController controller, CellComponent observable)
        {
            InitializeComponent();
            this.controller = controller;
            this.cell       = observable;

            // Initialize Image
            if (observable != null)
            {
                // Register for TileChange event.
                observable.TileChangedEvent += this.ChangeTile;
                observable.UnitAddedEvent   += this.UnitAddedToCell;
                observable.UnitRemovedEvent += this.UnitRemovedFromCell;

                TileFactory tf = TileFactory.Instance;
                this.Image = tf.getBitmapImproved(observable.GetTile());

                foreach (ModelComponent m in observable.EntitiesContainedWithin)
                {
                    if (m is UnitComponent)
                    {
                        UnitUI unitUI = new UnitUI(controller, m as UnitComponent);
                        Controls.Add(unitUI);
                        unitUI.MouseClick += TileUI_MouseDown;
                    }
                }
            }



            AllowDrop = true;
        }
Example #3
0
        private void UnitAddedToCell(Object sender, UnitArgs args)
        {
            for (int i = 0; i < Controls.Count;)
            {
                if (Controls[0] != null)
                {
                    Controls[0].Dispose();
                }
            }
            UnitUI unitUI = new UnitUI(controller, args.Unit);

            Controls.Add(unitUI);
            unitUI.MouseClick += TileUI_MouseDown;
        }
 private void UnitAddedToCell(Object sender, UnitArgs args)
 {
     for (int i = 0; i < Controls.Count; )
     {
         if (Controls[0] != null)
             Controls[0].Dispose();
     }
     UnitUI unitUI = new UnitUI(controller, args.Unit);
     Controls.Add(unitUI);
     unitUI.MouseClick += TileUI_MouseDown;
 }