Commit b3c0074e authored by Chae Ho Shin's avatar Chae Ho Shin

major model overhaul, makes turns transparent

parent a330b52a
...@@ -29,14 +29,16 @@ namespace ISEKAI_Model ...@@ -29,14 +29,16 @@ namespace ISEKAI_Model
} }
public abstract class EventCore // Every future event must inherit this. public abstract class EventCore // Every future event must inherit this.
{ {
public bool isNew => (_seasonMadeIn == game.turn.season) && (turnsLeft == givenMaxTurn); public bool isNew => (_seasonMadeIn == game.turn.season) && (monthsLeft == givenMaxMonth);
public bool isForcedEvent => forcedEventPriority > 0; public bool isForcedEvent => forcedEventPriority > 0;
public bool isActivatedAlready; public bool isActivatedAlready;
public abstract int forcedEventPriority {get;} // 0 if the event is not forced event. public abstract int forcedEventPriority {get;} // 0 if the event is not forced event.
public abstract string eventName {get;} public abstract string eventName {get;}
public EventStatus status {get; set;} public EventStatus status {get; set;}
public abstract int givenMaxTurn {get;} // -1 if the event is permanent. public abstract int givenMaxTurn {get;} // -1 if the event is permanent.
public int turnsLeft {get; protected set;} // how many turns left for this event to be gone. public int givenMaxMonth { get { return (6 * givenMaxTurn); } }
//public int turnsLeft {get; protected set;} // how many turns left for this event to be gone.
public int monthsLeft { get; protected set; }
public abstract int cost {get;} // how many AP this event takes. public abstract int cost {get;} // how many AP this event takes.
public abstract Season availableSeason {get;} // when this event is available. public abstract Season availableSeason {get;} // when this event is available.
public abstract EventLocation location { get; } public abstract EventLocation location { get; }
...@@ -53,7 +55,7 @@ namespace ISEKAI_Model ...@@ -53,7 +55,7 @@ namespace ISEKAI_Model
public void ActivateEvent() public void ActivateEvent()
{ {
status = EventStatus.Visible; status = EventStatus.Visible;
turnsLeft = givenMaxTurn; monthsLeft = givenMaxMonth;
isActivatedAlready = true; isActivatedAlready = true;
} }
...@@ -61,7 +63,7 @@ namespace ISEKAI_Model ...@@ -61,7 +63,7 @@ namespace ISEKAI_Model
{ {
status = EventStatus.Ready; status = EventStatus.Ready;
this.game = game; this.game = game;
turnsLeft = 0; monthsLeft = 0;
} }
...@@ -84,9 +86,15 @@ namespace ISEKAI_Model ...@@ -84,9 +86,15 @@ namespace ISEKAI_Model
} }
public void ReduceTurnsLeft() /*public void ReduceTurnsLeft()
{ {
turnsLeft--; turnsLeft--;
}*/
public void ReduceMonthsLeft(int monthspassed)
{
monthsLeft -= monthspassed;
} }
public virtual void Complete() public virtual void Complete()
...@@ -96,6 +104,7 @@ namespace ISEKAI_Model ...@@ -96,6 +104,7 @@ namespace ISEKAI_Model
game.turn.totalMonthNumber += cost; game.turn.totalMonthNumber += cost;
game.Proceed(beforeSeason); game.Proceed(beforeSeason);
game._ReduceEveryEventsMonthsLeft(cost);
game.OccurEvents(); game.OccurEvents();
/* /*
if (beforeSeason != game.turn.season) if (beforeSeason != game.turn.season)
......
...@@ -68,8 +68,8 @@ namespace ISEKAI_Model ...@@ -68,8 +68,8 @@ namespace ISEKAI_Model
private void _InitEvents() // should add EVERY events when new event plan comes. private void _InitEvents() // should add EVERY events when new event plan comes.
{ {
allEventsList.Add(new Prolog_1(this)); //allEventsList.Add(new Prolog_1(this));
allEventsList.Add(new Prolog_2(this)); //allEventsList.Add(new Prolog_2(this));
allEventsList.Add(new ReturnWarning(this)); allEventsList.Add(new ReturnWarning(this));
...@@ -224,7 +224,7 @@ namespace ISEKAI_Model ...@@ -224,7 +224,7 @@ namespace ISEKAI_Model
{ {
town.ApplyPostTurnChange(); town.ApplyPostTurnChange();
turn.IncreaseTurnNumber(); turn.IncreaseTurnNumber();
_ReduceEveryEventsTurnsLeft(); //_ReduceEveryEventsTurnsLeft();
} }
public void ApplyChoiceEffect(ChoiceEffect choiceEffect) public void ApplyChoiceEffect(ChoiceEffect choiceEffect)
...@@ -283,7 +283,7 @@ namespace ISEKAI_Model ...@@ -283,7 +283,7 @@ namespace ISEKAI_Model
} }
} }
private void _ReduceEveryEventsTurnsLeft() // Not recommended to call manually. Only called by Proceed(). /*private void _ReduceEveryEventsTurnsLeft() // Not recommended to call manually. Only called by Proceed().
{ {
foreach (EventCore e in allEventsList) foreach (EventCore e in allEventsList)
{ {
...@@ -301,6 +301,26 @@ namespace ISEKAI_Model ...@@ -301,6 +301,26 @@ namespace ISEKAI_Model
e.isRemovedLastTurn = true; e.isRemovedLastTurn = true;
} }
} }
}*/
public void _ReduceEveryEventsMonthsLeft(int monthsPassed) // Not recommended to call manually. Only called by Proceed().
{
foreach (EventCore e in allEventsList)
{
if (e.givenMaxMonth < 0)
continue;
if (e.status == EventStatus.Completed)
continue;
if (e.isActivatedAlready)
e.ReduceMonthsLeft(monthsPassed);
if (e.monthsLeft <= 0 && e.isActivatedAlready)
{
e.status = EventStatus.Ready;
e.isActivatedAlready = false;
e.isRemovedLastTurn = true;
}
}
} }
private void _SetAllEventActivable() private void _SetAllEventActivable()
...@@ -328,7 +348,7 @@ namespace ISEKAI_Model ...@@ -328,7 +348,7 @@ namespace ISEKAI_Model
} }
else if (e.isActivatedAlready) else if (e.isActivatedAlready)
{ {
if (e.SeasonCheck() && e.turnsLeft > 0) if (e.SeasonCheck() && e.monthsLeft > 0)
e.status = EventStatus.Visible; e.status = EventStatus.Visible;
else else
e.status = EventStatus.Ready; e.status = EventStatus.Ready;
......
...@@ -18,7 +18,7 @@ namespace ISEKAI_Model ...@@ -18,7 +18,7 @@ namespace ISEKAI_Model
protected override bool exclusiveCondition() protected override bool exclusiveCondition()
{ {
bool turnCondition = game.turn.totalMonthNumber >= 13; bool turnCondition = game.allEventsList.Find(e => e.eventName.Equals("농사 이벤트 3")).status == EventStatus.Completed;
int chance = (new Random()).Next() / 10; int chance = (new Random()).Next() / 10;
bool chanceCondition = chance <= 2; bool chanceCondition = chance <= 2;
if (_isFirstOccur && turnCondition) if (_isFirstOccur && turnCondition)
......
...@@ -9,7 +9,7 @@ namespace ISEKAI_Model ...@@ -9,7 +9,7 @@ namespace ISEKAI_Model
public override string eventName { get { return "농사 이벤트 3"; } } public override string eventName { get { return "농사 이벤트 3"; } }
public override EventLocation location { get { return EventLocation.Field; } } public override EventLocation location { get { return EventLocation.Field; } }
public override int givenMaxTurn { get { return 1; } } public override int givenMaxTurn { get { return 1; } }
public override int cost { get { return 2; } } public override int cost { get { return 3; } }
public override Season availableSeason { get { return Season.Spring; } } public override Season availableSeason { get { return Season.Spring; } }
public override List<Command> script { get { return Parser.ParseScript("Assets/ISEKAI_Model/Scripts/Farming_3.txt"); } } // command list. public override List<Command> script { get { return Parser.ParseScript("Assets/ISEKAI_Model/Scripts/Farming_3.txt"); } } // command list.
...@@ -20,7 +20,7 @@ namespace ISEKAI_Model ...@@ -20,7 +20,7 @@ namespace ISEKAI_Model
public Farming_3(Game game) : base(game) public Farming_3(Game game) : base(game)
{ {
turnsLeft = 0; monthsLeft = 0;
} }
} }
} }
...@@ -18,7 +18,7 @@ namespace ISEKAI_Model ...@@ -18,7 +18,7 @@ namespace ISEKAI_Model
protected override bool exclusiveCondition() protected override bool exclusiveCondition()
{ {
bool turnCondition = game.turn.totalMonthNumber >= 13 && game.turn.totalMonthNumber <= 36; bool turnCondition = (game.allEventsList.Find(e => e.eventName.Equals("농사 이벤트 3")).status == EventStatus.Completed) && game.turn.totalMonthNumber <= 40;
int chance = (new Random()).Next() / 10; int chance = (new Random()).Next() / 10;
bool chanceCondition = chance <= 1; bool chanceCondition = chance <= 1;
if (_isFirstOccur && turnCondition) if (_isFirstOccur && turnCondition)
......
...@@ -18,7 +18,7 @@ namespace ISEKAI_Model ...@@ -18,7 +18,7 @@ namespace ISEKAI_Model
protected override bool exclusiveCondition() protected override bool exclusiveCondition()
{ {
bool turnCondition = game.turn.totalMonthNumber >= 13 && game.turn.totalMonthNumber <= 44; bool turnCondition = game.turn.totalMonthNumber <= 44;
int chance = (new Random()).Next() / 10; int chance = (new Random()).Next() / 10;
bool chanceCondition = chance <= 1; bool chanceCondition = chance <= 1;
bool prevCondition = game.allEventsList.Find(e => e.eventName == "사냥 이벤트 1").status == EventStatus.Completed; bool prevCondition = game.allEventsList.Find(e => e.eventName == "사냥 이벤트 1").status == EventStatus.Completed;
......
...@@ -18,7 +18,7 @@ namespace ISEKAI_Model ...@@ -18,7 +18,7 @@ namespace ISEKAI_Model
protected override bool exclusiveCondition() protected override bool exclusiveCondition()
{ {
bool turnCondition = game.turn.totalMonthNumber >= 13; bool turnCondition = game.allEventsList.Find(e => e.eventName.Equals("농사 이벤트 3")).status == EventStatus.Completed;
int chance = (new Random()).Next() / 10; int chance = (new Random()).Next() / 10;
bool chanceCondition = chance <= 2; bool chanceCondition = chance <= 2;
if (_isFirstOccur && turnCondition) if (_isFirstOccur && turnCondition)
......
...@@ -20,7 +20,7 @@ namespace ISEKAI_Model ...@@ -20,7 +20,7 @@ namespace ISEKAI_Model
public Prolog_2(Game game) : base(game) public Prolog_2(Game game) : base(game)
{ {
turnsLeft = 0; monthsLeft = 0;
} }
} }
} }
...@@ -7,7 +7,6 @@ Load Background "Background\Door" ...@@ -7,7 +7,6 @@ Load Background "Background\Door"
## "나" "「계십니까.」" ## "나" "「계십니까.」"
# "잠시 기다렸지만 아무 소리도 없었다." # "잠시 기다렸지만 아무 소리도 없었다."
# "딱 떠나려는 참에, 문이 열렸다." # "딱 떠나려는 참에, 문이 열렸다."
VFX Sound "VFX\Sound\Dooropening"
Load Character "Character\Carpenter\a\normal" -center Load Character "Character\Carpenter\a\normal" -center
## "마을 목수" "「누구십니.. 아 장동무 아니십니까.」" -center ## "마을 목수" "「누구십니.. 아 장동무 아니십니까.」" -center
## "나" "「아. 나무를 다룰줄 안다고 들어서 왔습니다만.. 다룰줄 압니까?」" ## "나" "「아. 나무를 다룰줄 안다고 들어서 왔습니다만.. 다룰줄 압니까?」"
......
...@@ -91,12 +91,10 @@ public class EventManager : MonoBehaviour ...@@ -91,12 +91,10 @@ public class EventManager : MonoBehaviour
{ {
if (!scriptEnumerator.MoveNext()) if (!scriptEnumerator.MoveNext())
{ {
Debug.Log(GameManager.instance.game.allEventsList.Find(e => e.eventName.Equals("농사 이벤트 2")).status + " " + GameManager.instance.game.allEventsList.Find(e => e.eventName.Equals("농사 이벤트 2")).IsFirstVisible());
eventCore.Complete(); eventCore.Complete();
Debug.Log(GameManager.instance.game.allEventsList.Find(e => e.eventName.Equals("농사 이벤트 2")).status + " " + GameManager.instance.game.allEventsList.Find(e => e.eventName.Equals("농사 이벤트 2")).IsFirstVisible());
SceneManager.LoadScene("TownScene", LoadSceneMode.Single); SceneManager.LoadScene("TownScene", LoadSceneMode.Single);
Debug.Log("HONTONI: " + GameManager.instance.game.turn.totalMonthNumber.ToString());
GameManager.instance.TryOccurForcedEvent(); GameManager.instance.TryOccurForcedEvent();
Debug.Log(GameManager.instance.game.allEventsList.Find(e => e.eventName.Equals("농사 이벤트 2")).status + " " + GameManager.instance.game.allEventsList.Find(e => e.eventName.Equals("농사 이벤트 2")).IsFirstVisible());
GameManager.instance.TryInstantiateEventSDs(); GameManager.instance.TryInstantiateEventSDs();
GameManager.instance.TryUpdateEventSDs(); GameManager.instance.TryUpdateEventSDs();
} }
......
...@@ -14,7 +14,7 @@ public class GameManager : MonoBehaviour ...@@ -14,7 +14,7 @@ public class GameManager : MonoBehaviour
public static GameManager instance; public static GameManager instance;
public EventCore currentEvent; public EventCore currentEvent;
public Sprite[] turnsLeftSprites; public Sprite[] monthsLeftSprites;
public Sprite[] seasonSprites; public Sprite[] seasonSprites;
public Sprite[] numberSprites; public Sprite[] numberSprites;
...@@ -79,19 +79,14 @@ public class GameManager : MonoBehaviour ...@@ -79,19 +79,14 @@ public class GameManager : MonoBehaviour
sd.position = GetEventSDVectorByLocation(e.location); sd.position = GetEventSDVectorByLocation(e.location);
sd.name = e.eventName; sd.name = e.eventName;
if (e.givenMaxTurn < 0) if (e.givenMaxMonth < 0)
sd.GetChild(2).gameObject.SetActive(false); sd.GetChild(2).gameObject.SetActive(false);
//else //else
//sd.GetChild(2).GetComponent<SpriteRenderer>().sprite = turnsLeftSprites[e.givenMaxTurn - 1]; // sprite array index is 0-based, but starts with sprite of 1, so -1 is needed. //sd.GetChild(2).GetComponent<SpriteRenderer>().sprite = turnsLeftSprites[e.givenMaxTurn - 1]; // sprite array index is 0-based, but starts with sprite of 1, so -1 is needed.
else else
{ {
int monthOffset;
if (game.turn.monthNumber >= 0 && game.turn.monthNumber < 6) int totalMonthLeft = e.monthsLeft;
monthOffset = 5 - game.turn.monthNumber;
else
monthOffset = 11 - game.turn.monthNumber;
int totalMonthLeft = 6 * (e.turnsLeft - 1) + monthOffset;
int year = totalMonthLeft / 12; int year = totalMonthLeft / 12;
int month = totalMonthLeft % 12 + 1; int month = totalMonthLeft % 12 + 1;
...@@ -130,19 +125,14 @@ public class GameManager : MonoBehaviour ...@@ -130,19 +125,14 @@ public class GameManager : MonoBehaviour
else else
sd.gameObject.SetActive(false); sd.gameObject.SetActive(false);
if (e.givenMaxTurn < 0) if (e.givenMaxMonth < 0)
continue; continue;
if (e.turnsLeft >= 1) if (e.monthsLeft >= 1)
{ {
//sd.GetChild(2).GetComponent<SpriteRenderer>().sprite = turnsLeftSprites[e.turnsLeft - 1]; // sprite array index is 0-based, but starts with sprite of 1, so -1 is needed. //sd.GetChild(2).GetComponent<SpriteRenderer>().sprite = turnsLeftSprites[e.turnsLeft - 1]; // sprite array index is 0-based, but starts with sprite of 1, so -1 is needed.
int monthOffset;
if (game.turn.monthNumber >= 0 && game.turn.monthNumber < 6) int totalMonthLeft = e.monthsLeft;
monthOffset = 5 - game.turn.monthNumber;
else
monthOffset = 11 - game.turn.monthNumber;
int totalMonthLeft = 6 * (e.turnsLeft - 1) + monthOffset;
int year = totalMonthLeft / 12; int year = totalMonthLeft / 12;
int month = totalMonthLeft % 12 + 1; int month = totalMonthLeft % 12 + 1;
...@@ -162,9 +152,9 @@ public class GameManager : MonoBehaviour ...@@ -162,9 +152,9 @@ public class GameManager : MonoBehaviour
sd.GetChild(4).gameObject.SetActive(false); sd.GetChild(4).gameObject.SetActive(false);
else else
sd.GetChild(4).GetComponent<SpriteRenderer>().sprite = seasonSprites[(int)e.availableSeason - 1]; sd.GetChild(4).GetComponent<SpriteRenderer>().sprite = seasonSprites[(int)e.availableSeason - 1];
if (e.turnsLeft != e.givenMaxTurn) if (e.monthsLeft != e.givenMaxMonth)
sd.GetChild(3).gameObject.SetActive(false); sd.GetChild(3).gameObject.SetActive(false);
if (e.turnsLeft <= 0) if (e.monthsLeft <= 0)
{ {
toDestroyList.Add(sd); toDestroyList.Add(sd);
continue; continue;
......
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