Inheritance: RealTimeMultiplayerListener
Exemple #1
0
 void Start()
 {
     instance   = this;
     PlayerName = PlayerPrefs.GetString("PlayerName");
     CurrentMap = MapList[0];
     DontDestroyOnLoad(gameObject);
 }
Exemple #2
0
 void EventGenerated(string regionName, string eventName, double[] pickedConsequences0,
                     double[] pickedConsequences1, double[] pickedConsequences2, double[] pickedTemporaryConsequences0,
                     double[] pickedTemporaryConsequences1, double[] pickedTemporaryConsequences2)
 {
     MultiplayerManager.CallStartEvent(regionName, eventName, pickedConsequences0, pickedConsequences1, pickedConsequences2,
                                       pickedTemporaryConsequences0, pickedTemporaryConsequences1, pickedTemporaryConsequences2);
 }
    private void Start()
    {
        // Get references
        cameraTransform = Camera.main.transform;
        carDrifting = GetComponent<CarDrifting>();

        if(GameObject.FindWithTag("MultiplayerManager"))
        {
            multiplayerManager = GetComponent<MultiplayerManager>();
        }

        // Initialize values
        scaleValue = 0.3f;
        lerpTime = 5f;
        currentLerpTime = 0.0f;
        t = 0.0f;
        startPos1 = cameraTransform.position;
        startRot1 = cameraTransform.localRotation;
        endPos1 = wantedPosition1;
        endRot1 = Quaternion.Euler (wantedRotation1);
        startPos2 = cameraTransform.position;
        startRot2 = cameraTransform.localRotation;
        endPos2 = wantedPosition2;
        endRot2 = Quaternion.Euler (wantedRotation2);
        SetAnimation(1);
    }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="InvalidOperationException">Thrown if a TorchBase instance already exists.</exception>
        protected TorchBase()
        {
            if (Instance != null)
            {
                throw new InvalidOperationException("A TorchBase instance already exists.");
            }

            Instance = this;

            TorchVersion = Assembly.GetExecutingAssembly().GetName().Version;
            RunArgs      = new string[0];

            Plugins     = new PluginManager(this);
            Multiplayer = new MultiplayerManager(this);
            Entities    = new EntityManager(this);
            Network     = new NetworkManager(this);
            Commands    = new CommandManager(this);

            _managers = new List <IManager> {
                new FilesystemManager(this), new UpdateManager(this), Network, Commands, Plugins, Multiplayer, Entities, new ChatManager(this),
            };


            TorchAPI.Instance = this;
        }
    public void onPrivateUpdateReceived(string sender, byte[] update, bool fromUdp)
    {
        LogManager.Log(sender.ToString() + ": " + ByteHelper.GetString(update));

        string networkMessage = ByteHelper.GetString(update);

        string[] splittedMessage = networkMessage.Split(':');

        switch (splittedMessage[0])
        {
        case "DEAL":

            string[]      cardsString   = splittedMessage[1].Split('|');
            List <Card>[] splittedCards = new List <Card> [4];

            for (int i = 0; i < 4; i++)
            {
                splittedCards[i] = new List <Card>();
                string[] cards = cardsString[i].Split(',');
                for (int j = 0; j < 13; j++)
                {
                    splittedCards[i].Add(CardHelper.StringToCard(cards[j]));
                }
            }

            multiplayerGamers.GameTable.gameTable.ReceiveCards(splittedCards);
            MultiplayerManager.SendBytes(ByteHelper.GetBytes("DEALCALLBACK"));
            break;
        }
    }
Exemple #6
0
    public void RpcLockTeams()
    {
        LockTeams();
        List <Player> list        = MultiplayerManager.GetInstance().playerList;
        Player        localPlayer = MultiplayerManager.FindPlayer(GetLocalPlayer().GetComponent <NetworkIdentity>().netId);
        string        info        = "You are on the " + (localPlayer.team == 0 ? "Red" : "Blue") + " team ";
        List <Player> teammates   = list.FindAll(p => p.team == localPlayer.team && !p.Equals(localPlayer));

        if (teammates.Count > 0)
        {
            info += "(Teammates: ";
            for (int i = 0; i < teammates.Count - 1; i++)
            {
                info += teammates[i].name + ", ";
            }
            info += teammates[teammates.Count - 1].name + ")";
        }
        infoText.text = info;
        //Disable other team's player names
        foreach (Player p in list)
        {
            if (p.team != localPlayer.team)
            {
                ClientScene.FindLocalObject(p.objectId).SetActive(false);
            }
        }
        humanToggle.isOn = true;
    }
Exemple #7
0
 //This is hooked to the Join Server button
 public void StartClient()
 {
     if (!NetworkClient.active)
     {
         MultiplayerManager.GetInstance().StartClient();
     }
 }
    public bool needToLeave = false; //Used by client when room creator left room


    void Start()
    {
        Instance = this;
        DontDestroyOnLoad(gameObject);
        MasterServer.ipAddress = "192.168.1.91";
        MasterServer.port      = 23466;
    }
    void Start()
    {
        gameManager = GameObject.Find("GameManager").GetComponent <MultiplayerManager>();
        bottomObj   = GameObject.Find("Bottom Object");

        rbs = GetComponentsInChildren <Rigidbody>();
    }
Exemple #10
0
    // Use this for initialization
    void Start()
    {
        instance   = this;
        playerName = PlayerPrefs.GetString("Player Name");                     //get saved player settings for their name

        DirectoryInfo levelDir = new DirectoryInfo("Assets/Resources/Levels"); //load all the levels

        FileInfo[] levelInfo = levelDir.GetFiles("*.*");

        foreach (FileInfo level in levelInfo)
        {
            if (level.Name.EndsWith(".xml"))
            {
                MapSettings newLevelDisplay = new MapSettings();
                newLevelDisplay.mapName     = level.Name.Remove(level.Name.Length - 4);
                newLevelDisplay.mapLoadName = level.Name.Remove(level.Name.Length - 4);
                MapList.Add(newLevelDisplay);
            }
        }

        if (MapList.Count > 0)
        {
            currentMap = MapList[0];
        }

        skins = Resources.LoadAll("Skins");
    }
Exemple #11
0
 // Use this for initialization
 void Start()
 {
     Instance    = this;
     _lobbyHooks = GetComponent <LobbyHook>();
     DontDestroyOnLoad(gameObject);
     SwitchPanel(MainMenuPanel);
 }
Exemple #12
0
        /// <summary>
        ///
        /// </summary>
        /// <exception cref="InvalidOperationException">Thrown if a TorchBase instance already exists.</exception>
        protected TorchBase()
        {
            if (Instance != null)
            {
                throw new InvalidOperationException("A TorchBase instance already exists.");
            }

            Instance = this;

            TorchVersion = Assembly.GetExecutingAssembly().GetName().Version;
            RunArgs      = new string[0];

            Managers = new DependencyManager();

            Plugins     = new PluginManager(this);
            Multiplayer = new MultiplayerManager(this);
            Entities    = new EntityManager(this);
            Network     = new NetworkManager(this);
            Commands    = new CommandManager(this);

            Managers.AddManager(new FilesystemManager(this));
            Managers.AddManager(new UpdateManager(this));
            Managers.AddManager(Network);
            Managers.AddManager(Commands);
            Managers.AddManager(Plugins);
            Managers.AddManager(Multiplayer);
            Managers.AddManager(Entities);
            Managers.AddManager(new ChatManager(this));


            TorchAPI.Instance = this;
        }
Exemple #13
0
 public void showPlayerDeadMessage(NetworkPlayer player)
 {
     playerDeathMessage    = MultiplayerManager.getMPPlayer(player).playerName + " has been defeated";
     isMessageShown        = true;
     isMessageShownForever = false;
     startTime             = Time.time;
 }
    //the spare tower comes out of board and lands on the target tile
    private void FlyPawnOut(Transform targetPawn, Vector3 targetPosition)
    {
        float multiplier = 1;

        if (MultiplayerManager.GetPlayerTag() == Constants.PlayerTag.PLAYER_1)
        {
            if (targetPawn.position.z < 0)
            {
                multiplier = -1;
            }
            else
            {
                multiplier = 1;
            }
        }

        float   zOffset          = 2 * multiplier;
        float   zDuration        = 0.8f;
        float   yOffset          = 0.8f;
        float   rotationDuration = 0.8f;
        float   finalDuration    = 0.5f;
        Vector3 rotationValue    = new Vector3(-90, 0, 0);


        Sequence mySequence = DOTween.Sequence();

        mySequence.Append(targetPawn.DOLocalMoveZ(zOffset, zDuration));                             // move out of the side of the board
        mySequence.Append(targetPawn.DOLocalRotate(rotationValue, rotationDuration));
        mySequence.Append(targetPawn.DOLocalMoveY(yOffset, zDuration));                             //fly upwards
        mySequence.Append(targetPawn.DOMove(targetPosition, finalDuration)).SetEase(Ease.OutCubic); //finally go to the target position
    }
 // Use this for initialization
 void Start()
 {
     ui       = FindObjectOfType <UIManager>();
     mManager = FindObjectOfType <MultiplayerManager>();
     mManager.AddManager(this);
     //GenerateTiles();
 }
Exemple #16
0
 void Awake()
 {
     if (s_Instance == null) {
         s_Instance = this;
     }
     DontDestroyOnLoad(this);
 }
 public void OnCancelClick()
 {
     MultiplayerManager.GetInstance().StopMatchMaker();
     startBtn.SetActive(true);
     cancelBtn.SetActive(false);
     dialogue.SetActive(false);
 }
    private void Start()
    {
        multiplayerManagerClass = this;

        //Aktif oyuncu sahneye bağlandığı sırada Database'e kendi verilerini gönderir ve kostüm değişikliği uygulanır.
        userDataRef.Child(auth.CurrentUser.UserId).GetValueAsync().ContinueWithOnMainThread(task =>
        {
            DataSnapshot snapshot = task.Result;
            if (snapshot.GetRawJsonValue() != null)
            {
                UserData me     = JsonUtility.FromJson <UserData>(snapshot.GetRawJsonValue());
                Player playerMe = new Player();
                playerMe.userId = auth.CurrentUser.UserId;
                playerMe.nick   = me.nick;
                playerMe.skin   = me.skin;
                roomRef.Child("GameScene").Child(auth.CurrentUser.UserId).SetRawJsonValueAsync(JsonUtility.ToJson(playerMe));
                playerObject.GetComponent <Renderer>().material.color = me.skin;
            }
        });

        //Aktif oyuncunun bulunduğu odadaki oyuna bağlanacak olan oyuncu sayısı ilgili değişkene atanır.
        roomRef.GetValueAsync().ContinueWithOnMainThread(task =>
        {
            DataSnapshot snapshot = task.Result;
            if (snapshot.GetRawJsonValue() != null)
            {
                RoomData room      = JsonUtility.FromJson <RoomData>(snapshot.GetRawJsonValue());
                playingPlayerCount = room.playingPlayerCount;
            }
        });
    }
Exemple #19
0
    // Use this for initialization
    void Start()
    {
        if (SceneManager.GetActiveScene().buildIndex == 0) // Main Menu
        {
            for (int x = 0; x < board.GetLength(0); x++)
            {
                for (int y = 0; y < board.GetLength(1); y++)
                {
                    board[x, y] = false;
                }
            }
            StartCoroutine(BackgroundPlay());
        }
        mManager = FindObjectOfType <MultiplayerManager>();

        if (mManager.client != null && SceneManager.GetActiveScene().buildIndex == 0)
        {
            OnLogin();
            mManager.RefreshRooms();
        }
        if (SceneManager.GetActiveScene().buildIndex == 1 && mManager.connection != null)
        {
            if (mManager.connection.Connected)
            {
                StatusText.text = "Waiting for your opponent";
            }
        }
    }
Exemple #20
0
    private void Start()
    {
        chatQueue = new Queue();

        mpManager = GameObject.FindObjectOfType <MultiplayerManager>();

        playerCurrentChatValue = String.Empty;

        //initialize the chat slots
        //make as many as messages shown on screen
        //do math to fit all of them in a children of the chat record panel
        //textSlots = new Text[messagesShownOnScreen];
        //for (int i = 0; i < messagesShownOnScreen; i++)
        //{
        //    GameObject chatSlot = Instantiate(chatSlotPrefab);
        //    chatSlot.transform.SetParent(chatRecord.transform);
        //    RectTransform slotsRect = chatSlot.GetComponent<RectTransform>();
        //    slotsRect.anchorMin = new Vector2(0, i / (float)messagesShownOnScreen);
        //    slotsRect.anchorMax = new Vector2(1, (i + 1) / (float)messagesShownOnScreen);
        //    slotsRect.offsetMin = Vector2.zero;
        //    slotsRect.offsetMax = Vector2.zero;

        //    textSlots[i] = chatSlot.GetComponent<Text>();
        //}

        //this assumes the window won't be resized
        //calculate font size
        currentFontSize = (int)(chatEnterField.GetComponent <RectTransform>().rect.height * 0.5f - 1);
        chatEnterField.transform.Find("Text").GetComponent <Text>().fontSize = currentFontSize;
        //fetch displaybounds
        RectTransform rt = chatRecord.GetComponent <RectTransform>();

        //rt.position is actual position of rt.rect, rt.rect.position is offset... unity why
        displayBounds = new Rect(new Vector2(rt.position.x, rt.position.y) + rt.rect.position, rt.rect.size);
    }
Exemple #21
0
        /// <summary>
        /// Room Owner will send a Callback to this method after receiving feedback from all the players
        /// </summary>
        public void PlayersReadyCallback()
        {
            if (LobbyPlayerStats.RoomData.getRoomOwner() == MultiplayerManager.StaticPlayer.GetInternalPlayer().PlayerName)
            {
                MultiplayerManager.SendBytes(ByteHelper.GetBytes("START"));
            }
            GameEndingCondition gameEndingCondition = null;

            switch (MultiplayerManager.CurrentEndCondition)
            {
            case GameMode.TargetScore:
                gameEndingCondition = new TargetScoreCondition(new object[1] {
                    MultiplayerManager.CurrentEndConditionGoal
                });
                break;

            case GameMode.RoundCount:
                object[] roundCountConditionParams = new object[2];
                roundCountConditionParams[0] = this;
                roundCountConditionParams[1] = MultiplayerManager.CurrentEndConditionGoal;
                gameEndingCondition          = new RoundCountCondition(roundCountConditionParams);
                break;
            }

            game = new UnityGame(this, gameEndingCondition);
            game.Commence(UITable.MultiplayerGamers.GetPlayerByPlayerName(LobbyPlayerStats.RoomData.getRoomOwner()).GetPlayersSeat());
            state = GameState.PLAYING;
        }
    // Use this for initialization
    void Start()
    {
        if (MultiplayerManager.GetPlayerTag() == Constants.PlayerTag.PLAYER_2)
        {
            transform.parent.rotation = Quaternion.Euler(0, 180, 0);
        }
        ResetAllSquare(); //Turns off highlights
        if (!Constants.isAI)
        {
            InitializeGameRules += InitializeMultiplayerGame;
        }
        else
        {
            InitializeGameRules += InitializeGame;
        }

        GamePlay.OnViewTypeChange += OnViewTypeChanged;

        //Move this to choose panel later
        local_spareTowerMaterial.color  = local_pawnMaterial.color;
        remote_spareTowerMaterial.color = remote_pawnMaterial.color;
        SetupSecondaryIds();
        for (int i = 0; i < players.Length; i++)
        {
            dic_players.Add(players[i].currentPlayerType, players[i]);
        }
        if (MultiplayerManager.GetPlayerTag() == Constants.PlayerTag.PLAYER_2)
        {
            Debug.Log("Switching spare pawns");
            SwitchSparePawns();
        }
    }
 void Start()
 {
     MainMenuButton.onClick.AddListener(MainMenuButtonClicked);
     gm        = GameObject.Find("GameManager").GetComponent <GameManager>();
     scores    = new float[PlayerPrefs.GetInt("NOP")];
     MpManager = GameObject.Find("MultiplayerManager").GetComponent <MultiplayerManager>();
 }
Exemple #24
0
    public void DoChangeTeam(short team)
    {
        if (isLocalPlayer)
        {
            if (MultiplayerManager.GetInstance().localPlayerTeam != team)
            {
                GameObject.Find("SwitchTeam").GetComponent <AudioSource>().Play(); //only play if actually changing teams
            }
            MultiplayerManager.GetInstance().localPlayerTeam = team;
            if (team == 0)
            {
                lobby.redTeam.parent.GetComponent <Button>().interactable  = false;
                lobby.blueTeam.parent.GetComponent <Button>().interactable = true;
                lobby.blueTeam.parent.GetComponent <Button>().OnPointerExit(null);
            }
            else
            {
                lobby.blueTeam.parent.GetComponent <Button>().interactable = false;
                lobby.redTeam.parent.GetComponent <Button>().interactable  = true;
                lobby.redTeam.parent.GetComponent <Button>().OnPointerExit(null);
            }
        }

        if (team == 0)
        {
            transform.SetParent(lobby.redTeam, false);
        }

        else
        {
            transform.SetParent(lobby.blueTeam, false);
        }
    }
Exemple #25
0
    // Use this for initialization
    void Start()
    {
        //__NEW_FOR_ASSESSMENT_4__(START)
        if (GameObject.Find("Multiplayer Manager Object") != null)
        {
            MultiplayerManager multiplayerManager = GameObject.Find("Multiplayer Manager Object").GetComponent <MultiplayerManager> ();
            TurnManager        turnManager        = multiplayerManager.GetTurnManager();
            playerNumberReference.text = "Player " + turnManager.GetPlayerTurn() + " Selection";
        }
        else
        {
            playerNumberReference.text = "Select your Detective";
        }
        //__NEW_FOR_ASSESSMENT_4__(END)


        //Initalise detectives
        GameObject GlobalScripts = (GameObject)Instantiate(Resources.Load("GlobalScripts"));   //ADDITION BY WEDUNNIT - - new scenario

        GlobalScripts.name = "GlobalScripts";                                                  //ADDITION BY WEDUNNIT - - removes (clone) from name
        GameObject NoteBookCanvas = (GameObject)Instantiate(Resources.Load("NotebookCanvas")); // ADDITON BY WEDUNNIT

        NoteBookCanvas.name = "NotebookCanvas";                                                //ADDITION BY WEDUNNIT - - removes (clone) from name

        chaseHunter = new PlayerCharacter("Chase Hunter", chaseHunterSprite, "The Loose Cannon", "Aggressive", chaseHunterQuestioningStyles, "An ill tempered detective who will do whatever it takes to get to the bottom of a crime.");
        johnnySlick = new PlayerCharacter("Johnny Slick", johnnySlickSprite, "The Greaseball", "Wisecracking", johnnySlickQuestioningStyles, "A witty detective who finds the comedic value in everything... even death apparently.");
        adamFounder = new PlayerCharacter("Adam Founder", adamFounderSprite, "Good Cop", "By the Book", adamFounderQuestioningStyles, "A by the book cop who uses proper detective techniques to solve mysteries");
        detectives  = new PlayerCharacter[3] {
            chaseHunter, johnnySlick, adamFounder
        };
        ChangeDetective();         //Sets first detective to be viewed in GUI
    }
Exemple #26
0
    public void ModifyMoney(double changevalue, bool isAdded)
    {
        if (!ApplicationModel.multiplayer)
        {
            if (isAdded)
            {
                money += changevalue;
            }
            else
            {
                money -= changevalue;
            }
        }
        else
        {
            if (isAdded)
            {
                playerMoney[playerNumber] += changevalue;
            }
            else
            {
                playerMoney[playerNumber] -= changevalue;
            }

            MultiplayerManager.CallChangeOwnMoney(changevalue, isAdded);
        }
    }
    protected void SendNetworkData(ActionType actionType, object actionValue)
    {
        string networkMessage = string.Empty;

        switch (actionType)
        {
        case ActionType.DO_BIDDING:
            string bid = actionValue.ToString();
            if (bid == "-1")
            {
                bid = "999";
            }
            networkMessage = "BID-" + GetPlayersSeat() + "-" + bid;
            break;

        case ActionType.SET_TRUMP_TYPE:
            networkMessage = "SETTRMP-" + GetPlayersSeat() + "-" + actionValue.ToString();
            break;

        case ActionType.PLAY_CARD:
            Card cardToPlay = (Card)actionValue;
            networkMessage = "PLAY-" + GetPlayersSeat() + "-" + CardHelper.GetNumericTypeFromEnum(cardToPlay.GetCardType()) + "-" + cardToPlay.GetNumericValue();
            break;
        }

        MultiplayerManager.SendBytes(ByteHelper.GetBytes(networkMessage));
    }
    public void SitToTable(int seat, MultiplayerGamersCommunicator multiplayerGamersCommunicator)
    {
        int playersSeat = GetPlayersSeat();

        if (LobbyPlayerStats.RoomData.getRoomOwner() == PlayerName)
        {
            //  INFORM OTHERS
            Dictionary <string, object> tableProperties = new Dictionary <string, object>();
            tableProperties.Add("SEAT" + seat.ToString(), PlayerName);
            List <string> removeProperties = null;
            if (playersSeat != -1)
            {
                gameTable.LeaveTable(playersSeat);
                removeProperties = new List <string>();
                removeProperties.Add("SEAT" + playersSeat.ToString());
            }
            WarpClient.GetInstance().UpdateRoomProperties(LobbyPlayerStats.RoomData.getId(), tableProperties, removeProperties);
        }
        else
        {
            string peerSitUpdate = "SIT-" + seat.ToString() + "-" + PlayerName;
            if (playersSeat != -1)
            {
                gameTable.LeaveTable(playersSeat);
            }
            MultiplayerManager.SendBytes(ByteHelper.GetBytes(peerSitUpdate));
        }
    }
    public static IEnumerator CreateQuickGame()
    {
        instance = new MultiplayerManager();
        uint variant;
        if (GameManager.eloRating >= 1500)
            variant = 6;
        else if (GameManager.eloRating >= 1200)
            variant = 5;
        else if (GameManager.eloRating >= 900)
            variant = 4;
        else if (GameManager.eloRating >= 600)
            variant = 3;
        else if (GameManager.eloRating >= 300)
            variant = 2;
        else
            variant = 1;
        PlayGamesPlatform.Instance.RealTime.CreateQuickGame(1, 1, variant, instance);

        yield return new WaitUntil(() => isMatchFound);

        do
        {
            PlayGamesPlatform.Instance.RealTime.SendMessageToAll(true, Encoding.ASCII.GetBytes("username?"));
            PlayGamesPlatform.Instance.RealTime.SendMessageToAll(true, Encoding.ASCII.GetBytes("elo?"));
            PlayGamesPlatform.Instance.RealTime.SendMessageToAll(true, Encoding.ASCII.GetBytes("id?"));
            yield return new WaitForSeconds(0.5f);
        } while (opponentName.Equals("") || opponentId.Equals("") || opponentElo.Equals(""));

        List < Participant > participants = PlayGamesPlatform.Instance.RealTime.GetConnectedParticipants();
        Participant myself = PlayGamesPlatform.Instance.RealTime.GetSelf();
        if (participants[0].ParticipantId == myself.ParticipantId)
            isHost = true;

        SceneManager.LoadScene("VS Player");
    }
Exemple #30
0
 void Awake()
 {
     manager        = GetComponent <MultiplayerManager>();
     showScoreboard = false;
     showDebug      = false;
     messageStack   = new List <string>();
 }
Exemple #31
0
 //This is hooked to the Host Server button
 public void StartHost()
 {
     if (!NetworkServer.active)
     {
         MultiplayerManager.GetInstance().StartHost();
     }
 }
Exemple #32
0
    public void Setup()
    {
        if (isDebug)
        {
            PlayerList pList = Instantiate(playerListPrefab).GetComponent <PlayerList>();
            pList.AddPlayer(new Player(new ControlScheme(1, true), 1));
            pList.AddPlayer(new Player(new ControlScheme(2, true), 2));
        }

        for (int i = 0; i < PlayerList.Obj.numPlayers; i++)
        {
            GameObject player = Instantiate(PlayerPrefabs[i]);
            GameObject camera = Instantiate(playerCameraPrefab);
            if (i > 0)
            {
                Destroy(camera.GetComponent <AudioListener>());
            }

            player.transform.position = spawnPoints [i].transform.position;
            PlayerController pCtrl  = player.GetComponent <PlayerController> ();
            GameObject       canvas = Instantiate(playerCanvasPrefab);

            pCtrl.Setup(PlayerList.Obj.playerList [i], camera.GetComponent <PlayerCameraController> (), canvas.GetComponent <PlayerCanvasController> ());

            playerControllerList.Add(pCtrl);
        }
        GameController.Obj.SetPlayers(PlayerList.Obj.playerList);
        SetCameras();
        MultiplayerManager.Obj = this;
    }
 private void Start()
 {
     multiplayerManager = transform.root.GetComponent<MultiplayerManager>();
     auxPosition = 0;
     canWork = true;
     players = GameObject.FindGameObjectsWithTag("Player");
     playersData = new PlayerSync[players.Length];
     for (int i = 0; i < players.Length; i++)
     {
         playersData[i] = players[i].GetComponent<PlayerSync>();
     }
 }
Exemple #34
0
    public override void OnStartLocalPlayer()
    {
        // Get references
        multiplayerManager = GameObject.FindWithTag("MultiplayerManager").GetComponent<MultiplayerManager>();
        playerTransform = transform;
        carEngine = GetComponent<CarEngine>();

        // Set up player name
        GetNetIdentity();
        SetNetIdentity();

        // Set up MultiplayerManager if player is match server
        if (isServer)
        {
            multiplayerManager.itIsServer = true;
        }

        if (!isLocalPlayer)
        {
            GetComponent<CarController>().enabled = false;
        }
    }
    private void OnEnable()
    {
        usedSlots = 0;
        selected = 0;
        pressed = false;
        moving = false;
        multiplayerManager = transform.root.GetComponent<MultiplayerManager>();
        carInput = CarInput.Instance;

        for(int i = 0; i < nameLabel.Length; i++)
        {
            nameLabel[i].transform.parent.gameObject.SetActive (false);
        }

        for(int i = 0; i < sizeLabel.Length; i++)
        {
            sizeLabel[i].transform.parent.gameObject.SetActive (false);
        }

        cursor.gameObject.SetActive (false);
        errorMessage.SetActive (false);

        UpdateList();
    }
 // ON INITIALIZATION
 void Start()
 {
     instance = this;
     playerName = PlayerPrefs.GetString("playerName");
 }
 private void Start()
 {
     multiplayerManager = GetComponent<MultiplayerManager>();
 }
 void FixedUpdate()
 {
     Instance = this;
 }
 void Start()
 {
     Instance = this;
     DontDestroyOnLoad(gameObject);
     MasterServer.ipAddress = "192.168.1.91";
     MasterServer.port = 23466;
 }
Exemple #40
0
    private void Update()
    {
        // Check for null references
        if (playerTransform == null)
        {
            playerTransform = transform;
        }

        // Set identity if it is not set yet
        if (playerTransform.name == "" || playerTransform.name.Contains("Clone"))
        {
            SetNetIdentity();
        }

        // Check if player is match server
        if (isServer)
        {
            // Check for null references
            if (multiplayerManager == null)
            {
                multiplayerManager = GameObject.FindWithTag("MultiplayerManager").GetComponent<MultiplayerManager>();
            }

            // Set the match time
            SetServerTime(multiplayerManager.LeftTime);
        }
        else
        {
            // Check for null references
            if (serverSync == null)
            {
                players = GameObject.FindGameObjectsWithTag("Player");
                for (int i = 0; i < players.Length; i++)
                {
                    if (players[i].name.Contains("host"))
                    {
                        serverSync = players[i].GetComponent<PlayerSync>();
                        break;
                    }
                }
            }

            if (multiplayerManager == null)
            {
                multiplayerManager = GameObject.FindWithTag("MultiplayerManager").GetComponent<MultiplayerManager>();
            }

            // If player is not match server, read match left time from server sync
            multiplayerManager.LeftTime = serverSync.serverTime;
        }

        // Update player score
        TransmitScore();
    }
Exemple #41
0
    private void Update()
    {
        if(playerTransform == null && GameObject.FindWithTag ("Player"))
        {
            playerTransform = GameObject.FindWithTag ("Player").transform;
            if(GameObject.Find ("DriftManager"))
            {
                carDrifting = GameObject.Find ("DriftManager").GetComponent<CarDrifting>();
            }
            else if (GameObject.Find("MultiplayerManager"))
            {
                multiplayerManager = GameObject.Find("MultiplayerManager").GetComponent<MultiplayerManager>();
            }
        }

        if(playerTransform != null)
        {
            switch(rotationAxis)
            {
                case RotationAxis.NONE:
                {
                    break;
                }
                case RotationAxis.X:
                {
                    pickupRotation = animationPivot.localRotation.eulerAngles;
                    pickupRotation.x += rotationSpeed * Time.deltaTime;
                    animationPivot.localRotation = Quaternion.Euler (pickupRotation);
                    break;
                }
                case RotationAxis.Y:
                {
                    pickupRotation = animationPivot.localRotation.eulerAngles;
                    pickupRotation.y += rotationSpeed * Time.deltaTime;
                    animationPivot.localRotation = Quaternion.Euler (pickupRotation);
                    break;
                }
                case RotationAxis.Z:
                {
                    pickupRotation = animationPivot.localRotation.eulerAngles;
                    pickupRotation.z += rotationSpeed * Time.deltaTime;
                    animationPivot.localRotation = Quaternion.Euler (pickupRotation);
                    break;
                }
            }

            if(levitate)
            {
                pickupPosition = animationPivot.localPosition;
                pickupPosition.y = initPosition.y + Mathf.Sin (Time.time * levitationSpeed) * positionScale;
                animationPivot.localPosition = pickupPosition;
            }

            if(helper != null && playerTransform != null)
            {
                playerDistance = playerTransform.position - transform.position;
                helperColor = helper.material.GetColor ("_TintColor");

                if((Mathf.Abs(playerDistance.sqrMagnitude) * 0.001f) > helperMaxValue)
                {
                    helperColor.a = helperMaxValue;
                }
                else
                {
                    helperColor.a = Mathf.Abs (playerDistance.sqrMagnitude) * 0.001f/4;
                }

                helper.material.SetColor ("_TintColor", helperColor);
            }

            if(animateMaterial)
            {
                for(int i = 0; i < meshRenderer.Length; i++)
                {
                    materialMultiplier = meshRenderer[i].material.GetFloat ("_RimMultiplier");

                    if(ascending)
                    {
                        if(materialMultiplier < maxValue - 1.95f)
                        {
                            materialMultiplier = Mathf.Lerp (materialMultiplier, maxValue, Time.deltaTime * fadeSpeed * 0.6f);
                        }
                        else
                        {
                            ascending = false;
                        }
                    }
                    else
                    {
                        if(materialMultiplier > minValue + 0.05f)
                        {
                            materialMultiplier = Mathf.Lerp (materialMultiplier, minValue, Time.deltaTime * fadeSpeed);
                        }
                        else
                        {
                            ascending = true;
                        }
                    }

                    meshRenderer[i].material.SetFloat("_RimMultiplier", materialMultiplier);
                }
            }
        }
    }
Exemple #42
0
    private void Start()
    {
        // Get references
        multiplayerManager = GameObject.FindWithTag("MultiplayerManager").GetComponent<MultiplayerManager>();
        playerTransform = transform;
        carEngine = GetComponent<CarEngine>();

        if (!isLocalPlayer)
        {
            GetComponent<CarController>().enabled = false;
        }
    }
Exemple #43
0
    private void Start()
    {
        if(GameObject.Find ("DriftManager"))
        {
            carDrifting = GameObject.Find ("DriftManager").GetComponent<CarDrifting>();
        }
        else if (GameObject.Find("MultiplayerManager"))
        {
            multiplayerManager = GameObject.Find("MultiplayerManager").GetComponent<MultiplayerManager>();
        }

        audioSource = GetComponent<AudioSource>();
        initPosition = animationPivot.localPosition;
        ascending = true;
    }
 void Start()
 {
     instance = this;
     PlayerName = PlayerPrefs.GetString("PlayerName");
     CurrentMap = MapList[0];
     DontDestroyOnLoad(gameObject);
 }
    private void Start()
    {
        if(audioSource == null)
        {
            audioSource = GetComponent<AudioSource>();
        }

        if(settingsManager == null)
        {
            settingsManager = transform.root.GetComponent<SettingsManager>();
        }

        if(carDrifting == null)
        {
            carDrifting = settingsManager.GetComponent<CarDrifting>();
        }

        if(multiplayerManager == null)
        {
            multiplayerManager = settingsManager.GetComponent<MultiplayerManager>();
        }

        if(carInput == null)
        {
            carInput = CarInput.Instance;
        }

        _showing = false;
        menuAudioSource.enabled = true;
        audioSource.enabled = true;

        hasExternal = false;
        folderPath = Application.dataPath + "/Music/";

        #if !UNITY_EDITOR
        StartCoroutine(GetStreamMusic());
        #endif
    }
	public void Init (MultiplayerManager multiplayer) {
		this.multiplayer = multiplayer;
	}
Exemple #47
0
 void Start()
 {
     instance = this;
     playerName = PlayerPrefs.GetString("Player Name");
     currentMap = mapList[0];
 }
Exemple #48
0
 void Start()
 {
     mm = GameObject.FindWithTag("MultiplayerManager").GetComponent<MultiplayerManager>();
     kart = mm.thisKart;
     carNoise = GetComponent<AudioSource>();
     if(kart == "kart")
     {
         sprite.renderer.material.mainTextureOffset = new Vector2(0,0);
         turn = 5;
         speed = 15;
         carNoise.clip = car2Clip;
         carNoise.loop = true;
         carNoise.Play();
     }
     else if(kart == "dirtbike")
     {
         sprite.renderer.material.mainTextureOffset = new Vector2(0.03125f,0);
         turn = 7;
         speed = 20;
         carNoise.clip = car3Clip;
         carNoise.loop = true;
         carNoise.Play();
     }
     else if(kart == "tricycle")
     {
         sprite.renderer.material.mainTextureOffset = new Vector2((0.03125f)*2,0);
         turn = 5;
         speed = 12;
         carNoise.clip = car4Clip;
         carNoise.loop = true;
         carNoise.Play();
     }
 }