Пример #1
0
    public void Move(IField oldField, IField field)
    {
        IMoveable moveable = oldField.Moveables.First();

        field.PlaceMoveable(moveable);
        oldField.RemoveMoveable(moveable);
    }
Пример #2
0
        //################
        //##    MONO    ##
        //################

        void Start()
        {
            mMovement    = GetComponent <IMoveable>();
            mInventory   = GetComponent <IInventory>();
            mAudioSource = GetComponent <AudioSource>();
            StartCoroutine(unblockMovement());
        }
Пример #3
0
 public Player(Texture2D texture, Vector2 position, IMoveable mover, float moveSpeed) : base(texture, position, mover, moveSpeed)
 {
     Health  = 100;
     Score   = 0;
     Attack  = 10;
     Defense = 0;
 }
Пример #4
0
        public Vector2 GetMotionPerSecond(IMoveable objectToMove)
        {
            int xFlipAdjust = (objectToMove.Direction == FlipXWhen) ? -1 : 1;
            int yFlipAdjust = (objectToMove.Direction == FlipYWhen) ? -1 : 1;

            return(new Vector2(MotionPerSecond.X * xFlipAdjust, MotionPerSecond.Y * yFlipAdjust));
        }
Пример #5
0
 public Bullet(string id, IMoveable bulletShip, int damage, string playerID)
 {
     ID         = id;
     BulletShip = bulletShip;
     Damage     = damage;
     PlayerID   = playerID;
 }
Пример #6
0
 public void Drop()
 {
     icon.enabled = false;
     MyMoveable   = null;
     icon.enabled = false;
     InventoryScript.MyInstance.FromSlot = null;
 }
Пример #7
0
 public virtual void Remove(IMoveable moveable)
 {
     if (this.Elements.Exists(moveable))
     {
         this.Elements.Remove(moveable);
     }
 }
Пример #8
0
 public virtual bool CanPlace(IMoveable moveable)
 {
     if (moveable == typeof(Barricade))
     {
         if (Moveables.Count != 0)
         {
             return(false);
         }
         else
         {
             if (this.IsFirstRow)
             {
                 return(false);
             }
             else
             {
                 return(true);
             }
         }
     }
     else
     {
         return(true);
     }
 }
Пример #9
0
        private static void Move(IMoveable movable, List <List <Map> > map)
        {
            var swap = map[movable.Position.CurY][movable.Position.CurX];

            map[movable.Position.CurY][movable.Position.CurX]   = map[movable.Position.PrevY][movable.Position.PrevX];
            map[movable.Position.PrevY][movable.Position.PrevX] = swap;
        }
Пример #10
0
 public Gingando(IMoveable objMovimentavel)
     : base(objMovimentavel, "Gingando")
 {
     this.spriteSheet = ContentManagerFacade.Load <Texture2D>(@"Ryu\ryu_gingando");
     this.steps.Add(new Rectangle(103, 53, 88, 108));
     this.steps.Add(new Rectangle(390, 53, 88, 108));
 }
Пример #11
0
    public void TakeMoveable(IMoveable moveable) {

        this.MyMoveable = moveable;
        icon.sprite = moveable.MyIcon;
        icon.color = Color.white;
    
    }
Пример #12
0
        public void InitObject(MonoBehaviour monoBehaviourObj)
        {
            UninitObject();

            _monoBehaviour = monoBehaviourObj;
            _selectable    = _monoBehaviour.GetComponent <ISelectable>();

            if (_selectable == null || !_selectable.CanSelect())
            {
                UninitObject();
                return;
            }

            _damageable         = _monoBehaviour.GetComponent <IDamageable>();
            _targetable         = _monoBehaviour.GetComponent <ITargetable>();
            _moveable           = _monoBehaviour.GetComponent <IMoveable>();
            _attackable         = _monoBehaviour.GetComponent <IAttackable>();
            _behaviorSwitchable = _monoBehaviour.GetComponent <IBehaviorSwitchable>();
            _carriable          = _monoBehaviour.GetComponent <ICarriable>();

            if (_damageable != null)
            {
                // If enemy, don't select.
                if (_targetable.IsEnemy(_targetable.TeamId))
                {
                    UninitObject();
                    return;
                }
            }

            _selectable.Select();

            _isInit = true;
        }
Пример #13
0
        private Boolean AddViewWithPreviousSlot(IMoveable go, ESize size, out Vector3 localPosition, Int32 p_comeFrom, EntityPositioning p_oldPositioning)
        {
            Boolean searchNearestSlot = false;

            if (p_oldPositioning != null)
            {
                EDirection direction = EDirectionFunctions.GetDirection(p_oldPositioning.Position, m_gridSlot.Position);
                if (direction != m_direction && direction != EDirectionFunctions.Add(m_direction, 2))
                {
                    searchNearestSlot = true;
                }
            }
            Boolean flag;

            if (size == ESize.MEDIUM)
            {
                flag = AddViewWithPreviousSlotMedium(go, out localPosition, p_comeFrom, p_oldPositioning, searchNearestSlot);
            }
            else if (size == ESize.BIG)
            {
                flag = AddViewWithPreviousSlotBig(go, out localPosition, p_comeFrom);
            }
            else
            {
                flag = AddViewWithPreviousSlotSmall(go, out localPosition, p_comeFrom, p_oldPositioning, searchNearestSlot);
            }
            return(!flag);
        }
Пример #14
0
        private static void setupDTOs(PlayerDTO playerDTO, IList <PlayerDTO> opponentDTOs, IList <ResourceDTO> resourceDTOs)
        {
            // create the player
            IMoveable playerShip = PlayerAdapter.playerDTOToMoveable(playerDTO, Colors.Black);

            playerShip.Mover = new MoveStrategy();
            UIDispatcher.Invoke(() => { Player = new Player(Username, UserID, playerDTO.Wallet, playerDTO.Health, playerShip); });

            // convert data transfer objects to their respective types and add them to list
            foreach (PlayerDTO opponent in opponentDTOs)
            {
                IMoveable moveable = PlayerAdapter.playerDTOToMoveable(opponent, Colors.Red);
                while (!Opponents.TryAdd(opponent.Name, moveable))
                {
                    Task.Delay(1);
                }
            }
            foreach (ResourceDTO resource in resourceDTOs)
            {
                IResource r = ResourceAdapter.DTOToResource(resource);
                while (!Resources.TryAdd(resource.ID, r))
                {
                    Task.Delay(1);
                }
            }
        }
Пример #15
0
 public override bool CanPlace(IMoveable moveable)
 {
     if (Moveables.Count != 0)
         return false;
     else
         return true;
 }
Пример #16
0
        /// <summary>
        /// All logic about collision and physics is kept here.
        /// </summary>
        public static bool ObjectCollisionDetector(IMoveable moveableObject, MoveDirection moveDirection, out GameObject collisionObj)
        {
            Vector2 currentPosition = moveableObject.Position;
            float x = currentPosition.X;
            float y = currentPosition.Y;

            switch (moveDirection)
            {
                case MoveDirection.Up:
                    y -= moveableObject.Speed;
                    break;
                case MoveDirection.Down:
                    y += moveableObject.Speed;
                    break;
                case MoveDirection.Left:
                    x -= moveableObject.Speed;
                    break;
                case MoveDirection.Right:
                    x += moveableObject.Speed;
                    break;
            }

            Rectangle futureBounds = new Rectangle((int)x, (int)y, moveableObject.Bounds.Width, moveableObject.Bounds.Height);
            foreach (GameObject gameObject in ObjectFactory.AllObjects.Where(obj => !(obj is Player)))
            {
                if (futureBounds.Intersects(gameObject.Bounds))
                {
                    if (moveableObject is Player)
                    {
                        collisionObj = gameObject;
                        Console.WriteLine("collision detected!");
                        return true;
                    }
                    if (moveableObject is NPC)
                    {
                        if (gameObject is NPC)
                        {
                            collisionObj = gameObject;
                            return false;
                        }
                        else if (gameObject is Player)
                        {
                            collisionObj = gameObject;
                            return true;
                        }
                    }
                }
            }
            if (futureBounds.X <= 0 ||
               !(futureBounds.X + futureBounds.Width <= Constants.WINDOW_DEFAULT_WIDTH) ||
               futureBounds.Y <= 0 ||
               futureBounds.Y + futureBounds.Height >= Constants.WINDOW_DEFAULT_HEIGHT)
            {
                collisionObj = ObjectFactory.PLAYER;
                Console.WriteLine("Collision detected at ({0},{1})", futureBounds.X, futureBounds.Y);
                return true;
            }
            collisionObj = null;
            return false;
        }
Пример #17
0
 public void Drop()
 {
     MyMoveable = null;
     icon.color = new Color(0, 0, 0, 0);
     Inventory.MyInstance.FromSlot = null;
     Inventory.MyInstance.equipInventory.FromSlot = null;
 }
Пример #18
0
 public PlayerMovement(IMoveable moveable)
     : base(moveable)
 {
     horizontalState = Direction.none;
     verticalState = Direction.none;
     m_moveable = moveable;
 }
Пример #19
0
 public void Deselect()
 {
     CurrentSelected = null;
     moveableSelection = null;
     UIPortrait.sprite = PortrraitNoneSelected;
     UIPortraitText.text = "None Selected";
 }
Пример #20
0
 public void Drop()
 {
     MyMoveable  = null;
     icon.sprite = null;
     icon.color  = new Color(0, 0, 0, 0);
     InventotyScript.MyInstance.FromSlot = null;
 }
Пример #21
0
 public void SetUp()
 {
     moveable = new MoveableStub {
         Position  = Vec.Zero,
         BaseSpeed = 1.0
     };
 }
Пример #22
0
    public bool CanPlace(IMoveable moveable)
	{
        if (moveable == typeof(Pawn))
            return true;
        else
            return false;
    }
Пример #23
0
 public Mediator()
 {
     _moveUp    = new MoveUp();
     _moveDown  = new MoveDown();
     _moveLeft  = new MoveLeft();
     _moveRight = new MoveRight();
 }
Пример #24
0
        void Start()
        {
            fuelContainer = GetComponentInChildren <ICargoHold>().getContainer(ResourceType.FUEL);
            moveBehavior  = GetComponent <IMoveable>();

            subscribe();
        }
Пример #25
0
        public override void Execute()
        {
            IMoveable m = Target as IMoveable;

            if (m != null)
            {
                var vector = new SharpDX.Vector2(m.Location.X - X, m.Location.Y - Y);
                var length = vector.Length();
                vector.Normalize();
                float dx, dy;
                dx = vector.X;
                dy = vector.Y;
                Task moveTask = new Task(() =>
                {
                    var i = 0.0f;
                    while (length >= i)
                    {
                        m.Offset(-dx, -dy);
                        Thread.Sleep(1);
                        i += 1;
                    }
                });
                moveTask.Start();
            }
        }
Пример #26
0
 public void TakeMoveable(IMoveable moveable)
 {
     //Debug.Log("HandScript.TakeMoveable(" + moveable.ToString() + ")");
     this.MyMoveable = moveable;
     icon.sprite     = moveable.MyIcon;
     icon.color      = Color.white;
 }
Пример #27
0
 public Avancar(IMoveable objMovimentavel)
     : base(objMovimentavel, "Avancar")
 {
     this.updateInterval = 250;
     this.spriteSheet    = ContentManagerFacade.Load <Texture2D>(@"Ryu\ryu_andando_para_frente");
     this.steps.Add(new Rectangle(1261, 49, 96, 109));
     this.steps.Add(new Rectangle(1549, 49, 90, 113));
 }
Пример #28
0
 void Start()
 {
     player         = ReferenceManager.Instance.player.GetComponent <Character>();
     character      = GetComponent <Character>();
     combat         = GetComponent <CharacterCombat>();
     moveable       = GetComponent <IMoveable>();
     weaponAttacker = GetComponentInChildren <IWeaponAttacker>();
 }
Пример #29
0
 public Recuar(IMoveable objMovimentavel)
     : base(objMovimentavel, "Recuar")
 {
     this.updateInterval = 200;
     this.spriteSheet = ContentManagerFacade.Load<Texture2D>(@"Ryu\ryu_andando_para_atras");
     this.steps.Add(new Rectangle(378, 53, 85, 109));
     this.steps.Add(new Rectangle(969, 48, 73, 113));
 }
 /// <summary>
 /// Instantiates a MovementController with an array of <see cref="IMoveable"/> objects that are synchronized to the MovementControllers position and rotation.
 /// </summary>
 /// <param name="moveables">A list of moveables to synchronize the rotation and position of.</param>
 public MovementController(IMoveable[] moveables)
 {
     Position = moveables.Length > 0 ? moveables[0].Position : Vector2d.Zero;
     Velocity = Vector2d.Zero;
     Rotation = 0;
     Frozen = false;
     Moveables = moveables;
 }
Пример #31
0
 public Avancar(IMoveable objMovimentavel)
     : base(objMovimentavel, "Avancar")
 {
     this.updateInterval = 250;
     this.spriteSheet = ContentManagerFacade.Load<Texture2D>(@"Ryu\ryu_andando_para_frente");
     this.steps.Add(new Rectangle(1261, 49, 96, 109));
     this.steps.Add(new Rectangle(1549, 49, 90, 113));
 }
Пример #32
0
    public IMoveable Put()
    {
        IMoveable tmp = MyMoveable;

        MyMoveable = null;
        icon.color = new Color(0, 0, 0, 0);
        return(tmp);
    }
Пример #33
0
 public static void MoveAwayFrom(IMoveable moveable, IMappable mapObject)
 {
     if (moveable.Position != null && mapObject.Position != null && OpenNeighbors(moveable).Any())
     {
         moveable.Move(OpenNeighbors(moveable).FirstOrDefault(p => MovementCost(moveable.Position,
                                                                                p, mapObject.Position) == GetMaxCost(moveable, mapObject)));
     }
 }
Пример #34
0
 public Move(IMoveable client, FrameworkElement arena, IEnumerable<SceneElement> elements)
 {
     Client = client;
     Arena = arena;
     IsColision = false;
     GraphArticle = elements;
     DS = Delta;
 }
Пример #35
0
 public virtual void PlaceMoveable(IMoveable moveable)
 {
     if (Moveables.Count != 0)
     {
         RemoveMoveable(Moveables.First());
     }
     Moveables.Add(moveable);
 }
Пример #36
0
 public void TakeMoveable(IMoveable moveable)
 {
     Debug.Log("Taking moveable");
     MyMoveable = moveable;
     Debug.Log("The hand is holding a: " + MyMoveable);
     icon.sprite = moveable.MyIcon;
     icon.color  = Color.white;
 }
Пример #37
0
 public bool CanWalk(IMoveable <Node> moveable, Vector2Int from, Vector2Int to)
 {
     nodeCache.Clear();
     NavGrid.GetLine(nodeCache, from, to);
     nodeCache.RemoveAt(0);
     nodeCache.RemoveAt(nodeCache.Count - 1);
     return(nodeCache.IsLineWalkable(moveable));
 }
 private void Move(object sender, MouseEventArgs e)
 {
     if (_moving)
     {
         IMoveable c = (IMoveable)_control;
         c.OnDrag(e);
     }
 }
Пример #39
0
        static void Main(string[] args)
        {
            IFactory  factory = new PlaneFactory();
            IMoveable m       = factory.create();

            m.run();
            Console.ReadKey();
        }
Пример #40
0
 private void Improve(IMoveable moveable)
 {
     if (_improved)
         return;
     moveable.Velocity += _acceleration;
     _improvedObject = moveable;
     _improved = true;
     Game.GameObjectCollection.Add(new BubbleLabel(Game, "Accelerate!", CenterPosition));
     Visible = false;
 }
Пример #41
0
 public void Select(GameObject toSelect)
 {
     if (toSelect.GetComponent<ISelectable>() != null)
     {
         Deselect();
         CurrentSelected = toSelect;
         moveableSelection = CurrentSelected.GetComponent<IMoveable>();
         selection = CurrentSelected.GetComponent<ISelectable>();
         UIPortrait.sprite = selection.GetSelectionPortrait();
         UIPortraitText.text = selection.GetName();
     }
 }
Пример #42
0
 public DefesaPorCima(IMoveable objMovimentavel)
     : base(objMovimentavel, "DefesaPorCima")
 {
     this.updateInterval = 120;
     this.spriteSheet = ContentManagerFacade.Load<Texture2D>(@"Ryu\ryu_escapando_por_cima");
     this.steps.Add(new Rectangle(104, 34, 82, 130));
     this.steps.Add(new Rectangle(393, 33, 81,133));
     this.steps.Add(new Rectangle(682, 39, 80, 111));
     this.steps.Add(new Rectangle(971, 45, 78, 94));
     this.steps.Add(new Rectangle(1261, 47, 82, 88));
     this.steps.Add(new Rectangle(1557, 42, 77, 89));
     this.steps.Add(new Rectangle(1893, 43, 83, 94));
 }
        public LinearMovementController(IMoveable[] moveables, double moveSpeed, bool rotateWithMovements, bool multiDirectional)
            : base(moveables)
        {
            Moving = new LinearDirections();
            _moveSpeed = moveSpeed;
            _rotateWithMovements = rotateWithMovements;

            OnMove = _ => { };

            if (multiDirectional)
            {
                _velocityUpdater = UpdateVelocityWithMultiDirection;
            }
            else
            {
                _velocityUpdater = UpdateVelocityNoMultiDirection;
            }
        }
Пример #44
0
    public virtual bool CanPlace(IMoveable moveable)
	{
        if (moveable == typeof(Barricade))
        {
            if (Moveables.Count != 0)
            {
                return false;
            }
            else
            {
                if (this.IsFirstRow)
                    return false;
                else
                    return true;
            }
        }
        else
        {
            return true;
        }
    }
Пример #45
0
 /// <summary>
 /// Shows animation of thing moved from start- to endposition
 /// </summary>
 /// <param name="mover"></param>
 /// <param name="old"></param>
 /// <param name="newLoc"></param>
 private void MoveThing(IMoveable mover, HexLocation old, HexLocation newLoc)
 {
     Point2D oldPoint = AddRobberOffset(CalculatePosition(old));
     Point2D newPoint = AddRobberOffset(CalculatePosition(newLoc));
     int duration = 1000;
     DoubleAnimation dax = new DoubleAnimation(oldPoint.X, newPoint.X, new Duration(new TimeSpan(0, 0, 0, 0, duration)));
     DoubleAnimation day = new DoubleAnimation(oldPoint.Y, newPoint.Y, new Duration(new TimeSpan(0, 0, 0, 0, duration)));
     DoubleAnimation daz = new DoubleAnimation(0, 20, new Duration(new TimeSpan(0, 0, 0, 0, duration / 2)));
     daz.AutoReverse = true;
     day.AccelerationRatio = 0.4;
     day.DecelerationRatio = 0.4;
     mover.Move.BeginAnimation(TranslateTransform3D.OffsetXProperty, dax);
     mover.Move.BeginAnimation(TranslateTransform3D.OffsetZProperty, day);
     mover.Move.BeginAnimation(TranslateTransform3D.OffsetYProperty, daz);
 }
 public LinearMovementController(IMoveable[] moveables, double moveSpeed)
     : this(moveables, moveSpeed, true, true)
 { }
 public LinearMovementController(IMoveable[] moveables, double moveSpeed, bool rotateWithMovements)
     : this(moveables, moveSpeed, rotateWithMovements, true)
 { }
Пример #48
0
        public override void MouseUp(MouseButtons b)
        {
            if( scroll_active ) {
                StopScrolling();
            }

            parent.SetDefaultDrawingMode();
            original_selected = null;

            switch( action ) {
                case MouseAction.Scroll:
                    Cursor.Current = Cursors.Arrow;
                    if( first_move ) {
                        System.Windows.Forms.ContextMenu m = new ContextMenu();
                        parent.AddMenuItems( m );
                        if( m.MenuItems.Count > 0 )
                            m.Show( parent.cview, new Point( menurealx, menurealy ) );
                    }
                    break;
                case MouseAction.CreateConnection:
                    if( conn.second.item == null )
                        conn.Invalidate();
                    else {
                        conn.ConnectionCreated( parent, null, null, null, null );
                        parent.Undo.Push( new CreateOperation( conn ), false );
                    }
                    conn = null;
                    break;
                case MouseAction.Move:

                    ArrayList movedobjects = new ArrayList();
                    foreach( GuiObject o in movestates.Keys )
                        if( o is IAroundObject )
                            movedobjects.Add( o );
                    if( movedobjects.Count > 0 )
                        parent.AroundObjectsMoved( movedobjects, movestates );

                    foreach( IMoveable o in movestates.Keys )
                        o.Moved();

                    if( movestates.Count == 1 ) {
                        foreach( IStateObject t in movestates.Keys )
                            parent.Undo.Push( new StateOperation( t, movestates[t] as ObjectState, t.GetState() ), false );

                    } else if( movestates.Count > 1 ) {
                        MultipleOperation p = new MultipleOperation();
                        foreach( IStateObject t in movestates.Keys )
                            p.l.Add( new StateOperation( t, movestates[t] as ObjectState, t.GetState() ) );
                        parent.Undo.Push( p, false );
                    }
                    movestates.Clear();
                    moveitem = null;
                    movelist = null;
                    break;
                case MouseAction.Select:
                    parent.SelectedObjects.Clear();
                    parent.SelectInRectangle( selrect );
                    parent.cview.InvalidatePage( selrect );
                    selrect = Rectangle.Empty;
                    break;
            }
            action = MouseAction.None;
        }
Пример #49
0
 private void Awake()
 {
     carouselCenterOnChild = carouselCenterOnChild ?? GetComponent<CarouselCenterOnChild>();
     carousel = carousel ?? GetComponent<AbstractCarousel>();
     if (carousel != null)
     {
         Moveable = carousel;
     }
 }
Пример #50
0
 public Action(IMoveable objMovimentavel, String descricao)
 {
     this.objMovimentavel = objMovimentavel;
     this.descricao = descricao;
 }
Пример #51
0
        public override void MouseDown( int x, int y, MouseButtons b, Keys modif, int realx, int realy )
        {
            // Left mouse button

            if( action != MouseAction.None )
                return;

            if( b == MouseButtons.Left ) {

                if( current_operation == MouseOperation.DrawComment || current_operation == MouseOperation.DrawPackage ) {

                    switch( current_operation ) {
                        case MouseOperation.DrawComment:
                            moveitem = GuiElementFactory.CreateMemo( parent, x, y );
                            break;
                        case MouseOperation.DrawPackage:
                            moveitem = GuiElementFactory.CreatePackage( parent, x, y );
                            break;
                    }

                    first_move = true;
                    moveux = 0;
                    moveuy = 0;
                    action = MouseAction.Move;

                } else if( (modif & Keys.Control) == Keys.Control || current_operation == MouseOperation.DrawConnection ) {

                    conn_item = parent.FindItem( x, y, out moveux, out moveuy, true ) as IAcceptConnection;
                    if( conn_item == null ) {
                        action = MouseAction.Scroll;
                        selx = x;
                        sely = y;
                        return;
                    }

                    int ux;
                    float uy;
                    conn_item.coord_nearest( x, y, out ux, out uy );
                    action = MouseAction.CreateConnection;

                    conn = new GuiConnection( new GuiConnectionPoint( conn_item, ux, uy, 0 ), new GuiConnectionPoint( x, y, 1 ), conn_type, parent, conn_type == UmlRelationType.Attachment ? GuiConnectionStyle.Line : conn_style );
                    conn.first.item.coord_nearest( x, y, out conn.first.ux, out conn.first.uy );
                    conn.first.UpdatePosition( true );
                    conn.DoCreationFixup();
                    conn.InvalidateTemporary();
                    conn.Invalidate();

                } else if( ( modif & Keys.Shift) == Keys.Shift ) {

                    GuiObject obj = parent.FindItem( x, y, false );
                    if( obj != null ) {
                        parent.SelectedObjects.Add( obj );
                        obj.Invalidate();
                    }

                } else {

                    //   Left button click:
                    //      select
                    //      move, move multiple

                    GuiObject s = parent.FindItem( x, y, out moveux, out moveuy, false );
                    if( s == null ) {
                        parent.SelectedObjects.Clear();
                        action = MouseAction.Select;
                        selx = x;
                        sely = y;
                        return;
                    }

                    if( !s.selected ) {
                        parent.SelectedObjects.Clear();
                        parent.SelectedObjects.Add( s );
                    }

                    // deciding: to move, or not ...

                    moveitem = null;
                    movelist = null;
                    movestates.Clear();
                    original_selected = null;
                    GuiObject t = parent.FindItem( x, y, out moveux, out moveuy, true );
                    if( t != null ) {
                        if( t is IMoveRedirect ) {
                            if( t.selected )
                                original_selected = t;
                            moveitem = (t as IMoveRedirect).MoveRedirect( ref moveux, ref moveuy );
                        } else if( t is IMoveMultiple && (t as IMoveMultiple).CanMoveInGroup ) {
                            movelist = new ArrayList();
                            if( !t.selected )
                                movelist.Add( t );
                            foreach( GuiObject o in parent.SelectedObjects )
                                if( o is IMoveMultiple && (o as IMoveMultiple).CanMoveInGroup )
                                    movelist.Add( o );
                            selx = x;
                            sely = y;

                        } else if( t is IMoveable && (t as IMoveable).IsMoveable( x, y ) )
                            moveitem = t as IMoveable;

                        if( moveitem != null || movelist != null ) {
                            first_move = true;
                            action = MouseAction.Move;
                        } else if( t is IClickable ) {
                            (t as IClickable).LeftClick( false, x, y );
                        }
                    }

                }

            } else if( b == MouseButtons.Right ) {

                ISelectable obj = parent.FindItem( x, y, true ) as ISelectable;
                if( obj != null ) {

                    if( obj is IDropMenu ) {

                        parent.SelectedObjects.Clear();
                        parent.SelectedObjects.Add( obj as GuiObject );

                        System.Windows.Forms.ContextMenu m = new ContextMenu();
                        (obj as IDropMenu).AddMenuItems( m, x, y );
                        if( m.MenuItems.Count > 0 )
                            m.Show( parent.cview, new Point( realx, realy ) );
                    }

                } else {
                    action = MouseAction.Scroll;
                    Cursor.Current = Cursors.Hand;
                    selx = x;
                    sely = y;
                    menurealx = realx;
                    menurealy = realy;
                    first_move = true;
                }
            }
        }
Пример #52
0
        public override void Update(GameTime gameTime, bool isInForeground)
        {
            base.Update(gameTime, isInForeground);

            if (!isInForeground)
            {
                leftButtonRealsed = false;
                return;
            }

            if (lastScreenOpen != null)
            {
                if (lastScreenOpen is AddTileScreen)
                    UpdateDatas();
                lastScreenOpen = null;
            }

            World.Update(gameTime);

            tabPanel.Update(gameTime);
            UpdateTileDataControls();
            UpdateEntityDataControls();
            UpdateLocTileDataControls();

            if (Input.MiddleButton.Down)
            {
                World.MoveView(-Input.XDelta, -Input.YDelta);
            }

            if (!Input.LeftButton.Down)
                leftButtonRealsed = true;
            if (Input.LeftButton.Down && leftButtonRealsed)
            {
                // Set tile
                if (tileList.SelectedItem != null && tabPanel.CurrentPanel == tilePanel)
                {
                    Tile selectedTile = Tile.UnLocatedTile[tileList.SelectedItem];
                    int x = (Input.X - worldBound.X + World.View.X) / Tile.Width;
                    int y = (Input.Y - worldBound.Y + World.View.Y) / Tile.Height;
                    if (worldBound.Contains(Input.X, Input.Y) && (lastXTileSet != x || lastYTileSet != y))
                        World.SetTile(x, y, selectedTile);
                    lastXTileSet = x;
                    lastYTileSet = y;
                }
            }
            if (Input.LeftButton.Pressed)
            {
                lastXTileSet = -1;
                lastYTileSet = -1;

                if (worldBound.Contains(Input.X, Input.Y))
                {
                    // Place entity
                    if (entityToPlace != null)
                    {
                        Vector2 pos = Vector2.Zero;
                        pos.X = Input.X - worldBound.X + World.View.X;
                        pos.Y = Input.Y - worldBound.Y + World.View.Y;
                        entityToPlace.Position = pos;
                        World.Entities.Add(World.GetNextEntityId(), entityToPlace);
                        entityToPlace = null;
                    }
                    // Place LocTile
                    if (locTileToPlace != null)
                    {
                        Vector2 pos = Vector2.Zero;
                        pos.X = (Input.X - worldBound.X + World.View.X) / Tile.Width;
                        pos.Y = (Input.Y - worldBound.Y + World.View.Y) / Tile.Height;
                        World.SetTile((int)pos.X, (int)pos.Y, locTileToPlace);
                        locTileToPlace = null;
                    }
                    // Start Drag and Drop
                    if (selectedEntity != null && selectedEntity is IMoveable && selectedEntity.DestinationRect.Contains(Input.X, Input.Y))
                    {
                        dragingElement = (IMoveable)selectedEntity;
                        dragingStartPos = selectedEntity.Position;
                    }
                    else if (selectedLocTile != null && selectedLocTile is IMoveable && selectedLocTile.Bound.Contains(Input.X, Input.Y))
                    {
                        dragingElement = (IMoveable)selectedLocTile;
                        dragingStartPos = selectedLocTile.Position;
                        World.SetTile((int)selectedLocTile.X, (int)selectedLocTile.Y, null);
                    }
                    // Select IBounded
                    bool foundOne = false;
                    int x = Input.X - worldBound.X;
                    int y = Input.Y - worldBound.Y;
                    foreach (Entity ent in World.Entities.Values)
                    {
                        if (ent is IBounded)
                        {
                            IBounded bounded = (IBounded)ent;
                            if (bounded.Bound.Contains(x, y))
                            {
                                selectedEntity = ent;
                                ReconstructEntityDataPanel();
                                foundOne = true;
                                break;
                            }
                        }
                    }
                    if (!foundOne)
                    {
                        selectedEntity = null;
                        ReconstructEntityDataPanel();
                    }
                    foundOne = false;
                    Tile tile = World.GetTile((x + World.View.X) / Tile.Width, (y + World.View.Y) / Tile.Height);
                    if (tile is LocatedTile && tile is IBounded)
                    {
                        IBounded bounded = (IBounded)tile;
                        if (bounded.Bound.Contains(x, y))
                        {
                            selectedLocTile = (LocatedTile)tile;
                            ReconstructLocTileDataPanel();
                            foundOne = true;
                        }
                    }
                    if (!foundOne && selectedLocTile != dragingElement)
                    {
                        selectedLocTile = null;
                        ReconstructLocTileDataPanel();
                    }
                }
            }
            if (Input.LeftButton.Released)
            {
                if (dragingElement != null)
                {
                    if (worldBound.Contains(Input.X, Input.Y))
                    {
                        if (dragingElement is Entity)
                        {
                            dragingElement.X = Input.X - worldBound.X + World.View.X;
                            dragingElement.Y = Input.Y - worldBound.Y + World.View.Y;
                            ReconstructEntityDataPanel();
                        }
                        if (dragingElement is LocatedTile)
                        {
                            LocatedTile tile = (LocatedTile)dragingElement;
                            World.SetTile((Input.X - worldBound.X + World.View.X) / Tile.Width, (Input.Y - worldBound.Y + World.View.Y) / Tile.Height, tile);
                            ReconstructLocTileDataPanel();
                        }
                        dragingElement = null;
                    }
                    else
                    {
                        dragingElement.X = dragingStartPos.X;
                        dragingElement.Y = dragingStartPos.Y;
                        dragingElement = null;
                    }
                }
            }
            if (tileList.SelectedItem != lastSelectedTile)
            {
                lastSelectedTile = tileList.SelectedItem;
                ReconstructTileDataPanel();
            }

            if (tileAddButton.IsPressed())
            {
                lastScreenOpen = new AddTileScreen(Manager, World.Resources);
                Manager.OpenScreen(lastScreenOpen);
            }
            if (tileRemoveButton.IsPressed())
            {
                if (tileList.SelectedItem != null)
                {
                    Tile.UnLocatedTile.Remove(tileList.SelectedItem);
                    UpdateDatas();
                }
            }
            if (tileDataSubmitButton != null && tileDataForm != null && tileDataSubmitButton.IsPressed())
                SubmitTileData();

            if (entityAddButton.IsPressed())
            {
                Type type = this.GetType().Assembly.GetType(typeof(Entity).Namespace + "." + entityListButton.List[entityListButton.CurrentIndex]);
                if (type != null)
                    entityToPlace = (Entity)type.GetConstructor(new Type[] { typeof(World) }).Invoke(new object[] { World });
            }
            if (entityRemoveButton != null && entityRemoveButton.IsPressed() && selectedEntity != null)
            {
                IEnumerable<KeyValuePair<int, Entity>> result = World.Entities.Where(pair => pair.Value == selectedEntity);
                if (result.Count() > 0)
                    World.Entities.Remove(result.ElementAt(0).Key);
                selectedEntity = null;
                ReconstructEntityDataPanel();
            }
            if (entityDataSubmitButton != null && entityDataForm != null && entityDataSubmitButton.IsPressed())
                SubmitEntityData();

            if (locTileAddButton.IsPressed())
            {
                Type type = this.GetType().Assembly.GetType(typeof(Tile).Namespace + "." + locTileListButton.List[locTileListButton.CurrentIndex]);
                if (type != null)
                    locTileToPlace = (LocatedTile)type.GetConstructor(new Type[] { typeof(World), typeof(int), typeof(int) }).Invoke(new object[] { World, 0, 0 });
            }
            if (locTileRemoveButton != null && locTileRemoveButton.IsPressed() && selectedLocTile != null)
            {
                World.SetTile((int)selectedLocTile.X, (int)selectedLocTile.Y, null);
                selectedLocTile = null;
                ReconstructLocTileDataPanel();
            }
            if (locTileDataSubmitButton != null && locTileDataForm != null && locTileDataSubmitButton.IsPressed())
                SubmitLocTileData();
        }
Пример #53
0
 void Awake()
 {
     animator = GetComponent<Animator>();
     moveable = GetComponent<IMoveable> ();
 }
Пример #54
0
 public MovementBehavior(IMoveable moveable)
 {
     horizontalState = Direction.none;
     verticalState = Direction.none;
     m_moveable = moveable;
 }
Пример #55
0
 void Start()
 {
     moveable = GetComponent<IMoveable> ();
 }
Пример #56
0
    public virtual void PlaceMoveable(IMoveable moveable)
	{
        if (Moveables.Count != 0)
            RemoveMoveable(Moveables.First());
        Moveables.Add(moveable);
	}
Пример #57
0
 public WizardManager(World world)
 {
     _coord = new Coordinate(2,1);
     _world = world;
 }
Пример #58
0
 public void PlaceMoveable(IMoveable moveable)
 {
     Moveables.Add(moveable);
 }
Пример #59
0
 public void RemoveMoveable(IMoveable moveable)
 {
     Moveables.Remove(moveable);
 }
Пример #60
0
 public override void HandleCollision(IMoveable other, MoveDirection direction)
 {
 }