Skip to content

Commit

Permalink
feat: ✨ add Areas
Browse files Browse the repository at this point in the history
- add GameObj of Areas
- add AreaFactory
- adjust the switch-expr of other factories
  • Loading branch information
asdawej committed Oct 27, 2023
1 parent d988fab commit 65532b5
Show file tree
Hide file tree
Showing 16 changed files with 265 additions and 170 deletions.
19 changes: 19 additions & 0 deletions logic/GameClass/GameObj/Areas/AreaFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Preparation.Utility;

namespace GameClass.GameObj.Areas;

public static class AreaFactory
{
public static Immovable GetArea(XY pos, PlaceType placeType) => placeType switch
{
PlaceType.Home => new Home(pos, GameObjType.Home),
PlaceType.Ruin => new Ruin(pos, GameObjType.Ruin),
PlaceType.Shadow => new Shadow(pos, GameObjType.Shadow),
PlaceType.Asteroid => new Asteroid(pos, GameObjType.Asteroid),
PlaceType.Resource => new Resource(pos, GameObjType.Resource),
PlaceType.Construction => new Construction(pos, GameObjType.Construction),
PlaceType.Wormhole => new Wormhole(pos, GameObjType.Wormhole),
_ => throw new System.NotImplementedException()
};
public static OutOfBoundBlock GetOutOfBoundBlock(XY pos) => new(pos);
}
14 changes: 14 additions & 0 deletions logic/GameClass/GameObj/Areas/Asteroid.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Preparation.Utility;
using System;

namespace GameClass.GameObj.Areas;

public class Asteroid : Immovable
{
public override bool IsRigid => throw new NotImplementedException();
public override ShapeType Shape => ShapeType.Square;
public Asteroid(XY initPos, GameObjType initType)
: base(initPos, int.MaxValue, initType)
{
}
}
14 changes: 14 additions & 0 deletions logic/GameClass/GameObj/Areas/Construction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Preparation.Utility;
using System;

namespace GameClass.GameObj.Areas;

public class Construction : Immovable
{
public override bool IsRigid => throw new NotImplementedException();
public override ShapeType Shape => ShapeType.Square;
public Construction(XY initPos, GameObjType initType)
: base(initPos, int.MaxValue, initType)
{
}
}
22 changes: 22 additions & 0 deletions logic/GameClass/GameObj/Areas/Home.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Preparation.Interface;
using Preparation.Utility;
using System;

namespace GameClass.GameObj.Areas;

public class Home : Immovable, IHome
{
public AtomicLong TeamID => throw new NotImplementedException();
public LongWithVariableRange HP => throw new NotImplementedException();
public long Score => throw new NotImplementedException();
public override bool IsRigid => throw new NotImplementedException();
public override ShapeType Shape => ShapeType.Square;
public void AddScore(long add)
{
throw new NotImplementedException();
}
public Home(XY initPos, GameObjType initType)
: base(initPos, int.MaxValue, initType)
{
}
}
18 changes: 18 additions & 0 deletions logic/GameClass/GameObj/Areas/OutOfBoundBlock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Preparation.Interface;
using Preparation.Utility;

namespace GameClass.GameObj.Areas;

/// <summary>
/// 逻辑墙
/// </summary>
public class OutOfBoundBlock : Immovable, IOutOfBound
{
public OutOfBoundBlock(XY initPos)
: base(initPos, int.MaxValue, GameObjType.OutOfBoundBlock)
{
}

public override bool IsRigid => true;
public override ShapeType Shape => ShapeType.Square;
}
14 changes: 14 additions & 0 deletions logic/GameClass/GameObj/Areas/Resource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Preparation.Utility;
using System;

namespace GameClass.GameObj.Areas;

public class Resource : Immovable
{
public override bool IsRigid => throw new NotImplementedException();
public override ShapeType Shape => ShapeType.Square;
public Resource(XY initPos, GameObjType initType)
: base(initPos, int.MaxValue, initType)
{
}
}
14 changes: 14 additions & 0 deletions logic/GameClass/GameObj/Areas/Ruin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Preparation.Utility;
using System;

namespace GameClass.GameObj.Areas;

public class Ruin : Immovable
{
public override bool IsRigid => throw new NotImplementedException();
public override ShapeType Shape => ShapeType.Square;
public Ruin(XY initPos, GameObjType initType)
: base(initPos, int.MaxValue, initType)
{
}
}
14 changes: 14 additions & 0 deletions logic/GameClass/GameObj/Areas/Shadow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Preparation.Utility;
using System;

namespace GameClass.GameObj.Areas;

public class Shadow : Immovable
{
public override bool IsRigid => throw new NotImplementedException();
public override ShapeType Shape => ShapeType.Square;
public Shadow(XY initPos, GameObjType initType)
: base(initPos, int.MaxValue, initType)
{
}
}
18 changes: 18 additions & 0 deletions logic/GameClass/GameObj/Areas/Wormhole.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using Preparation.Interface;
using Preparation.Utility;
using System;
using System.Collections.Generic;

namespace GameClass.GameObj.Areas;

public class Wormhole : Immovable, IWormhole
{
public List<XY> Entrance => throw new NotImplementedException();
public List<XY> Content => throw new NotImplementedException();
public override bool IsRigid => throw new NotImplementedException();
public override ShapeType Shape => ShapeType.Square;
public Wormhole(XY initPos, GameObjType initType)
: base(initPos, int.MaxValue, initType)
{
}
}
19 changes: 8 additions & 11 deletions logic/GameClass/GameObj/Bullets/BulletFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@ namespace GameClass.GameObj.Bullets;

public static class BulletFactory
{
public static Bullet? GetBullet(Ship ship, XY pos, BulletType bulletType)
public static Bullet? GetBullet(Ship ship, XY pos, BulletType bulletType) => bulletType switch
{
return bulletType switch
{
BulletType.Laser => new Laser(ship, pos),
BulletType.Plasma => new Plasma(ship, pos),
BulletType.Shell => new Shell(ship, pos),
BulletType.Missile => new Missile(ship, pos),
BulletType.Arc => new Arc(ship, pos),
_ => null,
};
}
BulletType.Laser => new Laser(ship, pos),
BulletType.Plasma => new Plasma(ship, pos),
BulletType.Shell => new Shell(ship, pos),
BulletType.Missile => new Missile(ship, pos),
BulletType.Arc => new Arc(ship, pos),
_ => throw new System.NotImplementedException()
};
}
13 changes: 0 additions & 13 deletions logic/GameClass/GameObj/Home.cs

This file was deleted.

12 changes: 6 additions & 6 deletions logic/GameClass/GameObj/Immovable.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Preparation.Utility;

namespace GameClass.GameObj
namespace GameClass.GameObj;

public abstract class Immovable : GameObj
{
public abstract class Immovable : GameObj
public override XY Position => position;
public Immovable(XY initPos, int initRadius, GameObjType initType)
: base(initPos, initRadius, initType)
{
public override XY Position => position;
public Immovable(XY initPos, int initRadius, GameObjType initType) : base(initPos, initRadius, initType)
{
}
}
}
Loading

0 comments on commit 65532b5

Please sign in to comment.