public void SetMSXVolume(float amt) { if (amt < 0f || amt > 1f) { CBUG.Error("Volume amount must be betweeen 0 and 1."); } myMusicAudio.volume = amt; PlayerPrefs.SetFloat("MSXVol", amt); PlayerPrefs.Save(); CBUG.Log("MSXVolume Set"); }
void Pickup(int itemId, PhotonMessageInfo info) { cItem = neighbourhoodMan.allItems[itemId] = detector.closeObj; CBUG.Do("MY PHOTRON ID IS " + photonView.ViewID); charAnim.SetBool("Packing", true); cItem.transform.parent = holdPos; cItem.transform.localPosition = cItem.localPos; cItem.transform.localEulerAngles = cItem.localErot; cItem.collido.enabled = false; cItem.rby.isKinematic = true; if (photonView.IsMine) { canAttack = true; hudMan.SetInstructionText(1); playerState = PlayerState.Holding; bool pos = false; for (int i = 0; i < cItem.traits.Count; i++) { if (cItem.traits[i] == myPersonality) { pos = true; } } if (pos == true) { positiveObj.SetActive(true); Invoke("TurnOffParticleFx", 1.5f); } else { bool neg = false; for (int i = 0; i < cItem.negativeTraits.Count; i++) { if (cItem.negativeTraits[i] == myPersonality) { neg = true; } } if (neg == true) { negativeObj.SetActive(true); Invoke("TurnOffParticleFx", 1.5f); } } } }
private int getImageNum() { for (int i = 0; i < UIHeads.Length; i++) { if (i == M.PlayerCharNum) { return(i); } } CBUG.Error("No Head Found!"); return(-1); }
private void updateJumpingPhysics() { if (applyJumpPhysics) { CBUG.Do("JUMP!"); CBUG.Do("JUMP!"); applyJumpPhysics = false; _Rigibody3D.isKinematic = true; _Rigibody3D.position += new Vector3(0f, 500f, 0f); _Rigibody3D.isKinematic = false; } }
public override void OnConnectedToMaster() { base.OnConnectedToMaster(); CBUG.Do("Connected To Master! Joining Lobby ..."); TypedLobby sqlLobby = new TypedLobby("Lobby", LobbyType.SqlLobby); bool success = PhotonNetwork.JoinLobby(sqlLobby); if (!success) { CBUG.Do("PunCockpit: Could not join Lobby ..."); } }
void OnPhotonPlayerConnected(PhotonPlayer player) { //Add new player info tracking. storeRemoteData(player); CBUG.Log("OnPhotonPlayerConnected: " + player); //Tell everyone to reset their ready status. ResetReadyStatus(); plrStateChange = true; rdyStateChange = true; startCountdown = false; startTimer = CountdownLength; }
// Update is called once per frame void Update() { if (!testRan && TestInRelease && ParseManager.DoneInstantiating && URLLoader.DoneInstatiating) { if (!Application.isEditor && !TestInRelease) { return; } testRan = true; URLLoader.BuildURL(URLLoader.GetDataFrom(TestURL + "?" + TestCode).ToArray()); CBUG.Do("Retrieved URL: " + URLLoader.URL); } }
public GameObject SpawnSingletonResource(string singletonName) { //todo ??? network-ize this. GameObject singleton = SpawnObject(singletonName); if (singleton == null) { CBUG.SrsError("No singleton is available for name: " + singletonName); return(null); } singletons.Add(singletonName, singleton); return(singleton); }
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)); } }
public void Save() { int i = 0; CBUG.Log("Saving PlayerPrefs!"); foreach (InputField obj in SaveObjs) { CBUG.Log("Key: " + i + " String: " + SaveObjs[i].text); PlayerPrefs.SetString("" + i, SaveObjs[i].text); i++; } PlayerPrefs.Save(); }
private static EndGameManager getRef() { for (int x = 0; x < SceneManager.GetSceneAt(0).GetRootGameObjects().Length; x++) { if (SceneManager.GetSceneAt(0).GetRootGameObjects()[x].name == "EndGameCanvas") { return(SceneManager.GetSceneAt(0).GetRootGameObjects()[x].GetComponent <EndGameManager>()); } //CBUG.Do("RootObjName: " + SceneManager.GetSceneAt(0).GetRootGameObjects()[x]); } CBUG.Error("FRIEND NOT FOUND!"); return(null); }
private IEnumerator StartBoilBuffer() { CBUG.Do("STARTING BOIL!!"); isBuffered = true; yield return(boilBuffer); if (CanBoil && !GameControls.IsQuizTime()) { IsBoiling = true; Tips.Spawn(0); } isBuffered = false; }
public static void Remove(int netID) { if (roomIDsList == null) { roomIDsList = new List <int>(); } bool removedSuccessfully = roomIDsList.Remove(netID); if (!removedSuccessfully) { CBUG.SrsError("Attempted to remove a NetID that doesn't exist!"); } }
public void Load() { int i = 0; string temp; CBUG.Log("Loading PlayerPrefs"); foreach (InputField obj in SaveObjs) { temp = PlayerPrefs.GetString("" + i, ""); CBUG.Log("Key: " + i + " String: " + temp); SaveObjs[i].text = temp; i++; } }
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); } }
// Use this for initialization void Start() { charactersUnlockedTotal = PlayerPrefs.GetInt("UnlockedChars", defaultUnlocked); // 6 = Default usable characters. SetMSXVolume(PlayerPrefs.GetFloat("MSXVol", 0.5f)); SetSFXVolume(PlayerPrefs.GetFloat("SFXVol", 0.5f)); escapeHardened = false; escapeDisabled = false; if (IsOfflineMode) { return; } CBUG.Print(VersionUI.text); //_Audio.Play(10); }
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); } }
// Update is called once per frame void Update() { if (ClearAll) { PlayerPrefs.DeleteAll(); ClearAll = false; CBUG.Log("Clearing All PlayerPrefs!"); } if (Clear) { Clear = false; PlayerPrefs.DeleteKey(ClearKey); CBUG.Log("Clearing Key: " + ClearKey); } }
public Photon.Realtime.Room GetRoom() { if (CurrentServerUserDepth == ServerDepthLevel.Offline) { return(null); //??? TODO HANDLE BETTER } else if (CurrentServerUserDepth == ServerDepthLevel.InRoom) { return(PhotonNetwork.CurrentRoom); } else { CBUG.Error("We are not currently in a room!"); return(null); //??? TODO HANDLE BETTER! } }
public bool IsLocalClient(PhotonView playerView) { if (CurrentServerUserDepth == ServerDepthLevel.Offline) { return(true); } else if (CurrentServerUserDepth == ServerDepthLevel.InRoom) { return(playerView.IsMine); } else { CBUG.Error("This can only be called when player is in a room or offline! You're currently in: " + CurrentServerUserDepth.ToString()); return(false); } }
public int GetLocalPlayerID() { if (CurrentServerUserDepth == ServerDepthLevel.Offline) { return(1); } else if (CurrentServerUserDepth == ServerDepthLevel.InRoom) { return(PhotonNetwork.LocalPlayer.ActorNumber); //??? unchanging? Unique? Todo; } else { CBUG.Error("This can only be called when player is in a room or offline! You're currently in: " + CurrentServerUserDepth.ToString()); return(PhotonNetwork.LocalPlayer.ActorNumber); } }
public void HandleUnityLog(string LogString, string StackTrace, LogType type) { switch (type) { case LogType.Error: CBUG.Error(type.ToString() + LogString + "/n" + StackTrace); break; case LogType.Exception: CBUG.Error(type.ToString() + LogString + "/n" + StackTrace); break; default: break; } }
//[PunRPC] private void netDie() { CBUG.Do("DIED!"); dieSound.Play(); isDead = true; ArmLeft.transform.SetParent(null); ArmLeft.GetComponent <Rigidbody>().isKinematic = false; ArmLeft.GetComponent <BoxCollider>().isTrigger = false; ArmRight.transform.SetParent(null); ArmRight.GetComponent <BoxCollider>().isTrigger = false; ArmRight.GetComponent <Rigidbody>().isKinematic = false; Body.transform.SetParent(null); Body.GetComponent <Rigidbody>().isKinematic = false; Head.transform.SetParent(null); Head.GetComponent <Rigidbody>().isKinematic = false; }
/// <summary> /// Shows character a player is hovering over. /// </summary> public void SetCharacter() { CBUG.Log("Adding player property"); ExitGames.Client.Photon.Hashtable playerProperties = PhotonNetwork.player.CustomProperties; //Update local player's chosen character online. if (playerProperties.ContainsKey("characterNum")) { playerProperties["characterNum"] = M.PlayerCharNum; } else { playerProperties.Add("characterNum", M.PlayerCharNum); } PhotonNetwork.player.SetCustomProperties(playerProperties); SetCharDisplay(PhotonTargets.All, M.PlayerCharNum); }
private void updateJumping() { //bool K = (); CBUG.Do(Input.GetAxisRaw("Jump") + ""); if ((Input.GetButtonDown("Jump") == true || _MobileInput.GetButtonDown("Jump") || Input.GetAxisRaw("Jump") > 0f) && jumpsRemaining > 0 && totalJumpFrames < 0) { jumped = true; //CBUG.Log("Jumped is true!"); jumpsRemaining -= 1; totalJumpFrames = jumpLag; } totalJumpFrames -= 1; }
/// <summary> /// Makes sure there is space available for Char N Friends. /// If so, also tell friend to go as well. /// </summary> /// <param name="ID"></param> /// <param name="CurrentState"></param> /// <param name="NextState"></param> /// <returns></returns> public bool includeDependencies(int ID, CharController.State CurrentState, CharController.State NextState) { //If we're already "WaitingIn" Selection, or have no friends, nothing to do here. if (DependenciesOf[ID].Length == 0 || NextState == CharController.State.WaitingIn) { return(true); } //Is there space for us and our friends? If not, don't act! int totalDependenciesNotSelected = 0; for (int x = 0; x < DependenciesOf[ID].Length; x++) { if (Characters[DependenciesOf[ID][x]].GetComponent <CharController>().NextState == CharController.State.WaitingOut) { totalDependenciesNotSelected++; } } if (!IsPositionAvailable(totalDependenciesNotSelected + 1)) { return(false); } //Tell friends they got "clicked". CBUG.Log(ID_to_Name[ID] + " has " + DependenciesOf[ID].Length + " friends to add"); for (int i = 0; i < DependenciesOf[ID].Length; i++) { //To prevent multiple calls to a Character within a single frame, we check action buffer. if (!ActionBufferAdd.ContainsKey(DependenciesOf[ID][i])) { //Fixing circular dependency with this: //Don't call the one who called me. //if Caller of Past == Character I want to Call, don't call if ((!ActionBufferAdd.ContainsKey(ID)) || ActionBufferAdd[ID] != DependenciesOf[ID][i]) { //Don't call anyone already settled in. if (Characters[DependenciesOf[ID][i]].GetComponent <CharController>().NextState != CharController.State.WaitingIn) { ActionBufferAdd.Add(DependenciesOf[ID][i], ID); Characters[DependenciesOf[ID][i]].GetComponent <CharController>().OnPointerClick(null); } } } } return(true); }
/// <summary> /// To other Menu Canvas "Scenes" or to an in-game scene. /// </summary> /// <param name="to">To.</param> public void GoTo(int to) { switch (to) { case (int)Menu.main: switchCanvas((int)Menu.main); break; case (int)Menu.map: N.JoinServer(true); StartCoroutine(gotoMap()); break; case (int)Menu.chara: StartCoroutine(gotoCharacterSelect()); break; case (int)Menu.options: switchCanvas((int)Menu.options); break; case (int)Menu.ingame: //game is actually loaded up from map -> chara. //This just disables the main menu. switchCanvas((int)Menu.ingame); unloadMenu(); PlayMSX(1); GameObject.FindGameObjectWithTag("StageCamera").GetComponent <AudioListener>().enabled = true; break; case (int)Menu.practice: loadStage(); switchCanvas((int)Menu.ingame); unloadMenu(); PlayMSX(1); break; case -1: //Disabling all UI switchCanvas(-1); break; default: CBUG.Error("BAD MENU SCENE GIVEN!! :: " + to); break; } }
public string GetLocalUsername() { if (CurrentServerUserDepth == ServerDepthLevel.Offline) { return(_fakeServer.Username); } else if (CurrentServerUserDepth == ServerDepthLevel.InRoom) { string username = PhotonNetwork.LocalPlayer.UserId; username = username.Substring(0, username.IndexOf('_')); return(username); } else { CBUG.Error("Username only available when Offline or InRoom, this was called at " + CurrentServerUserDepth.ToString() + "."); return(null); } }
public override void OnJoinedLobby() { CBUG.Log("Lobby Joined!"); CBUG.Log("Joining Random Room ..."); if (needsNewRoom) { PhotonNetwork.CreateRoom(null, new RoomOptions() { MaxPlayers = 2, CleanupCacheOnLeave = false }, null); } else { //string sqlLobbyFilter = "GameStartTime = -1"; //todo ??? implement sql lobbying PhotonNetwork.JoinRandomRoom(); } currentServerUserDepth = ServerDepthLevel.InLobby; }
//public override void On public override void OnJoinedRoom() { CBUG.Log("Joined Room! Total Players: " + PhotonNetwork.CurrentRoom.PlayerCount); currentServerUserDepth = ServerDepthLevel.InRoom; SaveData("FirstTimeSetupDone", false); if (PhotonNetwork.IsMasterClient) { //spawn singletons foreach (var singleton in singletonNames) { SpawnObject(singleton); } } SaveData("FirstTimeSetupDone", true); }