|
| 1 | +using GameClass.GameObj; |
| 2 | +using GameClass.GameObj.Areas; |
| 3 | +using Preparation.Utility; |
| 4 | +using Protobuf; |
| 5 | +using Utility = Preparation.Utility; |
| 6 | + |
| 7 | +namespace Server |
| 8 | +{ |
| 9 | + public static class CopyInfo |
| 10 | + { |
| 11 | + public static MessageOfObj? Auto(GameObj gameObj, long time) |
| 12 | + { |
| 13 | + if (gameObj.IsRemoved == true) |
| 14 | + return null; |
| 15 | + switch (gameObj.Type) |
| 16 | + { |
| 17 | + case GameObjType.CHARACTER: |
| 18 | + return Character((Character)gameObj, time); |
| 19 | + case GameObjType.ECONOMY_RESOURCE: |
| 20 | + return EconomyResource((E_Resource)gameObj); |
| 21 | + case GameObjType.ADDITIONAL_RESOURCE: |
| 22 | + return AdditionResource((A_Resource)gameObj); |
| 23 | + case GameObjType.CONSTRUCTION: |
| 24 | + Construction construction = (Construction)gameObj; |
| 25 | + if (construction.ConstructionType == Utility.ConstructionType.BARRACKS) |
| 26 | + return Barracks(construction); |
| 27 | + else if (construction.ConstructionType == Utility.ConstructionType.SPRING) |
| 28 | + return Spring(construction); |
| 29 | + else if (construction.ConstructionType == Utility.ConstructionType.FARM) |
| 30 | + return Farm(construction); |
| 31 | + return null; |
| 32 | + case GameObjType.TRAP: |
| 33 | + if (gameObj is HOLE hole) |
| 34 | + return Traps(hole); |
| 35 | + else if (gameObj is Cage cage) |
| 36 | + return Traps(cage); |
| 37 | + return null; |
| 38 | + default: return null; |
| 39 | + } |
| 40 | + } |
| 41 | + |
| 42 | + public static MessageOfObj? Auto(MessageOfNews news) |
| 43 | + { |
| 44 | + MessageOfObj objMsg = new() |
| 45 | + { |
| 46 | + NewsMessage = news |
| 47 | + }; |
| 48 | + return objMsg; |
| 49 | + } |
| 50 | + private static MessageOfObj? Base(Base player, long time) |
| 51 | + { |
| 52 | + MessageOfObj msg = new() |
| 53 | + { |
| 54 | + TeamMessage = new() |
| 55 | + { |
| 56 | + TeamId = player.TeamID, |
| 57 | + PlayerId = player.PlayerID, |
| 58 | + Score = player.MoneyPool.Score, |
| 59 | + Energy = player.MoneyPool.Money, |
| 60 | + } |
| 61 | + }; |
| 62 | + return msg; |
| 63 | + } |
| 64 | + |
| 65 | + public static MessageOfObj? Auto(Base @base, long time) |
| 66 | + { |
| 67 | + return Base(@base, time); |
| 68 | + } |
| 69 | + private static MessageOfObj? Character(Character player, long time) |
| 70 | + { |
| 71 | + MessageOfObj msg = new() |
| 72 | + { |
| 73 | + CharacterMessage = new() |
| 74 | + { |
| 75 | + Guid = player.ID, |
| 76 | + |
| 77 | + TeamId = player.TeamID, |
| 78 | + PlayerId = player.PlayerID, |
| 79 | + |
| 80 | + CharacterType = Transformation.CharacterTypeToProto(player.CharacterType), |
| 81 | + |
| 82 | + CharacterActiveState = Transformation.CharacterStateToProto(player.CharacterState1), |
| 83 | + |
| 84 | + IsBlind = player.blind, |
| 85 | + BlindTime = player.BlindTime, |
| 86 | + IsStunned = player.stunned, |
| 87 | + StunnedTime = player.StunnedTime, |
| 88 | + IsInvisible = !player.visible, |
| 89 | + InvisibleTime = player.InvisibleTime, |
| 90 | + IsBurned = player.burned, |
| 91 | + BurnedTime = player.BurnedTime, |
| 92 | + HarmCut = player.HarmCut, |
| 93 | + HarmCutTime = player.HarmCutTime, |
| 94 | + |
| 95 | + CharacterPassiveState = Transformation.CharacterStateToProto(player.CharacterState2), |
| 96 | + |
| 97 | + X = player.Position.x, |
| 98 | + Y = player.Position.y, |
| 99 | + |
| 100 | + FacingDirection = player.FacingDirection.Angle(), |
| 101 | + Speed = player.MoveSpeed, |
| 102 | + ViewRange = player.ViewRange, |
| 103 | + |
| 104 | + CommonAttack = (int)player.AttackPower, |
| 105 | + // 待修改,Character.cs中没有CommonAttackCD |
| 106 | + CommonAttackCd = (int)(1 / player.ATKFrequency), |
| 107 | + CommonAttackRange = (int)player.AttackSize, |
| 108 | + |
| 109 | + SkillAttackCd = player.skillCD, |
| 110 | + |
| 111 | + EconomyDepletion = player.EconomyDepletion, |
| 112 | + KillScore = (int)player.GetCost(), |
| 113 | + |
| 114 | + Hp = (int)player.HP, |
| 115 | + |
| 116 | + // 待修改,Shield要分两类 |
| 117 | + ShieldEquipment = (int)player.Shield, // 护盾装备 |
| 118 | + ShoesEquipment = (int)player.Shoes, // 加成值 |
| 119 | + ShoesTime = player.ShoesTime, // 包含所有速度加成的时间 |
| 120 | + IsPurified = player.Purified, |
| 121 | + PurifiedTime = player.PurifiedTime, |
| 122 | + IsBerserk = player.IsBerserk, |
| 123 | + BerserkTime = player.BerserkTime, |
| 124 | + |
| 125 | + AttackBuffNum = (int)player.CrazyManNum, |
| 126 | + AttackBuffTime = player.CrazyManTime, |
| 127 | + SpeedBuffTime = player.QuickStepTime, |
| 128 | + VisionBuffTime = player.WideViewTime, |
| 129 | + } |
| 130 | + }; |
| 131 | + return msg; |
| 132 | + } |
| 133 | + |
| 134 | + private static MessageOfObj EconomyResource(E_Resource economyresource) |
| 135 | + { |
| 136 | + MessageOfObj msg = new() |
| 137 | + { |
| 138 | + EconomyResourceMessage = new() |
| 139 | + { |
| 140 | + EconomyResourceState = Transformation.EconomyResourceStateToProto(economyresource.ERstate), |
| 141 | + EconomyResourceType = Transformation.EconomyResourceTypeToProto(economyresource.EResourceType), |
| 142 | + |
| 143 | + X = economyresource.Position.x, |
| 144 | + Y = economyresource.Position.y, |
| 145 | + |
| 146 | + Process = (10000 - (int)economyresource.HP) / 10000, |
| 147 | + Id = 0, |
| 148 | + } |
| 149 | + }; |
| 150 | + return msg; |
| 151 | + } |
| 152 | + |
| 153 | + private static MessageOfObj AdditionResource(A_Resource additionResource) |
| 154 | + { |
| 155 | + MessageOfObj msg = new() |
| 156 | + { |
| 157 | + AdditionResourceMessage = new() |
| 158 | + { |
| 159 | + AdditionResourceType = Transformation.AResourceToProto(additionResource.AResourceType), |
| 160 | + AdditionResourceState = Transformation.AResourceStateToProto(additionResource.ARstate), |
| 161 | + |
| 162 | + X = additionResource.Position.x, |
| 163 | + Y = additionResource.Position.y, |
| 164 | + |
| 165 | + Hp = (int)additionResource.HP, |
| 166 | + Id = 0, |
| 167 | + } |
| 168 | + }; |
| 169 | + // Debugger.Output(additionResource, additionResource.Place.ToString()+" "+additionResource.Position.ToString()); |
| 170 | + return msg; |
| 171 | + } |
| 172 | + |
| 173 | + private static MessageOfObj Barracks(Construction construction) |
| 174 | + { |
| 175 | + MessageOfObj msg = new() |
| 176 | + { |
| 177 | + BarracksMessage = new() |
| 178 | + { |
| 179 | + X = construction.Position.x, |
| 180 | + Y = construction.Position.y, |
| 181 | + |
| 182 | + Hp = (int)construction.HP, |
| 183 | + |
| 184 | + TeamId = construction.TeamID, |
| 185 | + Id = 0, |
| 186 | + } |
| 187 | + }; |
| 188 | + return msg; |
| 189 | + } |
| 190 | + |
| 191 | + private static MessageOfObj Spring(Construction construction) |
| 192 | + { |
| 193 | + MessageOfObj msg = new() |
| 194 | + { |
| 195 | + SpringMessage = new() |
| 196 | + { |
| 197 | + X = construction.Position.x, |
| 198 | + Y = construction.Position.y, |
| 199 | + |
| 200 | + Hp = (int)construction.HP, |
| 201 | + |
| 202 | + TeamId = construction.TeamID, |
| 203 | + Id = 0, |
| 204 | + } |
| 205 | + }; |
| 206 | + return msg; |
| 207 | + } |
| 208 | + |
| 209 | + private static MessageOfObj Farm(Construction construction) |
| 210 | + { |
| 211 | + MessageOfObj msg = new() |
| 212 | + { |
| 213 | + FarmMessage = new() |
| 214 | + { |
| 215 | + X = construction.Position.x, |
| 216 | + Y = construction.Position.y, |
| 217 | + |
| 218 | + Hp = (int)construction.HP, |
| 219 | + |
| 220 | + TeamId = construction.TeamID, |
| 221 | + Id = 0, |
| 222 | + } |
| 223 | + }; |
| 224 | + return msg; |
| 225 | + } |
| 226 | + |
| 227 | + // private static MessageOfObj Traps(GameObj trap) |
| 228 | + // { |
| 229 | + // MessageOfObj msg = new() |
| 230 | + // { |
| 231 | + // TrapMessage = new() |
| 232 | + // { |
| 233 | + // TrapType = trap switch |
| 234 | + // { |
| 235 | + // HOLE _ => Protobuf.TrapType.Hole, |
| 236 | + // Cage _ => Protobuf.TrapType.Cage, |
| 237 | + // }, |
| 238 | + |
| 239 | + // X = trap.Position.x, |
| 240 | + // Y = trap.Position.y, |
| 241 | + |
| 242 | + // TeamId = trap switch |
| 243 | + // { |
| 244 | + // HOLE t => t.TeamID.Get(), |
| 245 | + // Cage c => c.TeamID.Get(), |
| 246 | + // }, |
| 247 | + // Id = 0, |
| 248 | + |
| 249 | + // TrapValid = !trap.IsActivated.Get(), |
| 250 | + // } |
| 251 | + // }; |
| 252 | + // return msg; |
| 253 | + // } |
| 254 | + private static MessageOfObj Traps(HOLE trap) |
| 255 | + { |
| 256 | + MessageOfObj msg = new() |
| 257 | + { |
| 258 | + TrapMessage = new() |
| 259 | + { |
| 260 | + TrapType = Protobuf.TrapType.Hole, |
| 261 | + |
| 262 | + X = trap.Position.x, |
| 263 | + Y = trap.Position.y, |
| 264 | + |
| 265 | + TeamId = trap.TeamID.Get(), |
| 266 | + Id = 0, |
| 267 | + |
| 268 | + TrapValid = !trap.IsActivated.Get(), |
| 269 | + } |
| 270 | + }; |
| 271 | + return msg; |
| 272 | + } |
| 273 | + |
| 274 | + private static MessageOfObj Traps(Cage trap) |
| 275 | + { |
| 276 | + MessageOfObj msg = new() |
| 277 | + { |
| 278 | + TrapMessage = new() |
| 279 | + { |
| 280 | + TrapType = Protobuf.TrapType.Cage, |
| 281 | + |
| 282 | + X = trap.Position.x, |
| 283 | + Y = trap.Position.y, |
| 284 | + |
| 285 | + TeamId = trap.TeamID.Get(), |
| 286 | + Id = 0, |
| 287 | + |
| 288 | + TrapValid = !trap.IsActivated.Get(), |
| 289 | + } |
| 290 | + }; |
| 291 | + return msg; |
| 292 | + } |
| 293 | + } |
| 294 | +} |
0 commit comments