// --------- Init stuff --------- void Start() { DontDestroyOnLoad(this); MasterServer.dedicatedServer = true; MasterServer.ipAddress = "84.113.142.137"; Application.targetFrameRate = 60; guiScript = GetComponent<FPSGUI>(); messageScript = GetComponent<FPSMessages>(); artilleryScript = GetComponent<FPSArtillery>(); gameSettings = GetComponent<GameModeScript>(); Application.LoadLevel("MenuScene"); }
public void Detonate(NetworkViewID viewID) { for (int i = 0; i < activeGrenades.Count; i++) { if (viewID == activeGrenades[i].viewID) { //grenade jumping for (int k = 0; k < theNetwork.players.Count; k++) { float Dist = Vector3.Distance(theNetwork.players[k].fpsEntity.transform.position, activeGrenades[i].transform.position); float push = 5; if (Dist < GetDetonationRadius("grenade")) { if (theNetwork.players[k].local) { if (theNetwork.players[k].fpsEntity.transform.position.y - 0.2f > activeGrenades[i].transform.position.y) { theNetwork.players[k].fpsEntity.yMove += push; } theNetwork.players[k].fpsEntity.sendRPCUpdate = true; } } } GameObject grenadeFlash = (GameObject)GameObject.Instantiate(grenadeFlashPrefab); grenadeFlash.transform.position = activeGrenades[i].transform.position; grenadeFlash.GetComponent <GrenadeFlashScript>().Rad = FPSArtillery.GetDetonationRadius("grenade"); GameObject grenadeSoundObj = (GameObject)GameObject.Instantiate(soundObjectPrefab); grenadeSoundObj.transform.position = activeGrenades[i].transform.position; grenadeSoundObj.audio.clip = sfx_grenadeExplode; grenadeSoundObj.audio.volume = 5f; Destroy(activeGrenades[i].gameObject); activeGrenades.RemoveAt(i); } } for (int i = 0; i < activeRockets.Count; i++) { if (viewID == activeRockets[i].viewID) { int shooteridx = -1; for (int j = 0; j < theNetwork.players.Count; j++) { if (theNetwork.players[j].viewID == activeRockets[i].shooterID) { shooteridx = j; } } //rocket jumping for (int k = 0; k < theNetwork.players.Count; k++) { float Dist = Vector3.Distance(theNetwork.players[k].fpsEntity.transform.position, activeRockets[i].transform.position); float push = 5; if (Dist < GetDetonationRadius("rocket")) { if (theNetwork.players[k].local) { if (theNetwork.players[k].fpsEntity.transform.position.y - 0.2f > activeRockets[i].transform.position.y) { theNetwork.players[k].fpsEntity.yMove += push; } theNetwork.players[k].fpsEntity.sendRPCUpdate = true; } } } //detonate rocket GameObject grenadeFlash = (GameObject)GameObject.Instantiate(grenadeFlashPrefab); grenadeFlash.transform.position = activeRockets[i].transform.position; grenadeFlash.GetComponent <GrenadeFlashScript>().Rad = FPSArtillery.GetDetonationRadius("rocket"); GameObject rocketSoundObj = (GameObject)GameObject.Instantiate(soundObjectPrefab); rocketSoundObj.transform.position = activeRockets[i].transform.position; rocketSoundObj.audio.clip = sfx_rocketExplode; rocketSoundObj.audio.volume = 5f; Destroy(activeRockets[i].gameObject); activeRockets.RemoveAt(i); } } }
// Use this for initialization void Start() { theNetwork = GameObject.Find("_SophieNet").GetComponent<SophieNetworkScript>(); theGUI = GameObject.Find("_SophieNet").GetComponent<FPSGUI>(); artillery = GameObject.Find("_SophieNet").GetComponent<FPSArtillery>(); if (thisPlayer.local && theNetwork.gameSettings.pitchBlack){ Camera.main.backgroundColor = Color.black; RenderSettings.ambientLight = Color.black; } cc = GetComponent<CharacterController>(); if (thisPlayer.lives>=0){ if (isLocal){ SetModelVisibility(false); }else{ SetModelVisibility(true); } Respawn(); }else{ //we joined as a spectator SetModelVisibility(false); transform.position = -Vector3.up * 99f; } }
void Start() { theNetwork = GetComponent<SophieNetworkScript>(); messageScript = GetComponent<FPSMessages>(); artillery = GetComponent<FPSArtillery>(); //make local player theNetwork.localPlayer = new FPSPlayer(); theNetwork.localPlayer.local = true; theNetwork.localPlayer.name = PlayerPrefs.GetString("PlayerName", "Player Playerson"); theNetwork.localPlayer.headType = PlayerPrefs.GetInt("PlayerHead", 0); theNetwork.localPlayer.colA.r = PlayerPrefs.GetFloat("PlayerColA_R", Color.red.r); theNetwork.localPlayer.colA.g = PlayerPrefs.GetFloat("PlayerColA_G", Color.red.g); theNetwork.localPlayer.colA.b = PlayerPrefs.GetFloat("PlayerColA_B", Color.red.b); theNetwork.localPlayer.colA.a = 1; theNetwork.localPlayer.colB.r = PlayerPrefs.GetFloat("PlayerColB_R", Color.green.r); theNetwork.localPlayer.colB.g = PlayerPrefs.GetFloat("PlayerColB_G", Color.green.g); theNetwork.localPlayer.colB.b = PlayerPrefs.GetFloat("PlayerColB_B", Color.green.b); theNetwork.localPlayer.colB.a = 1; theNetwork.localPlayer.colC.r = PlayerPrefs.GetFloat("PlayerColC_R", Color.cyan.r); theNetwork.localPlayer.colC.g = PlayerPrefs.GetFloat("PlayerColC_G", Color.cyan.g); theNetwork.localPlayer.colC.b = PlayerPrefs.GetFloat("PlayerColC_B", Color.cyan.b); theNetwork.localPlayer.colC.a = 1; //load settings invX = PlayerPrefs.GetInt("InvertX", 0) == 1; invY = PlayerPrefs.GetInt("InvertY", 0) == 1; mouseSensitivity = PlayerPrefs.GetFloat("MouseSensitivity", 2f); messageScript.textFadeTime = PlayerPrefs.GetFloat("textFadeTime", 10f); theNetwork.gunBobbing = PlayerPrefs.GetInt("GunBobbing",1)==1; theNetwork.autoPickup = PlayerPrefs.GetInt("autoPickup",0)==1; theNetwork.autoPickupHealth = PlayerPrefs.GetInt("autoPickupHealth",0)==1; theNetwork.announcer = PlayerPrefs.GetInt("announcer", 1)==1; theNetwork.autoSwitch = PlayerPrefs.GetInt ("autoSwitch",0)==1; theNetwork.gameVolume = PlayerPrefs.GetFloat("GameVolume", 1f); }