Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (5)
Showing
with 248 additions and 791 deletions
This diff is collapsed.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using UnityEngine.UI;
public class ChangeMin : MonoBehaviour
{
public static float plus = Ui.motiv;
public void changeMinus(string word)
{
plus = Ui.difficulty;
plus--;
if (plus < 0)
{
plus = 0;
}
Ui.difficulty = plus;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using UnityEngine.SceneManagement;
public class ChangePlus : MonoBehaviour
{
public static float moins;
public void changePlus(string word)
{
moins = Ui.difficulty;
moins++;
if (moins > 10)
{
moins = 10;
}
Ui.difficulty = moins;
}
}
fileFormatVersion: 2
guid: ef740db83eb559f43a863d061e079ade
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -17,6 +17,7 @@ namespace Scripts.IA
public List<GameObject> _listRunners; //<! "Insérer description de la variable"
public float moyenneMotivation = 0; //<! "Insérer description de la variable"
// Champs privés
private System.Random rdn; //<! "Insérer description de la variable"
private static RunnersFactory instance; //<! "Insérer description de la variable"
private AbstractMap _map; //<! "Insérer description de la variable"
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using TMPro;
public class DragDropM : MonoBehaviour, IDragHandler, IDropHandler
{
[SerializeField] private Canvas canvas;
private RectTransform rectransform;
public TMP_Text textshowed;
bool block = true;
private void Awake()
{
rectransform = GetComponent<RectTransform>();
}
public void OnDrag(PointerEventData eventData)
{
rectransform.anchoredPosition += eventData.delta / canvas.scaleFactor;
}
public void OnDrop(PointerEventData eventData)
{
while (block == true)
{
Ui.nbObst = Ui.nbObst - 1;
Ui.difficulty = Ui.difficulty + 2;
block = false;
}
}
}
fileFormatVersion: 2
guid: 02e48c10dc39a4c498c2eccc20883084
guid: 380d8a9115a818141b41c663eb957408
MonoImporter:
externalObjects: {}
serializedVersion: 2
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using TMPro;
public class DragDropS : MonoBehaviour, IDragHandler, IDropHandler
{
[SerializeField] private Canvas canvas;
private RectTransform rectransform;
public TMP_Text textshowed;
bool block = true;
private void Awake()
{
rectransform = GetComponent<RectTransform>();
}
public void OnDrag(PointerEventData eventData)
{
rectransform.anchoredPosition += eventData.delta / canvas.scaleFactor;
}
public void OnDrop(PointerEventData eventData)
{
while (block == true)
{
Ui.nbObst = Ui.nbObst - 1;
Ui.difficulty = Ui.difficulty + 3;
block = false;
}
}
}
fileFormatVersion: 2
guid: 23ab3ae128f56e241b83e249e823556a
guid: 6eb5a4ed1248c2d4eb03f052c9db5eb4
MonoImporter:
externalObjects: {}
serializedVersion: 2
......
......@@ -4,13 +4,14 @@ using UnityEngine;
using UnityEngine.EventSystems;
using TMPro;
public class DragDrop : MonoBehaviour, IDragHandler, IDropHandler
public class DragDropW : MonoBehaviour, IDragHandler, IDropHandler
{
[SerializeField] private Canvas canvas;
private RectTransform rectransform;
public TMP_Text textshowed;
bool block = true;
private void Awake()
......@@ -29,18 +30,19 @@ public class DragDrop : MonoBehaviour, IDragHandler, IDropHandler
public void OnDrop(PointerEventData eventData)
{
if (Ui.protec == false)
{
textshowed = GameObject.Find("nbobstacle").GetComponent<TMP_Text>();
textshowed.GetComponent<TMP_Text>().text = "dffd";
}
else
while(block == true)
{
textshowed = GameObject.Find("nbobstacle").GetComponent<TMP_Text>();
textshowed.GetComponent<TMP_Text>().text = "aaaaa";
Ui.nbObst = Ui.nbObst - 1;
Ui.difficulty = Ui.difficulty + 1;
block = false;
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
public class UiProtec : MonoBehaviour
{
public void protectedUi()
{
Ui.protec = true;
}
public void unProtectedUi()
{
Ui.protec = false;
}
}
......@@ -6,12 +6,12 @@ using UnityEngine.EventSystems;
public class midObj : MonoBehaviour, IDropHandler
{
private GameObject go;
public void OnDrop(PointerEventData eventData)
{
float Uix = GameObject.Find("Image").transform.position.x;
float Uiy = GameObject.Find("Image").transform.position.y;
Ui.nameObj = GameObject.FindWithTag("moyen").tag;
float objx = GameObject.Find("bin").transform.position.x;
float objy = GameObject.Find("bin").transform.position.y;
......@@ -20,17 +20,11 @@ public class midObj : MonoBehaviour, IDropHandler
{
go = GameObject.FindWithTag("moyen");
Destroy(go);
Ui.difficulty = Ui.difficulty - 2;
Ui.nbObst = Ui.nbObst + 1;
}
if (Uix + 888.2423/2 > Input.mousePosition.x && Uix - 888.2423/2 < Input.mousePosition.x && objy + 66.11261/2 > Input.mousePosition.y && Uiy - 66.11261/2 < Input.mousePosition.y)
{
Ui.protec = false;
}
else
{
Ui.protec = true;
}
}
}
......@@ -9,6 +9,8 @@ public class strongObj : MonoBehaviour, IDropHandler
public void OnDrop(PointerEventData eventData)
{
Ui.nameObj = GameObject.FindWithTag("fort").tag;
float objx = GameObject.Find("bin").transform.position.x;
float objy = GameObject.Find("bin").transform.position.y;
......@@ -17,7 +19,8 @@ public class strongObj : MonoBehaviour, IDropHandler
{
go = GameObject.FindWithTag("fort");
Destroy(go);
Ui.difficulty = Ui.difficulty - 3;
Ui.nbObst = Ui.nbObst + 1;
}
}
......
......@@ -9,15 +9,20 @@ public class weakObj : MonoBehaviour, IDropHandler
public void OnDrop(PointerEventData eventData)
{
Ui.nameObj = GameObject.FindWithTag("faible").tag;
float objx = GameObject.Find("bin").transform.position.x;
float objy = GameObject.Find("bin").transform.position.y;
if (objx + 90 > Input.mousePosition.x && objx - 90 < Input.mousePosition.x && objy + 90 > Input.mousePosition.y && objy - 90 < Input.mousePosition.y)
{
go = GameObject.FindWithTag("faible");
Destroy(go);
{
go = GameObject.FindWithTag("faible");
Destroy(go);
Ui.difficulty = Ui.difficulty - 1;
Ui.nbObst = Ui.nbObst + 1;
}
}
......
......@@ -61,9 +61,6 @@
GameObject.Find("Sportifs").GetComponent<RunnersFactory>().enabled = true;
}
//! @param start Position du @b GameObject de départ.
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using TMPro;
public class DiffScale : MonoBehaviour
{
public TMP_Text textshowed;
// Start is called before the first frame update
void Start()
{
......@@ -24,7 +25,8 @@ public class DiffScale : MonoBehaviour
Ui.difficulty = 0;
}
textshowed = GameObject.Find("nbobstacle").GetComponent<TMP_Text>();
textshowed.GetComponent<TMP_Text>().text = "Obstacles restants : " + Ui.nbObst.ToString();
}
}
......@@ -8,13 +8,15 @@ public class Ui : MonoBehaviour
public static bool stop = false;
public static bool start = false;
public static bool protec = false;
public static float motiv;
public static float difficulty;
public static int fame;
public static int nbObst;
public static int nbObst = 5;
public static string nameObj;
public GameObject prefab;
public Canvas parent;
}
......@@ -8,9 +8,9 @@ public class nbObstacle : MonoBehaviour
public TMP_Text textshowed;
public static void decreaseObstacle()
private void Start()
{
Ui.nbObst = Ui.nbObst - 1;
textshowed.GetComponent<TMP_Text>().text = "Obstacles restants : " + Ui.nbObst.ToString();
}
}
namespace Scripts.Waypoints
{
using UnityEngine;
using Mapbox.Utils;
using Mapbox.Unity.Map;
using Mapbox.Unity.MeshGeneration.Factories;
using Mapbox.Unity.Utilities;
using System.Collections.Generic;
using UnityEngine;
using Mapbox.Utils;
using Mapbox.Unity.Map;
using Mapbox.Unity.MeshGeneration.Factories;
using Mapbox.Unity.Utilities;
using System.Collections.Generic;
using Scripts.Routes;
using Scripts.Map;
//! @authors MapBox
//! Wakestufou
//! @brief Fait apparaître des waypoints sur la Map.
//! @details Cette classe s'occupe de transformer une liste de coordonnées GPS en waypoints liés à la map.
//! De cette maniètre la caméra peut bouger, les waypoints resterons à leur position de base.
//! du placement des waypoints et tu tracé de la route.
public class SpawnOnMap : MonoBehaviour
{
[SerializeField]
AbstractMap _map;
{
// Champs publiques
public List<GameObject> spawnedObjects; //!< Liste des waypoints placés.
public Transform parent; //!< Parent de la liste des waypoints placés.
[SerializeField]
[Geocode]
Vector2d[] _locations;
[SerializeField]
float _spawnScale = 1f;
[SerializeField]
float _spawnScaleStartEnd = 6f;
[SerializeField]
GameObject _markerPrefab;
[SerializeField]
GameObject _prefabDebut;
[SerializeField]
GameObject _prefabFin;
public List<GameObject> _spawnedObjects;
public Transform parent;
private float _zoom;
private static SpawnOnMap instance;
// Champs privés
private float _zoom; //!< Valeur du zoom de la caméra sur la map.
private static SpawnOnMap _instance; //!< Instance actuelle.
[SerializeField] AbstractMap _map; //!< Map Google Street View.
[SerializeField] [Geocode] Vector2d[] _locations; //!< Liste des positions GPS des waypoints à placer.
[SerializeField] float _spawnScale = 1f; //!< Taille d'un waypoint de base.
[SerializeField] float _spawnScaleStartEnd = 6f; //!< Taille des waypoints de départ et d'arrivée.
[SerializeField] GameObject _markerPrefab; //!< Préfabriqué d'un waypoint de base.
[SerializeField] GameObject _startPrefab; //!< Préfabriqué du waypoint de départ.
[SerializeField] GameObject _endPrefab; //!< Préfabriqué du waypoint d'arrivée.
//! @brief Se lance au lancement du script.
//! @details Crée les waypoints sur la map à partir des coordonnées GPS.
void Start()
{
instance = this;
_instance = this;
List<Vector2d> Waypoints = new List<Vector2d>(WaypointsFactory.getInstance().getWp());
_locations = new Vector2d[Waypoints.Count];
_spawnedObjects = new List<GameObject>();
spawnedObjects = new List<GameObject>();
for (int i = 0; i < _locations.Length; i++)
{
_locations[i] = Waypoints[i];
var instances = Instantiate(_markerPrefab, parent); ;
var _instances = Instantiate(_markerPrefab, parent); ;
if (i == 0)
{
instances = Instantiate(_prefabDebut, parent);
instances.transform.localScale = new Vector3(_spawnScaleStartEnd, _spawnScaleStartEnd, _spawnScaleStartEnd);
_instances = Instantiate(_startPrefab, parent);
_instances.transform.localScale = new Vector3(_spawnScaleStartEnd, _spawnScaleStartEnd, _spawnScaleStartEnd);
}
else if (i == _locations.Length - 1)
{
instances = Instantiate(_prefabFin, parent);
instances.transform.localScale = new Vector3(_spawnScaleStartEnd, _spawnScaleStartEnd, _spawnScaleStartEnd);
_instances = Instantiate(_endPrefab, parent);
_instances.transform.localScale = new Vector3(_spawnScaleStartEnd, _spawnScaleStartEnd, _spawnScaleStartEnd);
}
else
{
instances.transform.localScale = new Vector3(_spawnScale, _spawnScale, _spawnScale);
_instances.transform.localScale = new Vector3(_spawnScale, _spawnScale, _spawnScale);
}
instances.transform.localPosition = _map.GeoToWorldPosition(_locations[i], true);
_spawnedObjects.Add(instances);
_instances.transform.localPosition = _map.GeoToWorldPosition(_locations[i], true);
spawnedObjects.Add(_instances);
}
//GameObject.Find("Map").GetComponent<QuadTreeCameraMovement>().enabled = true;
//_cam = GameObject.Find("GameManager").GetComponent<QuadTreeCameraMovement>();
//_cam.enabled = true;
//_cam.minZoom = 0;
_zoom = _map.Zoom;
}
//! @brief Se répète toutes les 14ms (temps par défaut dans Unity).
//! @details Met à jour les waypoints de la map afin qu'ils gardent leur place réelle et non leur position Unity.
private void Update()
{
int count = _spawnedObjects.Count;
int count = spawnedObjects.Count;
for (int i = 0; i < count; i++)
{
var spawnedObject = _spawnedObjects[i];
var spawnedObject = spawnedObjects[i];
var location = _locations[i];
spawnedObject.transform.localPosition = _map.GeoToWorldPosition(location, true);
spawnedObject.transform.localScale = new Vector3(_spawnScale, _spawnScale, _spawnScale);
......@@ -88,12 +81,11 @@
if (VerifVisible())
{
GameObject.Find("GameManager").GetComponent<RouteTracer>().enabled = true;
//this.enabled = false;
} else if (_zoom <= 2)
}
else if (_zoom <= 2)
{
GameObject.Find("GameManager").GetComponent<RouteTracer>().enabled = true;
//this.enabled = false;
}
}
else
{
_zoom -= 0.25f;
......@@ -101,24 +93,32 @@
}
}
//! @brief Test la visibilité des waypoints.
//! @details Si un waypoints n'est dans le champs de vision de la caméra.
//! @return @e bool Si un waypoint n'est pas visible renvoie @b false, sinon renvoie @b true
private bool VerifVisible()
{
bool verif = true;
for (int i = 0; i<_spawnedObjects.Count; i++)
for (int i = 0; i < spawnedObjects.Count; i++)
{
if (!_spawnedObjects[i].GetComponent<Renderer>().isVisible) verif = false;
if (!spawnedObjects[i].GetComponent<Renderer>().isVisible) verif = false;
}
return verif;
}
//! @brief Récupère les objets crées.
//! @return @e List<GameObject> Liste des waypoints qui ont été placés.
public List<GameObject> getSpawnedObject()
{
return _spawnedObjects;
return spawnedObjects;
}
//! @brief Récupère l'instance de Waypoints.SpawnOnMap
//! @details Récupère l'instance du script actuel afin de respecter un patterne @b singleton.
//! @return @e SpawnOnMap Instance actuelle.
public static SpawnOnMap getInstance()
{
return instance;
return _instance;
}
}
}
\ No newline at end of file