Modification du cycle jour/nuit

L'animator de DayController comprend maintenant quatre états:

-Discussion: sort et discussion autorisée
-Accusation: la même mais on rajoute la possibilités d'accuser quelqu'un
-Killing: si quelqu'un est accusé, on décide ou non de l'abattre à l'arbre des pendus.
-Nuit: il fait tous les noirs, les gros chats sont de sortie.

L'état killing n'est pour le moment pas utilisé.
A chaque nouveau jour, une entrée dans le chaque renseigne sur le compte de jour.

Modiciation de la classe ChatWindow: ajout de la méthode writeText qui permet d'écrire dans le chat. A modifier cependant: rajouter un paramètre pour définir le style du message pour pouvoir modifier la police, la taille etc...

Il faudra aussi rajouter egalement un message qui pope lorsque l'on passe en fasse d'accusation. Pour faire ce, modifier la classe CreateScrollList pour y ajouter une méthode addMessage()
This commit is contained in:
Romain Pellé 2015-01-22 18:32:01 +01:00
parent 5edd46e20e
commit 55686f63fb
7 changed files with 405 additions and 47 deletions

View File

@ -26,35 +26,86 @@ AnimatorController:
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1101 &110100000
- serializedVersion: 3
m_Name: New Layer
m_StateMachine: {fileID: 110781112}
m_Mask: {fileID: 0}
m_BlendingMode: 0
m_SyncedLayerIndex: -1
m_StateMachineMotionSetIndex: 0
m_DefaultWeight: 0
m_IKPass: 0
m_SyncedLayerAffectsTiming: 0
m_Controller: {fileID: 9100000}
--- !u!1101 &110102594
Transition:
serializedVersion: 2
m_ObjectHideFlags: 3
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_SrcState: {fileID: 110206034}
m_DstState: {fileID: 110200000}
m_SrcState: {fileID: 110286057}
m_DstState: {fileID: 110238901}
m_TransitionDuration: .100000001
m_TransitionOffset: 0
m_Conditions:
- m_ConditionMode: 6
m_ConditionEvent: day_status
m_EventTreshold: 1
m_EventTreshold: 3
m_ExitTime: .899999976
m_Atomic: 1
m_Solo: 0
m_Mute: 0
m_CanTransitionToSelf: 0
--- !u!1101 &110119981
--- !u!1101 &110104043
Transition:
serializedVersion: 2
m_ObjectHideFlags: 3
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_SrcState: {fileID: 110200000}
m_DstState: {fileID: 110206034}
m_SrcState: {fileID: 110286057}
m_DstState: {fileID: 110246936}
m_TransitionDuration: .100000001
m_TransitionOffset: 0
m_Conditions:
- m_ConditionMode: 5
m_ConditionEvent:
m_EventTreshold: 0
m_ExitTime: .899999976
m_Atomic: 1
m_Solo: 0
m_Mute: 0
m_CanTransitionToSelf: 0
--- !u!1101 &110116689
Transition:
serializedVersion: 2
m_ObjectHideFlags: 3
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_SrcState: {fileID: 110246936}
m_DstState: {fileID: 110238901}
m_TransitionDuration: .100000001
m_TransitionOffset: 0
m_Conditions:
- m_ConditionMode: 6
m_ConditionEvent: day_status
m_EventTreshold: 3
m_ExitTime: .899999976
m_Atomic: 1
m_Solo: 0
m_Mute: 0
m_CanTransitionToSelf: 0
--- !u!1101 &110137525
Transition:
serializedVersion: 2
m_ObjectHideFlags: 3
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_SrcState: {fileID: 110238901}
m_DstState: {fileID: 110219623}
m_TransitionDuration: .100000001
m_TransitionOffset: 0
m_Conditions:
@ -66,7 +117,42 @@ Transition:
m_Solo: 0
m_Mute: 0
m_CanTransitionToSelf: 0
--- !u!1102 &110200000
--- !u!1101 &110198633
Transition:
serializedVersion: 2
m_ObjectHideFlags: 3
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name:
m_SrcState: {fileID: 110219623}
m_DstState: {fileID: 110286057}
m_TransitionDuration: .100000001
m_TransitionOffset: 0
m_Conditions:
- m_ConditionMode: 6
m_ConditionEvent: day_status
m_EventTreshold: 1
m_ExitTime: .899999976
m_Atomic: 1
m_Solo: 0
m_Mute: 0
m_CanTransitionToSelf: 0
--- !u!1102 &110219623
State:
m_ObjectHideFlags: 3
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Discussion
m_Speed: -1
m_CycleOffset: 0
m_Motions:
- {fileID: 7400000, guid: df5cb0d3151acfa45a800c250ea2c5da, type: 2}
m_ParentStateMachine: {fileID: 110700000}
m_Position: {x: 672, y: -396, z: 0}
m_IKOnFeet: 0
m_Mirror: 0
m_Tag:
--- !u!1102 &110238901
State:
m_ObjectHideFlags: 3
m_PrefabParentObject: {fileID: 0}
@ -77,22 +163,37 @@ State:
m_Motions:
- {fileID: 7400000, guid: df5cb0d3151acfa45a800c250ea2c5da, type: 2}
m_ParentStateMachine: {fileID: 110700000}
m_Position: {x: 264, y: 72, z: 0}
m_Position: {x: 444, y: -312, z: 0}
m_IKOnFeet: 0
m_Mirror: 0
m_Tag:
--- !u!1102 &110206034
--- !u!1102 &110246936
State:
m_ObjectHideFlags: 3
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Day
m_Speed: -1
m_Name: Killing
m_Speed: 1
m_CycleOffset: 0
m_Motions:
- {fileID: 7400000, guid: df5cb0d3151acfa45a800c250ea2c5da, type: 2}
- {fileID: 0}
m_ParentStateMachine: {fileID: 110700000}
m_Position: {x: 264, y: -120, z: 0}
m_Position: {x: 672, y: -216, z: 0}
m_IKOnFeet: 0
m_Mirror: 0
m_Tag:
--- !u!1102 &110286057
State:
m_ObjectHideFlags: 3
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Accusation
m_Speed: 1
m_CycleOffset: 0
m_Motions:
- {fileID: 0}
m_ParentStateMachine: {fileID: 110700000}
m_Position: {x: 900, y: -324, z: 0}
m_IKOnFeet: 0
m_Mirror: 0
m_Tag:
@ -103,29 +204,58 @@ StateMachine:
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Base Layer
m_DefaultState: {fileID: 110206034}
m_DefaultState: {fileID: 110219623}
m_States:
- {fileID: 110200000}
- {fileID: 110206034}
- {fileID: 110219623}
- {fileID: 110286057}
- {fileID: 110238901}
- {fileID: 110246936}
m_ChildStateMachine: []
m_ChildStateMachinePosition: []
m_OrderedTransitions:
data:
first: {fileID: 110200000}
first: {fileID: 110246936}
second:
- {fileID: 110119981}
- {fileID: 110116689}
data:
first: {fileID: 110238901}
second:
- {fileID: 110137525}
data:
first: {fileID: 110286057}
second:
- {fileID: 110104043}
- {fileID: 110102594}
data:
first: {fileID: 110219623}
second:
- {fileID: 110198633}
data:
first: {fileID: 0}
second: []
data:
first: {fileID: 110206034}
second:
- {fileID: 110100000}
first: {fileID: 0}
second: []
data:
first: {fileID: 0}
second: []
m_MotionSetCount: 1
m_AnyStatePosition: {x: 696, y: -216, z: 0}
m_AnyStatePosition: {x: 216, y: -252, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
--- !u!1107 &110781112
StateMachine:
serializedVersion: 2
m_ObjectHideFlags: 3
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: New Layer
m_DefaultState: {fileID: 0}
m_States: []
m_ChildStateMachine: []
m_ChildStateMachinePosition: []
m_OrderedTransitions: {}
m_MotionSetCount: 1
m_AnyStatePosition: {x: 50, y: 20, z: 0}
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
--- !u!1107 &110784658
StateMachine:

View File

@ -72,6 +72,82 @@ AnimationClip:
path: MoonLight
classID: 108
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- time: 0
value: .453341246
inSlope: -.633774102
outSlope: -.633774102
tangentMode: 10
- time: .583333313
value: .0836397111
inSlope: -.633774102
outSlope: -.633774102
tangentMode: 10
m_PreInfinity: 2
m_PostInfinity: 2
attribute: m_BackGroundColor.r
path: Main Camera
classID: 20
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- time: 0
value: .600190401
inSlope: -.864488959
outSlope: -.864488959
tangentMode: 10
- time: .583333313
value: .0959051922
inSlope: -.864488959
outSlope: -.864488959
tangentMode: 10
m_PreInfinity: 2
m_PostInfinity: 2
attribute: m_BackGroundColor.g
path: Main Camera
classID: 20
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- time: 0
value: .948529422
inSlope: -1.41176474
outSlope: -1.41176474
tangentMode: 10
- time: .583333313
value: .125
inSlope: -1.41176474
outSlope: -1.41176474
tangentMode: 10
m_PreInfinity: 2
m_PostInfinity: 2
attribute: m_BackGroundColor.b
path: Main Camera
classID: 20
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- time: 0
value: .0196078438
inSlope: 0
outSlope: 0
tangentMode: 10
- time: .583333313
value: .0196078438
inSlope: 0
outSlope: 0
tangentMode: 10
m_PreInfinity: 2
m_PostInfinity: 2
attribute: m_BackGroundColor.a
path: Main Camera
classID: 20
script: {fileID: 0}
m_PPtrCurves: []
m_SampleRate: 60
m_WrapMode: 0
@ -98,6 +174,30 @@ AnimationClip:
classID: 108
customType: 0
isPPtrCurve: 0
- path: 1058044976
attribute: 544695226
script: {fileID: 0}
classID: 20
customType: 0
isPPtrCurve: 0
- path: 1058044976
attribute: 1303021393
script: {fileID: 0}
classID: 20
customType: 0
isPPtrCurve: 0
- path: 1058044976
attribute: 1036022750
script: {fileID: 0}
classID: 20
customType: 0
isPPtrCurve: 0
- path: 1058044976
attribute: 2764644964
script: {fileID: 0}
classID: 20
customType: 0
isPPtrCurve: 0
pptrCurveMapping: []
m_AnimationClipSettings:
serializedVersion: 2
@ -174,5 +274,81 @@ AnimationClip:
path: MoonLight
classID: 108
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- time: 0
value: .453341246
inSlope: -.633774102
outSlope: -.633774102
tangentMode: 10
- time: .583333313
value: .0836397111
inSlope: -.633774102
outSlope: -.633774102
tangentMode: 10
m_PreInfinity: 2
m_PostInfinity: 2
attribute: m_BackGroundColor.r
path: Main Camera
classID: 20
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- time: 0
value: .600190401
inSlope: -.864488959
outSlope: -.864488959
tangentMode: 10
- time: .583333313
value: .0959051922
inSlope: -.864488959
outSlope: -.864488959
tangentMode: 10
m_PreInfinity: 2
m_PostInfinity: 2
attribute: m_BackGroundColor.g
path: Main Camera
classID: 20
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- time: 0
value: .948529422
inSlope: -1.41176474
outSlope: -1.41176474
tangentMode: 10
- time: .583333313
value: .125
inSlope: -1.41176474
outSlope: -1.41176474
tangentMode: 10
m_PreInfinity: 2
m_PostInfinity: 2
attribute: m_BackGroundColor.b
path: Main Camera
classID: 20
script: {fileID: 0}
- curve:
serializedVersion: 2
m_Curve:
- time: 0
value: .0196078438
inSlope: 0
outSlope: 0
tangentMode: 10
- time: .583333313
value: .0196078438
inSlope: 0
outSlope: 0
tangentMode: 10
m_PreInfinity: 2
m_PostInfinity: 2
attribute: m_BackGroundColor.a
path: Main Camera
classID: 20
script: {fileID: 0}
m_EulerEditorCurves: []
m_Events: []

View File

@ -7906,7 +7906,7 @@ Transform:
- {fileID: 363748264}
- {fileID: 1367076073}
m_Father: {fileID: 2082661559}
m_RootOrder: 5
m_RootOrder: 4
--- !u!1 &578926050
GameObject:
m_ObjectHideFlags: 0
@ -12201,7 +12201,7 @@ Transform:
- {fileID: 828187915}
- {fileID: 1894284579}
m_Father: {fileID: 2082661559}
m_RootOrder: 4
m_RootOrder: 3
--- !u!1 &948892945
GameObject:
m_ObjectHideFlags: 0
@ -17251,7 +17251,7 @@ Transform:
- {fileID: 1880431846}
- {fileID: 717116040}
m_Father: {fileID: 2082661559}
m_RootOrder: 2
m_RootOrder: 1
--- !u!1 &1364751245
GameObject:
m_ObjectHideFlags: 0
@ -18554,7 +18554,7 @@ Transform:
- {fileID: 1868011519}
- {fileID: 961916967}
m_Father: {fileID: 2082661559}
m_RootOrder: 3
m_RootOrder: 2
--- !u!1 &1443112309
GameObject:
m_ObjectHideFlags: 0
@ -20827,7 +20827,7 @@ MonoBehaviour:
m_GameObject: {fileID: 1553687533}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: b291226aa9641df46a8b0236eceaf0a4, type: 3}
m_Script: {fileID: 11500000, guid: 84e29fc5bdebd1a4a86fd5af33497c7b, type: 3}
m_Name:
m_EditorClassIdentifier:
text_chat: {fileID: 1176907833}
@ -23497,7 +23497,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: .39199999}
m_Color: {r: 1, g: 1, b: 1, a: .811764717}
m_Sprite: {fileID: 21300000, guid: 5b533412749ae7f479b5b0e198032ffa, type: 3}
m_Type: 0
m_PreserveAspect: 0
@ -24347,7 +24347,7 @@ Transform:
- {fileID: 1731313763}
- {fileID: 377466160}
m_Father: {fileID: 2082661559}
m_RootOrder: 6
m_RootOrder: 5
--- !u!1 &1826980348
GameObject:
m_ObjectHideFlags: 0
@ -24645,7 +24645,7 @@ Camera:
m_Enabled: 1
serializedVersion: 2
m_ClearFlags: 1
m_BackGroundColor: {r: .192156866, g: .301960796, b: .474509805, a: .0196078438}
m_BackGroundColor: {r: .453341246, g: .600190401, b: .948529422, a: .0196078438}
m_NormalizedViewPortRect:
serializedVersion: 2
x: 0
@ -24675,11 +24675,11 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1859570684}
m_LocalRotation: {x: .412046075, y: .537379384, z: -.339061111, w: .653053582}
m_LocalPosition: {x: -299.316895, y: 246.031311, z: 273.437836}
m_LocalPosition: {x: -428.475494, y: 791.057251, z: -433.360657}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 2082661559}
m_RootOrder: 1
m_Father: {fileID: 2130265912}
m_RootOrder: 3
--- !u!1 &1860255179
GameObject:
m_ObjectHideFlags: 0
@ -28344,7 +28344,6 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1753276986}
- {fileID: 1859570690}
- {fileID: 1361733863}
- {fileID: 1437703998}
- {fileID: 948211392}
@ -28513,6 +28512,7 @@ Transform:
- {fileID: 161992413}
- {fileID: 1911482243}
- {fileID: 2047370601}
- {fileID: 1859570690}
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!114 &2130265913
@ -28527,8 +28527,9 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
machine: {fileID: 2130265911}
maxDay: 15
maxNight: 10
maxDay: 30
maxNight: 5
maxKilling: 15
--- !u!1 &2136149714
GameObject:
m_ObjectHideFlags: 0

View File

@ -2,7 +2,7 @@
using System.Collections;
using UnityEngine.UI;
public class chat_window : MonoBehaviour {
public class ChatWindow : MonoBehaviour {
public Text text_chat;
public ScrollRect scrollrect;
@ -34,4 +34,11 @@ public class chat_window : MonoBehaviour {
}
}
public void writeText(string text){
text_chat.text += text;
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: b291226aa9641df46a8b0236eceaf0a4
guid: 84e29fc5bdebd1a4a86fd5af33497c7b
MonoImporter:
serializedVersion: 2
defaultReferences: []

View File

@ -27,11 +27,11 @@ public class Clock : MonoBehaviour {
float fRot = clock.transform.rotation.z;
if(fRot>=0 && fRot<180){
clock.transform.Rotate(0, 0, (float)(Time.deltaTime * (-180.0)/maxDay));//2.5min
if(fRot>=0 && fRot>-180){
clock.transform.Rotate(0, 0, (float)(Time.deltaTime * (-180.0)/maxNight));//2.5min
}
else{
clock.transform.Rotate(0, 0, (float)(Time.deltaTime * (-180.0)/maxNight));//1min
clock.transform.Rotate(0, 0, (float)(Time.deltaTime * (-180.0)/maxDay));//1min
}
}
}

View File

@ -6,24 +6,46 @@ public class DayController : MonoBehaviour {
public Animator machine;
public int maxDay;
public int maxNight;
public int maxKilling;
float timer;
int maxDiscussion;
int maxAccusation;
int dayNb;
//appel de Window Chat
GameObject chatWindowScroll;
ChatWindow chatWindow;
// Use this for initialization
void Start () {
//calcul des différent timing.
machine.SetInteger ("day_status", 0);
maxDiscussion = (int) maxDay / 2;
maxAccusation = maxDay - maxDiscussion;
//appel de Window Chat
chatWindowScroll = GameObject.Find ("ChatWindowScroll");
chatWindow = chatWindowScroll.GetComponent<ChatWindow> ();
dayNb = 1;
chatWindow.writeText("\n\n\n JOUR 1 \n");
}
// Update is called once per frame
void Update () {
//DISUCSSION
if (machine.GetInteger("day_status")==0){
if (timer >= (float)maxDay){
timer =0;
if (timer >= (float)maxDiscussion){
machine.SetInteger("day_status",1);
print("il fait nuit");
print("Accusation!");
}
else{
@ -32,13 +54,35 @@ public class DayController : MonoBehaviour {
}
//ACCUSATION
if (machine.GetInteger("day_status")==1){
if (timer >= (float)maxDay){
machine.SetInteger("day_status",3);
print("il fait nuit!");
timer = 0;
}
else{
timer += Time.deltaTime;
}
}
//NUIT
if (machine.GetInteger("day_status")==3){
if (timer >= (float)maxNight){
timer =0;
machine.SetInteger("day_status",0);
print("il fait jour");
timer = 0;
dayNb ++;
string message = "\n\n\n JOUR "+ dayNb.ToString()+"\n";
chatWindow.writeText(message);
print("le jour se lève, discutez!");
}
else{