Fix some things in survival mode.

Not showing actual score at death screen, being able to pick entities past reach distance, and make 'score' earned by killing an entity configurable.
This commit is contained in:
UnknownShadow200 2017-08-22 10:22:04 +10:00
parent 0b2c67fd14
commit 0de32793c0
12 changed files with 26 additions and 20 deletions

View File

@ -18,10 +18,11 @@ namespace ClassicalSharp.Gui.Screens {
}
protected override void ContextRecreated() {
string score = game.Chat.Status1.Text;
widgets = new Widget[] {
TextWidget.Create(game, "Game over!", regularFont)
.SetLocation(Anchor.Centre, Anchor.Centre, 0, -150),
TextWidget.Create(game, "Score: 0", titleFont)
TextWidget.Create(game, score, titleFont)
.SetLocation(Anchor.Centre, Anchor.Centre, 0, -75),
ButtonWidget.Create(game, 400, "Generate new level...", titleFont, GenLevelClick)
.SetLocation(Anchor.Centre, Anchor.Centre, 0, 25),

View File

@ -8,7 +8,7 @@ namespace ClassicalSharp.Model {
public class CreeperModel : IModel {
public CreeperModel(Game window) : base(window) { }
public CreeperModel(Game window) : base(window) { SurivalScore = 200; }
/// <inheritdoc/>
public override void CreateParts() {

View File

@ -43,6 +43,9 @@ namespace ClassicalSharp.Model {
/// <summary> Whether the model uses humanoid skin texture, instead of mob skin texture. </summary>
public bool UsesHumanSkin;
/// <summary> Amount player score increased by when they kill an entity with this model. </summary>
public byte SurivalScore = 5;
/// <summary> Gravity applied to this entity. </summary>
public float Gravity = 0.08f;

View File

@ -8,7 +8,7 @@ namespace ClassicalSharp.Model {
public class PigModel : IModel {
public PigModel(Game window) : base(window) { }
public PigModel(Game window) : base(window) { SurivalScore = 10; }
/// <inheritdoc/>
public override void CreateParts() {

View File

@ -13,6 +13,7 @@ namespace ClassicalSharp.Model {
int furIndex;
public SheepModel(Game game) : base(game) {
SurivalScore = 10;
furIndex = game.ModelCache.GetTextureIndex("sheep_fur.png");
}

View File

@ -8,7 +8,7 @@ namespace ClassicalSharp.Model {
public class SkeletonModel : IModel {
public SkeletonModel(Game window) : base(window) { }
public SkeletonModel(Game window) : base(window) { SurivalScore = 120; }
public override void CreateParts() {
vertices = new ModelVertex[boxVertices * 6];

View File

@ -8,7 +8,7 @@ namespace ClassicalSharp.Model {
public class SpiderModel : IModel {
public SpiderModel(Game window) : base(window) { }
public SpiderModel(Game window) : base(window) { SurivalScore = 105; }
/// <inheritdoc/>
public override void CreateParts() {

View File

@ -8,7 +8,7 @@ namespace ClassicalSharp.Model {
public class ZombieModel : IModel {
public ZombieModel(Game window) : base(window) { }
public ZombieModel(Game window) : base(window) { SurivalScore = 80; }
public override void CreateParts() {
vertices = new ModelVertex[boxVertices * 7];

View File

@ -54,11 +54,13 @@ namespace ClassicalSharp.Mode {
public bool PickEntity(byte id) {
Entity entity = game.Entities[id];
Entity player = game.Entities[EntityList.SelfID];
LocalPlayer p = game.LocalPlayer;
Vector3 delta = p.Position - entity.Position;
if (delta.LengthSquared > p.ReachDistance * p.ReachDistance) return false;
Vector3 delta = player.Position - entity.Position;
delta.Y = 0.0f;
delta = Vector3.Normalize(delta);
delta = Vector3.Normalize(delta) * 0.5f;
delta.Y = -0.5f;
entity.Velocity -= delta;
@ -67,7 +69,7 @@ namespace ClassicalSharp.Mode {
entity.Health -= 2;
if (entity.Health < 0) {
game.Entities.RemoveEntity(id);
score += GetScore(entity.ModelName);
score += entity.Model.SurivalScore;
UpdateScore();
}
return true;
@ -152,16 +154,6 @@ namespace ClassicalSharp.Mode {
hotbar[Inventory.BlocksPerRow - 1] = Block.TNT;
}
int GetScore(string model) {
if (model == "sheep" || model == "pig") return 10;
if (model == "zombie") return 80;
if (model == "spider") return 105;
if (model == "skeleton") return 120;
if (model == "creeper") return 200;
return 5;
}
void UpdateScore() {
game.Chat.Add("&fScore: &e" + score, MessageType.Status1);
}

View File

@ -28,6 +28,7 @@ void IModel_Init(IModel* model) {
model->UsesSkin = true;
model->CalcHumanAnims = false;
model->UsesHumanSkin = false;
model->SurvivalScore = 5;
model->Gravity = 0.08f;
model->Drag = Vector3_Create3(0.91f, 0.98f, 0.91f);

View File

@ -78,6 +78,9 @@ typedef struct IModel_ {
/* Whether the model uses humanoid skin texture, instead of mob skin texture. */
bool UsesHumanSkin;
/* Score earned by killing an entity with this model in survival mode. */
UInt8 SurvivalScore;
/* Gravity applied to this entity.*/
Real32 Gravity;

View File

@ -165,6 +165,7 @@ void CreeperModel_DrawModel(Entity* entity) {
IModel* CreeperModel_GetInstance(void) {
IModel_Init(&CreeperModel);
IModel_SetPointers(CreeperModel);
CreeperModel.SurvivalScore = 200;
return &CreeperModel;
}
@ -234,6 +235,7 @@ void PigModel_DrawModel(Entity* entity) {
IModel* PigModel_GetInstance(void) {
IModel_Init(&PigModel);
IModel_SetPointers(PigModel);
PigModel.SurvivalScore = 10;
return &PigModel;
}
@ -303,6 +305,7 @@ void SkeletonModel_DrawModel(Entity* entity) {
IModel* SkeletonModel_GetInstance(void) {
IModel_Init(&SkeletonModel);
IModel_SetPointers(SkeletonModel);
SkeletonModel.SurvivalScore = 120;
return &SkeletonModel;
}
@ -382,6 +385,7 @@ void SpiderModel_DrawModel(Entity* entity) {
IModel* SpiderModel_GetInstance(void) {
IModel_Init(&SpiderModel);
IModel_SetPointers(SpiderModel);
SpiderModel.SurivalScore = 105;
return &SpiderModel;
}
@ -459,6 +463,7 @@ void ZombieModel_DrawModel(Entity* entity) {
IModel* ZombieModel_GetInstance(void) {
IModel_Init(&ZombieModel);
IModel_SetPointers(ZombieModel);
ZombieModel.SurivalScore = 80;
return &ZombieModel;
}