コード例 #1
0
ファイル: Scenario.cs プロジェクト: agustinsantos/Sxta
        private void UpdateCurrentPackagePosition(int packagePosX, int packagePosY, Actor.MoveDirection direction)
        {
            if (IsThereTarget(packagePosX, packagePosY))
            {
                item3 = new Item(ItemType.PackageOnGoal, packagePosX, packagePosY);
            }
            else
            {
                switch (direction)
                {
                case Actor.MoveDirection.Right:
                    if (packagePosX > target.PosX)
                    {
                        if (packagePosY < target.PosY)
                        {
                            item3 = new Item(ItemType.Package, packagePosX - 1, packagePosY + 1);
                        }
                        else
                        {
                            item3 = new Item(ItemType.Package, packagePosX - 1, packagePosY - 1);
                        }
                    }
                    else
                    {
                        item3 = new Item(ItemType.Package, packagePosX, packagePosY);
                    }
                    break;

                case Actor.MoveDirection.Left:
                    if (packagePosX < target.PosX)
                    {
                        if (packagePosY < target.PosY)
                        {
                            item3 = new Item(ItemType.Package, packagePosX + 1, packagePosY + 1);
                        }
                        else
                        {
                            item3 = new Item(ItemType.Package, packagePosX + 1, packagePosY - 1);
                        }
                    }
                    else
                    {
                        item3 = new Item(ItemType.Package, packagePosX, packagePosY);
                    }
                    break;

                case Actor.MoveDirection.Up:
                case Actor.MoveDirection.Down:
                    item3 = new Item(ItemType.Package, packagePosX, packagePosY);
                    break;
                }
            }
        }
コード例 #2
0
ファイル: Scenario.cs プロジェクト: agustinsantos/Sxta
        /// <summary>
        /// Check in what direction we want to move and call the corresponding
        /// method.
        /// </summary>
        /// <param name="direction">Direction to move in</param>
        public void MoveActor(Actor.MoveDirection direction)
        {
            switch (direction)
            {
            case Actor.MoveDirection.Up:
                MoveUp(actor);
                break;

            case Actor.MoveDirection.Down:
                MoveDown(actor);
                break;

            case Actor.MoveDirection.Right:
                MoveRight(actor);
                break;

            case Actor.MoveDirection.Left:
                MoveLeft(actor);
                break;
            }
        }
コード例 #3
0
ファイル: Scenario.cs プロジェクト: agustinsantos/Sxta
        /// <summary>
        /// When Sokoban moves or pushes we only draws these changes instead of
        /// redrawing the whole level again. Great performance improvement.
        /// </summary>
        /// <returns>The 'level' image that will be drawn to screen</returns>
        public void DrawChanges(Actor.MoveDirection direction)
        {
            if (item1 != null)
            {
                Image image1 = GetLevelImage(item1.ItemType, direction);
                g.DrawImage(image1, item1.XPos * ITEM_SIZE,
                            item1.YPos * ITEM_SIZE, ITEM_SIZE, ITEM_SIZE);
            }

            if (item2 != null)
            {
                Image image2 = GetLevelImage(item2.ItemType, direction);
                g.DrawImage(image2, item2.XPos * ITEM_SIZE,
                            item2.YPos * ITEM_SIZE, ITEM_SIZE, ITEM_SIZE);
            }

            if (item3 != null)
            {
                Image image3 = GetLevelImage(item3.ItemType, direction);
                g.DrawImage(image3, item3.XPos * ITEM_SIZE,
                            item3.YPos * ITEM_SIZE, ITEM_SIZE, ITEM_SIZE);
            }
        }
コード例 #4
0
 public static void Serialize(HlaEncodingWriter writer, Actor.MoveDirection val)
 {
     writer.WriteHLAinteger32BE((int)val);
 }
コード例 #5
0
 public void UpdateUI(Actor.MoveDirection direction)
 {
     // InvokeRequired required compares the thread ID of the
     // calling thread to the thread ID of the creating thread.
     // If these threads are different, it returns true.
     if (this.screen.InvokeRequired)
     {
         this.direction = direction;
         DrawChangesDelegate d = new DrawChangesDelegate(_UpdateUI);
         Invoke(d);
     }
     else
     {
         _UpdateUI();
     }
 }
コード例 #6
0
ファイル: Scenario.cs プロジェクト: agustinsantos/Sxta
        /// <summary>
        /// Depending on the 'item character' in the XML for the level set we
        /// need to display an image on the screen. This is what happens here.
        /// We also take into account the direction Sokoban is moving in,
        /// because we want him to face to the left when he is moving left.
        /// </summary>
        /// <param name="itemType">Level item</param>
        /// <param name="direction">Sokoban direction</param>
        /// <returns>The image to be displayed on screen</returns>
        public Image GetLevelImage(ItemType itemType, Actor.MoveDirection direction)
        {
            Image image;

            if (itemType == ItemType.Wall)
            {
                image = ImgWall;
            }
            else if (itemType == ItemType.Floor)
            {
                image = ImgFloor;
            }
            else if (itemType == ItemType.Package)
            {
                image = ImgPackage;
            }
            else if (itemType == ItemType.Goal)
            {
                image = ImgGoal;
            }
            else if (itemType == ItemType.Sokoban)
            {
                if (direction == Actor.MoveDirection.Up)
                {
                    image = ImgSokoUp;
                }
                else if (direction == Actor.MoveDirection.Down)
                {
                    image = ImgSokoDown;
                }
                else if (direction == Actor.MoveDirection.Right)
                {
                    image = ImgSokoRight;
                }
                else
                {
                    image = ImgSokoLeft;
                }
            }
            else if (itemType == ItemType.PackageOnGoal)
            {
                image = ImgPackageGoal;
            }
            else if (itemType == ItemType.SokobanOnGoal)
            {
                if (direction == Actor.MoveDirection.Up)
                {
                    image = ImgSokoUpGoal;
                }
                else if (direction == Actor.MoveDirection.Down)
                {
                    image = ImgSokoDownGoal;
                }
                else if (direction == Actor.MoveDirection.Right)
                {
                    image = ImgSokoRightGoal;
                }
                else
                {
                    image = ImgSokoLeftGoal;
                }
            }
            else
            {
                image = ImgSpace;
            }

            return(image);
        }