示例#1
0
        /// <summary>
        /// Trigger fucntion in the event of new unit being added
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void onUnitAdded(object sender, UnitAddedEventArgs e)
        {
            ZRTSCompositeViewUIFactory factory = ZRTSCompositeViewUIFactory.Instance;
            UnitUI unitUI = factory.BuildUnitUI(e.Unit);

            unitUI.DrawBox = new Rectangle((int)(e.Unit.PointLocation.X * cellDimension), (int)(e.Unit.PointLocation.Y * cellDimension), unitUI.DrawBox.Width, unitUI.DrawBox.Height);
            AddChild(unitUI);
            componentToUI.Add(e.Unit, unitUI);
            e.Unit.MovedEventHandlers     += updateLocationOfUnit;
            e.Unit.HPChangedEventHandlers += killUnit;
        }
示例#2
0
 public override void AddChild(ModelComponent child)
 {
     if (child is UnitComponent)
     {
         base.AddChild(child);
         UnitAddedEventArgs args = new UnitAddedEventArgs();
         args.Unit = (UnitComponent)child;
         if (UnitAddedEvent != null)
         {
             UnitAddedEvent(this, args);
         }
     }
 }