コード例 #1
0
        static int FindMaxWidthBar(SpacePart b1,
                                   SpacePart b2, SpacePart b3)
        {
            int maxWidth = 0;
            int w        = 0;

            if (b1 != null)
            {
                w = FindMaxWidthBar(b1);
                if (w > maxWidth)
                {
                    maxWidth = w;
                }
            }
            if (b2 != null)
            {
                w = FindMaxWidthBar(b2);
                if (w > maxWidth)
                {
                    maxWidth = w;
                }
            }
            if (b3 != null)
            {
                w = FindMaxWidthBar(b3);
                if (w > maxWidth)
                {
                    maxWidth = w;
                }
            }
            return(maxWidth);
        }
コード例 #2
0
        static int FindMaxHeightBar(SpacePart b1,
                                    SpacePart b2, SpacePart b3)
        {
            //find bar with max height
            int maxHeight = 0;
            int h         = 0;

            if (b1 != null)
            {
                h = FindMaxHeightBar(b1);
                if (h > maxHeight)
                {
                    maxHeight = h;
                }
            }
            if (b2 != null)
            {
                h = FindMaxHeightBar(b2);
                if (h > maxHeight)
                {
                    maxHeight = h;
                }
            }
            if (b3 != null)
            {
                h = FindMaxHeightBar(b3);
                if (h > maxHeight)
                {
                    maxHeight = h;
                }
            }

            return(maxHeight);
        }
コード例 #3
0
 public void GetBrokenPart()
 {
     foreach (SpacePart part in spaceShip)
     {
         if (part.isDamage)
         {
             repairedPart = part;
             return;
         }
     }
 }
コード例 #4
0
        static int FindMaxWidthBar(SpacePart bx)
        {
            switch (bx.OverlapMode)
            {
            case NamedSpaceContainerOverlapMode.Middle:
            {
                return(bx.Width / 2);
            }

            case NamedSpaceContainerOverlapMode.Outer:
            {
                return(bx.Width);
            }

            default:
            {
                return(0);
            }
            }
        }
コード例 #5
0
    public string GetEvent()
    {
        string str = "";

        if (Random.Range(0f, 1f) < persenDamage)
        {
            int         size = Random.Range(1, 3);
            SpacePart[] temp = new SpacePart[size];

            for (int i = 0; i < size; i++)
            {
                // temp[i] = spaceShip[Random.Range(0, spaceShip.Length)];
                int index = Random.Range(0, spaceShip.Length);
                spaceShip[index].DoDamage();
            }

            str = " SpaceShip hit by\n space junk . . .";
        }

        return(str);
    }
コード例 #6
0
        void SetBoundOfFreeSpace(SpacePart space,
                                 SpacePart centerspace,
                                 bool suddenArr)
        {
            if (space == null)
            {
                return;
            }

            suddenArr = false;
            var centerspacex = centerspace.Content;
            int x_pos        = centerspace.X;
            int y_pos        = centerspace.Y;
            int dw           = OwnerVisualElement.Width;
            int dh           = OwnerVisualElement.Height;

            if (space.DesiredWidth < dw)
            {
                dw = space.DesiredWidth;
            }
            if (space.DesiredHeight < dh)
            {
                dh = space.DesiredHeight;
            }


            SetDockBound(space,
                         0,
                         0,
                         dw,
                         dh);
            switch (space.SpaceName)
            {
            case SpaceName.Left:
            {
                switch (space.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Outer:
                {
                    x_pos -= space.Width;
                }
                break;

                case NamedSpaceContainerOverlapMode.Middle:
                {
                    x_pos -= space.Width / 2;
                }
                break;
                }
                space.SetLocation(x_pos, y_pos);
            }
            break;

            case SpaceName.Right:
            {
                x_pos = centerspace.Right;
                switch (space.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Inner:
                {
                    x_pos -= space.Width;
                }
                break;

                case NamedSpaceContainerOverlapMode.Middle:
                {
                    x_pos -= space.Width / 2;
                }
                break;
                }
            }
            break;

            case SpaceName.Top:
            {
                switch (space.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Outer:
                {
                    y_pos -= space.Height;
                }
                break;

                case NamedSpaceContainerOverlapMode.Middle:
                {
                    y_pos -= space.Height / 2;
                }
                break;
                }
            }
            break;

            case SpaceName.Bottom:
            {
                y_pos = centerspace.Bottom;
                switch (space.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Inner:
                {
                    y_pos -= space.Height;
                }
                break;

                case NamedSpaceContainerOverlapMode.Middle:
                {
                    y_pos -= space.Height / 2;
                }
                break;
                }
            }
            break;

            case SpaceName.LeftTop:
            {
                switch (space.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Outer:
                {
                    x_pos -= space.Width;
                    y_pos -= space.Height;
                }
                break;

                case NamedSpaceContainerOverlapMode.Middle:
                {
                    x_pos -= space.Width / 2;
                    y_pos -= space.Height / 2;
                }
                break;
                }
            }
            break;

            case SpaceName.LeftBottom:
            {
                switch (space.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Outer:
                {
                    x_pos -= space.Width;
                    y_pos  = centerspace.Bottom;
                }
                break;

                case NamedSpaceContainerOverlapMode.Inner:
                {
                    y_pos = centerspace.Bottom - space.Height;
                }
                break;

                case NamedSpaceContainerOverlapMode.Middle:
                {
                    x_pos -= space.Width / 2;
                    y_pos  = centerspace.Bottom - space.Height / 2;
                }
                break;
                }
            }
            break;

            case SpaceName.RightTop:
            {
                switch (space.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Outer:
                {
                    x_pos  = centerspace.Right;
                    y_pos -= space.Height;
                }
                break;

                case NamedSpaceContainerOverlapMode.Inner:
                {
                    x_pos = centerspace.Right - space.Width;
                }
                break;

                case NamedSpaceContainerOverlapMode.Middle:
                {
                    //outter - half of grip
                    x_pos  = centerspace.Right - (space.Width / 2);
                    y_pos -= space.Height - (space.Height / 2);
                }
                break;
                }
            }
            break;

            case SpaceName.RightBottom:
            {
                switch (space.OverlapMode)
                {
                case NamedSpaceContainerOverlapMode.Outer:
                {
                    x_pos = centerspace.Right;
                    y_pos = centerspace.Bottom;
                }
                break;

                case NamedSpaceContainerOverlapMode.Inner:
                {
                    x_pos = centerspace.Right - space.Width;
                    y_pos = centerspace.Bottom - space.Height;
                }
                break;

                case NamedSpaceContainerOverlapMode.Middle:
                {
                    //outer - half of grid box
                    x_pos = centerspace.Right - (space.Width / 2);
                    y_pos = centerspace.Bottom - (space.Height / 2);
                }
                break;
                }
            }
            break;
            }

            //VisualInvalidateCanvasArgs vinv = contentArrVisitor.GetVisualInvalidateCanvasArgs();
            space.SetLocation(x_pos, y_pos);
        }
コード例 #7
0
        void SetBoundOfFreeSpace(SpacePart space,
            SpacePart centerspace,
            bool suddenArr)
        {
            if (space == null)
            {
                return;
            }

            suddenArr = false;
            var centerspacex = centerspace.Content;
            int x_pos = centerspace.X;
            int y_pos = centerspace.Y;
            int dw = OwnerVisualElement.Width;
            int dh = OwnerVisualElement.Height;
            if (space.DesiredWidth < dw)
            {
                dw = space.DesiredWidth;
            }
            if (space.DesiredHeight < dh)
            {
                dh = space.DesiredHeight;
            }


            SetDockBound(space,
                0,
                0,
                dw,
                dh);
            switch (space.SpaceName)
            {
                case SpaceName.Left:
                    {
                        switch (space.OverlapMode)
                        {
                            case NamedSpaceContainerOverlapMode.Outer:
                                {
                                    x_pos -= space.Width;
                                }
                                break;
                            case NamedSpaceContainerOverlapMode.Middle:
                                {
                                    x_pos -= space.Width / 2;
                                }
                                break;
                        }
                        space.SetLocation(x_pos, y_pos);
                    }
                    break;
                case SpaceName.Right:
                    {
                        x_pos = centerspace.Right;
                        switch (space.OverlapMode)
                        {
                            case NamedSpaceContainerOverlapMode.Inner:
                                {
                                    x_pos -= space.Width;
                                }
                                break;
                            case NamedSpaceContainerOverlapMode.Middle:
                                {
                                    x_pos -= space.Width / 2;
                                }
                                break;
                        }
                    }
                    break;
                case SpaceName.Top:
                    {
                        switch (space.OverlapMode)
                        {
                            case NamedSpaceContainerOverlapMode.Outer:
                                {
                                    y_pos -= space.Height;
                                }
                                break;
                            case NamedSpaceContainerOverlapMode.Middle:
                                {
                                    y_pos -= space.Height / 2;
                                }
                                break;
                        }
                    }
                    break;
                case SpaceName.Bottom:
                    {
                        y_pos = centerspace.Bottom;
                        switch (space.OverlapMode)
                        {
                            case NamedSpaceContainerOverlapMode.Inner:
                                {
                                    y_pos -= space.Height;
                                }
                                break;
                            case NamedSpaceContainerOverlapMode.Middle:
                                {
                                    y_pos -= space.Height / 2;
                                }
                                break;
                        }
                    }
                    break;
                case SpaceName.LeftTop:
                    {
                        switch (space.OverlapMode)
                        {
                            case NamedSpaceContainerOverlapMode.Outer:
                                {
                                    x_pos -= space.Width;
                                    y_pos -= space.Height;
                                }
                                break;
                            case NamedSpaceContainerOverlapMode.Middle:
                                {
                                    x_pos -= space.Width / 2;
                                    y_pos -= space.Height / 2;
                                }
                                break;
                        }
                    }
                    break;
                case SpaceName.LeftBottom:
                    {
                        switch (space.OverlapMode)
                        {
                            case NamedSpaceContainerOverlapMode.Outer:
                                {
                                    x_pos -= space.Width;
                                    y_pos = centerspace.Bottom;
                                }
                                break;
                            case NamedSpaceContainerOverlapMode.Inner:
                                {
                                    y_pos = centerspace.Bottom - space.Height;
                                }
                                break;
                            case NamedSpaceContainerOverlapMode.Middle:
                                {
                                    x_pos -= space.Width / 2;
                                    y_pos = centerspace.Bottom - space.Height / 2;
                                }
                                break;
                        }
                    }
                    break;
                case SpaceName.RightTop:
                    {
                        switch (space.OverlapMode)
                        {
                            case NamedSpaceContainerOverlapMode.Outer:
                                {
                                    x_pos = centerspace.Right;
                                    y_pos -= space.Height;
                                }
                                break;
                            case NamedSpaceContainerOverlapMode.Inner:
                                {
                                    x_pos = centerspace.Right - space.Width;
                                }
                                break;
                            case NamedSpaceContainerOverlapMode.Middle:
                                {
                                    //outter - half of grip
                                    x_pos = centerspace.Right - (space.Width / 2);
                                    y_pos -= space.Height - (space.Height / 2);
                                }
                                break;
                        }
                    }
                    break;
                case SpaceName.RightBottom:
                    {
                        switch (space.OverlapMode)
                        {
                            case NamedSpaceContainerOverlapMode.Outer:
                                {
                                    x_pos = centerspace.Right;
                                    y_pos = centerspace.Bottom;
                                }
                                break;
                            case NamedSpaceContainerOverlapMode.Inner:
                                {
                                    x_pos = centerspace.Right - space.Width;
                                    y_pos = centerspace.Bottom - space.Height;
                                }
                                break;
                            case NamedSpaceContainerOverlapMode.Middle:
                                {
                                    //outer - half of grid box
                                    x_pos = centerspace.Right - (space.Width / 2);
                                    y_pos = centerspace.Bottom - (space.Height / 2);
                                }
                                break;
                        }
                    }
                    break;
            }

            //VisualInvalidateCanvasArgs vinv = contentArrVisitor.GetVisualInvalidateCanvasArgs();
            space.SetLocation(x_pos, y_pos);
        }
コード例 #8
0
 static int FindMaxWidthBar(SpacePart bx)
 {
     switch (bx.OverlapMode)
     {
         case NamedSpaceContainerOverlapMode.Middle:
             {
                 return bx.Width / 2;
             }
         case NamedSpaceContainerOverlapMode.Outer:
             {
                 return bx.Width;
             }
         default:
             {
                 return 0;
             }
     }
 }
コード例 #9
0
 static int FindMaxWidthBar(SpacePart b1,
     SpacePart b2, SpacePart b3)
 {
     int maxWidth = 0;
     int w = 0;
     if (b1 != null)
     {
         w = FindMaxWidthBar(b1);
         if (w > maxWidth)
         {
             maxWidth = w;
         }
     }
     if (b2 != null)
     {
         w = FindMaxWidthBar(b2);
         if (w > maxWidth)
         {
             maxWidth = w;
         }
     }
     if (b3 != null)
     {
         w = FindMaxWidthBar(b3);
         if (w > maxWidth)
         {
             maxWidth = w;
         }
     }
     return maxWidth;
 }
コード例 #10
0
        static int FindMaxHeightBar(SpacePart b1,
            SpacePart b2, SpacePart b3)
        {
            //find bar with max height
            int maxHeight = 0;
            int h = 0;
            if (b1 != null)
            {
                h = FindMaxHeightBar(b1);
                if (h > maxHeight)
                {
                    maxHeight = h;
                }
            }
            if (b2 != null)
            {
                h = FindMaxHeightBar(b2);
                if (h > maxHeight)
                {
                    maxHeight = h;
                }
            }
            if (b3 != null)
            {
                h = FindMaxHeightBar(b3);
                if (h > maxHeight)
                {
                    maxHeight = h;
                }
            }

            return maxHeight;
        }