示例#1
0
 /// <summary>
 /// Creates a new instance of SquareMapItem class.
 /// </summary>
 /// <param name="position">The position this item occupies on map.</param>
 /// <param name="square">The square this item contains.</param>
 public SquareMapItem(Position position, ISquareElement square)
 {
     this.position = position;
     this.square = square;
 }
示例#2
0
        /// <summary>
        /// Initializes component.
        /// </summary>
        protected override void OnInitializeComponent()
        {
            IElementService elements = this.GetElementService();

            /* create an empty square by default if not set */
            if (elements != null)
            {
                if (this.square == null)
                {
                    this.square = elements.CreateEmptySquare();
                }
            }

            /* attach to commands */
            this.enterBinding = this.CreateBinding(GameCommands.SquareMapItem.Enter);

            if (this.enterBinding != null)
            {
                this.enterBinding.Executed += new EventHandler<EventArgs<ICommand>>(OnSquareMapItemEnterCommandExecuted);
            }

            this.leaveBinding = this.CreateBinding(GameCommands.SquareMapItem.Leave);

            if (this.leaveBinding != null)
            {
                this.leaveBinding.Executed += new EventHandler<EventArgs<ICommand>>(OnSquareMapItemLeaveCommandExecuted);
            }

            this.fixBinding = this.CreateBinding(GameCommands.SquareMapItem.Fix);

            if (this.fixBinding != null)
            {
                this.fixBinding.Executed += new EventHandler<EventArgs<ICommand>>(OnSquareMapItemFixCommandExecuted);
            }

            this.fixCompleteBinding = this.CreateBinding(GameCommands.SquareMapItem.FixComplete);

            if (this.fixCompleteBinding != null)
            {
                this.fixCompleteBinding.Executed += new EventHandler<EventArgs<ICommand>>(OnSquareMapItemFixCompleteCommandExecuted);
            }

            base.OnInitializeComponent();
        }
示例#3
0
        /// <summary>
        /// Restores the initial square presentation of this item, which effectively removes any overlayed squares.
        /// </summary>
        public void RestoreSquare()
        {
            if (this.candidateSquare != null)
            {
                this.isActivated = false;

                this.ChangeSquare(this.candidateSquare);
                this.candidateSquare = null;
            }
        }
示例#4
0
        /// <summary>
        /// Overlays the current square presentation of this item with the given new square presentation.
        /// </summary>
        /// <param name="newSquare">The new square to overlay current square with.</param>
        public void OverlaySquare(ISquareElement newSquare)
        {
            if ((newSquare != null) && (!this.isFixed))
            {
                this.isActivated = true;

                this.candidateSquare = this.square;
                this.ChangeSquare(newSquare);
            }
        }
示例#5
0
        /// <summary>
        /// Applies definition to square map item.
        /// </summary>
        /// <param name="definition">The square map item definition to apply from.</param>
        public void FromDefinition(SquareMapItemDefinition definition)
        {
            if (definition != null)
            {
                /* we have to recreate square here because the type of square acually
                 * changes the class of square as well.
                 * */
                IElementService elements = this.GetElementService();

                if (elements != null)
                {
                    this.square = elements.CreateSquare(definition.Square);
                    this.position = definition.Position;
                }
            }
        }
示例#6
0
 /// <summary>
 /// Changes the square presentation of this item.
 /// </summary>
 /// <param name="newSquare">The new square this item should present.</param>
 public void ChangeSquare(ISquareElement newSquare)
 {
     if ((newSquare != null) && (!this.isFixed))
     {
         this.square = newSquare;
         this.ExecuteCommand(PresentationCommands.SquareMapItem.ChangeSquare, new PresentSquareMapItemParameter(this.Id, this.position, this.isActivated, this.isFixed, this.square.Id, this.square.Type));
     }
 }