-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from daud-io/masonry
Masonry
- Loading branch information
Showing
13 changed files
with
247 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
namespace Game.API.Common.Models | ||
{ | ||
using System.Collections.Generic; | ||
using System.Numerics; | ||
|
||
public class MapModel | ||
{ | ||
public Vector2 Position { get; set; } | ||
public int TileSize { get; set; } | ||
public string Type { get; set; } | ||
public int Rows { get; set; } | ||
public int Columns { get; set; } | ||
public List<MapTileModel> Tiles { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Game.Engine.Core.Maps | ||
{ | ||
public class TileBase : ActorBody | ||
{ | ||
public WorldMap WorldMap { get; internal set; } | ||
public float Drag { get; set; } | ||
|
||
public TileBase() | ||
{ | ||
MaximumCleanTime = 100000; | ||
IsStatic = true; | ||
} | ||
|
||
public virtual void InteractWithShip(Ship ship) | ||
{ | ||
if (Drag != 0 && ship.Momentum.Length() < 5) | ||
ship.Momentum *= Drag; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
namespace Game.Engine.Core.Maps | ||
{ | ||
using Game.Engine.Core.Weapons; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Numerics; | ||
|
||
public class TileTurret : TileBase, ICollide | ||
{ | ||
private long ShotCooldown = 0; | ||
private List<ShipWeaponBullet> NewBullets = new List<ShipWeaponBullet>(); | ||
|
||
public bool IsCollision(Body projectedBody) | ||
{ | ||
if (projectedBody is ShipWeaponBullet bullet) | ||
if (bullet.Group != WorldMap.WeaponGroup) | ||
return Vector2.Distance(projectedBody.Position, Position) < projectedBody.Size + Size; | ||
|
||
return false; | ||
} | ||
|
||
public void CollisionExecute(Body projectedBody) | ||
{ | ||
if (projectedBody is ShipWeaponBullet bullet) | ||
{ | ||
this.Sprite += 1; | ||
} | ||
} | ||
|
||
public override void Think() | ||
{ | ||
if (ShotCooldown < World.Time) | ||
{ | ||
var target = World.BodiesNear(this.Position, 2500) | ||
.OfType<Ship>() | ||
.Where(s => s.Abandoned == false) | ||
.Where(s => s.Sprite != API.Common.Sprites.fish) | ||
.FirstOrDefault(); | ||
|
||
if (target != null) | ||
{ | ||
var bullet = new ShipWeaponBullet(); | ||
var toTarget = target.Position - Position; | ||
bullet.FireFrom(this, MathF.Atan2(toTarget.Y, toTarget.X)); | ||
|
||
NewBullets.Add(bullet); | ||
|
||
ShotCooldown = World.Time + 300; | ||
} | ||
} | ||
} | ||
|
||
public override void CreateDestroy() | ||
{ | ||
base.CreateDestroy(); | ||
|
||
foreach (var bullet in NewBullets) | ||
bullet.Init(World); | ||
|
||
NewBullets.Clear(); | ||
} | ||
} | ||
} |
Oops, something went wrong.