Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.SceneManagement;
- using Random = System.Random;
- public class Game : MonoBehaviour
- {
- public RequestToServer rts;
- public MapGenerator mg;
- public string mapUID;
- public int seed;
- public Vector3[] vector3;
- public int gameEnd;
- public static Game g;
- public MapGenMode mapGenMode;
- void Start()
- {
- rts = gameObject.AddComponent<RequestToServer>();
- }
- void Update()
- {
- if (rts.response != null)
- {
- rts.response = null;
- // GET MAP_UID
- Dictionary<string, string> mapInfo = new Dictionary<string, string>();
- mapInfo = Json.DeserializeIntoString(rts.response);
- MapGenerator.uid = mapInfo["map_uid"];
- }
- }
- /*WARNING: THE FOLLOWING FUNCTIONS ARE ONLY TO BE CALLED BY MAPGENERATOR,
- IF YOU WANT TO USE THEM, SET MAPGENMODE TO THE CORRESPONDING VALUE AND SWITCH TO THE MAP SCENE*/
- public void StartGame()
- {
- rts = gameObject.AddComponent<RequestToServer>();
- mg = FindObjectOfType<MapGenerator>();
- mg.seed = new Random().Next(1,100);
- mg.GenerateMap();
- mg.GetSpawnablePoints();
- mg.AddFlagCoords(100);
- Dictionary<string,string> shitToSend = new Dictionary<string, string>();
- shitToSend.Add("token", Login.token);
- shitToSend.Add("seed", mg.seed.ToString());
- shitToSend.Add("Vector3", Json.SerializeVector3(mg.flagCoords.ToArray()));
- Debug.Log("ready to send:" + Json.SerializeVector3(mg.flagCoords.ToArray()));
- StartCoroutine(rts.PostRequest("https://doe:doe@game.strategydivision.fr/map/create_map.php", shitToSend));
- }
- }
- public enum MapGenMode
- {
- Create, Join
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement