Example #1
0
    void Start()
    {
        playMain = PlayMain.Singleton.GetComponent <PlayMain>();
        toggleManualPlacing.isOn = playMain.manualPlaceEnabled;

        playMain.OnNextPhase  += PhaseSwitched;
        playMain.OnMatchStart += OnMatchStart;

        UpdateAnim();
        UpdateTimeText();
        UpdateScoreText();

        menuBackground.SetActive(false);
        menuMain.SetActive(false);
        menuStrategy.SetActive(false);

        MenuStack = new Stack <GameObject>();
        PushMenu(menuMain);

        if (recorder == null)
        {
            recorder = new DataRecorder();
        }

        blueInputField.text   = $"127.0.0.1:{StrategyConfig.BlueStrategyPort}";
        yellowInputField.text = $"127.0.0.1:{StrategyConfig.YellowStrategyPort}";
    }
Example #2
0
    // Tries to migrate the user to the target actor.
    // If targetActor == null, the user will be actorless.
    public void MigrateUserTo(VoosActor targetActor)
    {
        PlayMain   pm = playMain.GetComponent <PlayMain>();
        PlayerBody targetPlayerBody = targetActor?.GetPlayerBody();

        if (targetActor != null && (!targetActor.GetIsPlayerControllable() || null == targetPlayerBody))
        {
            targetActor.SetIsPlayerControllable(true);
            targetPlayerBody = targetActor.GetPlayerBody();
            Debug.Assert(targetPlayerBody != null, "MigrateUserTo could not add a PlayerBody to target actor.");
        }
        pm.SetPlayerBody(targetPlayerBody);
        // If we are in play mode, we need to reparent the user body.
        // Otherwise this will be done later, when we enter play mode.
        if (!InEditMode())
        {
            userBody.transform.SetParent(playMain.bodyParent);
            userBody.transform.localPosition = Vector3.zero;
            userBody.transform.localRotation = Quaternion.identity;
        }
        if (targetActor != null)
        {
            targetActor.RequestOwnership();
        }
        VoosActor playMainActor = pm.GetPlayerActor();

        Debug.Assert(targetActor == playMainActor, "MigrateUserTo didn't succeed, we wanted targetActor to be " + targetActor + " but PlayMain still has " + playMain);
    }