Наследование: System.Windows.Forms.Label
Пример #1
0
        public Grid(Point size, Cell[] cells)
        {
            this.size = size;
            this.cells = cells;

            this.copy = new Cell[size.X * size.Y];
        }
Пример #2
0
        public Grid(Point size, Cell[] cells, int iteration)
        {
            this.size = size;
            this.cells = cells;
            this.iteration = iteration;

            this.copy = new Cell[size.X * size.Y];
        }
Пример #3
0
        public Cell(Cell cell)
        {
            this.parent = cell.parent;

            this.alive = cell.alive;
            this.position = cell.position;

            this.color = cell.color;
            this.aliveColor = cell.aliveColor;
        }
Пример #4
0
      /// <summary>
      /// 伤害
      /// </summary>
      /// <param name="cell"></param>
      public void Hurt(Cell cell)
      {
         int hurt = this.Attack;

         StringBuilder strMsg = new StringBuilder();
         strMsg.Append(this.ToString());

         if (IsHaveAbility(AbilityEnum.奋力一击))
         {
            hurt += this.Strength;
            strMsg.AppendFormat("[奋力一击](+{0})", this.Strength.ToString());
         }

         if (IsHaveAbility(AbilityEnum.击中要害))
         {
            hurt += 10 + this.Intelligence / 3 + 1;
            strMsg.AppendFormat("[击中要害](+{0})", 10 + this.Intelligence / 3 + 1);
         }

         if (IsHaveAbility(AbilityEnum.拌摔))
         {
            cell.State |= CellStateEnum.被拌摔;
            strMsg.Append("[拌摔]");
         }

         if (IsHaveAbility(AbilityEnum.专注))
         {
            this.Rival.Clear();
            this.Rival.Add(cell);
            strMsg.Append("[专注]");
         }

         if (IsHaveAbility(AbilityEnum.闪避) && _random.Probability(0.01 * cell.Dexterity))
         {
            GameMessage.AddMsg(new FightMessage()
            {
               Msg = cell.ToString() + "[闪避]" + this.ToString() + "的一次攻击",
               被攻击者 = cell,
               攻击者 = this
            });
            return;
         }

         bool isAlive = cell.GetHurt(hurt);

         strMsg.Append("对" + cell.ToString() + "造成" + hurt + "点伤害");
         GameMessage.AddMsg(new FightMessage() { Msg = strMsg.ToString(), 攻击者 = this, 被攻击者 = cell });

         cell.AddRival(this);

         if (isAlive)
         {
            if (IsHaveAbility(AbilityEnum.反击) && _random.Probability(0.05 * cell.Dexterity))
            {
               GameMessage.AddMsg(new FightMessage()
               {
                  Msg = cell.ToString() + "对" + this.ToString() + "进行[反击]",
                  被攻击者 = cell,
                  攻击者 = this
               });

               cell.Hurt(this);
            }
         }
         else
         {
            CellDeadEventArgs e = new CellDeadEventArgs();
            e.Killer = this;
            e.LastHurt = hurt;

            if (cell.Dead != null)
            {
               cell.Dead(cell, e);

               GameMessage.AddMsg(new FightMessage()
               {
                  Msg = this.ToString() + "杀死了" + cell.ToString(),
                  被攻击者 = cell,
                  攻击者 = this
               });
            }
         }
      }
Пример #5
0
        public static Color GetMeanColor(Cell[] neighbours)
        {
            float red = 0, green = 0, blue = 0;

            foreach (Cell cell in neighbours)
            {
                red += cell.color.R;
                green += cell.color.G;
                blue += cell.color.B;
            }

            red /= neighbours.Length;
            green /= neighbours.Length;
            blue /= neighbours.Length;

            return Color.FromArgb((int)red, (int)green, (int)blue);
        }
Пример #6
0
      public Cell AddCell()
      {
         Cell cell = new Cell();
         cell.BackColor = Color.Gray;

         if (cell.Strength > 10)
         {
            cell.BackColor = Color.Red;
         }
         else if (cell.Dexterity > 10)
         {
            cell.BackColor = Color.Green;
         }
         else if (cell.Intelligence > 10)
         {
            cell.BackColor = Color.Blue;
         }

         return AddCell(cell);
      }
Пример #7
0
 public void GetVision(Cell cell)
 {
    Graphics g = this.CreateGraphics();
    foreach (var item in cell.Position.Within(cell.Vision).Select(p => GetLocation(p)))
    {
       g.FillRectangle(new SolidBrush(Color.Gold), new Rectangle(item, new Size(Rule.CELLWIDTH - 1, Rule.CELLWIDTH - 1)));
    }
 }
Пример #8
0
      public Cell AddCell(Cell cell)
      {
         if (_lstCell.Count > Rule.ROWS * Rule.COLUMNS / 3)
         {
            return null;
         }

         while (_lstCell.Select(cl => cl.Position).Contains(cell.Position))
         {
            cell.RandomPosition();
         }

         cell.No = _lstCell.Count;
         cell.ParentWorldMapPanel = this;
         while (!cell.GetAbility()) ;
         cell.Dead += (sender, e) => 
            {
               _lstCell.Remove(cell);
               this.Controls.Remove(cell);
            };
         cell.PositionChanged += (sender, e) => 
            {
               cell.Location = GetLocation(e.TargetPosition);
            };
         _lstCell.Add(cell);
         this.Controls.Add(cell);

         this.Invalidate(cell.ClientRectangle);

         return cell;
      }
Пример #9
0
 void AddRival(Cell cell)
 {
    this.Rival.Add(cell);
 }
Пример #10
0
 private void FillGrid()
 {
     for (int x = 0; x < Width; x++)
         for (int y = 0; y < Height; y++)
         {
             //to know more about CoordinateSystemConverter, see above (file start, before using's)
             int i = CoordinateSystemConverter.PlaneToLine(new Vector2D(x, y), Width);
             cells[i] = new Cell(new Point(x, y), rand.NextDouble() < 0.4, this);
         }
 }
Пример #11
0
 private void DetermineCellMeanColor(int i, Cell[] neighbours)
 {
     if (neighbours.Length > 0 && cells[i].Alive)
         cells[i].Color = Cell.GetMeanColor(neighbours);
 }