/// <summary> /// 告知队伍攻击结果 /// </summary> /// <param name="v"></param> /// <param name="result"></param> private void TellResult(int Team, FirePoint point, GameBoardBlock result) { if (Info.ShowKindWhileShoot) { string msg = "AUGB|" + point.Team + '|' + point.X + '|' + point.Y + '|' + GameBoards[point.Team].CheckName(result) + "|" + ((int)result).ToString(); foreach (string name in Teams[Team]) { Server.SendTo(name, msg); } } else { string msg = "AUGB|" + point.Team + '|' + point.X + '|' + point.Y + '|'; if (Enum.IsDefined(result.GetType(), result) && result != GameBoardBlock.ModelBody && result != GameBoardBlock.ModelHead) { msg += result.ToString(); } else { if (char.IsUpper((char)result)) { msg += GameBoardBlock.Head.ToString(); } else { msg += GameBoardBlock.Body.ToString(); } } msg += "|" + ((int)result).ToString(); foreach (string name in Teams[Team]) { Server.SendTo(name, msg); } } }
public GameBoardBlockView(GameBoardBlock block, bool showname = false) { InitializeComponent(); ShowName = showname; Block = block; if (!Properties.Settings.Default.LowGraphics) { CZBackGround.SetValue(ShadowAssist.ShadowDepthProperty, ShadowDepth.Depth1); CZBackGround.CornerRadius = new CornerRadius(3); } }
/// <summary> /// 尝试攻击某格。 /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <returns>攻击结果</returns> public GameBoardBlock Attack(int x, int y) { if (NotInRange(x, y)) { return(GameBoardBlock.Null); } else { GameBoardBlock result = this[x, y]; if (char.IsUpper((char)this[x, y])) { HeadCount--; this[x, y] = GameBoardBlock.Killed; } return(result); } }
/// <summary> /// 获取指定block的名字 /// </summary> /// <param name="block"></param> /// <returns></returns> public string CheckName(GameBoardBlock block) { if (char.IsLetter((char)block)) { if (char.IsUpper((char)block)) { block = (GameBoardBlock)char.ToLower((char)block); } if (PatternChars.ContainsKey((char)block)) { return(PatternChars[(char)block]); } else { return("Unknown Plane"); } } else { return(block.ToString()); } }
public void SetBlock(GameBoardBlock block, int x, int y, string detail = null) { this[x, y] = block; BlockDetails[x][y] = detail; BlockChanged?.Invoke(x, y); }
/// <summary> /// 按玩家顺序的形式开局 /// </summary> /// <param name="order">玩家的顺序</param> void StartByPlayerOrder(List <string> order) { AliveTeam.Clear(); for (int i = 0; i < Info.TeamCount; i++) { AliveTeam.Add(i); } TellGameStart(); int now = 0; int DieOrder = 0; //记录已经死了几个队伍 while (true) { string Name = order[now]; //当前玩家的名字 bool ExistPlayer = TeamOf.Keys.Contains(Name) && AliveTeam.Contains(TeamOf[Name]); if (!ExistPlayer) //跳过已经输了的队伍 { order.Remove(Name); continue; } ShowRound(Name, TeamOf[Name]); List <FirePoint> points = GetPoints(Name, GetFireCount(Name)); //从客户端获取攻击目标 //依次处理攻击目标 foreach (FirePoint i in points) { TellAttact(i); GameBoardBlock result = GameBoards[i.Team].Attack(i.X, i.Y); TellResult(TeamOf[Name], i, result); if (GameBoards[i.Team].HeadCount == 0) { if (AliveTeam.Contains(i.Team)) { //处理队伍挂了的情况 DieOrder++; foreach (string name in Teams[i.Team]) { Score[name] += DieOrder; UpdateScore(name); } TellFailure(i.Team); AliveTeam.Remove(i.Team); } } } //处理终局的计分情况 if (AliveTeam.Count <= 1) { DieOrder++; foreach (string name in Teams[0]) { Score[name] += DieOrder; UpdateScore(name); } break; } if (order.Count <= 1) { break; } now++; now %= order.Count; } TellGameEnd(); }