Exemplo n.º 1
0
        public EnemyShip(Texture2D image, Vector2 position, TypeShip type)
            : base(image, position)
        {
            double angle = 1.6;

            rotationAngle = (float)angle;
            velocity.X    = (float)(Math.Sin((double)rotationAngle) * ENEMY_SPEED);
            velocity.Y    = (float)(Math.Cos((double)rotationAngle) * ENEMY_SPEED);
            Type          = type;
            bullets       = new Bullet[MAX_BULLETS];
        }
Exemplo n.º 2
0
 public TypesShip()
 {
     typesShip = new TypeShip[5] {
         (new TypeShip {
             Steps = new bool[3, 3] {
                 { false, false, false }, { false, false, false }, { false, false, false }
             },
             Rotation = false,
             Reflection = new byte[3, 3] {
                 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }
             }
         }),
         (new TypeShip {
             Steps = new bool[3, 3] {
                 { false, false, false }, { true, false, true }, { false, false, false }
             },
             Rotation = false,
             Reflection = new byte[3, 3] {
                 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }
             }
         }),
         (new TypeShip {
             Steps = new bool[3, 3] {
                 { true, true, true }, { true, true, true }, { true, true, true }
             },
             Rotation = false,
             Reflection = new byte[3, 3] {
                 { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }
             }
         }),
         (new TypeShip {
             Steps = new bool[3, 3] {
                 { false, true, false }, { true, false, true }, { false, true, false }
             },
             Rotation = true,
             Reflection = new byte[3, 3] {
                 { 0, 0, 0 }, { 0, 0, 1 }, { 0, 1, 0 }
             }
         }),
         (new TypeShip {
             Steps = new bool[3, 3] {
                 { false, false, true }, { false, false, false }, { true, false, false }
             },
             Rotation = true,
             Reflection = new byte[3, 3] {
                 { 0, 2, 0 }, { 2, 0, 1 }, { 0, 1, 0 }
             }
         })
     };
 }
Exemplo n.º 3
0
        /// <summary>
        /// Creates the enemy ship.
        /// </summary>
        /// <param name="typeShip">The type ship.</param>
        /// <param name="screenSize">Size of the screen.</param>
        /// <returns></returns>
        public static EnemyShip CreateEnemyShip(TypeShip typeShip,Vector2 screenSize)
        {
            Random r = new Random();
            int random = r.Next(0, (int)screenSize.Y);
            int startPosInX = -100;

            if (typeShip == TypeShip.littleShip)
            {
                return new LittleShip(Game1.contentManager.Load<Texture2D>("Graphics\\sprites\\LittleShip"), new Vector2(startPosInX,random), TypeShip.littleShip);
            }
            if (typeShip == TypeShip.bigShip)
            {
                return new BigShip(Game1.contentManager.Load<Texture2D>("Graphics\\sprites\\BigShip"), new Vector2(startPosInX, random), TypeShip.littleShip);
            }

            return new BigBossShip(Game1.contentManager.Load<Texture2D>("Graphics\\sprites\\BigBossShip"), new Vector2(startPosInX, random), TypeShip.bigBossShip);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates the enemy ship.
        /// </summary>
        /// <param name="typeShip">The type ship.</param>
        /// <param name="screenSize">Size of the screen.</param>
        /// <returns></returns>
        public static EnemyShip CreateEnemyShip(TypeShip typeShip, Vector2 screenSize)
        {
            Random r           = new Random();
            int    random      = r.Next(0, (int)screenSize.Y);
            int    startPosInX = -100;

            if (typeShip == TypeShip.littleShip)
            {
                return(new LittleShip(Game1.contentManager.Load <Texture2D>("Graphics\\sprites\\LittleShip"), new Vector2(startPosInX, random), TypeShip.littleShip));
            }
            if (typeShip == TypeShip.bigShip)
            {
                return(new BigShip(Game1.contentManager.Load <Texture2D>("Graphics\\sprites\\BigShip"), new Vector2(startPosInX, random), TypeShip.littleShip));
            }

            return(new BigBossShip(Game1.contentManager.Load <Texture2D>("Graphics\\sprites\\BigBossShip"), new Vector2(startPosInX, random), TypeShip.bigBossShip));
        }
Exemplo n.º 5
0
        public Ship this[TypeShip index]
        {
            get
            {
                foreach (var item in ships)
                {
                    if (item.Type == index)
                    {
                        return(item);
                    }
                }
                return(null);
            }

            set {
                for (int i = 0; i < ships.Count; i++)
                {
                    if (ships[i].Type == index)
                    {
                        ships[i] = value;
                    }
                }
            }
        }
Exemplo n.º 6
0
 void ReturnMoney(TypeShip ship)
 {
     switch(ship)
     {
         case TypeShip.Colonist:
             Res.Food += 80;
             Res.Titanium += 20;
             Res.Gold += 1250;
             break;
         case TypeShip.Destroyer:
             Res.Titanium += 8;
             Res.Iridium += 17;
             Res.Gold += 450;
             break;
     }
 }
Exemplo n.º 7
0
 public BigShip(Texture2D image, Vector2 position, TypeShip type)
     : base(image, position, type)
 {
 }
        public void SupplyShip(Box startPosition, TypeShip ship, Orientation orientation)
        {
            string name;

            do
            {
                name = Guid.NewGuid().ToString();
            } while (!CheckAvailabilityName(name));
            int position = boxes.GetIndexBox(startPosition.Panel);

            if (orientation == Orientation.Vertical)
            {
                for (int i = 0, j = 0; i < (int)ship; i++, j += 10)
                {
                    if ((position + j) > 99)
                    {
                        throw new IndexOutOfRangeException();
                    }
                }
                if (!CheckAvailabilityVertical(position, ship))
                {
                    throw new Exception("Рядом корабль");
                }


                for (int i = 0, j = 0; i < (int)ship; i++, j += 10)
                {
                    boxes[boxes.GetIndexBox(startPosition.Panel) + j].NameShip = name;
                    if (!boxes.Enemy)
                    {
                        boxes[boxes.GetIndexBox(startPosition.Panel) + j].Color     = Colors.Blue;
                        boxes[boxes.GetIndexBox(startPosition.Panel) + j].LastColor = Colors.Blue;
                    }
                    boxes[boxes.GetIndexBox(startPosition.Panel) + j].IsBusy = true;
                }
            }
            else
            {
                for (int i = 1; i < (int)ship; i++)
                {
                    if ((position + i) % 10 == 0)
                    {
                        throw new IndexOutOfRangeException();
                    }
                }
                if (!CheckAvailabilityGorizontal(position, ship))
                {
                    throw new Exception("Рядом корабль");
                }
                for (int i = 0; i < (int)ship; i++)
                {
                    boxes[boxes.GetIndexBox(startPosition.Panel) + i].NameShip = name;
                    if (!boxes.Enemy)
                    {
                        boxes[boxes.GetIndexBox(startPosition.Panel) + i].Color     = Colors.Blue;
                        boxes[boxes.GetIndexBox(startPosition.Panel) + i].LastColor = Colors.Blue;
                    }
                    boxes[boxes.GetIndexBox(startPosition.Panel) + i].IsBusy = true;
                }
            }
        }
        private bool CheckAvailabilityGorizontal(int startPosition, TypeShip ship)
        {
            if (startPosition != 0 && (startPosition - 1) % 10 != 9)
            {
                if (startPosition - 10 > 0)
                {
                    if (boxes[startPosition - 10 - 1].IsBusy)
                    {
                        return(false);
                    }
                }
                if (startPosition != 0 && boxes[startPosition - 1].IsBusy)
                {
                    return(false);
                }
                if (startPosition + 10 < 99)
                {
                    if (boxes[startPosition + 10 - 1].IsBusy)
                    {
                        return(false);
                    }
                }
            }//проверяем лево
            if ((startPosition + (int)ship) % 10 != 0)
            {
                if (startPosition - 10 > 0)
                {
                    if (boxes[startPosition - 10 + (int)ship].IsBusy)
                    {
                        return(false);
                    }
                }
                if (boxes[startPosition + (int)ship].IsBusy)
                {
                    return(false);
                }
                if (startPosition + 10 < 99)
                {
                    if (boxes[startPosition + 10 + (int)ship].IsBusy)
                    {
                        return(false);
                    }
                }
            }//проверяем право
            for (int i = 0; i < (int)ship; i++)
            {
                if (startPosition - 10 >= 0)
                {
                    if (boxes[startPosition + i - 10].IsBusy)
                    {
                        return(false);
                    }
                }
                if (startPosition + 10 <= 99)
                {
                    if (boxes[startPosition + i + 10].IsBusy)
                    {
                        return(false);
                    }
                }
                if (boxes[startPosition + i].IsBusy)
                {
                    return(false);
                }
            }//проверяем стороны

            return(true);
        }
 public bool CheckAvailabilityVertical(int startPosition, TypeShip ship)
 {
     if ((startPosition - 10) >= 0)
     {
         if (startPosition != 0 && (startPosition - 1) % 10 != 9)
         {
             if (boxes[startPosition - 1 - 10].IsBusy)
             {
                 return(false);
             }
         }
         if (boxes[startPosition - 10].IsBusy)
         {
             return(false);
         }
         if ((startPosition + 1) % 10 != 0)
         {
             if (boxes[startPosition - 10 + 1].IsBusy)
             {
                 return(false);
             }
         }
     }//проверяем верх
     if ((startPosition + (int)ship * 10) <= 99)
     {
         if ((startPosition + (int)ship * 10 - 1) % 10 != 9)
         {
             if (boxes[startPosition - 1 + (int)ship * 10].IsBusy)
             {
                 return(false);
             }
         }
         if (boxes[startPosition + (int)ship * 10].IsBusy)
         {
             return(false);
         }
         if ((startPosition + 1 + (int)ship * 10) % 10 != 0)
         {
             if (boxes[startPosition + (int)ship * 10 + 1].IsBusy)
             {
                 return(false);
             }
         }
     }//проверяем низ
     for (int i = 0, j = 0; i < (int)ship; i++, j += 10)
     {
         if (startPosition != 0 && (startPosition - 1) % 10 != 9)
         {
             if (boxes[startPosition - 1 + j].IsBusy)
             {
                 return(false);
             }
         }
         if ((startPosition + 1) % 10 != 0)
         {
             if (boxes[startPosition + 1 + j].IsBusy)
             {
                 return(false);
             }
         }
         if (boxes[startPosition + j].IsBusy)
         {
             return(false);
         }
     }//проверяем боковые стороны
     return(true);
 }
Exemplo n.º 11
0
 public LittleShip(Texture2D image, Vector2 position, TypeShip type)
     : base(image, position, type)
 {
 }
Exemplo n.º 12
0
 private void radioButton1_Click(object sender, RoutedEventArgs e)
 {
     TypeShip = (TypeShip)Convert.ToInt32((sender as RadioButton).Content);
 }
Exemplo n.º 13
0
 public BigBossShip(Texture2D image, Vector2 position, TypeShip type)
     : base(image, position, type)
 {
 }