Skip to content

Commit

Permalink
Merge branch 'eesast:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
SERENCH authored Dec 7, 2024
2 parents 2461012 + e0ecbcd commit 61ea415
Show file tree
Hide file tree
Showing 25 changed files with 331 additions and 28 deletions.
4 changes: 2 additions & 2 deletions installer/installer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@

<ItemGroup>
<PackageReference Include="CommunityToolkit.Maui" Version="7.0.1" />
<PackageReference Include="CommunityToolkit.Maui.Core" Version="9.0.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="CommunityToolkit.Maui.Core" Version="9.1.1" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.3.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.1" />
<PackageReference Include="Tencent.QCloud.Cos.Sdk" Version="5.4.40" />
<PackageReference Include="Microsoft.Maui.Controls" Version="8.0.100" />
Expand Down
51 changes: 46 additions & 5 deletions logic/GameClass/GameObj/Areas/A_Resource.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,57 @@
using GameClass.GameObj.Occupations;
using Preparation.Interface;
using Preparation.Utility;
using Preparation.Utility.Value;
using Preparation.Utility.Value.SafeValue.LockedValue;

namespace GameClass.GameObj.Areas;

public class A_Resource(XY initPos)
: Immovable(initPos, int.MaxValue, GameObjType.Null)
public class A_Resource
: Immovable, IA_Recource
{
public InVariableRange<long> HP { get; }
public InVariableRange<long> ATKpower { get; }
public InVariableRange<long> AttackPower { get; }
public override bool IsRigid(bool args = false) => false;
private AdditionResourceState State { get; }
private A_ResourceType Type { get; }
protected readonly object actionLock = new();
public object ActionLock => actionLock;
public IAROccupation Occupation { get; }
private AdditionResourceState State = AdditionResourceState.NULL_ADDITION_RESOURCE_STATE;
public AdditionResourceState ARstate
{
get
{
lock (actionLock)
return State;
}
}
public A_ResourceType AResourceType { get; }
public override ShapeType Shape => ShapeType.NULL_SHAPE_TYPE;
public void SetARState(AdditionResourceState state)
{
State = state;
}
public bool TryToRemoveFromGame()
{
lock (actionLock)
{
TryToRemove();
position = GameData.PosNotInGame;
}
return true;
}
public void Init()
{
HP.SetMaxV(Occupation.MaxHp);
HP.SetVToMaxV();
AttackPower.SetMaxV(Occupation.AttackPower);
AttackPower.SetVToMaxV();
}
public A_Resource(int radius, A_ResourceType type, XY initPos) :
base(initPos, radius, GameObjType.A_Resource)
{
Occupation = ARFactory.FindAROccupation(Type = type);
HP = new(Occupation.MaxHp);
AttackPower = new(Occupation.AttackPower);
Init();
}
}
11 changes: 11 additions & 0 deletions logic/GameClass/GameObj/Areas/A_Resource/CrazyMan1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Preparation.Interface;
using Preparation.Utility;
using Preparation.Utility.Value.SafeValue.LockedValue;

namespace GameClass.GameObj.Areas;

public class CrazyMan1 : IAROccupation
{
public int MaxHp { get; } = GameData.CrazyMan1HP;
public int AttackPower { get; } = GameData.CrazyMan1ATK;
}
11 changes: 11 additions & 0 deletions logic/GameClass/GameObj/Areas/A_Resource/CrazyMan2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Preparation.Interface;
using Preparation.Utility;
using Preparation.Utility.Value.SafeValue.LockedValue;

namespace GameClass.GameObj.Areas;

public class CrazyMan2 : IAROccupation
{
public int MaxHp { get; } = GameData.CrazyMan2HP;
public int AttackPower { get; } = GameData.CrazyMan2ATK;
}
11 changes: 11 additions & 0 deletions logic/GameClass/GameObj/Areas/A_Resource/CrazyMan3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Preparation.Interface;
using Preparation.Utility;
using Preparation.Utility.Value.SafeValue.LockedValue;

namespace GameClass.GameObj.Areas;

public class CrazyMan3 : IAROccupation
{
public int MaxHp { get; } = GameData.CrazyMan3HP;
public int AttackPower { get; } = GameData.CrazyMan3ATK;
}
19 changes: 19 additions & 0 deletions logic/GameClass/GameObj/Areas/A_Resource/Factory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Preparation.Interface;
using Preparation.Utility;

namespace GameClass.GameObj.Areas;

public static class ARFactory
{
public static IAROccupation FindAROccupation(A_ResourceType type) => type switch
{
A_ResourceType.CrazyMan1 => new CrazyMan1(),
A_ResourceType.CrazyMan2 => new CrazyMan2(),
A_ResourceType.CrazyMan3 => new CrazyMan3(),
A_ResourceType.LifePool1 => new LifePool1(),
A_ResourceType.LifePool2 => new LifePool2(),
A_ResourceType.LifePool3 => new LifePool3(),
A_ResourceType.QuickStep => new QuickStep(),
A_ResourceType.WideView => new WideView(),
};
}
11 changes: 11 additions & 0 deletions logic/GameClass/GameObj/Areas/A_Resource/LifePool1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Preparation.Interface;
using Preparation.Utility;
using Preparation.Utility.Value.SafeValue.LockedValue;

namespace GameClass.GameObj.Areas;

public class LifePool1 : IAROccupation
{
public int MaxHp { get; } = GameData.LifePool1HP;
public int AttackPower { get; } = GameData.LifePoolATK;
}
11 changes: 11 additions & 0 deletions logic/GameClass/GameObj/Areas/A_Resource/LifePool2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Preparation.Interface;
using Preparation.Utility;
using Preparation.Utility.Value.SafeValue.LockedValue;

namespace GameClass.GameObj.Areas;

public class LifePool2 : IAROccupation
{
public int MaxHp { get; } = GameData.LifePool2HP;
public int AttackPower { get; } = GameData.LifePoolATK;
}
11 changes: 11 additions & 0 deletions logic/GameClass/GameObj/Areas/A_Resource/LifePool3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Preparation.Interface;
using Preparation.Utility;
using Preparation.Utility.Value.SafeValue.LockedValue;

namespace GameClass.GameObj.Areas;

public class LifePool3 : IAROccupation
{
public int MaxHp { get; } = GameData.LifePool3HP;
public int AttackPower { get; } = GameData.LifePoolATK;
}
11 changes: 11 additions & 0 deletions logic/GameClass/GameObj/Areas/A_Resource/QuickStep.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Preparation.Interface;
using Preparation.Utility;
using Preparation.Utility.Value.SafeValue.LockedValue;

namespace GameClass.GameObj.Areas;

public class QuickStep : IAROccupation
{
public int MaxHp { get; } = GameData.QuickStepHP;
public int AttackPower { get; } = GameData.QuickStepATK;
}
11 changes: 11 additions & 0 deletions logic/GameClass/GameObj/Areas/A_Resource/WideView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Preparation.Interface;
using Preparation.Utility;
using Preparation.Utility.Value.SafeValue.LockedValue;

namespace GameClass.GameObj.Areas;

public class WideView : IAROccupation
{
public int MaxHp { get; } = GameData.WideViewHP;
public int AttackPower { get; } = GameData.WideViewATK;
}
11 changes: 10 additions & 1 deletion logic/GameClass/GameObj/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public bool Commandable()

public bool TryToRemoveFromGame(CharacterState state)
{
lock (actionlock)
lock (actionLock)
{
if (SetCharacterState(CharacterState.NULL_CHARACTER_STATE, state) == -1)
return false;
Expand All @@ -182,6 +182,13 @@ public bool TryToRemoveFromGame(CharacterState state)
}
return true;
}
public void Init()
{
HP.SetMaxV(Occupation.MaxHp);
HP.SetVToMaxV();
AttackPower.SetMaxV(Occupation.AttackPower);
AttackPower.SetVToMaxV();
}
public Character(int radius, CharacterType type, MoneyPool pool) :
base(GameData.PosNotInGame, radius, GameObjType.Character)
{
Expand All @@ -190,8 +197,10 @@ public Character(int radius, CharacterType type, MoneyPool pool) :
Occupation = OccupationFactory.FindIOccupation(CharacterType = type);
ViewRange = Occupation.ViewRange;
HP = new(Occupation.MaxHp);
AttackPower = new(Occupation.AttackPower);
AttackSize = new(Occupation.BaseAttackSize);
MoneyPool = pool;
Init();
}
public bool InSquare(XY pos, int range)
{
Expand Down
1 change: 1 addition & 0 deletions logic/GameClass/GameObj/Immovable.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Preparation.Utility;
using Preparation.Utility.Value;
using System.Threading.Tasks.Dataflow;

namespace GameClass.GameObj;

Expand Down
10 changes: 0 additions & 10 deletions logic/GameClass/GameObj/Sources/CrazyMan.cs

This file was deleted.

Empty file.
Empty file.
Empty file.
126 changes: 126 additions & 0 deletions logic/Gaming/A_ResourceManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
using GameClass.GameObj;
using GameClass.GameObj.Map;
using Preparation.Utility;
using Preparation.Utility.Value;
using GameClass.GameObj.Areas;


namespace Gaming
{
public partial class Game
{
private readonly A_ResourceManager ARmanager;
private class A_ResourceManager(Game game, Map gameMap)
{
private readonly Game game = game;
private readonly Map map = gameMap;
public static A_Resource? AddAResource(A_ResourceType type, XY pos)
{
A_Resource NewAResource = new(GameData.AResourceRadius, type, pos);
return NewAResource;
}
public bool activateAR(A_Resource AResource)
{
if (AResource.ARstate == AdditionResourceState.BEATEN)
{
return false;
}
gameMap.Add(AResource);
AResource.SetARState(AdditionResourceState.BEATABLE);
return true;
}
public bool BeAttacked(A_Resource AResource, Character character)
{
if (AResource.ARstate == AdditionResourceState.BEATEN)
return false;
long subHP = character.AttackPower;
AResource.HP.SubPositiveV(subHP);
if (AResource.HP == 0)
{
long score = 0;
switch (AResource.AResourceType)
{
case A_ResourceType.CrazyMan1:
score = 4000;
break;
case A_ResourceType.CrazyMan2:
score = 5000;
break;
case A_ResourceType.CrazyMan3:
score = 6000;
break;
case A_ResourceType.LifePool1:
score = 2000;
break;
case A_ResourceType.LifePool2:
score = 3000;
break;
case A_ResourceType.LifePool3:
score = 4000;
break;
case A_ResourceType.QuickStep:
score = 3000;
break;
case A_ResourceType.WideView:
score = 3000;
break;
}//此部分缺失加得分代码
AResource.SetARState(AdditionResourceState.BEATEN);
return true;
}
AResource.SetARState(AdditionResourceState.BEING_BEATEN);
return true;
}
public bool BeAttacked(A_Resource AResource, long AP)
{
if (AResource.ARstate == AdditionResourceState.BEATEN)
return false;
long subHP = AP;
AResource.HP.SubPositiveV(subHP);
if (AResource.HP == 0)
{
long score = 0;
switch (AResource.AResourceType)
{
case A_ResourceType.CrazyMan1:
score = 4000;
break;
case A_ResourceType.CrazyMan2:
score = 5000;
break;
case A_ResourceType.CrazyMan3:
score = 6000;
break;
case A_ResourceType.LifePool1:
score = 2000;
break;
case A_ResourceType.LifePool2:
score = 3000;
break;
case A_ResourceType.LifePool3:
score = 4000;
break;
case A_ResourceType.QuickStep:
score = 3000;
break;
case A_ResourceType.WideView:
score = 3000;
break;
}
AResource.SetARState(AdditionResourceState.BEATEN);
return true;
}
AResource.SetARState(AdditionResourceState.BEING_BEATEN);
return true;
}
public void Remove(A_Resource AResource)
{
if (!AResource.TryToRemoveFromGame())
{
return;
}
gameMap.Remove(AResource);
}
}
}
}
14 changes: 14 additions & 0 deletions logic/Gaming/CharacterManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ public void Remove(Character character)
}
gameMap.Remove(character);
}
public static bool ImproveATK(Character character, long ATK)
{
if (ATK <= 0)
return false;
character.AttackPower.AddPositiveV(ATK);//暂未添加时间限制
return true;
}
public static bool ImproveSpeed(Character character, long speed)
{
if (speed <= 0)
return false;
character.Shoes.AddPositiveV(speed);//暂未添加时间限制
return true;
}
}
}
}
Loading

0 comments on commit 61ea415

Please sign in to comment.