Пример #1
0
    private void SpawnTargetPosition(GameObject prefab, Coordinate coordinate)
    {
        GameObject newTargetPosition = Instantiate(prefab, game.transform);

        TargetPosition newTargetPositionScript = newTargetPosition.GetComponent <TargetPosition>();

        newTargetPositionScript.UpdateInformation(coordinate);
        targetPositionInstances.Add(newTargetPosition);
    }
Пример #2
0
    private void UpdateGame()
    {
        if (serverController.game.started)
        {
            if (!hasStarted)
            {
                gameStartText.text = "";
                serverController.uiManager.ShowPopup("The game has started", serverController.uiManager.popupDuration);
                hasStarted = true;

                foreach (GameObject targetPositionInstance in targetPositionInstances)
                {
                    Destroy(targetPositionInstance);
                }
            }
        }
        else
        {
            if (serverController.isAtStart)
            {
                gameStartText.text = "Wait for other players to get to their start position.";
            }
            else
            {
                gameStartText.text = "Please move to your start position.";
            }
        }



        if (playerInstances.Count == 0)
        {
            CreatePlayerList();
        }
        else
        {
            List <Player> playerList = serverController.game.players;
            for (int i = 0; i < playerList.Count; i++)
            {
                Player            player = playerList[i];
                GameObject        otherPlayerInstance       = playerInstances[i];
                OtherPlayerScript otherPlayerInstanceScript = otherPlayerInstance.GetComponent <OtherPlayerScript>();
                otherPlayerInstanceScript.UpdateInformation(player.position);
            }

            if (targetPositionInstances.Count > 0)
            {
                foreach (GameObject targetPositionInstance in targetPositionInstances)
                {
                    TargetPosition targetPosition = targetPositionInstance.GetComponent <TargetPosition>();
                    targetPosition.UpdateInformation(targetPosition.targetCoordinate);
                }
            }
        }
    }