Ejemplo n.º 1
0
        public object Clone()
        {
            AGT_Pawn p = new AGT_Pawn();

            p._pawn_id        = this.Id;
            p._sprite_id      = this._sprite_id;
            p._position       = this.Position;
            p._rotation       = this.Rotation;
            p._scaling        = this.Scaling;
            p._texture_height = this.Height;
            p._texture_width  = this.Width;

            p._collision_rect.X      = (int)this.Position.X;
            p._collision_rect.Y      = (int)this.Position.Y;
            p._collision_rect.Height = this._texture_height;
            p._collision_rect.Width  = this._texture_width;

            return((object)p);
        }
Ejemplo n.º 2
0
 protected void AddLabel(AGT_Pawn p, AGT_Text label_info)
 {
     lock (this)
     {
         if (!_label_dictionary.ContainsKey(p.Id))
         {
             _label_dictionary.Add(p.Id, label_info);
         }
         else
         {
             _label_dictionary[p.Id] = label_info;
         }
     }
 }
Ejemplo n.º 3
0
 protected void AddPawn(AGT_Pawn pawn)
 {
     lock (this)
     {
         _pawn_stack.AddFirst(pawn);
     }
 }
Ejemplo n.º 4
0
 protected void RemoveMotionCalculator(AGT_Pawn pawn)
 {
     lock (this)
     {
         if (_motion_calculators.ContainsKey(pawn.Id))
         {
             _motion_calculators.Remove(pawn.Id);
         }
     }
 }
Ejemplo n.º 5
0
 protected void AddMotionCalculator(AGT_Pawn pawn, System.Threading.ThreadStart callback)
 {
     lock (this)
     {
         AGT_LinearMotion calculator = new AGT_LinearMotion(pawn.Position.X, pawn.Position.Y, pawn.Position.Z, callback);
         if (_motion_calculators.ContainsKey(pawn.Id))
         {
             _motion_calculators.Remove(pawn.Id);
         }
         _motion_calculators.Add(pawn.Id, calculator);
     }
 }
Ejemplo n.º 6
0
 protected void AddMotionCalculator(AGT_Pawn pawn)
 {
     lock (this)
     {
         AGT_LinearMotion calculator = new AGT_LinearMotion(pawn.Position.X, pawn.Position.Y, pawn.Position.Z);
         if (_motion_calculators.ContainsKey(pawn.Id))
         {
             _motion_calculators.Remove(pawn.Id);
         }
         _motion_calculators.Add(pawn.Id, calculator);
     }
 }
Ejemplo n.º 7
0
 public void ClearPawnSelection()
 {
     _primary_pawn_selection = AGT_Pawn.Empty;
 }
Ejemplo n.º 8
0
        public AGT_Pawn SelectPawn(string pawn_id)
        {
            lock (this)
            {
                if (_primary_pawn_selection != AGT_Pawn.Empty)
                {
                    SendPawnToBack(_primary_pawn_selection.Id);
                    _primary_pawn_selection = AGT_Pawn.Empty;
                }
                foreach (AGT_Pawn p in _pawn_stack)
                {
                    if (p.Id == pawn_id)
                    {
                        _primary_pawn_selection = p;

                        BringPawnToFront(p.Id);
                        //CursorImage = GameFramework.SystemImages.Cursor_Move;
                        return p;
                    }
                }

                //CursorImage = GameFramework.SystemImages.Cursor_Select;
                return AGT_Pawn.Empty;
            }
        }
Ejemplo n.º 9
0
        public AGT_Pawn SelectPawnAt(int x, int y)
        {
            lock (this)
            {
                if (_primary_pawn_selection != AGT_Pawn.Empty)
                {
                    SendPawnToBack(_primary_pawn_selection.Id);
                    _primary_pawn_selection = AGT_Pawn.Empty;
                }

                LinkedListNode<AGT_Pawn> node = _pawn_stack.Last;
                while (node != null)
                {
                    AGT_Pawn p = (AGT_Pawn)node.Value;
                    bool pawn = p.HitTest((int)((float)(x - _map_sprites.X) / PlayfieldScale), (int)((float)(y - _map_sprites.Y) / PlayfieldScale));
                    bool label = _label_dictionary[p.Id].RelativeHitTest(x, y, (int)_map_sprites.X, (int)_map_sprites.Y);

                    if (pawn || label)
                    {
                        lock (this)
                        {
                            _primary_pawn_selection = p;
                        }
                        BringPawnToFront(p.Id);
                        //CursorImage = GameFramework.SystemImages.Cursor_Move;
                        return p;
                    }
                    node = node.Previous;
                }
                CursorImage = GameFramework.SystemImages.Cursor_Select;
                return AGT_Pawn.Empty;
            }
        }
Ejemplo n.º 10
0
 public DDD_Playfield()
 {
     _primary_pawn_selection = new AGT_Pawn();
     _minmap_blip.Width = _minmap_blip.Height = 4;
     ShowMouseCursor = true;
 }
Ejemplo n.º 11
0
 public void RemoveMapObject(string id)
 {
     lock (this)
     {
         RemovePawn(id);
         RemoveLabel(id);
         RemoveMotionCalculator(id);
         _primary_pawn_selection = AGT_Pawn.Empty;
     }
 }
Ejemplo n.º 12
0
        public void AddMapObject(string id, string texture_reference, float x, float y, float z, Color color, System.Threading.ThreadStart callback)
        {
            try
            {
                Rectangle measure = Rectangle.Empty;

                AGT_SpriteId sprite_id;
                sprite_id.Id = texture_reference;

                AGT_SpriteResource t = _pawn_sprites.GetTextureDefinition(sprite_id);
                AGT_Pawn p = new AGT_Pawn(id, t);
                p.SetPosition(x, y, z);
                AddPawn(p);

                measure = _pawn_font.MeasureString(null, p.Id, DrawTextFormat.Center | DrawTextFormat.VerticalCenter, Color.White);
                AGT_Text text = new AGT_Text(p.Id, _pawn_font);
                text.Background = color;
                AddLabel(p, text);

                AddMotionCalculator(p, callback);
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 13
0
        public object Clone()
        {
            AGT_Pawn p = new AGT_Pawn();

            p._pawn_id = this.Id;
            p._sprite_id = this._sprite_id;
            p._position = this.Position;
            p._rotation = this.Rotation;
            p._scaling = this.Scaling;
            p._texture_height = this.Height;
            p._texture_width = this.Width;

            p._collision_rect.X = (int)this.Position.X;
            p._collision_rect.Y = (int)this.Position.Y;
            p._collision_rect.Height = this._texture_height;
            p._collision_rect.Width = this._texture_width;

            return (object)p;
        }