Exemple #1
0
    private void GameSetup()
    {
        NetworkManager = GameObject.Find("NetworkManager").GetComponent <NetworkManagerParty>();

        int        counter = 0;
        GameObject SpawnedObject;
        GameObject SpawndObject;

        foreach (var Player in NetworkManager.PartyPlayers)
        {
            SpawndObject = Instantiate(GameBoardPlayer);
            SpawndObject.GetComponent <GamePlayerInformation>().PlayerNetworkClone = Player;
            PlayerList.Add(SpawndObject);

            SpawnedObject = Instantiate(BoardObject);
            SpawnedObject.transform.parent        = StartingLocations[counter].transform;
            SpawnedObject.transform.localPosition = new Vector3(0, 0, 0);
            SpawnedObject.GetComponent <PlayerObjectMovmentScript>().ConnectedPlayer = SpawndObject.GetComponent <GamePlayerInformation>();
            SpawndObject.GetComponent <GamePlayerInformation>().BoardObject          = SpawnedObject.GetComponent <PlayerObjectMovmentScript>();
            SpawnedObject.GetComponent <PlayerObjectMovmentScript>().NextTile        = FirstTile;
            counter++;
        }
        StartCoroutine("DecideTurnOrder");
        // Decide the order in what players go
    }
    // Use this for initialization
    void Start()
    {
        GMScript = GM.GetComponent <GameManagerScript>();
        int ChildCount = SpawningPoints.transform.GetChildCount();

        for (int i = 0; i < ChildCount; i++)
        {
            GameObject ChildGO;
            ChildGO = SpawningPoints.transform.GetChild(i).gameObject;
            GameObject SpawnedObject;
            SpawnedObject = Instantiate(SphereSpawning, ChildGO.transform.position, ChildGO.transform.rotation);
            int randomMat = Random.Range(0, 3);
            SpawnedObject.GetComponent <SphereSpawningScript>().SetMat = randomMat;
            SpawnedObject.GetComponent <SphereSpawningScript>().GM     = GM;
        }
    }
Exemple #3
0
    public PooledObject Object(Spawns o, Color color, float mass, Vector3 pos, float corruption)
    {
        PooledObject  prefab;
        SpawnedObject spawnedObject = null;

        if (objects.TryGetValue(o, out prefab))
        {
            if (key == -1)
            {
                key = TerrainGenerator.GetNoise2D
                      (
                    pos,
                    Config.Instance.environment.key,
                    NoiseType.SimplexValue
                      );
            }

            if (o == Spawns.Pickup || o == Spawns.SilverPickup || o == Spawns.BlackPickup)
            {
                spawnedObject = SpawnPickup(prefab, color, key, corruption);
            }
            else
            {
                spawnedObject = SpawnBall(prefab, color, key, corruption);
            }
            if (spawnedObject == null)
            {
                return(null);
            }

            spawnedObject.transform.position = pos;
            spawnedObject.mass = mass;
            spawnedObject.StartSlowUpdate();
        }

        return(spawnedObject.GetComponent <PooledObject>());
    }
Exemple #4
0
    public virtual async Task SaveCurrentObjectAnchorToCloudAsync()
    {
        feedbackBox.text = "Saving Spawned Game Object";
        // Get the cloud-native anchor behavior
        CloudNativeAnchor cna = SpawnedObject.GetComponent <CloudNativeAnchor>();


        // If the cloud portion of the anchor hasn't been created yet, create it
        if (cna.CloudAnchor == null)
        {
            cna.NativeToCloud();
        }

        // Get the cloud portion of the anchor
        CloudSpatialAnchor cloudAnchor = cna.CloudAnchor;

        // In this sample app we delete the cloud anchor explicitly, but here we show how to set an anchor to expire automatically
        cloudAnchor.Expiration = DateTimeOffset.Now.AddDays(7);

        String test = CloudManager.SessionStatus == null ? "null" : "not null";

        feedbackBox.text = $"Cloud manager is ready: {CloudManager.IsReadyForCreate} and status: {test}";

        while (!CloudManager.IsReadyForCreate)
        {
            await Task.Delay(330);

            float createProgress = CloudManager.SessionStatus.RecommendedForCreateProgress;
            feedbackBox.text = $"Move your device to capture more environment data: {createProgress:0%}";
        }

        bool success = false;

        feedbackBox.text = "Saving...";

        try
        {
            // Actually save
            await CloudManager.CreateAnchorAsync(cloudAnchor);

            // Store
            var currentCloudAnchor = cloudAnchor;

            // Success?
            success = currentCloudAnchor != null;

            if (success && !isErrorActive)
            {
                // Await override, which may perform additional tasks
                // such as storing the key in the AnchorExchanger
                feedbackBox.text = $"Saved Anchor succesfully: {currentCloudAnchor.Identifier}";
                _savedAnchor     = currentCloudAnchor;

                //POSTING ANCHOR
                string jsonString = JsonUtility.ToJson(new  AnchorDTO {
                    identifier = currentCloudAnchor.Identifier, model = this.model, userId = this.currentUser.id, longitude = Input.location.lastData.longitude, latitude = Input.location.lastData.latitude, srid = 4326
                });
                Debug.Log("JSON ANCHOR : " + jsonString);

                using (HttpClient client = new HttpClient())
                {
                    HttpContent httpContent = new StringContent(jsonString, Encoding.UTF8, "application/json");
                    print("MESSAGE : " + httpContent.ReadAsStringAsync().Result);
                    HttpResponseMessage httpResponseMessage = client.PostAsync($"{ApiURL}/api/AnchorsAPI", httpContent).Result;
                    if (httpResponseMessage.IsSuccessStatusCode)
                    {
                        HttpContent content  = httpResponseMessage.Content;
                        string      response = content.ReadAsStringAsync().Result;
                        feedbackBox.text += $"\n API Response: {response}";
                    }
                    else
                    {
                        feedbackBox.text += $"\n API ERROR Response: {httpResponseMessage.StatusCode}";
                    }
                }
                _uiHandler.SetScreenCaptureVisible(true);
                await OnSaveCloudAnchorSuccessfulAsync();
            }
            else
            {
                OnSaveCloudAnchorFailed(new Exception("Failed to save, but no exception was thrown."));
            }
        }
        catch (Exception ex)
        {
            OnSaveCloudAnchorFailed(ex);
        }
    }