Exemplo n.º 1
0
    /// <summary>
    /// All games start from here.
    /// </summary>
    /// <returns></returns>
    private IEnumerator GameCountdown()
    {
        while (startCountdown == true && startTimer >= 0)
        {
            yield return(new WaitForSeconds(1f));

            startTimer--;
        }
        if (startCountdown == true)
        {
            //BOTTLENECK AND HOOK TO START A GAME
            // Mark room as "GameStarted"
            ExitGames.Client.Photon.Hashtable tempRoomTable = PhotonNetwork.room.CustomProperties;
            tempRoomTable["GameStarted"] = true;
            PhotonNetwork.room.SetCustomProperties(tempRoomTable);
            startTheMatch = true; // used by WaitGUI
            //Does the following:
            //set "gameStarted" as true.
            //GameStarted:
            // - Triggers WaitUI to go into SpectateMode
            //   if GameStarted is caught in Start()
            // - Disables WaitUI's polling if GameStarted
            // - Activates the Fade Effect on the Border Images
            M.GameStarts(readyTotal);
            //Does the following:
            // - Reenabled escape function (disabled during spawn)
            // TODO: Find use for room size?
            StageAnimations.Activate();
            //Does the following:
            // - Activates animations for things that need to be in sync Network-wise.
            GameManager.GameStart(NetIDs.PlayerNumber(PhotonNetwork.player.ID), M.GetClientCharacterName());
            //Does the following:
            // - Spawns local player over network.
        }
    }
Exemplo n.º 2
0
    private IEnumerator doRespawnOrGhost <PlayerController>(int deadPlayerNum, bool isDisconnect) where PlayerController : PlayerController2D
    {
        if (playerLives[deadPlayerNum] <= -1 || isDisconnect)
        {
            totalGhosts++;
            Players[deadPlayerNum].GetComponent <PlayerController>().Ghost();
            //ONLY OUR PLAYER SHOPULD SPECTATE MODE
            if (deadPlayerNum == NetIDs.PlayerNumber(PhotonNetwork.player.ID))
            {
                WaitGUIController.ActivateSpectatingMode();
            }
            yield return(null);
        }
        else
        {
            yield return(respawnWait);

            //Player spawn position is controlled by Game Manager.
            //But we only wanna reposition OUR player's position.
            //BUT ALSO
            Players[deadPlayerNum].GetComponent <PlayerController>().Respawn(
                SpawnPositions[Random.Range(0, SpawnPositions.Length - 1)].position
                );
        }
    }
Exemplo n.º 3
0
    private void updatePlayerCharDisplay()
    {
        int slotNum;
        int charNum;

        for (int x = 0; x < PhotonNetwork.room.PlayerCount; x++)
        {
            slotNum = NetIDs.PlayerNumber(PhotonNetwork.playerList[x].ID);
            charNum = N.GetCharNum(PhotonNetwork.playerList[x].ID);
            RoomSlotImages[slotNum].sprite = UIHeads[charNum];
            CBUG.Log(string.Format("UpdateHUDCharDisplay playerID/slotNum: {0} charNum: {1}", slotNum, charNum));
        }
    }
Exemplo n.º 4
0
 void OnPhotonPlayerDisconnected(PhotonPlayer player)
 {
     CBUG.Log("OnPhotonPlayerDisconnected: " + player);
     //Tell everyone to reset their ready status.
     ResetReadyStatus();
     unassignPlayerTracking(player);
     plrStateChange = true;
     rdyStateChange = true;
     if (gameStarted)
     {
         GameManager.RecordDeath(-1, NetIDs.PlayerNumber(player.ID), true);
         GameManager.HandleDeath(NetIDs.PlayerNumber(player.ID), true);
     }
 }
    void Awake()
    {
        isFrozen = false;
        //DontDestroyOnLoad(gameObject);
        anim            = GetComponentInChildren <Animator>();
        moveRight       = 0;
        moveLeft        = 0;
        controlsPaused  = false;
        myAudioSrc      = GetComponent <AudioSource>();
        myAudioSrc.clip = DeathNoise;
        punching        = false;

        isDead        = false;
        StrengthsList = GameObject.FindGameObjectWithTag("Master").
                        GetComponent <Master>().GetStrengthList();

        CBUG.Log("Str List: " + StrengthsList.ToStringFull());
        jumpForceTemp      = 0f;
        SpeedTemp          = 0f;
        attackDisableDelay = new WaitForSeconds(AttackLife);
        facingRight        = true;
        position           = new Vector2();
        _Rigibody2D        = GetComponent <Rigidbody2D>();
        jumpsRemaining     = TotalJumpsAllowed;
        _PhotonView        = GetComponent <PhotonView>();
        _PhotonTransform   = GetComponent <PhotonTransformView>();

        AttackObjs    = new GameObject[3];
        AttackObjs[0] = transform.GetChild(3).gameObject;
        AttackObjs[1] = transform.GetChild(1).gameObject;
        AttackObjs[2] = transform.GetChild(2).gameObject;

        _MobileInput = GameObject.FindGameObjectWithTag("MobileController").GetComponent <MobileController>();

        spawnPause     = 0.5f;
        spawnPauseWait = new WaitForSeconds(spawnPause);

        lastHitBy           = -1;
        lastHitTime         = Time.time;
        lastHitForgetLength = 5;//Seconds

        if (_PhotonView.isMine)
        {
            tag = "PlayerSelf";
            _PhotonView.RPC("SetSlotNum", PhotonTargets.All, NetIDs.PlayerNumber(PhotonNetwork.player.ID));
            CamManager.SetTarget(transform);
        }
    }
Exemplo n.º 6
0
    private void updateReadyStatusDisplay()
    {
        PercentReady.text = "" + N.ReadyTotal + "/" + N.GetInRoomTotal;

        //Any change to the ready status requires everyone to re-ready up.
        //Yes.SetActive(true);
        //No.SetActive(false);

        int playerNumber;

        for (int x = 0; x < PhotonNetwork.room.PlayerCount; x++)
        {
            playerNumber = NetIDs.PlayerNumber(PhotonNetwork.playerList[x].ID);
            RoomSlotImages[playerNumber].color = N.GetRdyStatus(PhotonNetwork.playerList[x].ID) ? rdyColor : unRdyColor;
        }
    }