private void SendTowerData(UserToken token, MSGModel message) { int team = message.GetMessage <int>();//获取队伍编号 int towerID = 20; switch (team) { case 1: towerID = 20; break; case 2: towerID = -20; break; } TowerActorModel tam = room.worldAcotr[towerID] as TowerActorModel; TowerData td = new TowerData(); td.ID = towerID; td.Team = team; td.HP = tam.HP; td.Attack = tam.Attack; td.Defence = tam.Defence; room.Write(token, Protocol.TYPE_FIGHT, Protocol.AREA_S_RES_TOWERDATA, 0, td); }
private void TowerAttack(UserToken token, AttackInfo attackInfo) { int a = attackInfo.a; int b = attackInfo.b; TowerActorModel temp = room.worldAcotr[a] as TowerActorModel; lock (room.worldAcotr) { if (!room.worldAcotr.ContainsKey(a)) { throw new Exception("物体不存在"); } if (!temp.IsAttacking) { temp.IsAttacking = true; room.Brocast(Protocol.TYPE_FIGHT, Protocol.AREA_S_NPCATTACK, 0, attackInfo, null); ScheduleUtil.Instance.Schedule(delegate() { temp.IsAttacking = false; }, 1); } } }