Skip to content

Commit

Permalink
Merge branch 'v0.4.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
loulou123546 committed Dec 30, 2018
2 parents 854b388 + 5b3e0ac commit 4070646
Show file tree
Hide file tree
Showing 30 changed files with 2,414 additions and 63 deletions.
16 changes: 13 additions & 3 deletions On The CALL/Assets/UI/VHC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class VHC : MonoBehaviour {
public GameObject spawn_door;
public GameObject[] gyros;
float toggleGyro = 0.25f;
public GameObject[] gyrosecondaires;
public int gyro_secondaire_mode = 0;
public int code_alerte = 1;
public float resetDriver = 0.0f;
public GameObject World;
Expand All @@ -41,9 +43,9 @@ void Update () {
speed = speed + 0.2f;
} else if (Input.GetKey (KeyCode.S) && speed > 0.1f) {
speed = speed - 0.2f;
} else if (Input.GetKey (KeyCode.Z)) {
} else if (Input.GetKey (KeyCode.Z) && speed < maxspeed) {
speed = speed + Time.deltaTime;
} else if (Input.GetKey (KeyCode.S)) {
} else if (Input.GetKey (KeyCode.S) && speed > (0 - maxspeed)) {
speed = speed - Time.deltaTime;
} else if (speed > 0.05f) {
speed = speed - 0.05f;
Expand Down Expand Up @@ -92,6 +94,9 @@ void Update () {
if (code_alerte < 3 && gameObject.GetComponent<AudioSource> ().isPlaying == true) {
gameObject.GetComponent<AudioSource> ().Stop ();
}
foreach (GameObject led in gyrosecondaires) {
led.GetComponent<LED_model> ().send (Time.time, gyro_secondaire_mode);
}
}

public void change_code(int code, bool force){
Expand Down Expand Up @@ -127,12 +132,13 @@ public void change_code(int code, bool force){
}
}

public void NetUpdate(int code, float x, float y, float zaxis, int driverID){
public void NetUpdate(int code, int gyro2, float x, float y, float zaxis, int driverID){
// this is not called if you are the driver
Imdriver = false;
if (code_alerte != code) {
change_code (code, true);
}
gyro_secondaire_mode = gyro2;
//Vector3 oldpos = gameObject.GetComponent<Transform> ().position;
gameObject.GetComponent<Transform> ().position = new Vector3 (x, y, -3.0f);
//gameObject.GetComponent<Transform> ().LookAt (oldpos);
Expand Down Expand Up @@ -166,6 +172,10 @@ public void menuE (){
World.GetComponent<IG_menu>().OpenMenu("Brancard", "Attacher Brancard", "medic_rentrer_brancard_dans#VSAV 01#" + World.GetComponent<fromNetwork>().ID.ToString());
} else if (VHCname == "VSAV 01") {
World.GetComponent<IG_menu>().OpenMenu("Equipement", "Gants Latex", "taketool#hand", "Sac de secours", "taketool#medpack", "Brancard", "taketool#brancard", "Reprendre la victime", "medic_prendre_brancard_avec_victime#VSAV 01#" + World.GetComponent<fromNetwork>().ID.ToString());
} else if (VHCname == "FPTSR 01" && gyro_secondaire_mode == 1) {
World.GetComponent<IG_menu>().OpenMenu("FPTSR", "Eteindre TriFlash", "setGyro2model#FPTSR 01#0");
} else if (VHCname == "FPTSR 01" && gyro_secondaire_mode == 0) {
World.GetComponent<IG_menu>().OpenMenu("FPTSR", "Allumer TriFlash", "setGyro2model#FPTSR 01#1");
}
}
}
34 changes: 27 additions & 7 deletions On The CALL/Assets/UI/actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public class actions : MonoBehaviour {
public GameObject cone_model;
public GameObject car_VSAV1;
public GameObject car_FPT1;
public GameObject car_FPTSR1;
public GameObject car_VL1;
public GameObject car_SAMU_VL1;
public GameObject[] interventions;

// Use this for initialization
Expand All @@ -27,6 +30,8 @@ public void DoAction (string todo){
if (todo == "open Ordi") {
gameObject.GetComponent<IG_menu> ().CloseMenu ();
gameObject.GetComponent<IG_menu> ().OpenMenu ("Ordinateur", "Prendre feuille route", "take departure paper");
} else if (todo == "close"){
gameObject.GetComponent<IG_menu> ().CloseMenu ();
} else if (todo == "open Hospital Menu"){
gameObject.GetComponent<IG_menu> ().CloseMenu ();
gameObject.GetComponent<IG_menu> ().OpenMenu ("CHU St-Brieuc", "Déposer une victime", "medic_deposer_brancard_hopital#" + gameObject.GetComponent<fromNetwork>().ID.ToString());
Expand Down Expand Up @@ -56,7 +61,23 @@ public void DoAction (string todo){
gameObject.GetComponent<NetTCP> ().DoAction ("medic_asistance_resp", splitedTodo [1]);
} else if (splitedTodo[0] == "medic_menu_blessures") {
gameObject.GetComponent<IG_menu> ().CloseMenu ();
//TODO region choose, and after type of soin
string[] Tags = splitedTodo[1].Split(':');
NetAction("Inter#" + Tags[0] + "#menu_blessure#" + Tags[1]);
} else if (splitedTodo[0] == "medic_menu_blessures2") {
gameObject.GetComponent<IG_menu> ().CloseMenu ();
gameObject.GetComponent<IG_menu> ().OpenMenu (splitedTodo[2], "Désinfecter", "medic_soins_desinfecter#" + splitedTodo[1] + "#" + splitedTodo[2], "Mettre bandage", "medic_soins_bandage#" + splitedTodo[1] + "#" + splitedTodo[2], "Mettre crème anti-douleur", "medic_soins_antidouleur#" + splitedTodo[1] + "#" + splitedTodo[2], "Mettre pansement", "medic_soins_pansement#" + splitedTodo[1] + "#" + splitedTodo[2]);
} else if (splitedTodo[0] == "medic_soins_desinfecter") {
gameObject.GetComponent<IG_menu> ().CloseMenu ();
gameObject.GetComponent<NetTCP> ().DoAction ("medic_soins_desinfecter", splitedTodo [1], splitedTodo [2]);
} else if (splitedTodo[0] == "medic_soins_bandage") {
gameObject.GetComponent<IG_menu> ().CloseMenu ();
gameObject.GetComponent<NetTCP> ().DoAction ("medic_soins_bandage", splitedTodo [1], splitedTodo [2]);
} else if (splitedTodo[0] == "medic_soins_antidouleur") {
gameObject.GetComponent<IG_menu> ().CloseMenu ();
gameObject.GetComponent<NetTCP> ().DoAction ("medic_soins_antidouleur", splitedTodo [1], splitedTodo [2]);
} else if (splitedTodo[0] == "medic_soins_pansement") {
gameObject.GetComponent<IG_menu> ().CloseMenu ();
gameObject.GetComponent<NetTCP> ().DoAction ("medic_soins_pansement", splitedTodo [1], splitedTodo [2]);
} else if (splitedTodo[0] == "medic_put_victim_in_brancard") {
gameObject.GetComponent<IG_menu> ().CloseMenu ();
gameObject.GetComponent<NetTCP> ().DoAction ("medic_put_victim_in_brancard", splitedTodo [1], splitedTodo [2]);
Expand All @@ -74,6 +95,9 @@ public void DoAction (string todo){
} else if (splitedTodo[0] == "taketool") {
gameObject.GetComponent<IG_menu> ().CloseMenu ();
gameObject.GetComponent<IG_menu> ().change_tool (splitedTodo [1]);
} else if (splitedTodo[0] == "setGyro2model") {
gameObject.GetComponent<IG_menu> ().CloseMenu ();
gameObject.GetComponent<NetTCP> ().DoAction ("setGyro2model", splitedTodo [1], splitedTodo [2]);
}
}

Expand All @@ -84,12 +108,7 @@ public void NetAction(string rawaction){
nbline = nbline + 1;
}
if (nbline > 0) {
if (datas [0] == "addcone" && nbline > 3) {
GameObject temp = Instantiate (cone_model, new Vector3 (float.Parse (datas [2]), float.Parse (datas [3]), -2.0f), new Quaternion (0, 0, 0, 0));
temp.GetComponent<NetID> ().ID = int.Parse (datas [1]);
} else if (datas [0] == "remcone" && nbline > 1) {
eventmanager.GetComponent<IDsenpai> ().actionTo (int.Parse (datas [1]), "destroy");
} else if(datas[0] == "Inter" && nbline > 2) {
if(datas[0] == "Inter" && nbline > 2) {
foreach (GameObject inter in interventions) {
if (inter.GetComponent<intervention> ().NAME == datas [1]) {
string preparestring = "fromServer";
Expand All @@ -100,6 +119,7 @@ public void NetAction(string rawaction){
return;
}
}
Debug.Log ("inter not find : " + rawaction);
} else {
//unknow action
}
Expand Down
24 changes: 12 additions & 12 deletions On The CALL/Assets/gameplay/IDsenpai.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public class IDsenpai : MonoBehaviour {

string[] Orders = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" };
//string[] Orders = { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" };

// Use this for initialization
void Start () {
Expand All @@ -16,28 +16,28 @@ void Update () {

}

void OnTriggerStay(Collider col){
/*void OnTriggerStay(Collider col){
for (int i = 0; i < Orders.Length; i++) {
if (Orders [i] != "") {
string[] data = Orders [i].Split ('#');
if (col != null && col.gameObject != null && col.gameObject.GetComponent<NetID>() != null && int.Parse (data [0]) == col.gameObject.GetComponent<NetID> ().ID) {
if (data [1] == "destroy") {
col.gameObject.GetComponent<NetID> ().deleteMyself ();
Orders [i] = "";
return;
}
}
//if (col != null && col.gameObject != null && col.gameObject.GetComponent<NetID>() != null && int.Parse (data [0]) == col.gameObject.GetComponent<NetID> ().ID) {
//if (data [1] == "destroy") {
// col.gameObject.GetComponent<NetID> ().deleteMyself ();
//Orders [i] = "";
//return;
//}
//}
}
}
}
}*/

public void actionTo(int ID, string ask, string data = ""){
/*public void actionTo(int ID, string ask, string data = ""){
for (int i = 0; i < Orders.Length; i++) {
if (Orders [i] == "") {
Orders [i] = ID.ToString () + "#" + ask + "#" + data;
return;
}
}
// If your come here, there was a BIG PROBLEM, action will be skipped
}
}*/
}
37 changes: 37 additions & 0 deletions On The CALL/Assets/gameplay/LED_model.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LED_model : MonoBehaviour {

/* Modes :
* 0 : off
* 1 : blink sync (FPTSR)
* 2 : cross
* 3 : arrowLeft
* 4 : arrow Right
*/
public bool[] TurnOnFor = { true, false, false, false, false };

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}

public void send (float TimeS, int mode){
if (TurnOnFor [mode] == false) {
gameObject.GetComponent<SpriteRenderer> ().enabled = false;
} else if (mode == 1) {
if (TimeS % 0.3f >= 0.15f) {
gameObject.GetComponent<SpriteRenderer> ().enabled = false;
} else {
gameObject.GetComponent<SpriteRenderer> ().enabled = true;
}
}
}
}
11 changes: 11 additions & 0 deletions On The CALL/Assets/gameplay/LED_model.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions On The CALL/Assets/gameplay/NetID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

public class NetID : MonoBehaviour {

public int ID = 0;
//public int ID = 0;

// Use this for initialization
void Start () {
Expand All @@ -16,11 +16,11 @@ void Update () {

}

public void deleteMyself(){
/*public void deleteMyself(){
Destroy (gameObject);
}
public void setVHCcode(int code){
gameObject.GetComponent<VHC>().change_code(code, true);
}
}*/
}
16 changes: 10 additions & 6 deletions On The CALL/Assets/gameplay/NetTCP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,21 @@ public void DoAction(string act, string d1 = " ", string d2 = " ", string d3 = "
StartCoroutine (makeAweb(act, d1, d2, d3));
}

public void receive(string chat, string chat_inter, string act1 = " ", string act2 = " ", string act3 = " ", string act4 = " ", string act5 = " "){
public void receive(string chat, string chat_inter, string cones = " ", string inter_info = " "){
gameObject.GetComponent<IG_menu> ().update_chat(chat);
gameObject.GetComponent<OBJ_manger> ().updateCones (cones);
if (gameObject.GetComponent<IG_menu> ().truck_text.GetComponent<Text> ().text == "") {
gameObject.GetComponent<IG_menu> ().msg_inter ("");
} else {
gameObject.GetComponent<IG_menu> ().msg_inter (chat_inter);
}
if(act1 != " ") gameObject.GetComponent<actions> ().NetAction (act1);
if(act2 != " ") gameObject.GetComponent<actions> ().NetAction (act2);
if(act3 != " ") gameObject.GetComponent<actions> ().NetAction (act3);
if(act4 != " ") gameObject.GetComponent<actions> ().NetAction (act4);
if(act5 != " ") gameObject.GetComponent<actions> ().NetAction (act5);

string[] inter_data = inter_info.Split ('&');
foreach (string inter in inter_data) {
string[] parsed = inter.Split ('#');
if (parsed [0] == "Victim_blessure") {
gameObject.GetComponent<actions> ().NetAction ("Inter#" + parsed[1] + "#Victim_blessure#" + parsed[2] + "#" + parsed[3]);
}
}
}
}
14 changes: 10 additions & 4 deletions On The CALL/Assets/gameplay/NetUDP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,16 @@ public void receive (string rawdata){
gameObject.GetComponent<IG_menu> ().set_bip_msg (cmds2 [2]);
gameObject.GetComponent<IG_menu> ().set_bip_vhc (cmds2 [3]);
}
} else if(cmds2 [0] == "VSAV 01" && int.Parse(cmds2[5]) != playerID){
gameObject.GetComponent<actions> ().car_VSAV1.GetComponent<VHC> ().NetUpdate (int.Parse(cmds2[1]),float.Parse(cmds2[2]),float.Parse(cmds2[3]),float.Parse(cmds2[4]),int.Parse(cmds2[5]));
} else if(cmds2 [0] == "FPT 01" && int.Parse(cmds2[5]) != playerID){
gameObject.GetComponent<actions> ().car_FPT1.GetComponent<VHC> ().NetUpdate (int.Parse(cmds2[1]),float.Parse(cmds2[2]),float.Parse(cmds2[3]),float.Parse(cmds2[4]),int.Parse(cmds2[5]));
} else if(cmds2 [0] == "VSAV 01" && int.Parse(cmds2[6]) != playerID){
gameObject.GetComponent<actions> ().car_VSAV1.GetComponent<VHC> ().NetUpdate (int.Parse(cmds2[1]),int.Parse(cmds2[2]),float.Parse(cmds2[3]),float.Parse(cmds2[4]),float.Parse(cmds2[5]),int.Parse(cmds2[6]));
} else if(cmds2 [0] == "FPT 01" && int.Parse(cmds2[6]) != playerID){
gameObject.GetComponent<actions> ().car_FPT1.GetComponent<VHC> ().NetUpdate (int.Parse(cmds2[1]),int.Parse(cmds2[2]),float.Parse(cmds2[3]),float.Parse(cmds2[4]),float.Parse(cmds2[5]),int.Parse(cmds2[6]));
} else if(cmds2 [0] == "FPTSR 01" && int.Parse(cmds2[6]) != playerID){
gameObject.GetComponent<actions> ().car_FPTSR1.GetComponent<VHC> ().NetUpdate (int.Parse(cmds2[1]),int.Parse(cmds2[2]),float.Parse(cmds2[3]),float.Parse(cmds2[4]),float.Parse(cmds2[5]),int.Parse(cmds2[6]));
} else if(cmds2 [0] == "VL 01" && int.Parse(cmds2[6]) != playerID){
gameObject.GetComponent<actions> ().car_VL1.GetComponent<VHC> ().NetUpdate (int.Parse(cmds2[1]),int.Parse(cmds2[2]),float.Parse(cmds2[3]),float.Parse(cmds2[4]),float.Parse(cmds2[5]),int.Parse(cmds2[6]));
} else if(cmds2 [0] == "SAMU_VL 01" && int.Parse(cmds2[6]) != playerID){
gameObject.GetComponent<actions> ().car_SAMU_VL1.GetComponent<VHC> ().NetUpdate (int.Parse(cmds2[1]),int.Parse(cmds2[2]),float.Parse(cmds2[3]),float.Parse(cmds2[4]),float.Parse(cmds2[5]),int.Parse(cmds2[6]));
}
else if(cmds2 [0] == "VICTIME"){
gameObject.GetComponent<actions> ().NetAction ("Inter#" + cmds2[1] + "#VICTIME#" + cmds2[2] + "#" + cmds2[3] + "#" + cmds2[4] + "#" + cmds2[5] + "#" + cmds2[6]);
Expand Down
40 changes: 40 additions & 0 deletions On The CALL/Assets/gameplay/OBJ_manger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class OBJ_manger : MonoBehaviour {

public GameObject cone_model;
public GameObject[] cones = new GameObject[100];

// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {

}

public void updateCones (string raw = "&"){
string[] list = raw.Split ('&');
for (int i = 0; i < 100; i++) {
if (list [i] != "") {
string[] coord = list [i].Split ('#');
if (cones [i] == null) {
cones[i] = Instantiate (cone_model, new Vector3 (float.Parse (coord [0]), float.Parse (coord [1]), -2.0f), new Quaternion (0, 0, 0, 0));
} else {
if (cones [i].GetComponent<Transform> ().position.x != float.Parse (coord [0]) || cones [i].GetComponent<Transform> ().position.y != float.Parse (coord [1])) {
Destroy (cones [i]);
cones [i] = null;
cones[i] = Instantiate (cone_model, new Vector3 (float.Parse (coord [0]), float.Parse (coord [1]), -2.0f), new Quaternion (0, 0, 0, 0));
}
}
} else if (cones [i] != null) {
Destroy (cones [i]);
cones [i] = null;
}
}
}
}
11 changes: 11 additions & 0 deletions On The CALL/Assets/gameplay/OBJ_manger.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion On The CALL/Assets/gameplay/fromNetwork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ IEnumerator fetchMainData (){
yield return downloadFM;
if (string.IsNullOrEmpty (downloadFM.error)) {
monObjFM = JSON.Parse(downloadFM.text);
gameObject.GetComponent<NetTCP> ().receive (monObjFM ["chat"], monObjFM ["chat_inter"], monObjFM ["act1"], monObjFM ["act2"], monObjFM ["act3"], monObjFM ["act4"], monObjFM ["act5"]);
gameObject.GetComponent<NetTCP> ().receive (monObjFM ["chat"], monObjFM ["chat_inter"], monObjFM ["cones"], monObjFM ["inter_info"]);
}
sendOnNext = true;
}
Expand Down
6 changes: 1 addition & 5 deletions On The CALL/Assets/gameplay/keyListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,7 @@ void Update () {
}
if (listen_cone && Input.GetKeyDown (convertKey (PlayerPrefs.GetString ("keyboard_cone", "C"))) && gameObject.GetComponent<perso> ().inacar == false) {
listen_cone = false;
if (gameObject.GetComponent<getCollides> ().nearCone == null) {
gameObject.GetComponent<perso> ().World.GetComponent<NetTCP> ().DoAction ("addcone", gameObject.GetComponent<Transform> ().position.x.ToString (), (gameObject.GetComponent<Transform> ().position.y + 1.0f).ToString ());
} else {
gameObject.GetComponent<perso> ().World.GetComponent<NetTCP> ().DoAction ("remcone", gameObject.GetComponent<getCollides> ().nearCone.GetComponent<NetID> ().ID.ToString ());
}
gameObject.GetComponent<perso> ().World.GetComponent<NetTCP> ().DoAction ("keycone", gameObject.GetComponent<Transform> ().position.x.ToString (), (gameObject.GetComponent<Transform> ().position.y).ToString ());
}

if (Input.GetKeyUp (convertKey (PlayerPrefs.GetString ("keyboard_car", "Space")))) {
Expand Down
6 changes: 6 additions & 0 deletions On The CALL/Assets/interventions/intervention.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ public void Action (string rawaction){
if (datas [1] == "victime_menu" && nbline > 2) {
victimes [ int.Parse(datas[2]) ].GetComponent<victimes> ().action ("menu");
}
else if (datas [1] == "menu_blessure" && nbline > 2) {
victimes [ int.Parse(datas[2]) ].GetComponent<victimes> ().action ("menu_blessure");
}
else if (datas [1] == "Victim_blessure" && nbline > 3) {
victimes [ int.Parse(datas[2]) ].GetComponent<victimes> ().updateBlessures (datas[3]);
}
else if (datas [1] == "VICTIME" && nbline > 2) {
victimes [ int.Parse(datas[2]) ].GetComponent<victimes> ().update (float.Parse(datas[3]), float.Parse(datas[4]), float.Parse(datas[5]), float.Parse(datas[6]));
}
Expand Down
Loading

0 comments on commit 4070646

Please sign in to comment.