Ejemplo n.º 1
0
    /* SERVER ONLY */
    public void EnvironmentChange(string env)
    {
        Debug.Log(env);
        // change env to server
        if (env == "mirror" || env == "mirrorAlt")
        {
            scenarioEvents.ToggleMirror(!scenarioEvents.mirrorAct, 0, 0);
        }

        // change env to clients
        networkManager.EnvironmentChangeOrder(userManager.usersPlaying, env);
    }
Ejemplo n.º 2
0
    public void ChangeVisualisationMode(string newVisualisationMode, GameEngine gameEngine, bool fade)
    {
        // if i'm server, i send order to clients
        if (me._userRole == UserRole.Server)
        {
            gameEngine.osc.sender.SendVisualisationChange(newVisualisationMode, usersPlaying);
        }

        if (gameEngine.currentVisualisationMode == "2D")
        {
            Camera.main.cullingMask = scenarioEvents.oldMirrorMask;                                             // revert camera layers if last mode was 2D
        }
        // main parameters

        if (newVisualisationMode == "0")
        {
            scenarioEvents.SetTimeOfDay(6);
        }
        else
        {
            scenarioEvents.SetTimeOfDay(8);
        }


        //
        if ((newVisualisationMode == "2B" || newVisualisationMode == "2C" || newVisualisationMode == "2D" || newVisualisationMode == "2E"))
        {
            if (newVisualisationMode == "2D" && gameEngine._userRole == UserRole.Player)
            {
                scenarioEvents.ToggleMirror(true, 1, ReturnMyRank() + 1);                                                                       // only the others reflection
            }
            else if (newVisualisationMode == "2E" && gameEngine._userRole == UserRole.Player)
            {
                scenarioEvents.ToggleMirror(true, 2, ReturnMyRank() + 1);                                                                            // only the others reflection
            }
            else
            {
                scenarioEvents.ToggleMirror(true, 0, 0);  // normal mode
            }
        }
        else if (scenarioEvents.mirrorAct)
        {
            scenarioEvents.ToggleMirror(false, 0, 0);
        }


        if (newVisualisationMode != "2C")// && !(gameEngine._userRole == UserRole.Playback && gameEngine.playbackManager.mode == PlaybackMode.Offline)) // if we're in playback offline mode, we keep different colors
        {
            if (usersPlaying.Count > 1)
            {
                ChangePlayerColor(usersPlaying[1], whiteColor);
            }
            if (usersPlaying.Count > 2)
            {
                ChangePlayerColor(usersPlaying[2], whiteColor);
            }
        }

        else if (gameEngine._userRole == UserRole.Playback && gameEngine.playbackManager.mode == PlaybackMode.Offline)
        {
            if (usersPlaying.Count > 1)
            {
                ChangePlayerColor(usersPlaying[1], playbackColor1);
            }
            if (usersPlaying.Count > 2)
            {
                ChangePlayerColor(usersPlaying[2], playbackColor2);
            }
        }

        if (newVisualisationMode == "3a") // median
        {
            scenarioEvents.ActivateMedian(MedianMode.median);
        }

        if (newVisualisationMode == "3b") // barycentre
        {
            scenarioEvents.ActivateMedian(MedianMode.babis);
        }

        if (newVisualisationMode == "1D") // barycentre
        {
            HidePlayers();
        }

        if (newVisualisationMode == "m1")
        {
            //scenarioEvents.medianDancer.ChangeColor()
        }
        if (newVisualisationMode == "m2")
        {
            scenarioEvents.medianDancer.ChangeColor(Color.red);
        }
        if (newVisualisationMode == "m3")
        {
            scenarioEvents.medianDancer.ChangeColor(Color.blue);
        }
        if (newVisualisationMode == "m4")
        {
            scenarioEvents.medianDancer.ChangeColor(Color.magenta);
        }


        /*
         * if(weight == 0)
         * {
         *  medianDancer.GetComponent<MedianDancer>().weight = 1;
         * }
         * else if (weight == 25)
         * {
         *  medianDancer.GetComponent<MedianDancer>().weight = 0.5f;
         * }
         * else if (weight == 40)
         * {
         *  medianDancer.GetComponent<MedianDancer>().weight = 0.2f;
         * }
         * else if (weight == 50)
         * {
         *  medianDancer.GetComponent<MedianDancer>().weight = 0;
         * }
         * else if (weight == 60)
         * {
         *  medianDancer.GetComponent<MedianDancer>().weight = -0.2f;
         * }
         * else if (weight == 75)
         * {
         *  medianDancer.GetComponent<MedianDancer>().weight = -0.5f;
         * }
         * else if (weight == 100)
         * {
         *  medianDancer.GetComponent<MedianDancer>().weight = -1;
         * }*
         */


        // both share same weight, but 0 on one side is 100 on the other
        else if (newVisualisationMode == "0/100")
        {
            scenarioEvents.ChangeMedianWeight(1);
        }

        else if (newVisualisationMode == "25/75")
        {
            scenarioEvents.ChangeMedianWeight(0.5f);
        }

        else if (newVisualisationMode == "40/60")
        {
            scenarioEvents.ChangeMedianWeight(0.2f);
        }

        else if (newVisualisationMode == "50/50")
        {
            scenarioEvents.ChangeMedianWeight(0);
        }

        else if (newVisualisationMode == "60/40")
        {
            scenarioEvents.ChangeMedianWeight(-0.2f);
        }

        else if (newVisualisationMode == "75/25")
        {
            scenarioEvents.ChangeMedianWeight(-0.5f);
        }

        else if (newVisualisationMode == "100/0")
        {
            scenarioEvents.ChangeMedianWeight(-1);
        }

        // pourquoi les poids sont pareils de part et d'autre ??
        else if (newVisualisationMode == "0/0")
        {
            if (me._registeredRank == 0)
            {
                scenarioEvents.ChangeMedianWeight(1);
            }
            else if (me._registeredRank == 1)
            {
                scenarioEvents.ChangeMedianWeight(-1);
            }
            else
            {
                scenarioEvents.ChangeMedianWeight(0);
            }
        }

        else if (newVisualisationMode == "25/25")
        {
            if (me._registeredRank == 0)
            {
                scenarioEvents.ChangeMedianWeight(0.5f);
            }
            else if (me._registeredRank == 1)
            {
                scenarioEvents.ChangeMedianWeight(-0.5f);
            }
            else
            {
                scenarioEvents.ChangeMedianWeight(0);
            }
        }

        else if (newVisualisationMode == "40/40")
        {
            if (me._registeredRank == 0)
            {
                scenarioEvents.ChangeMedianWeight(0.2f);
            }
            else if (me._registeredRank == 1)
            {
                scenarioEvents.ChangeMedianWeight(-0.2f);
            }
            else
            {
                scenarioEvents.ChangeMedianWeight(0);
            }
        }

        else if (newVisualisationMode == "60/60")
        {
            if (me._registeredRank == 0)
            {
                scenarioEvents.ChangeMedianWeight(-0.2f);
            }
            else if (me._registeredRank == 1)
            {
                scenarioEvents.ChangeMedianWeight(0.2f);
            }
            else
            {
                scenarioEvents.ChangeMedianWeight(0);
            }
        }

        else if (newVisualisationMode == "75/75")
        {
            if (me._registeredRank == 0)
            {
                scenarioEvents.ChangeMedianWeight(-0.5f);
            }
            else if (me._registeredRank == 1)
            {
                scenarioEvents.ChangeMedianWeight(0.5f);
            }
            else
            {
                scenarioEvents.ChangeMedianWeight(0);
            }
        }

        else if (newVisualisationMode == "100/100")
        {
            if (me._registeredRank == 0)
            {
                scenarioEvents.ChangeMedianWeight(-1);
            }
            else if (me._registeredRank == 1)
            {
                scenarioEvents.ChangeMedianWeight(1);
            }
            else
            {
                scenarioEvents.ChangeMedianWeight(50);
            }
        }



        // per user parameters
        foreach (UserData user in usersPlaying)
        {
            if (user._userRole == UserRole.Player)
            {
                if (gameEngine.currentVisualisationMode == "2C" && newVisualisationMode != "2C")
                {
                    ChangePlayerColor(user, whiteColor); // revert
                }
                if (newVisualisationMode == "0")         // basic condition
                {
                    if (me._userRole == UserRole.Server || me._userRole == UserRole.Viewer || user._ID == me._ID)
                    {
                        user.ChangeSkin(this, "all");
                    }
                    else
                    {
                        user.ChangeSkin(this, "nothing");
                    }
                }

                else if (newVisualisationMode == "1A") // every spheres visible
                {
                    user.ChangeSkin(this, "all");
                }

                else if (newVisualisationMode == "1B") // other's hand visible, mine are not
                {
                    if (user._ID == me._ID)
                    {
                        user.ChangeSkin(this, "noHands");
                    }
                    else
                    {
                        user.ChangeSkin(this, "all");
                    }
                }

                else if (newVisualisationMode == "1C") // other's hand visible, mine are not
                {
                    if (user._ID != me._ID)
                    {
                        user.ChangeSkin(this, "nothing");
                    }
                    else
                    {
                        user.ChangeSkin(this, "all");
                    }
                }

                else if (newVisualisationMode == "2B") // mirror mode, same color
                {
                    user.ChangeSkin(this, "all");
                }
                else if (newVisualisationMode == "2C") // mirror mode, different color
                {
                    user.ChangeSkin(this, "all");
                    if (user._ID == me._ID)
                    {
                        ChangePlayerColor(user, whiteColor);
                    }
                    else
                    {
                        ChangePlayerColor(user, cyanColor);
                    }
                    // different color
                }

                else
                {
                    Debug.Log("%% Wrong VisualisationMode Request ! %%");
                }
            }
        }
        Debug.Log("Visualisation changed : " + newVisualisationMode);

        gameEngine.currentVisualisationMode = newVisualisationMode;
    }