diff --git a/dependency/MapGenerator/README.md b/dependency/MapGenerator/README.md new file mode 100644 index 00000000..df0bb384 --- /dev/null +++ b/dependency/MapGenerator/README.md @@ -0,0 +1,3 @@ +# THUAI7 随机地图生成器 + +地图生成逻辑极为简单,有待其他大佬进一步改进。 \ No newline at end of file diff --git a/dependency/MapGenerator/assets/css/map.css b/dependency/MapGenerator/assets/css/map.css new file mode 100644 index 00000000..69d1f965 --- /dev/null +++ b/dependency/MapGenerator/assets/css/map.css @@ -0,0 +1,62 @@ +#paint { + float: left; +} + +#paint canvas { + border: 1px solid #333; + border-radius: 10px; + cursor: crosshair; + margin: 0 20px 20px 0; +} + +#color-picker { + float: left; +} + +#color-picker div { + width: 120px; + height: 40px; + text-align: center; + cursor: pointer; + margin: 14px; + border-radius: 10px; + border: 1px solid #000; +} + +#color-picker div:hover { + border: 1px solid #333; + box-shadow: 0 0 5px #333; + text-shadow: 0 0 5px #333; +} + +#color-picker div p { + font-size: 16px; + font-weight: 500; + line-height: 40px; + margin: 0; +} + +#random-settings { + float: left; +} + +#random-settings p { + font-size: 16px; + font-weight: 500; + margin: 0 0 10px; + text-align: right; +} + +#random-settings p:hover { + color: #025b9e; +} + +#random-settings input { + border-radius: 5px; + border: 1px solid #333; + width: 64px; +} + +#operate { + clear: both; +} \ No newline at end of file diff --git a/dependency/MapGenerator/assets/css/style.css b/dependency/MapGenerator/assets/css/style.css new file mode 100644 index 00000000..7b740219 --- /dev/null +++ b/dependency/MapGenerator/assets/css/style.css @@ -0,0 +1,185 @@ +html { + box-sizing: border-box; + font-family: 'Roboto', sans-serif; + background-color: #fff; +} + +header { + background-color: #fff; + border-bottom: 1px solid #eee; + height: 60px; + line-height: 60px; + position: fixed; + top: 0; + width: 100%; + z-index: 999; +} + +header .logo { + float: left; + margin-left: 30px; +} + +header .logo a { + color: #333; + font-size: 20px; + font-weight: 700; + text-decoration: none; +} + +header .logo a:hover { + color: #025b9e; +} + +header .logo img { + height: 40px; + margin-top: 10px; +} + +header .top-nav { + float: right; + margin-right: 30px; +} + +header .top-nav ul { + list-style: none; + margin: 0; + padding: 0; +} + +header .top-nav ul li { + display: inline-block; + margin-left: 20px; + position: relative; +} + +header .top-nav ul li a { + color: #333; + font-size: 16px; + font-weight: 500; + text-decoration: none; +} + +header .top-nav ul li a:hover { + color: #025b9e; +} + +main { + margin-top: 60px; + padding: 30px; +} + +main h1 { + color: #333; + font-size: 24px; + font-weight: 700; + margin: 0 0 20px; +} + +main h2 { + color: #333; + font-size: 20px; + font-weight: 700; + margin: 0 0 20px; +} + +main p { + color: #333; + font-size: 16px; + font-weight: 400; + line-height: 1.5; + margin: 0 0 20px; +} + +main a { + color: #027dcd; + font-size: 16px; + font-weight: 500; + text-decoration: none; +} + +main a:hover { + color: #025b9e; +} + +main ul { + /* list-style: none; */ + margin: 0; + /* padding: 0; */ +} + +main ul li { + margin-bottom: 20px; +} + +main ul li a { + color: #333; + font-size: 16px; + font-weight: 500; + /* text-decoration: none; */ +} + +main ul li a:hover { + color: #025b9e; +} + +main button { + background-color: #027dcd; + border: 0; + border-radius: 10px; + color: #fff; + cursor: pointer; + font-size: 16px; + font-weight: 500; + height: 40px; + margin-bottom: 20px; + padding: 0 20px; +} + +main button:hover { + background-color: #025b9e; + box-shadow: 0 0 5px #333; + text-shadow: 0 0 5px #333; +} + +main fieldset { + border: 1px solid #333; + border-radius: 10px; + margin-bottom: 20px; + padding: 20px; +} + +main fieldset legend { + color: #333; + font-size: 16px; + font-weight: 500; +} + +main fieldset label { + color: #333; + font-size: 16px; + font-weight: 500; +} + +main fieldset input[type="text"], +main fieldset input[type="email"], +main fieldset input[type="password"], +main fieldset select { + border: 1px solid #eee; + border-radius: 10px; + color: #333; + font-size: 16px; + font-weight: 400; + height: 40px; + margin-bottom: 20px; + padding: 0 10px; + width: 100%; +} + +main fieldset input[type="text"]:focus, +main fieldset input[type="email"]:focus, +main fieldset input[type="password"]:focus, +main fieldset select:focus { + border: 1px solid #333; + box-shadow: 0 0 5px #333; +} \ No newline at end of file diff --git a/dependency/MapGenerator/assets/img/favicon.ico b/dependency/MapGenerator/assets/img/favicon.ico new file mode 100644 index 00000000..75325016 Binary files /dev/null and b/dependency/MapGenerator/assets/img/favicon.ico differ diff --git a/dependency/MapGenerator/assets/js/map.js b/dependency/MapGenerator/assets/js/map.js new file mode 100644 index 00000000..e07e3666 --- /dev/null +++ b/dependency/MapGenerator/assets/js/map.js @@ -0,0 +1,333 @@ +var canvas = document.getElementById("map"); +var ctx = canvas.getContext("2d"); +var currentColor = 0; +var map = new Array(50); +for (var i = 0; i < 50; i++) { + map[i] = new Array(50); + for (var j = 0; j < 50; j++) { + map[i][j] = 0; + } +} +var color = [ + "#FFFFFF", // Space + "#B97A57", // Ruin + "#22B14C", // Shadow + "#99D9EA", // Asteroid + "#A349A4", // Resource + "#FF7F27", // Construction + "#880015", // Wormhole + "#ED1C24", // Home +]; + +function draw() { + ctx.clearRect(0, 0, 500, 500); + for (var i = 0; i < 50; i++) { + for (var j = 0; j < 50; j++) { + ctx.fillStyle = color[map[i][j]]; + ctx.fillRect(i * 10, j * 10, 10, 10); + } + } +} + +canvas.onmousedown = function (e) { + var x = Math.floor(e.offsetX / 10); + var y = Math.floor(e.offsetY / 10); + map[x][y] = currentColor; + draw(); +} + +document.getElementById("space").onclick = function () { + currentColor = 0; + document.getElementById("current").innerHTML = "当前:Space"; +} +document.getElementById("ruin").onclick = function () { + currentColor = 1; + document.getElementById("current").innerHTML = "当前:Ruin"; +} +document.getElementById("shadow").onclick = function () { + currentColor = 2; + document.getElementById("current").innerHTML = "当前:Shadow"; +} +document.getElementById("asteroid").onclick = function () { + currentColor = 3; + document.getElementById("current").innerHTML = "当前:Asteroid"; +} +document.getElementById("resource").onclick = function () { + currentColor = 4; + document.getElementById("current").innerHTML = "当前:Resource"; +} +document.getElementById("construction").onclick = function () { + currentColor = 5; + document.getElementById("current").innerHTML = "当前:Construction"; +} +document.getElementById("wormhole").onclick = function () { + currentColor = 6; + document.getElementById("current").innerHTML = "当前:Wormhole"; +} +document.getElementById("home").onclick = function () { + currentColor = 7; + document.getElementById("current").innerHTML = "当前:Home"; +} + +function saveAsTxt() { + var str = ""; + for (var i = 0; i < 50; i++) { + for (var j = 0; j < 50; j++) { + str += map[j][i]; + } + str += "\n"; + } + var a = document.createElement("a"); + a.style.display = "none"; + a.href = "data:text/plain;charset=utf-8," + str; + a.download = "map.txt"; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); +} + +function saveAsCs() { + var str = "public static uint[,] Map = new uint[50, 50] {\n"; + for (var i = 0; i < 50; i++) { + str += " {"; + for (var j = 0; j < 50; j++) { + str += map[j][i]; + if (j != 49) { + str += ", "; + } + } + str += "}"; + if (i != 49) { + str += ","; + } + str += "\n"; + } + str += "};"; + var a = document.createElement("a"); + a.style.display = "none"; + a.href = "data:text/plain;charset=utf-8," + str; + a.download = "map.cs"; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); +} + +function saveAsPng() { + var a = document.createElement("a"); + a.style.display = "none"; + a.href = canvas.toDataURL("image/png"); + a.download = "map.png"; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); +} + +function isEmptyNearby(x, y, radius) { + for (var i = (x - radius >= 0 ? x - radius : 0); i <= (x + radius <= 49 ? x + radius : 49); i++) { + for (var j = (y - radius >= 0 ? y - radius : 0); j <= (y + radius <= 49 ? y + radius : 49); j++) { + if (map[i][j] != 0) { + return false; + } + } + } + return true; +} + +function haveSthNearby(x, y, radius, type) { + var ret = 0; + for (var i = (x - radius >= 0 ? x - radius : 0); i <= (x + radius <= 49 ? x + radius : 49); i++) { + for (var j = (y - radius >= 0 ? y - radius : 0); j <= (y + radius <= 49 ? y + radius : 49); j++) { + if (map[i][j] == type) { + ret++; + } + } + } + return ret; +} + +function haveSthCross(x, y, radius, type) { + var ret = 0; + for (var i = (x - radius >= 0 ? x - radius : 0); i <= (x + radius <= 49 ? x + radius : 49); i++) { + if (map[i][y] == type) { + ret++; + } + } + for (var j = (y - radius >= 0 ? y - radius : 0); j <= (y + radius <= 49 ? y + radius : 49); j++) { + if (map[x][j] == type) { + ret++; + } + } + return ret; +} + +function generateBorderRuin() { + for (var i = 0; i < 50; i++) { + map[i][0] = 1; + map[i][49] = 1; + map[0][i] = 1; + map[49][i] = 1; + } +} + +function generateHome() { + map[3][46] = 7; + map[46][3] = 7; +} + +function generateAsteroid(width = 2) { + for (var i = 1; i < 49; i++) { + for (var j = 24; j > 24 - width; j--) { + map[i][j] = 3; + map[49 - i][49 - j] = 3; + } + } + for (var i = 1; i < 23; i++) { + if (Math.random() < 0.5 && i != 9 && i != 10 && i != 11 && i != 12) { + map[i][24 - width] = 3; + map[i][24 + width] = 0; + map[49 - i][25 + width] = 3; + map[49 - i][25 - width] = 0; + } + } +} + +function generateResource(num = 7) { + for (var i = 0; i < num; i++) { + var x = Math.floor(Math.random() * 48) + 1; + var y = Math.floor(Math.random() * 23) + 1; + if (isEmptyNearby(x, y, 2)) { + map[x][y] = 4; + map[49 - x][49 - y] = 4; + } + else { + i--; + } + } +} + +function generateConstruction(num = 5) { + for (var i = 0; i < num; i++) { + var x = Math.floor(Math.random() * 48) + 1; + var y = Math.floor(Math.random() * 23) + 1; + if (isEmptyNearby(x, y, 1)) { + map[x][y] = 5; + map[49 - x][49 - y] = 5; + } + else { + i--; + } + } +} + +function generateShadow(prob = 0.015, crossBonus = 23) { + for (var i = 0; i < 50; i++) { + for (var j = 0; j < 50; j++) { + if (map[i][j] == 0 && Math.random() < prob * (haveSthCross(i, j, 1, 2) * crossBonus + 1)) { + map[i][j] = 2; + map[49 - i][49 - j] = 2; + } + } + } +} + +function generateRuin(prob = 0.01, crossBonus = 40) { + for (var i = 2; i < 48; i++) { + for (var j = 2; j < 48; j++) { + if ((map[i][j] == 0 || map[i][j] == 2) && !haveSthNearby(i, j, 1, 3) && !haveSthNearby(i, j, 1, 7) && Math.random() < prob * (haveSthCross(i, j, 1, 1) * (haveSthCross(i, j, 1, 1) > 1 ? 0 : crossBonus) + 1)) { + map[i][j] = 1; + map[49 - i][49 - j] = 1; + } + } + } +} + +function generateWormhole() { + for (var i = 1; i < 49; i++) { + if (map[10][i] == 3) { + map[10][i] = 6; + map[39][49 - i] = 6; + } + if (map[11][i] == 3) { + map[11][i] = 6; + map[38][49 - i] = 6; + } + if (map[24][i] == 3) { + map[24][i] = 6; + map[25][49 - i] = 6; + } + } +} + +function clearCanvas() { + for (var i = 0; i < 50; i++) { + map[i] = new Array(50); + for (var j = 0; j < 50; j++) { + map[i][j] = 0; + } + } + // generateBorderRuin(); + // generateHome(); + draw(); +} + +function random() { + for (var i = 0; i < 50; i++) { + map[i] = new Array(50); + for (var j = 0; j < 50; j++) { + map[i][j] = 0; + } + } + var asteroidWidth = parseInt(document.getElementById("asteroid-width").value); + var resourceNum = parseInt(document.getElementById("resource-num").value); + var constructionNum = parseInt(document.getElementById("construction-num").value); + var shadowProb = parseFloat(document.getElementById("shadow-prob").value); + var shadowCrossBonus = parseInt(document.getElementById("shadow-cross-bonus").value); + var ruinProb = parseFloat(document.getElementById("ruin-prob").value); + var ruinCrossBonus = parseInt(document.getElementById("ruin-cross-bonus").value); + if (isNaN(asteroidWidth) || asteroidWidth < 1 || asteroidWidth > 4) { + asteroidWidth = 2; + alert("Asteroid 宽度非法,设置为默认值 2"); + document.getElementById("asteroid-width").value = 2; + } + if (isNaN(resourceNum) || resourceNum < 1 || resourceNum > 10) { + resourceNum = 7; + alert("Resource 数量非法,设置为默认值 7"); + document.getElementById("resource-num").value = 7; + } + if (isNaN(constructionNum) || constructionNum < 1 || constructionNum > 10) { + constructionNum = 5; + alert("Construction 数量非法,设置为默认值 5"); + document.getElementById("construction-num").value = 5; + } + if (isNaN(shadowProb) || shadowProb < 0 || shadowProb > 0.1) { + shadowProb = 0.015; + alert("Shadow 生成概率非法,设置为默认值 0.015"); + document.getElementById("shadow-prob").value = 0.015; + } + if (isNaN(shadowCrossBonus) || shadowCrossBonus < 1 || shadowCrossBonus > 50) { + shadowCrossBonus = 23; + alert("Shadow 蔓延加成非法,设置为默认值 23"); + document.getElementById("shadow-cross-bonus").value = 23; + } + if (isNaN(ruinProb) || ruinProb < 0 || ruinProb > 0.1) { + ruinProb = 0.01; + alert("Ruin 生成概率非法,设置为默认值 0.01"); + document.getElementById("ruin-prob").value = 0.01; + } + if (isNaN(ruinCrossBonus) || ruinCrossBonus < 1 || ruinCrossBonus > 50) { + ruinCrossBonus = 40; + alert("Ruin 蔓延加成非法,设置为默认值 40"); + document.getElementById("ruin-cross-bonus").value = 40; + } + generateBorderRuin(); + generateHome(); + generateAsteroid(asteroidWidth); + generateResource(resourceNum); + generateConstruction(constructionNum); + generateShadow(shadowProb, shadowCrossBonus); + generateRuin(ruinProb, ruinCrossBonus); + generateWormhole(); + draw(); +} + +clearCanvas(); diff --git a/dependency/MapGenerator/index.html b/dependency/MapGenerator/index.html new file mode 100644 index 00000000..8e8e44c1 --- /dev/null +++ b/dependency/MapGenerator/index.html @@ -0,0 +1,80 @@ + + + + + + THUAI7 地图生成器 + + + + + + + +
+ +
+
+

地图生成器

+
+ +

请使用支持 HTML5 的浏览器!

+
+
+
+
+

Space

+
+
+

Ruin

+
+
+

Shadow

+
+
+

Asteroid

+
+
+

Resource

+
+
+

Construction

+
+
+

Wormhole

+
+
+

Home

+
+

当前:Space

+
+
+
+ 随机参数设置 +

⚠ 请谨慎修改参数!

+

Asteroid 宽度:

+

Resource 数量:

+

Construction 数量:

+

Shadow 生成概率:

+

Shadow 蔓延加成:

+

Ruin 生成概率:

+

Ruin 蔓延加成:

+
+
+
+ + + + + +
+
+ + + + + \ No newline at end of file diff --git a/logic/GameClass/GameObj/Areas/Resource.cs b/logic/GameClass/GameObj/Areas/Resource.cs index 5879665d..07c7c96a 100644 --- a/logic/GameClass/GameObj/Areas/Resource.cs +++ b/logic/GameClass/GameObj/Areas/Resource.cs @@ -1,12 +1,54 @@ using Preparation.Utility; using System; +using System.Threading; namespace GameClass.GameObj.Areas; public class Resource : Immovable { + public LongInTheVariableRange HP => throw new NotImplementedException(); public override bool IsRigid => true; public override ShapeType Shape => ShapeType.Square; + private int producingNum = 0; + public int ProducingNum + { + get => Interlocked.CompareExchange(ref producingNum, 0, 0); + } + public void AddProducingNum() + { + Interlocked.Increment(ref producingNum); + } + public void SubProducingNum() + { + Interlocked.Decrement(ref producingNum); + } + public bool Produce(int produceSpeed, Ship ship) + { + long orgHP, value; + lock (gameObjLock) + { + if (HP == 0) + { + return false; + } + orgHP = HP.GetValue(); + HP.SubV(produceSpeed); + if (HP > HP.GetMaxV()) + { + HP.SetV(HP.GetMaxV()); + } + else if (HP < 0) + { + HP.SetV(0); + } + value = HP.GetValue(); + } + if (value < orgHP) + { + if (value == 0) return true; + } + return false; + } public Resource(XY initPos) : base(initPos, GameData.NumOfPosGridPerCell / 2, GameObjType.Resource) { diff --git a/logic/GameClass/GameObj/BombedBullet.cs b/logic/GameClass/GameObj/BombedBullet.cs new file mode 100644 index 00000000..8f3f3270 --- /dev/null +++ b/logic/GameClass/GameObj/BombedBullet.cs @@ -0,0 +1,22 @@ +using Preparation.Utility; + +namespace GameClass.GameObj +{ + // 为方便界面组做子弹爆炸特效,现引入“爆炸中的子弹”,在每帧发送给界面组 + public sealed class BombedBullet : Immovable + { + public override ShapeType Shape => ShapeType.Circle; + public override bool IsRigid => false; + public long MappingID { get; } + public readonly Bullet bulletHasBombed; + public readonly XY facingDirection; + + public BombedBullet(Bullet bullet) : + base(bullet.Position, bullet.Radius, GameObjType.BombedBullet) + { + this.bulletHasBombed = bullet; + this.MappingID = bullet.ID; + this.facingDirection = bullet.FacingDirection; + } + } +} diff --git a/logic/GameClass/GameObj/Team.cs b/logic/GameClass/GameObj/Team.cs index d9a0e0fe..b08385e0 100644 --- a/logic/GameClass/GameObj/Team.cs +++ b/logic/GameClass/GameObj/Team.cs @@ -1,6 +1,7 @@ using GameClass.GameObj.Areas; using Preparation.Utility; using System.Collections.Generic; +using System.Threading; namespace GameClass.GameObj { @@ -16,7 +17,16 @@ public class Team private readonly Dictionary birthPointList; public Dictionary BirthPointList => birthPointList; private Home home; - public int Score { get; private set; } = 0; + private long score = 0; + public long Score + { + get => Interlocked.Read(ref score); + } + private long totalScore; + public long TotalScore + { + get => Interlocked.Read(ref totalScore); + } public Ship? GetShip(long shipID) { foreach (Ship ship in shipList) @@ -48,6 +58,15 @@ public bool AddShip(Ship ship) shipList.Add(ship); return true; } + public void AddScore(long add) + { + Interlocked.Add(ref score, add); + Interlocked.Add(ref totalScore, add); + } + public void SubScore(long sub) + { + Interlocked.Add(ref score, -sub); + } public void SetHome(Home home) { this.home = home; diff --git a/logic/Gaming/ActionManager.cs b/logic/Gaming/ActionManager.cs index 807a1d0d..394b46cd 100644 --- a/logic/Gaming/ActionManager.cs +++ b/logic/Gaming/ActionManager.cs @@ -1,6 +1,7 @@ using System; using System.Threading; using GameClass.GameObj; +using GameClass.GameObj.Areas; using GameEngine; using Preparation.Utility; using Protobuf; @@ -13,7 +14,39 @@ public partial class Game private readonly ActionManager actionManager; private class ActionManager { + private readonly Map gameMap; + private readonly ShipManager shipManager; public readonly MoveEngine moveEngine; + public ActionManager(Map gameMap, ShipManager shipManager) + { + this.gameMap = gameMap; + this.shipManager = shipManager; + this.moveEngine = new MoveEngine( + gameMap: gameMap, + OnCollision: (obj, collisionObj, moveVec) => + { + Ship ship = (Ship)obj; + switch (collisionObj.Type) + { + case GameObjType.Bullet: + if (((Bullet)collisionObj).Parent != ship) + { + // TODO + gameMap.Remove((GameObj)collisionObj); + } + break; + default: + break; + } + return MoveEngine.AfterCollision.MoveMax; + }, + EndMove: obj => + { + obj.ThreadNum.Release(); + } + ); + this.shipManager = shipManager; + } public bool MoveShip(Ship shipToMove, int moveTimeInMilliseconds, double moveDirection) { if (moveTimeInMilliseconds < 5) @@ -57,6 +90,52 @@ public static bool Stop(Ship ship) } public bool Produce(Ship ship) { + Resource? resource = (Resource?)gameMap.OneForInteract(ship.Position, GameObjType.Resource); + if (resource == null) + { + return false; + } + if (resource.HP == 0) + { + return false; + } + long stateNum = ship.SetShipState(RunningStateType.Waiting, ShipStateType.Producing); + if (stateNum == -1) + { + return false; + } + new Thread + ( + () => + { + ship.ThreadNum.WaitOne(); + if (!ship.StartThread(stateNum, RunningStateType.RunningActively)) + { + ship.ThreadNum.Release(); + return; + } + resource.AddProducingNum(); + Thread.Sleep(GameData.CheckInterval); + new FrameRateTaskExecutor + ( + loopCondition: () => stateNum == ship.StateNum && gameMap.Timer.IsGaming, + loopToDo: () => + { + if (resource.HP == 0) + { + ship.ResetShipState(stateNum); + return false; + } + return true; + }, + timeInterval: GameData.CheckInterval, + finallyReturn: () => 0 + ).Start(); + ship.ThreadNum.Release(); + resource.SubProducingNum(); + } + ) + { IsBackground = true }.Start(); return false; } public bool Construct(Ship ship) diff --git a/logic/Gaming/AttackManager.cs b/logic/Gaming/AttackManager.cs index 1a0f56f8..fab35347 100644 --- a/logic/Gaming/AttackManager.cs +++ b/logic/Gaming/AttackManager.cs @@ -2,13 +2,69 @@ using System.Threading; using System.Collections.Generic; using GameClass.GameObj; +using GameClass.GameObj.Bullets; using Preparation.Utility; using GameEngine; using Preparation.Interface; +using Timothy.FrameRateTask; namespace Gaming { - internal class AttackManager + public partial class Game { + private readonly AttackManager attackManager; + private class AttackManager + { + readonly Map gameMap; + public readonly MoveEngine moveEngine; + readonly ShipManager shipManager; + public AttackManager(Map gameMap, ShipManager shipManager) + { + this.gameMap = gameMap; + moveEngine = new MoveEngine( + gameMap: gameMap, + OnCollision: (obj, collisionObj, moveVec) => + { + return MoveEngine.AfterCollision.Destroyed; + }, + EndMove: obj => + { + obj.CanMove.SetReturnOri(false); + } + ); + this.shipManager = shipManager; + } + public void ProduceBulletNaturally(BulletType bulletType, Ship ship, double angle, XY pos) + { + // 子弹如果没有和其他物体碰撞,将会一直向前直到超出人物的attackRange + if (bulletType == BulletType.Null) return; + Bullet? bullet = BulletFactory.GetBullet(ship, pos, bulletType); + if (bullet == null) return; + gameMap.Add(bullet); + moveEngine.MoveObj(bullet, (int)(bullet.AttackDistance * 1000 / bullet.MoveSpeed), angle, ++bullet.StateNum); // 这里时间参数除出来的单位要是ms + } + public bool TryRemoveBullet(Bullet bullet) + { + if (gameMap.Remove(bullet)) + { + bullet.CanMove.SetReturnOri(false); + if (bullet.BulletBombRange > 0) + { + BombedBullet bombedBullet = new(bullet); + gameMap.Add(bombedBullet); + new Thread + (() => + { + Thread.Sleep(GameData.FrameDuration * 5); + gameMap.RemoveJustFromMap(bombedBullet); + } + ) + { IsBackground = true }.Start(); + } + return true; + } + else return false; + } + } } } diff --git a/logic/Preparation/Utility/EnumType.cs b/logic/Preparation/Utility/EnumType.cs index 53317c03..eb48241e 100644 --- a/logic/Preparation/Utility/EnumType.cs +++ b/logic/Preparation/Utility/EnumType.cs @@ -79,14 +79,13 @@ public enum GunType public enum PlaceType { Null = 0, - BirthPoint = 1, - Home = 2, - Ruin = 3, - Shadow = 4, - Asteroid = 5, - Resource = 6, - Construction = 7, - Wormhole = 8, + Ruin = 1, + Shadow = 2, + Asteroid = 3, + Resource = 4, + Construction = 5, + Wormhole = 6, + Home = 7, } /// /// 采集器类型