Ejemplo n.º 1
0
        /// <summary>
        /// Снимает выделение со всех объектов заданного типа
        /// </summary>
        public void DeselectAll(Type type)
        {
            foreach (GameObject obj in gameData.GameObjects)
            {
                if (type.IsInstanceOfType(obj.RealObject()))
                {
                    obj.RealObject().State = GameObjectState.Simple;

                    BorderGameObjectDecorator borderDecorator = findDecorator(obj, typeof(BorderGameObjectDecorator)) as BorderGameObjectDecorator;

                    if (borderDecorator != null)
                    {
                        borderDecorator.Enabled = false;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Пометить объект как выделенный
        /// </summary>
        public void SetAsSelected(GameObject obj)
        {
            #region Приводим к общим классам игровых объектов, и снимаем выделение
            if (obj is Tower)
            {
                DeselectAll(typeof(Tower));
            }
            else if (obj is Monster)
            {
                DeselectAll(typeof(Monster));
            }
            else if (obj is Bullet)
            {
                DeselectAll(typeof(Bullet));
            }
            #endregion

            obj.State = GameObjectState.Selected;

            BorderGameObjectDecorator borderDecorator = findDecorator(findCommonGameObject(obj), typeof(BorderGameObjectDecorator)) as BorderGameObjectDecorator;
            if (borderDecorator != null)
            {
                borderDecorator.Enabled = true;
            }

            #region Вызываем события из класса Game
            if (obj is Monster)
            {
                Game.OnMonsterSelected(obj as Monster);
            }
            else if (obj is Tower)
            {
                Game.OnTowerSelected(obj as Tower);
            }
            #endregion
        }