Commit 66671a5c authored by 18김민수's avatar 18김민수

NextTurn button update

parent f79e5e72
......@@ -11,13 +11,13 @@ namespace ISEKAI_Model
public abstract class Event // Every future event must inherit this.
{
private bool _isActivatedAlready;
public abstract bool isForcedEvent {get;}
public List<(int, int)> choiceHistory = new List<(int, int)>(); // <item1>th choice, selected <item2>th branch. (0-based)
public abstract int forcedEventPriority {get;} // 0 if the event is not forced event.
public abstract string eventName {get;}
public EventStatus status {get; set;}
public abstract int givenMaxTurn {get;}
public abstract int turnsLeft {get; protected set;} // how many turns left for this event to be gone.
public abstract int cost {get;} // how many AP this event takes.
public abstract Season availableSeason {get;} // when this event is available.
protected abstract bool exclusiveCondition(Game game); // exclusive emergence condition of each event.
......@@ -25,7 +25,7 @@ namespace ISEKAI_Model
{
_activatedEvents.Add(new ExampleEvent1());
}
public static void OccurEvents(Game game)
public static void OccurEvents(Game game) // Not recommended to call manually. Only called by Proceed().
{
foreach (Event e in _activatedEvents)
{
......@@ -82,5 +82,6 @@ namespace ISEKAI_Model
seasonCheck = availableSeason == game.turn.season;
return seasonCheck;
}
public abstract List<Command> script {get;}
}
}
using System;
using System.Collections.Generic;
namespace ISEKAI_Model
{
......@@ -9,7 +10,9 @@ namespace ISEKAI_Model
public override int turnsLeft {get; protected set;}
public override int cost {get {return 2;}}
public override Season availableSeason {get {return Season.Summer;}}
public override bool isForcedEvent {get {return false;}}
public override int forcedEventPriority {get {return 0;}}
public override List<Command> script {get {return Parser.ParseScript("Scripts/ExampleEvent1.txt");}} // command list.
protected override bool exclusiveCondition(Game game)
{
bool chanceCheck;
......
......@@ -72,5 +72,61 @@ namespace ISEKAI_Model
town.ConsumeFood();
town.ApplyPleasantChange();
}
public void ApplyChoiceEffect(ChoiceEffect choiceEffect)
{
foreach((ChoiceEffectKind, ChoiceEffectType, float) effect in choiceEffect.effectList)
{
ChoiceEffectType type = effect.Item2;
float f = effect.Item3;
switch (effect.Item1)
{
case ChoiceEffectKind.Food:
town.remainFoodAmount = ApplyChoiceEffect(town.remainFoodAmount, type, f);
break;
case ChoiceEffectKind.FoodP:
town.totalFoodProduction = ApplyChoiceEffect(town.totalFoodProduction, type, f);
break;
case ChoiceEffectKind.Horse:
town.totalHorseAmount = ApplyChoiceEffect(town.totalHorseAmount, type, f);
break;
case ChoiceEffectKind.HorseP:
town.totalHorseProduction = ApplyChoiceEffect(town.totalHorseProduction, type, f);
break;
case ChoiceEffectKind.Morale:
town.totalPleasantAmount = ApplyChoiceEffect(town.totalPleasantAmount, type, f);
break;
case ChoiceEffectKind.Steel:
town.totalIronAmount = ApplyChoiceEffect(town.totalIronAmount, type, f);
break;
case ChoiceEffectKind.SteelP:
town.totalIronProduction = ApplyChoiceEffect(town.totalIronProduction, type, f);
break;
default:
break;
}
}
}
private float ApplyChoiceEffect(float toChange, ChoiceEffectType type, float f)
{
float result;
switch (type)
{
case ChoiceEffectType.Add:
result = toChange + f;
return result;
case ChoiceEffectType.Divide:
result = toChange / f;
return result;
case ChoiceEffectType.Multiply:
result = toChange * f;
return result;
case ChoiceEffectType.Subtract:
result = toChange - f;
return result;
default:
throw new InvalidOperationException("Error on ApplyChoiceEffect()");
}
}
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ namespace ISEKAI_Model
{
public Town() // initiallizes town instance with basic stats.
{
remainFoodAmount = 100000f;
remainFoodAmount = 50f;
maxFoodConsumption = 100f;
totalFoodProduction = 50f;
totalPleasantAmount = 100f;
......@@ -14,6 +14,8 @@ namespace ISEKAI_Model
suggestedFoodConsumption = 80f;
totalIronProduction = 0f;
totalHorseAmount = 0f;
totalHorseProduction = 0f;
totalIronAmount = 0f;
}
public float remainFoodAmount {get; set;}
public float totalFoodProduction {get; set;}
......@@ -23,8 +25,10 @@ namespace ISEKAI_Model
public float pleasantWeightFactor {get; set;}
public float suggestedFoodConsumption {get; set;}
public float pleasantChange => pleasantWeightFactor * (totalFoodConsumption - suggestedFoodConsumption);
public float totalIronAmount { get; set; }
public float totalIronProduction {get; set;}
public float totalHorseAmount {get; set;}
public float totalHorseProduction { get; set; }
public void AddFoodProduction() // just adds current food production to remaining food amount.
{
......
......@@ -13,22 +13,42 @@ namespace ISEKAI_Model
}
public class Turn
{
public Turn() // initiallize turn instance. It should be immediately proceeded to be {Spring, PreTurn, 1}, so should be look like this.
public Turn() // initiallize turn instance.
{
season = Season.Winter;
state = State.PreTurn;
turnNumber = 1;
year = 1994;
}
public Season season {get; private set;}
public State state {get; private set;}
public int turnNumber {get; private set;}
public int year {get; private set;}
public int turnNumber { get; private set; }
public override string ToString()
{
if (state == State.PreTurn || state == State.PostTurn)
return state + " of Turn " + turnNumber;
/*if (state == State.PreTurn || state == State.PostTurn)
return state + " of Turn " + year;
else
return season + " of Turn " + turnNumber;
return season + " of Turn " + year;*/
string s;
switch(season)
{
case Season.Autumn:
s = "";
break;
case Season.Spring:
s = "";
break;
case Season.Summer:
s = "";
break;
case Season.Winter:
s = "ܿ";
break;
default:
throw new InvalidOperationException("season of turn cannot be None.");
}
return (year + " " + s);
}
public bool IsFormerSeason() // if the current season is winter or summer, it returns true.
{
......@@ -40,6 +60,7 @@ namespace ISEKAI_Model
{
case Season.Winter:
season = Season.Spring;
year++;
break;
case Season.Spring:
......
using System;
using System.Collections.Generic;
namespace ISEKAI_Model
{
public class Choice : Command
{
public override int commandNumber {get {return 15;}}
public int choiceNumber {get; private set;}
public List<ChoiceEffect> choiceList {get; private set;}
public Choice(int choiceNumber, List<ChoiceEffect> choiceList)
{
this.choiceNumber = choiceNumber;
this.choiceList = choiceList;
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
namespace ISEKAI_Model
{
public enum ChoiceEffectKind
{
None, FoodP, Food, Morale, Steel, SteelP, Horse, HorseP
}
public enum ChoiceEffectType
{
None, Add, Subtract, Multiply, Divide
}
public class ChoiceEffect : Command
{
public override int commandNumber {get {return 16;}}
public int choiceBranchNumber {get; private set;}
public string choiceName {get; private set;}
public List<(ChoiceEffectKind, ChoiceEffectType, float)> effectList {get; private set;}
public ChoiceEffect(int choiceBranchNumber, string choiceName, List<(ChoiceEffectKind, ChoiceEffectType, float)> effectList)
{
this.choiceBranchNumber = choiceBranchNumber;
this.choiceName = choiceName;
this.effectList = effectList;
}
}
}
\ No newline at end of file
namespace ISEKAI_Model
{
public enum SpriteLocation
{
None = 0, Left = 1, Center = 2, Right = 3
}
public abstract class Command
{
public abstract int commandNumber {get;}
public (int, int) choiceDependency {get; set;} // (0, 0) if there is no choice dependency. (0, n) if there is dependency on recent choice, which resulted 'n'.
// (n, m) if there is dependency on n'th choice, which resulted 'm'.
public Command()
{
choiceDependency = (0, 0);
}
}
}
\ No newline at end of file
using System;
namespace ISEKAI_Model
{
public class Conversation : Command
{
public override int commandNumber {get {return 1;}}
public string characterName {get; private set;}
public string contents {get; private set;}
public SpriteLocation brightCharacter {get; private set;}
public Conversation(string characterName, string contents, SpriteLocation brightCharacter)
{
this.characterName = characterName;
this.contents = contents;
this.brightCharacter = brightCharacter;
}
}
}
\ No newline at end of file
using System;
namespace ISEKAI_Model
{
public class Explanation : Command
{
public override int commandNumber {get {return 0;}}
public string contents {get; private set;}
public Explanation(string contents)
{
this.contents = contents;
}
}
}
\ No newline at end of file
using System;
namespace ISEKAI_Model
{
public class LoadBackground : Command
{
public override int commandNumber {get {return 4;}}
public string filePath {get; private set;}
public LoadBackground(string filePath)
{
this.filePath = filePath;
}
}
}
\ No newline at end of file
using System;
namespace ISEKAI_Model
{
public class LoadCG : Command
{
public override int commandNumber {get {return 7;}}
public string filePath {get; private set;}
public LoadCG(string filePath)
{
this.filePath = filePath;
}
}
}
\ No newline at end of file
using System;
namespace ISEKAI_Model
{
public class LoadCharacter : Command
{
public override int commandNumber {get {return 2;}}
public string filePath {get; private set;}
public SpriteLocation location {get; private set;}
public LoadCharacter(string filePath, SpriteLocation location)
{
this.filePath = filePath;
this.location = location;
}
}
}
\ No newline at end of file
using System;
namespace ISEKAI_Model
{
public class LoadMinigame : Command
{
public override int commandNumber {get {return 13;}}
public string minigameName {get; private set;}
public LoadMinigame(string minigameName)
{
this.minigameName = minigameName;
}
}
}
\ No newline at end of file
using System;
namespace ISEKAI_Model
{
public class LoadVideo : Command
{
public override int commandNumber {get {return 14;}}
public string filePath {get; private set;}
public LoadVideo(string filePath)
{
this.filePath = filePath;
}
}
}
\ No newline at end of file
This diff is collapsed.
using System;
namespace ISEKAI_Model
{
public class PlayMusic : Command
{
public override int commandNumber { get {return 5;}}
public bool isRepeating {get; private set;}
public string filePath {get; private set;}
public PlayMusic(bool isRepeating, string filePath)
{
this.isRepeating = isRepeating;
this.filePath = filePath;
}
}
}
\ No newline at end of file
using System;
namespace ISEKAI_Model
{
public class StopMusic : Command
{
public override int commandNumber {get {return 6;}}
}
}
\ No newline at end of file
using System;
namespace ISEKAI_Model
{
public class UnloadCG : Command
{
public override int commandNumber {get {return 8;}}
}
}
\ No newline at end of file
using System;
namespace ISEKAI_Model
{
public class UnloadCharacter : Command
{
public override int commandNumber {get {return 3;}}
public SpriteLocation location {get; private set;}
public UnloadCharacter(SpriteLocation location)
{
this.location = location;
}
}
}
\ No newline at end of file
using System;
namespace ISEKAI_Model
{
public class VFXCameraShake : Command
{
public override int commandNumber {get {return 9;}}
}
}
\ No newline at end of file
using System;
namespace ISEKAI_Model
{
public class VFXLoadSprite : Command
{
public override int commandNumber {get {return 10;}}
public string filePath {get; private set;}
public int width {get; private set;}
public int height {get; private set;}
public VFXLoadSprite(string filePath, int width, int height)
{
this.width = width;
this.height = height;
this.filePath = filePath;
}
}
}
\ No newline at end of file
using System;
namespace ISEKAI_Model
{
public class VFXSound : Command
{
public override int commandNumber {get {return 12;}}
public string filePath {get; private set;}
public VFXSound(string filePath)
{
this.filePath = filePath;
}
}
}
\ No newline at end of file
using System;
namespace ISEKAI_Model
{
public class VFXUnloadSprite : Command
{
public override int commandNumber {get {return 11;}}
}
}
\ No newline at end of file
Load Background "Assets/Background/Placeholder.png"
Play Music "Assets/BGM/Placeholder.mp3" -r
# "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
# "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
# "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
Load Character "Assets/Sprites/Characters/Placeholder.png" -center
## "와!" "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." -center
## "나" "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
# "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."
Unload Character -center
Load Character "Assets/Sprites/Characters/Placeholder.png" -left
Load Character "Assets/Sprites/Characters/Placeholder2.png" -right
## "와!" "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." -left
## "와!" "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." -left
## "와! 2" "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." -right
## "와! 2" "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. " -right
## "와! 2" "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." -right
## "나" "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
## "와!" "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." -left
# "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur."
# "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."
Choice
-- "Lorem ipsum" -FoodP (+50) -Food (-20) -Morale (+5)
-- "dolor sit amet" -FoodP (+70) -Food (-30)
-- "consectetur adipiscing elit" -FoodP (+100) -Food (-50) -Morale (-30)
-#
--1 ## "와!" "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." -left
--2 ## "와!" "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." -left
--3 ## "와! 2" "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur." -right
--1 Unload Character -right
--2 Unload Character -right
--3 Unload Character -left
--1 Unload Character -left
--2 Unload Character -left
--3 Unload Character -right
--1 Load Character "Assets/Sprites/Characters/Placeholder.png" -center
--2 Load Character "Assets/Sprites/Characters/Placeholder.png" -center
--3 Load Character "Assets/Sprites/Characters/Placeholder2.png" -center
--1 ## "와!" "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." -center
--2 ## "와!" "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." -center
--3 ## "와! 2" "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." -center
Unload Character -center
# "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
# "Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."
\ No newline at end of file
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using ISEKAI_Model;
public class GameManager : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
textFood.text = game.town.remainFoodAmount.ToString();
textPleasant.text = game.town.totalPleasantAmount + "/" + 200;
textTurn.text = game.turn.ToString();
}
// Update is called once per frame
void Update()
{
}
public Text textPleasant;
public Text textFood;
public Text textTurn;
public Game game = new Game(); // represents one game.
public void OnClickNextTurn()
{
game.Proceed();
textFood.text = game.town.remainFoodAmount.ToString();
textPleasant.text = game.town.totalPleasantAmount + "/" + 200;
textTurn.text = game.turn.ToString();
}
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment