Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using Hashtable = ExitGames.Client.Photon.Hashtable; //Replace default Hashtables with Photon hashtables
- using SuperApi;
- using Steamworks;
- using LapinerTools.uMyGUI;
- public class RoomController : Photon.MonoBehaviour
- {
- public bool bombPlanted = false;
- public bool isKickedForPing = false;
- public enablecappoint hardPointELM;
- public GameObject Zombies;
- public bool cursorLocked;
- public GameObject Bomb;
- public Transform explosion;
- //This is main script that control in-room logic
- public Texture confirmedkill;
- public int killSteakXP = 0;
- public int startTime = 45;
- public GameObject[] spectatorCameras;
- public AudioClip healthSFX;
- bool showWeaponText = false;
- //*Ranking Info
- float infoCount = 3;
- int ranker_score;
- public int rank_number;
- public Texture currentRank;
- public Texture nextRank;
- public Texture rank_private;
- public Texture rank_pvf;
- public Texture rank_corporal;
- public Texture sgt;
- public Texture sgj_major;
- public Texture master_sgt;
- public Texture lt1;
- public Texture lt2;
- public Texture rank_captain;
- public Texture lt_major;
- public Texture major;
- public Texture colonel;
- public Texture Brigader_general;
- public Texture maj_general;
- public Texture lt_general;
- public Texture general;
- public Texture fivestargen;
- public bool ranked2;
- public bool didRank2;
- public int nextrank3 = 50;
- public bool ranked3;
- public int nextrank4 = 100;
- public bool ranked4;
- public int weapcycle = 0;
- public AudioSource ranked;
- public int nextrank5 = 400;
- public bool ranked5;
- public bool didRank5;
- public int nextrank6 = 600;
- public bool ranked6;
- public int nextrank7 = 1000;
- public bool ranked7;
- public int nextrank8 = 1750;
- public bool ranked8;
- public int nextrank9 = 3000;
- public bool ranked9;
- public int nextrank10 = 4750;
- public bool ranked10;
- public int nextrank11 = 6000;
- public bool ranked11;
- public int nextrank12 = 8500;
- public bool ranked12;
- public int nextrank13 = 10000;
- public bool ranked13;
- public int nextrank14 = 13500;
- public bool ranked14;
- public int nextrank15 = 15500;
- public bool ranked15;
- public bool ranked16;
- public int nextLevel = 0;
- //UI In-Game Vital Elements
- public Texture clock;
- public AudioClip hearbeat;
- public int healAfter;
- public Texture HPVital;
- public Texture HPVitalRed;
- public bool healDone = false;
- public Texture crouchGuy;
- public AudioClip hitmarker;
- public GameObject[] zAisDestory;
- public int botCount = 0;
- public int botKills = 0;
- bool freeforallstart;
- public AudioClip ffaAudio;
- public AudioClip firstBlood;
- public AudioClip hardpointSound;
- public bool spawnedPlayer = false;
- public int teamaplayersalive = 0;
- public int teambplayerslive = 0;
- public GameObject[] Ais;
- public GameObject[] curAis;
- public GameObject ai1;
- //Spawn System
- public GameObject[] holdupobjects = new GameObject[4];
- public int TimeToStartGame = 60;
- bool deployweapons;
- public bool countingDown;
- bool dome1MoveTextActive;
- bool dome2MoveTextActive;
- public int movesIn;
- public int movesIn2;
- public GameObject Dome1;
- public GameObject Dome2;
- public GameObject Dome3;
- public GameObject Dome4;
- public bool lmadead;
- //UI In-Game Element Bools
- public bool isCrouched;
- public AudioClip lightingmeup;
- public AudioClip gogogo;
- public AudioClip[] screams;
- public AudioClip[] kills;
- public AudioClip[] shouts;
- public Material DawnSkybox;
- public Material darkSkybox;
- public GameObject Lighting;
- public AudioClip infectedSoundEffect;
- public AudioClip machinegunfire1;
- public AudioSource soldierShout;
- bool playShoutOnce;
- bool playerHasBeenKilled = false;
- public Texture HUDOverlayBG;
- public Texture ScoreHUDOVERLAYBG;
- public GameObject radarping;
- public GameObject radarbg;
- public Texture rank2;
- public Texture rank3;
- public Texture rank4;
- public Texture rank5;
- public Texture rank6;
- public Texture rank7;
- public Texture rank8;
- public Texture rank9;
- public Texture rank10;
- public Texture rank11;
- public Texture rank12;
- public Texture rank13;
- public Texture rank14;
- public Texture rank15;
- public int Victories;
- public Texture scoreDisplay;
- public bool dead;
- public float time2Fade;
- public GUIText playerLeft;
- public int spawnProtectTime;
- public int expireKill = 2;
- public bool protectactive;
- public GameObject playerPrefab;
- public GameObject playerPrefab2;
- public Camera welcomeCamera;
- public Texture2D blackScreen;
- public Texture2D whiteTexture;
- public Texture2D shotgunTexture;
- //Hit detectors
- public Texture2D hitTop;
- public Texture2D hitBottom;
- public Texture2D hitLeft;
- public Texture2D hitRight;
- public AudioSource headshot_start;
- public AudioClip headshot_sound;
- public AudioClip buySound;
- public AudioClip cashRegisterSound;
- public string name;
- public Camera forge_cam;
- public int infectTime = Random.Range(10, 20);
- bool hasbeenpicked = false;
- public int respawnInfectTime = 0;
- public int[] infectRandTime;
- public Transform spawnpintA;
- public Transform spawnPontTmp = null;
- //Objects to buy in forge mode
- public GameObject barrel1;
- public GameObject concrete_block;
- public GameObject building1;
- public GameObject building2;
- public GameObject palette;
- public GameObject shipping_container1;
- public GameObject shipping_container2;
- public GameObject shipping_container3;
- public GameObject shipping_container4;
- //Delcare Spawnpoints in forge mode
- public GameObject spawnpntA;
- public GameObject spawnpntB;
- public int ranksforkill;
- public int recordedKills = 0;
- public int recordedDeaths = 0;
- public AudioSource announcersfx;
- public AudioClip gosfx;
- public AudioClip almostthere;
- public AudioClip soldierdeath1;
- public AudioClip holyshitsfx;
- public bool createdHardpoint = false;
- public GameObject spawnHardPoint;
- public GameObject spawnHardPoint2;
- public GameObject spawnHardPoint3;
- public GameObject hardpoint1;
- public GameObject capturepoint1;
- public GameObject capturepoint2;
- public GameObject capturepoint3;
- GUIStyle customLabel = new GUIStyle("label");
- GUIStyle customLayout1 = new GUIStyle("label");
- GUIStyle customLayout2 = new GUIStyle("label");
- public bool userKilled;
- public bool isPurchaseLoaded;
- string kredsPrefsName = "kredsPrefs";
- public AudioSource rankupsfx;
- public bool showIconA;
- public bool showIconB;
- public int expire;
- public Texture TeamAIcon;
- public Texture TeamBIcon;
- public List<Transform> teamASpawnPoints = new List<Transform>();
- public List<Transform> teamBSpawnPoints = new List<Transform>();
- [HideInInspector]
- public List<PhotonPlayer> teamAPlayers = new List<PhotonPlayer>();
- [HideInInspector]
- public List<PhotonPlayer> teamBPlayers = new List<PhotonPlayer>();
- [HideInInspector]
- public string spectatorNames = "";
- //Vehicle Controls
- public bool enteredVehicleSpot = false;
- [HideInInspector]
- public bool showScoreBoard = false;
- [HideInInspector]
- public bool eneteredBuySpot = false;
- [HideInInspector]
- public bool eneteredBombSpot = false;
- [HideInInspector]
- public bool leavingRoom = false;
- [HideInInspector]
- public bool showFPS = false;
- [HideInInspector]
- public bool showBuyMenu = false;
- [HideInInspector]
- public bool showOptions;
- public bool showPauseMenu = false;
- [HideInInspector]
- public PlayerNetwork ourPlayer;
- [HideInInspector]
- public List<PlayerNetwork> otherPlayers = new List<PlayerNetwork>(); //Keep references of other spawned players
- Transform welcomeCameraTransform;
- Vector3 defaultCamPos;
- Quaternion defaultCamRot;
- //bool playerKilled = false;
- [HideInInspector]
- public float distance; //Crosshair distance is also set at Weapon.cs when we fire
- float redScreenFade = 0;
- float hitTopFade = 0;
- float hitBottomFade = 0;
- float hitLeftFade = 0;
- float hitRightFade = 0;
- bool doingHitDetector = false;
- float hitDetectorsDistance = 125;
- //Get current fps
- float updateInterval = 1f;
- float accum = 0.0f;
- int frames = 0;
- float timeleft;
- float roundDuration = 0;
- public float referenceTime = 0;
- //Was = 600;
- public float currentRoundTime = 1500;
- float seconds;
- float minutes;
- string roundTimeString = "00:00";
- public SimpleColladaDemo scd;
- int healthAfter = 2;
- int count = 0;
- public int teamAScore = 0;
- public int teamBScore = 0;
- [HideInInspector]
- public int ourTeam = 0;
- [HideInInspector]
- public string currentGameMode = "";
- [HideInInspector]
- public int currentRespawnTime = -1;
- [HideInInspector]
- public int currentGameStatus = 0;
- //Used only for FFA (Free For All) mode
- [HideInInspector]
- public int currentKillLimit;
- [HideInInspector]
- public int currentScoreLimit;
- [HideInInspector]
- public PhotonPlayer winningPlayer;
- public bool createHardPoint = false;
- [HideInInspector]
- private bool cashes_boolean;
- [HideInInspector]
- public int totalCash = 5;
- public int totalGold = 0;
- public int LMACash = 0;
- public int BMCash = 25000;
- public int SRCash = 50000;
- public int tweetCashes = 0;
- public int savedGP;
- public gunShop weaponShop;
- int previousGameStatus = 0;
- bool doneSetup = false;
- int waitBeforeRespawn = 1; //How much seconds player need to wait before respawn again
- public int currentHP = 0;
- public string scoreToAddTmp = "+ 100";
- Color addingColor = new Color(0, 1, 0, 0.75f);
- Color substractingColor = new Color(1, 0.71f, 0.109f, 0.75f);
- Color addingColorFadeTo;
- Color currentAddingCashColor;
- Color currentTotalCashColor;
- bool addingKillCash = false;
- public GameObject scorezone;
- public int totalXP = 0;
- public int challengeXP = 0;
- public int rank_xp = 0;
- public Texture rank_pvt;
- public Texture rank_pfc;
- public Texture rank_cpl;
- public Texture rank_sgt;
- public Texture rank_ssgt;
- public Texture rank_sgtmaj;
- public Texture rank_slt;
- int lockState = -1;
- public ConnectMenu cm6;
- public RoomController rc7;
- public Transform spawnPoint;
- public GameObject ai;
- public GameObject[] spawnPoints;
- public List<GameObject> forgeItems = new List<GameObject>();
- [System.Serializable]
- public class ActionReport
- {
- public string leftText;
- public string middleText;
- public string rightText;
- public Color leftTextColor;
- public Color rightTextColor;
- public float timer; //How long this itema appear on screen in seconds
- public ActionReport(string lt, string mt, string rt, Color ltc, Color rtc, float t)
- {
- leftText = lt;
- middleText = mt;
- rightText = rt;
- leftTextColor = ltc;
- rightTextColor = rtc;
- timer = t;
- }
- }
- List<ActionReport> actionReports = new List<ActionReport>();
- MultiplayerChat mc;
- OptionsSettings os;
- FPSMouseLook cameraMouseLook;
- Scoreboard sb;
- BuyMenu bm;
- Texture2D scopeTexture;
- float scopeTextureRatio;
- AudioSource audioSource;
- int timeToPurchase = 0;
- int forgetimeToPurchase = 0;
- //Has player spawned in Zombie Escape mod yet?
- bool playerSpawnZE = false;
- int totalCash2 = 0;
- //Compare players by kills (sort by list)
- private static int SortPlayers(PhotonPlayer A, PhotonPlayer B)
- {
- return (int)B.customProperties["Kills"] - (int)A.customProperties["Kills"];
- }
- bool loadedHardpoint = false;
- bool isDom;
- /*private void Awake()
- {
- Dome1 = GameObject.Find("Dome");
- Dome2 = GameObject.Find("Dome2");
- Dome3 = GameObject.Find("Dome3");
- Dome4 = GameObject.Find("Dome4");
- }
- */
- // Use this for initialization
- IEnumerator Start()
- {
- //if(Application.loadedLevelName == "forge")
- //{
- //PhotonNetwork.offlineMode = true;
- //uMyGUI_PopupManager.Instance.ShowPopup("steam_ugc_browse");
- //}
- ranker_score = PlayerPrefs.GetInt("totalKill");
- if (ranker_score >= 0)
- {
- rank_number = 1;
- currentRank = rank_private;
- ranked2 = true;
- }
- if (ranker_score >= 15)
- {
- PlayerPrefs.SetInt("ranker_number", rank_number);
- rank_number = 2;
- currentRank = rank_corporal;
- ranked2 = false;
- ranked3 = true;
- }
- if (ranker_score >= 50)
- {
- PlayerPrefs.SetInt("ranker_number", rank_number);
- rank_number = 3;
- currentRank = sgt;
- ranked3 = false;
- ranked4 = true;
- }
- if (ranker_score >= 100)
- {
- PlayerPrefs.SetInt("ranker_number", rank_number);
- rank_number = 4;
- currentRank = lt1;
- ranked4 = false;
- ranked5 = true;
- }
- if (ranker_score >= 400)
- {
- PlayerPrefs.SetInt("ranker_number", rank_number);
- rank_number = 5;
- currentRank = lt2;
- ranked5 = false;
- ranked6 = true;
- }
- if (ranker_score >= 600)
- {
- PlayerPrefs.SetInt("ranker_number", rank_number);
- rank_number = 6;
- currentRank = rank_captain;
- ranked6 = false;
- ranked7 = true;
- }
- if (ranker_score >= 1000)
- {
- PlayerPrefs.SetInt("ranker_number", rank_number);
- rank_number = 7;
- currentRank = lt_major;
- ranked7 = false;
- ranked8 = true;
- }
- if (ranker_score >= 1750)
- {
- PlayerPrefs.SetInt("ranker_number", rank_number);
- rank_number = 8;
- currentRank = major;
- ranked8 = false;
- ranked9 = true;
- }
- if (ranker_score >= 3000)
- {
- PlayerPrefs.SetInt("ranker_number", rank_number);
- rank_number = 9;
- currentRank = colonel;
- ranked9 = false;
- ranked10 = true;
- }
- if (ranker_score >= 4750)
- {
- PlayerPrefs.SetInt("ranker_number", rank_number);
- rank_number = 10;
- currentRank = Brigader_general;
- ranked10 = false;
- ranked11 = true;
- }
- if (ranker_score >= 6000)
- {
- PlayerPrefs.SetInt("ranker_number", rank_number);
- rank_number = 11;
- currentRank = maj_general;
- ranked11 = false;
- ranked12 = true;
- }
- if (ranker_score >= 8500)
- {
- PlayerPrefs.SetInt("ranker_number", rank_number);
- rank_number = 12;
- currentRank = lt_general;
- ranked12 = false;
- ranked13 = true;
- }
- if (ranker_score >= 10000)
- {
- PlayerPrefs.SetInt("ranker_number", rank_number);
- rank_number = 13;
- currentRank = lt_general;
- ranked13 = false;
- ranked14 = true;
- }
- if (ranker_score >= 13500)
- {
- PlayerPrefs.SetInt("ranker_number", rank_number);
- rank_number = 14;
- currentRank = general;
- ranked14 = false;
- ranked15 = true;
- }
- if (ranker_score >= 15500)
- {
- PlayerPrefs.SetInt("ranker_number", rank_number);
- rank_number = 15;
- currentRank = fivestargen;
- ranked15 = false;
- ranked16 = true;
- }
- teamBPlayers.Count.ToString();
- Kongregate.Initialize();
- isPurchaseLoaded = false;
- totalCash = PlayerPrefs.GetInt("GP1");
- BMCash = 25000;
- LMACash = 0;
- totalXP = PlayerPrefs.GetInt("totalKill");
- challengeXP = PlayerPrefs.GetInt("cXP");
- recordedDeaths = PlayerPrefs.GetInt("totalDeath");
- PhotonNetwork.isMessageQueueRunning = true;
- photonView.viewID = 100;
- GameSettings.rc = this;
- GameSettings.menuOpened = true;
- leavingRoom = false;
- showScoreBoard = true;
- showOptions = false;
- eneteredBuySpot = false;
- eneteredBombSpot = false;
- showBuyMenu = false;
- currentAddingCashColor = addingColorFadeTo;
- currentTotalCashColor = GameSettings.HUDColor;
- mc = GetComponent<MultiplayerChat>();
- os = GetComponent<OptionsSettings>();
- os.rc = this;
- sb = GetComponent<Scoreboard>();
- sb.rc = this;
- bm = GetComponent<BuyMenu>();
- audioSource = GetComponent<AudioSource>();
- count = 0;
- cameraMouseLook = welcomeCamera.GetComponent<FPSMouseLook>();
- cameraMouseLook.AssignTarget(null);
- yield return new WaitForEndOfFrame();
- //Set out initial properties
- Hashtable setPlayerProperties = new Hashtable();
- setPlayerProperties.Add("Score", (int)0);
- setPlayerProperties.Add("Kills", (int)0);
- setPlayerProperties.Add("Deaths", (int)0);
- setPlayerProperties.Add("Ping", (int)PhotonNetwork.GetPing());
- setPlayerProperties.Add("Team", (int)0); //0 = Spectators, 1 = teamA, 2 = teamB, 3 = Draw
- setPlayerProperties.Add("PlayerHP", (int)-1);
- PhotonNetwork.player.SetCustomProperties(setPlayerProperties);
- RefreshPlayerList();
- welcomeCameraTransform = welcomeCamera.transform;
- defaultCamPos = welcomeCameraTransform.position;
- defaultCamRot = welcomeCameraTransform.rotation;
- timeleft = updateInterval;
- yield return new WaitForEndOfFrame();
- //Set Room properties
- if (PhotonNetwork.isMasterClient)
- {
- referenceTime = (float)PhotonNetwork.time;
- currentGameStatus = 0;
- Hashtable setRoomProperties = new Hashtable();
- setRoomProperties.Add("ReferenceTime", (float)PhotonNetwork.time);
- setRoomProperties.Add("GameStatus", (int)0); //0 = Play, 1 = team A won, 2 = team B won
- setRoomProperties.Add("TeamAScore", (int)0);
- setRoomProperties.Add("TeamBScore", (int)0);
- setRoomProperties.Add("bombTimer", (int)startTime);
- setRoomProperties.Add("bombPlatedTrue", (bool)bombPlanted);
- PhotonNetwork.room.SetCustomProperties(setRoomProperties);
- }
- else
- {
- referenceTime = (float)PhotonNetwork.room.customProperties["ReferenceTime"];
- currentGameStatus = (int)PhotonNetwork.room.customProperties["GameStatus"];
- }
- if (currentGameMode == "RUSH")
- {
- spawnHardPoint = GameObject.Find("HardPointSpawn");
- spawnHardPoint2 = GameObject.Find("HardPointSpawn2");
- spawnHardPoint3 = GameObject.Find("HardPointSpawn3");
- }
- if (currentGameMode == "RUSH")
- {
- createdHardpoint = false;
- //Added photonnetwork.ismasterclient 3/15/18
- if (createdHardpoint == false && PhotonNetwork.isMasterClient)
- {
- createdHardpoint = true;
- //PhotonNetwork.InstantiateSceneObject("Bomb Prefab (1)", spawnHardPoint.transform.position, spawnHardPoint.transform.rotation, 0, null);
- //PhotonNetwork.InstantiateSceneObject("Bomb Prefab (1)", spawnHardPoint2.transform.position, spawnHardPoint2.transform.rotation, 0, null);
- //PhotonNetwork.InstantiateSceneObject("Bomb Prefab (1)", spawnHardPoint3.transform.position, spawnHardPoint3.transform.rotation, 0, null);
- }
- if (createdHardpoint == true)
- {
- }
- }
- yield return new WaitForEndOfFrame();
- currentGameMode = (string)PhotonNetwork.room.customProperties["GameMode"];
- roundDuration = (float)PhotonNetwork.room.customProperties["RoundDuration"];
- GetTeamScores();
- previousGameStatus = currentGameStatus;
- //Used only for FFA mode
- if (PhotonNetwork.room.customProperties["KillLimit"] != null)
- {
- currentKillLimit = (int)PhotonNetwork.room.customProperties["KillLimit"];
- }
- else
- {
- currentKillLimit = 0;
- }
- //Used only for ELM mode
- if (PhotonNetwork.room.customProperties["ScoreLimit"] != null)
- {
- currentScoreLimit = (int)PhotonNetwork.room.customProperties["ScoreLimit"];
- }
- else
- {
- currentScoreLimit = 0;
- }
- if (PhotonNetwork.room.customProperties["WinningPlayer"] != null)
- {
- winningPlayer = (PhotonPlayer)PhotonNetwork.room.customProperties["WinningPlayer"];
- }
- else
- {
- winningPlayer = null;
- }
- //Display notification that we joined room (locally)
- PostActivityRemote(PhotonNetwork.player.name + " joined", "", "", 0, 0);
- InvokeRepeating("RefreshPing", 3.5f, 3.5f);
- GameSettings.currentGameMode = currentGameMode;
- yield return new WaitForEndOfFrame();
- doneSetup = true;
- }
- public void GetTeamScores()
- {
- teamAScore = (int)PhotonNetwork.room.customProperties["TeamAScore"];
- teamBScore = (int)PhotonNetwork.room.customProperties["TeamBScore"];
- }
- public void spawnAi()
- {
- //spawnPoints = GameObject.FindGameObjectsWithTag("spawn");
- if (botCount <= 34)
- {
- botCount++;
- InvokeRepeating("SpawnAi", 1, 3);
- ai1 = PhotonNetwork.Instantiate(Ais[Random.Range(0, Ais.Length)].name, spawnPoints[Random.Range(0, spawnPoints.Length)].transform.position, spawnPoint.rotation, 0) as GameObject;
- ai1.GetComponent<aiCon>().isMine = true;
- }
- PostActivityRemote("Zombie Bot" + Random.Range(1, 999).ToString() + " spawned", "", "", 0, 0);
- }
- //Added March 1st
- public void spawnAi1()
- {
- //spawnPoints = GameObject.FindGameObjectsWithTag("spawn1");
- if (botCount <= 34)
- {
- botCount++;
- InvokeRepeating("SpawnAi", 1, 3);
- ai1 = PhotonNetwork.Instantiate(Ais[Random.Range(0, Ais.Length)].name, spawnPoints[Random.Range(0, spawnPoints.Length)].transform.position, spawnPoint.rotation, 0) as GameObject;
- ai1.GetComponent<aiCon>().isMine = true;
- }
- PostActivityRemote("Marine Bot" + Random.Range(1, 999).ToString() + " spawned", "", "", 0, 0);
- }
- void RefreshPlayerList()
- {
- PhotonPlayer[] playerList = PhotonNetwork.playerList;
- teamAPlayers.Clear();
- teamBPlayers.Clear();
- spectatorNames = "";
- for (int i = 0; i < playerList.Length; i++)
- {
- int playerTeamTmp = playerList[i].customProperties["Team"] != null ? (int)playerList[i].customProperties["Team"] : 0;
- if (playerTeamTmp == 0 || playerTeamTmp < 1 || playerTeamTmp > 2)
- {
- if (spectatorNames != "")
- {
- spectatorNames += ", ";
- }
- spectatorNames += playerList[i].name;
- }
- else
- {
- if (playerTeamTmp == 1)
- {
- teamAPlayers.Add(playerList[i]);
- }
- else
- {
- teamBPlayers.Add(playerList[i]);
- }
- }
- }
- teamAPlayers.Sort(SortPlayers);
- teamBPlayers.Sort(SortPlayers);
- if (PhotonNetwork.player.customProperties["Team"] != null)
- {
- ourTeam = (int)PhotonNetwork.player.customProperties["Team"];
- GameSettings.ourTeam = ourTeam;
- }
- }
- void RefreshPing()
- {
- Hashtable setPlayerProperties = new Hashtable();
- setPlayerProperties.Add("Ping", (int)PhotonNetwork.GetPing());
- PhotonNetwork.player.SetCustomProperties(setPlayerProperties);
- int Ping = (int)PhotonNetwork.player.customProperties["Ping"];
- if(Ping >= 1150) {
- Debug.Log("Player Kicked for High Ping!");
- PhotonNetwork.LeaveRoom();
- }
- }
- public void ResetGameStatus(int statusIndex, PhotonPlayer wp)
- {
- referenceTime = (float)PhotonNetwork.time;
- Hashtable setRoomProperties = new Hashtable();
- setRoomProperties.Add("ReferenceTime", referenceTime);
- setRoomProperties.Add("bombTimer", (int)45);
- setRoomProperties.Add("GameStatus", statusIndex); //0 = Play, 1 = team A won, 2 = team B won, 3 = Draw
- if (statusIndex == 0)
- {
- setRoomProperties.Add("TeamAScore", (int)0);
- setRoomProperties.Add("TeamBScore", (int)0);
- }
- setRoomProperties.Add("WinningPlayer", wp); //Used only for FFA (Fre For All) mode to notify other the winning player
- PhotonNetwork.room.SetCustomProperties(setRoomProperties);
- }
- void announcersound()
- {
- announcersfx.PlayOneShot(almostthere);
- }
- void botSpawner()
- {
- }
- // Update is called once per frame
- void Update()
- {
- if(currentGameMode == "HOBH") {
- RenderSettings.skybox = darkSkybox;
- RenderSettings.fog = true;
- RenderSettings.fogDensity = 0.1F;
- RenderSettings.sun.gameObject.SetActive(false);
- }
- if (!doneSetup)
- return;
- if (Input.GetKeyDown(KeyCode.Tab))
- {
- //Removing showScoreBoard = !showScoreBoard; to the line right below to remove scoreboard for Last Man Standing Players
- showScoreBoard = !showScoreBoard;
- showBuyMenu = false;
- showOptions = false;
- showPauseMenu = true;
- if (showScoreBoard && currentGameMode == "TDM")
- {
- RefreshPlayerList();
- }
- }
- os.enabled = showOptions;
- sb.enabled = showScoreBoard;
- bm.enabled = showBuyMenu;
- if (!ourPlayer || timeToPurchase > 0)
- {
- if (Input.GetKeyDown(GameSettings.playerKeys[13]))
- {
- //print ("Buy menu key pressed");
- showBuyMenu = !showBuyMenu;
- showScoreBoard = false;
- showOptions = false;
- bm.buySection = BuyMenu.BuySection.Primary;
- }
- }
- //When some menu opened, block mouse views, walking, shooting etc.
- GameSettings.menuOpened = showScoreBoard || showBuyMenu || mc.chatState != MultiplayerChat.ChatState.None || showOptions;
- Hashtable setPlayerProperties = new Hashtable();
- setPlayerProperties.Add("Rank", (int)rank_number);
- PhotonNetwork.player.SetCustomProperties(setPlayerProperties);
- /*timeleft = updateInterval;
- accum += Time.timeScale / Time.deltaTime;
- ++frames;
- // Interval ended - update GUI text and start new interval
- if (timeleft <= 0.0)
- {
- // display two fractional digits (f2 format)
- //fps = (accum/frames).ToString("f2") + "FPS";
- GameSettings.currentFPS = accum / frames;
- timeleft = updateInterval;
- accum = 0.0f;
- frames = 0;
- }*/
- //Gradually reduce crosshair distance
- distance = Mathf.Lerp(distance, 5, Time.deltaTime * 10.5f);
- //Lock cursor when needed
- //Added || Input.GetKeyDown(KeyCode.Tab) to if statement below at the end
- //showScoreBoard || showBuyMenu || showOptions || remove on below on
- if (showScoreBoard || showBuyMenu || showOptions || Input.GetKeyDown(KeyCode.Tab))
- {
- if (lockState != 0)
- {
- cursorLocked = false;
- lockState = 0;
- LockCursor(false);
- }
- }
- else
- {
- cursorLocked = true;
- if (lockState != 1)
- {
- cursorLocked = true;
- lockState = 1;
- LockCursor(true);
- }
- }
- }
- IEnumerator Dome1Movein()
- {
- movesIn = 10;
- while(movesIn > 0)
- {
- movesIn--;
- dome1MoveTextActive = true;
- yield return new WaitForSeconds(2);
- dome1MoveTextActive = false;
- }
- }
- IEnumerator Dome2Movein()
- {
- movesIn2 = 10;
- while (movesIn2 > 0)
- {
- movesIn2--;
- dome2MoveTextActive = true;
- yield return new WaitForSeconds(2);
- dome2MoveTextActive = false;
- }
- }
- void LockCursor(bool lockCursor)
- {
- Cursor.lockState = lockCursor ? CursorLockMode.Locked : CursorLockMode.None;
- Cursor.visible = !lockCursor;
- }
- [PunRPC]
- void SetRank(int ranknum)
- {
- ranknum = cm6.rank_number;
- Debug.Log("Rank Number is " + ranknum.ToString());
- }
- void FixedUpdate()
- {
- if (!doneSetup)
- return;
- if (actionReports.Count > 0)
- {
- for (int i = 0; i < actionReports.Count; i++)
- {
- if (actionReports[i].timer > 0)
- {
- actionReports[i].timer -= Time.deltaTime;
- }
- else
- {
- actionReports.RemoveAt(i);
- }
- }
- }
- //Room logic, track round time
- if (currentGameStatus <= 0)
- {
- //currentRoundTime = roundDuration - Mathf.Round(((float)PhotonNetwork.time - referenceTime) * 10) / 10;
- seconds = Mathf.FloorToInt(Mathf.CeilToInt(currentRoundTime) % 60);
- minutes = Mathf.FloorToInt((Mathf.CeilToInt(currentRoundTime) / 60) % 60);
- roundTimeString = string.Format("{0:00}:{1:00}", minutes, seconds);
- if (currentGameMode == "FFA")
- {
- currentRoundTime = roundDuration - Mathf.Round(((float)PhotonNetwork.time - referenceTime) * 10) / 10;
- }
- if (currentGameMode == "BR")
- {
- currentRoundTime = roundDuration - Mathf.Round(((float)PhotonNetwork.time - referenceTime) * 10) / 10;
- }
- if (currentGameMode == "TDM")
- {
- currentRoundTime = roundDuration - Mathf.Round(((float)PhotonNetwork.time - referenceTime) * 10) / 10;
- }
- if (currentGameMode == "HOBH")
- {
- currentRoundTime = roundDuration - Mathf.Round(((float)PhotonNetwork.time - referenceTime) * 10) / 10;
- }
- if (currentGameMode == "RUSH")
- {
- currentRoundTime = roundDuration - Mathf.Round(((float)PhotonNetwork.time - referenceTime) * 10) / 10;
- }
- if (PhotonNetwork.isMasterClient)
- {
- if (currentRoundTime < 1 && PhotonNetwork.time > 0 && referenceTime > 0)
- {
- //Round time ended, check who won
- int tmpGameState = 3;
- PhotonPlayer tmpWinningPlayer = null;
- currentRoundTime = 600;
- if (currentGameMode == "TDM")
- {
- GetTeamScores();
- if (teamAScore > teamBScore)
- {
- tmpGameState = 1;
- }
- if (teamBScore > teamAScore)
- {
- tmpGameState = 2;
- }
- }
- if (currentGameMode == "RUSH")
- {
- GetTeamScores();
- if (teamAScore > teamBScore)
- {
- tmpGameState = 1;
- }
- if (teamBScore > teamAScore)
- {
- tmpGameState = 2;
- }
- }
- if (currentGameMode == "HOBH")
- {
- GetTeamScores();
- if (teamAScore == teamBPlayers.Count)
- {
- tmpGameState = 1;
- }
- if (teamBScore == teamAPlayers.Count)
- {
- tmpGameState = 2;
- }
- }
- if (currentGameMode == "FFA")
- {
- RefreshPlayerList();
- tmpWinningPlayer = teamAPlayers.Count > 0 ? teamAPlayers[0] : null;
- }
- if (currentGameMode == "BR")
- {
- RefreshPlayerList();
- tmpWinningPlayer = teamAPlayers.Count > 0 ? teamAPlayers[0] : null;
- }
- ResetGameStatus(tmpGameState, tmpWinningPlayer);
- }
- else
- {
- //Ensure that reference time always set
- if (referenceTime < 1)
- {
- referenceTime = (float)PhotonNetwork.time;
- Hashtable setRoomProperties = new Hashtable();
- setRoomProperties.Add("ReferenceTime", referenceTime);
- PhotonNetwork.room.SetCustomProperties(setRoomProperties);
- print("Reference time missing, setting it again");
- }
- }
- }
- }
- else
- {
- //Interval before next round
- currentRoundTime = 10 - Mathf.Round(((float)PhotonNetwork.time - referenceTime) * 10) / 10;
- roundTimeString = "00:00";
- if (PhotonNetwork.isMasterClient)
- {
- if (currentRoundTime <= 0)
- {
- //Restart round
- ResetGameStatus(currentGameStatus = 0, null);
- }
- if (currentRoundTime <= 0 && currentGameMode == "BR" && PhotonNetwork.playerList.Length == 1)
- {
- PhotonNetwork.LeaveRoom();
- }
- }
- }
- }
- void OnGUI()
- {
- if (PhotonNetwork.room == null)
- return;
- GUI.skin = GameSettings.guiSkin;
- /*if (ranked2 == true)
- {
- if (ranker_score < 15)
- {
- int currentxprank = ranker_score;
- int nextRank = 15;
- int ranksIn = currentxprank -= nextRank;
- GUI.Label(new Rect(Screen.width / 2 - 80, Screen.height - 100, 400, 30), "Next rank in " + Mathf.Abs(ranksIn).ToString() + " Kills");
- }
- }
- if (ranked3 == true)
- {
- if (ranker_score < 50)
- {
- int currentxprank = ranker_score;
- int nextRank = 50;
- int ranksIn = currentxprank -= nextRank;
- GUI.Label(new Rect(Screen.width / 2 - 80, Screen.height - 100, 400, 30), "Next rank in " + Mathf.Abs(ranksIn).ToString() + " Kills");
- }
- }
- if (ranked4 == true)
- {
- if (ranker_score < 100)
- {
- int currentxprank = ranker_score;
- int nextRank = 100;
- int ranksIn = currentxprank -= nextRank;
- GUI.Label(new Rect(Screen.width / 2 - 80, Screen.height - 100, 400, 30), "Next rank in " + Mathf.Abs(ranksIn).ToString() + " Kills");
- }
- }
- if (ranked5 == true)
- {
- if (ranker_score < 400)
- {
- int currentxprank = ranker_score;
- int nextRank = 400;
- int ranksIn = currentxprank -= nextRank;
- GUI.Label(new Rect(Screen.width / 2 - 80, Screen.height - 100, 400, 30), "Next rank in " + Mathf.Abs(ranksIn).ToString() + " Kills");
- }
- }
- if (ranked6 == true)
- {
- if (ranker_score < 600)
- {
- int currentxprank = ranker_score;
- int nextRank = 600;
- int ranksIn = currentxprank -= nextRank;
- GUI.Label(new Rect(Screen.width / 2 - 80, Screen.height - 100, 400, 30), "Next rank in " + Mathf.Abs(ranksIn).ToString() + " Kills");
- }
- }
- if (ranked7 == true)
- {
- if (ranker_score < 1000)
- {
- int currentxprank = ranker_score;
- int nextRank = 1000;
- int ranksIn = currentxprank -= nextRank;
- GUI.Label(new Rect(Screen.width / 2 - 80, Screen.height - 100, 400, 30), "Next rank in " + Mathf.Abs(ranksIn).ToString() + " Kills");
- }
- }
- if (ranked8 == true)
- {
- if (ranker_score < 1750)
- {
- int currentxprank = ranker_score;
- int nextRank = 1750;
- int ranksIn = currentxprank -= nextRank;
- GUI.Label(new Rect(Screen.width / 2 - 80, Screen.height - 100, 400, 30), "Next rank in " + Mathf.Abs(ranksIn).ToString() + " Kills");
- }
- }
- if (ranked9 == true)
- {
- if (ranker_score < 3000)
- {
- int currentxprank = ranker_score;
- int nextRank = 3000;
- int ranksIn = currentxprank -= nextRank;
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(Screen.width / 2 - 80, Screen.height - 100, 400, 30), "Next rank in " + Mathf.Abs(ranksIn).ToString() + " Kills");
- }
- }
- if (ranked10 == true)
- {
- if (ranker_score < 4750)
- {
- int currentxprank = ranker_score;
- int nextRank = 4750;
- int ranksIn = currentxprank -= nextRank;
- GUI.Label(new Rect(Screen.width / 2 - 80, Screen.height - 100, 400, 30), "Next rank in " + Mathf.Abs(ranksIn).ToString() + " Kills");
- }
- }
- if (ranked11 == true)
- {
- if (ranker_score < 6000)
- {
- int currentxprank = ranker_score;
- int nextRank = 6000;
- int ranksIn = currentxprank -= nextRank;
- GUI.Label(new Rect(Screen.width / 2 - 80, Screen.height - 100, 400, 30), "Next rank in " + Mathf.Abs(ranksIn).ToString() + " Kills");
- }
- }
- if (ranked12 == true)
- {
- if (ranker_score < 8500)
- {
- int currentxprank = ranker_score;
- int nextRank = 8500;
- int ranksIn = currentxprank -= nextRank;
- GUI.Label(new Rect(Screen.width / 2 - 80, Screen.height - 100, 400, 30), "Next rank in " + Mathf.Abs(ranksIn).ToString() + " Kills");
- }
- }
- if (ranked13 == true)
- {
- if (ranker_score < 10000)
- {
- int currentxprank = ranker_score;
- int nextRank = 10000;
- int ranksIn = currentxprank -= nextRank;
- GUI.Label(new Rect(Screen.width / 2 - 80, Screen.height - 100, 400, 30), "Next rank in " + Mathf.Abs(ranksIn).ToString() + " Kills");
- }
- }
- if (ranked14 == true)
- {
- if (ranker_score < 13500)
- {
- int currentxprank = ranker_score;
- int nextRank = 13500;
- int ranksIn = currentxprank -= nextRank;
- GUI.Label(new Rect(Screen.width / 2 - 80, Screen.height - 100, 400, 30), "Next rank in " + Mathf.Abs(ranksIn).ToString() + " Kills");
- }
- }
- if (ranked15 == true)
- {
- if (ranker_score < 15500)
- {
- int currentxprank = ranker_score;
- int nextRank = 15500;
- int ranksIn = currentxprank -= nextRank;
- GUI.Label(new Rect(Screen.width / 2 - 80, Screen.height - 100, 400, 30), "Next rank in " + Mathf.Abs(ranksIn).ToString() + " Kills");
- }
- }*/
- if (currentGameMode == "BR" && spawnedPlayer)
- {
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(5 + 1, 30 + 1, 250, 25), "Players Remaining " + teamAPlayers.Count.ToString() + " ");
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(5, 30, 250, 25), "Players Remaining " + teamAPlayers.Count.ToString() + " ");
- }
- GUIStyle customHUD = new GUIStyle("label");
- customHUD.fontSize = 28;
- customLabel.fontSize = 25;
- customLabel.normal.textColor = new Color(63, 91, 187);
- //Custom Zombies Label commented to remove
- //if (currentGameMode == "BM" && teamAPlayers.Count > 0)
- //{
- //GUI.Label(new Rect(Screen.width / 2 - 75, 50, 165, 150), botCount.ToString() + " Zombies", customLabel);
- //}
- if(currentGameMode == "DE")
- {
- customLayout1.normal.textColor = Color.red;
- customLayout2.normal.textColor = Color.blue;
- //GUI.Label(new Rect(175, 50, 150, 30), "Mercs Alive " + teamaplayersalive.ToString(), customLayout1);
- //GUI.Label(new Rect(425, 50, 150, 30), "Marines Alive " + teambplayerslive.ToString(), customLayout2);
- }
- if (currentGameMode == "TDM"|| currentGameMode == "RUSH" || currentGameMode == "HOBH")
- {
- //GUI.DrawTexture(new Rect(-5, Screen.height - 116, 185, 22), ScoreHUDOVERLAYBG);
- customLayout1.normal.textColor = Color.red;
- customLayout2.normal.textColor = Color.blue;
- customLayout1.fontSize = 30;
- customLayout2.fontSize = 30;
- //GUI.DrawTexture(new Rect(Screen.width / 2 - 0, 85, 150, 50), HUDOverlayBG);
- GUI.Label(new Rect(25, Screen.height - 115, 175, 50), teamAScore.ToString(), customLayout1);
- GUI.Label(new Rect(115, Screen.height - 115, 150, 50), teamBScore.ToString(), customLayout2);
- }
- if (showWeaponText == true)
- {
- GUI.color = Color.white;
- GUI.Label(new Rect(Screen.width / 2 - 10 - distance, Screen.height / 2 - 1, 250, 100), "Switch Weapons Using 1/2/3");
- }
- if (showWeaponText == false)
- {
- }
- if (dead == true)
- {
- this.StartCoroutine("confirmedKillTime");
- GUI.DrawTexture(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 50, 100, 100), confirmedkill);
- GUI.DrawTexture(new Rect(Screen.width / 2 - 50, Screen.height / 2 - 25, 100, 100), scoreDisplay);
- ranksforkill = PlayerPrefs.GetInt("totalKill");
- if (ranksforkill == 15)
- {
- GUI.DrawTexture(new Rect(Screen.width / 2 - 35, Screen.height / 2 - 25, 100, 100), rank2);
- rankupsfx.Play();
- }
- if (ranksforkill == 50)
- {
- GUI.DrawTexture(new Rect(Screen.width / 2 - 35, Screen.height / 2 - 25, 100, 100), rank4);
- rankupsfx.Play();
- }
- if (ranksforkill == 100)
- {
- GUI.DrawTexture(new Rect(Screen.width / 2 - 35, Screen.height / 2 - 25, 100, 100), rank5);
- rankupsfx.Play();
- SteamUserStats.SetAchievement("100_Kills");
- Debug.Log("We won! Achievement unlocked!");
- }
- if (ranksforkill == 400)
- {
- GUI.DrawTexture(new Rect(Screen.width / 2 - 35, Screen.height / 2 - 25, 100, 100), rank6);
- rankupsfx.Play();
- }
- if (ranksforkill == 600)
- {
- GUI.DrawTexture(new Rect(Screen.width / 2 - 35, Screen.height / 2 - 25, 100, 100), rank7);
- rankupsfx.Play();
- SteamUserStats.SetAchievement("600_Kills");
- Debug.Log("We won! Achievement unlocked!");
- }
- if (ranksforkill == 1000)
- {
- GUI.DrawTexture(new Rect(Screen.width / 2 - 35, Screen.height / 2 - 25, 100, 100), rank8);
- rankupsfx.Play();
- SteamUserStats.SetAchievement("1000_Kills");
- Debug.Log("We won! Achievement unlocked!");
- }
- if (ranksforkill == 1750)
- {
- GUI.DrawTexture(new Rect(Screen.width / 2 - 35, Screen.height / 2 - 25, 100, 100), rank9);
- rankupsfx.Play();
- }
- if (ranksforkill == 3000)
- {
- GUI.DrawTexture(new Rect(Screen.width / 2 - 35, Screen.height / 2 - 25, 100, 100), rank10);
- rankupsfx.Play();
- }
- if (ranksforkill == 4750)
- {
- GUI.DrawTexture(new Rect(Screen.width / 2 - 35, Screen.height / 2 - 25, 100, 100), rank11);
- rankupsfx.Play();
- }
- if (ranksforkill == 6000)
- {
- GUI.DrawTexture(new Rect(Screen.width / 2 - 35, Screen.height / 2 - 25, 100, 100), rank12);
- rankupsfx.Play();
- }
- if (ranksforkill == 8500)
- {
- GUI.DrawTexture(new Rect(Screen.width / 2 - 35, Screen.height / 2 - 25, 100, 100), rank13);
- rankupsfx.Play();
- }
- if (ranksforkill == 10000)
- {
- GUI.DrawTexture(new Rect(Screen.width / 2 - 35, Screen.height / 2 - 25, 100, 100), rank14);
- rankupsfx.Play();
- }
- if (ranksforkill == 13500)
- {
- GUI.DrawTexture(new Rect(Screen.width / 2 - 35, Screen.height / 2 - 25, 100, 100), rank15);
- rankupsfx.Play();
- }
- if (ranksforkill == 15500)
- {
- GUI.DrawTexture(new Rect(Screen.width / 2 - 35, Screen.height / 2 - 25, 100, 100), rank15);
- rankupsfx.Play();
- SteamUserStats.SetAchievement("MAX_OUT_1");
- Debug.Log("We won! Achievement unlocked!");
- }
- }
- if (dead == false)
- {
- }
- if (leavingRoom)
- {
- GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), blackScreen);
- }
- else
- {
- if (ourPlayer && !ourPlayer.playerKilled)
- {
- //Show sniper scope
- //if(scopeTexture && ourPlayer.playerWeapons.mainPlayerCamera && ourPlayer.playerWeapons.mainPlayerCamera.fieldOfView == GameSettings.sniperAimFOV){
- if (scopeTexture != GameSettings.currentScopeTexture)
- {
- scopeTexture = GameSettings.currentScopeTexture;
- if (scopeTexture != null)
- {
- scopeTextureRatio = (float)scopeTexture.width / (float)scopeTexture.height;
- //print("scope texture height: " + scopeTexture.height.ToString());
- }
- }
- if (scopeTexture != null)
- {
- GUI.DrawTexture(new Rect(Screen.width / 2 - (Screen.height * scopeTextureRatio) / 2, 0, Screen.height * scopeTextureRatio, Screen.height), scopeTexture, ScaleMode.StretchToFill);
- }
- //Crosshair, only show when not aiming
- if (GameSettings.currentFOV == GameSettings.defaultFOV)
- {
- GUI.color = GameSettings.HUDColor;
- GUI.DrawTexture(new Rect(Screen.width / 2 - 5 - distance, Screen.height / 2 - 1, 5, 1), whiteTexture);
- GUI.DrawTexture(new Rect(Screen.width / 2 + distance, Screen.height / 2 - 1, 5, 1), whiteTexture);
- GUI.DrawTexture(new Rect(Screen.width / 2 - 1, Screen.height / 2 - 5 - distance, 1, 5), whiteTexture);
- GUI.DrawTexture(new Rect(Screen.width / 2 - 1, Screen.height / 2 + distance, 1, 5), whiteTexture);
- }
- if (GameSettings.currentFOV == GameSettings.defaultFOV && ourPlayer.playerWeapons.currentSelectedWeapon.wSettings.fireType == PlayerWeapons.FireType.Shotgun)
- {
- GUI.color = GameSettings.HUDColor;
- GUI.DrawTexture(new Rect(Screen.width / 2 - 5 - distance, Screen.height / 2 - 1, 5, 1), shotgunTexture);
- GUI.DrawTexture(new Rect(Screen.width / 2 + distance, Screen.height / 2 - 1, 5, 1), shotgunTexture);
- GUI.DrawTexture(new Rect(Screen.width / 2 - 1, Screen.height / 2 - 5 - distance, 1, 5), shotgunTexture);
- GUI.DrawTexture(new Rect(Screen.width / 2 - 1, Screen.height / 2 + distance, 1, 5), shotgunTexture);
- }
- if (ourPlayer.fpsController.movementState == 2)
- {
- GUI.DrawTexture(new Rect(105, Screen.height - 52, 42, 42), crouchGuy);
- }
- else if (ourPlayer.fpsController.movementState == 2)
- {
- }
- //if ((int)PhotonNetwork.player.customProperties["PlayerHP"] <= 90)
- //{
- //this.StartCoroutine("RegenHealth");
- //}
- GUI.color = Color.white;
- GUI.DrawTexture(new Rect(-5, Screen.height - 60, 118, 58), HUDOverlayBG);
- GUI.Box(new Rect(10, Screen.height - 60, 100, 50), currentHP.ToString(), customHUD);
- GUI.Label(new Rect(10, Screen.height - 60, 100, 50), currentHP.ToString(), customHUD);
- if (currentHP > 50)
- {
- GUI.DrawTexture(new Rect(70, Screen.height - 55, 42, 42), HPVital);
- }
- //3/14/18
- if (currentHP <= 50)
- {
- //healDone = false;
- //this.StartCoroutine("RegenHealth");
- GUI.DrawTexture(new Rect(70, Screen.height - 56, 42, 42), HPVitalRed);
- }
- if (ourPlayer.playerWeapons.currentSelectedWeapon)
- {
- GUI.DrawTexture(new Rect(Screen.width - 150, Screen.height - 60, 175, 50), HUDOverlayBG);
- GUI.Label(new Rect(Screen.width - 145, Screen.height - 60, 175, 50),
- ourPlayer.playerWeapons.currentSelectedWeapon.wSettings.bulletsPerClip.ToString() + " / " + ourPlayer.playerWeapons.currentSelectedWeapon.wSettings.reserveBullets.ToString() + " ",
- customHUD);
- }
- }
- if (doingHitDetector)
- {
- //Fade hit detectors
- GUI.color = new Color(1, 0, 0, redScreenFade / 7);
- GUI.DrawTexture(new Rect(0, 0, Screen.width, Screen.height), whiteTexture);
- GUI.color = new Color(1, 1, 1, hitTopFade);
- GUI.DrawTexture(new Rect(Screen.width / 2 - 64, Screen.height / 2 - 31 - hitDetectorsDistance, 128, 31), hitTop);
- GUI.color = new Color(1, 1, 1, hitBottomFade);
- GUI.DrawTexture(new Rect(Screen.width / 2 - 64, Screen.height / 2 + hitDetectorsDistance, 128, 31), hitBottom);
- GUI.color = new Color(1, 1, 1, hitLeftFade);
- GUI.DrawTexture(new Rect(Screen.width / 2 - 31 - hitDetectorsDistance, Screen.height / 2 - 64, 31, 128), hitLeft);
- GUI.color = new Color(1, 1, 1, hitRightFade);
- GUI.DrawTexture(new Rect(Screen.width / 2 + hitDetectorsDistance, Screen.height / 2 - 64, 31, 128), hitRight);
- }
- //Show timer
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(Screen.width / 2 - 75, 10, 150, 50), roundTimeString, GameSettings.timeStyle);
- GUI.DrawTexture(new Rect(Screen.width / 2 - 75, 10, 32, 32), clock);
- //Show action reportsrespawn
- for (int i = 0; i < actionReports.Count; i++)
- {
- Vector2 size1 = actionReports[i].leftText != "" ? GameSettings.actionReportStyle.CalcSize(new GUIContent(actionReports[i].middleText)) + new Vector2(5, 0) : Vector2.zero;
- Vector2 size2 = actionReports[i].rightText != "" ? GameSettings.actionReportStyle.CalcSize(new GUIContent(actionReports[i].rightText)) + new Vector2(5, 0) : Vector2.zero;
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(Screen.width - size1.x - size2.x - 260 + 1, 10 + (i * 25) + 1, 250, 25), actionReports[i].leftText, GameSettings.actionReportStyle);
- GUI.color = actionReports[i].leftTextColor;
- GUI.Label(new Rect(Screen.width - size1.x - size2.x - 260, 10 + (i * 25), 250, 25), actionReports[i].leftText, GameSettings.actionReportStyle);
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(Screen.width - size2.x - 260 + 1, 10 + (i * 25) + 1, 250, 25), actionReports[i].middleText, GameSettings.actionReportWeaponStyle);
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(Screen.width - size2.x - 260, 10 + (i * 25), 250, 25), actionReports[i].middleText, GameSettings.actionReportWeaponStyle);
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(Screen.width - 260 + 1, 10 + (i * 25) + 1, 250, 25), actionReports[i].rightText, GameSettings.actionReportStyle);
- GUI.color = actionReports[i].rightTextColor;
- GUI.Label(new Rect(Screen.width - 260, 10 + (i * 25), 250, 25), actionReports[i].rightText, GameSettings.actionReportStyle);
- if (currentGameMode == "TDM")
- {
- //GUI.Label(new Rect(115, Screen.height - 60, 150, 50), (totalCash).ToString() + " GP", customHUD);
- }
- if (currentGameMode == "DE")
- {
- //GUI.Label(new Rect(115, Screen.height - 60, 150, 50), (totalCash).ToString() + " GP", customHUD);
- }
- if (currentGameMode == "RUSH")
- {
- //GUI.Label(new Rect(115, Screen.height - 60, 150, 50), (totalCash).ToString() + " GP", customHUD);
- }
- if (currentGameMode == "FFA")
- {
- //GUI.Label(new Rect(115, Screen.height - 60, 150, 50), (totalCash).ToString() + " GP", customHUD);
- }
- if (currentGameMode == "BR")
- {
- //GUI.Label(new Rect(115, Screen.height - 60, 150, 50), (LMACash).ToString() + " GP", customHUD);
- }
- if (currentGameMode == "BM")
- {
- //GUI.Label(new Rect(115, Screen.height - 60, 150, 50), (BMCash).ToString() + " GP", GameSettings.hudInfoStyle);
- }
- if (currentGameMode == "SR")
- {
- //GUI.Label(new Rect(115, Screen.height - 60, 150, 50), (SRCash).ToString() + " GP", GameSettings.hudInfoStyle);
- }
- }
- //Show cash
- GUI.color = currentAddingCashColor;
- if (currentGameMode == "TDM" || currentGameMode == "FFA" || currentGameMode == "BR" || currentGameMode == "HOBH" || currentGameMode == "RUSH" || currentGameMode == "BM")
- {
- GUI.Label(new Rect(Screen.width / 2 - 5 - distance, Screen.height / 2 - 1, 150, 50), scoreToAddTmp, GameSettings.hudInfoStyle);
- }
- GUI.color = currentTotalCashColor;
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(9, Screen.height - 175, 185, 50), "Press 'Tab' to pause");
- GUI.color = GameSettings.HUDColor;
- if (currentRespawnTime > -1 && currentGameMode != "BM")
- {
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(5 + 1, 30 + 1, 250, 25), "Player spawns in " + currentRespawnTime.ToString() + " ");
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(5, 30, 250, 25), "Player spawns in " + currentRespawnTime.ToString() + " ");
- }
- if (currentRespawnTime > -1 && spawnedPlayer == true && currentGameMode == "BM")
- {
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(5 + 1, 30 + 1, 250, 25), "Player spawns in " + currentRespawnTime.ToString() + " ");
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(5, 30, 250, 25), "Player spawns in " + currentRespawnTime.ToString() + " ");
- }
- if (TimeToStartGame > 0 && currentGameMode == "BR" && spawnedPlayer == true)
- {
- string textTmp = "Game Starts In: " + TimeToStartGame;
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(Screen.width / 2 - 200 + 1, Screen.height - 165 + 1, 400, 30), textTmp, GameSettings.keyPressStyle);
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(Screen.width / 2 - 200, Screen.height - 165, 400, 30), textTmp, GameSettings.keyPressStyle);
- }
- if (startTime > 0 && currentGameMode == "RUSH" && bombPlanted == true)
- {
- string textTmp = "Bomb Detonates In: " + startTime;
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(Screen.width / 2 - 200 + 1, Screen.height - 165 + 1, 400, 30), textTmp, GameSettings.keyPressStyle);
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(Screen.width / 2 - 200, Screen.height - 165, 400, 30), textTmp, GameSettings.keyPressStyle);
- }
- if (eneteredBombSpot && currentGameMode == "RUSH" && ourTeam == 1 && bombPlanted == false)
- {
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(Screen.width / 2 - 100 + 1, Screen.height / 2 + 150 + 1, 200, 30), "Press '" + GameSettings.playerKeys[14].ToString() + "' to arm bomb", GameSettings.keyPressStyle);
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(Screen.width / 2 - 100, Screen.height / 2 + 150, 200, 30), "Press '" + GameSettings.playerKeys[14].ToString() + "' to arm bomb", GameSettings.keyPressStyle);
- if (Input.GetKeyDown(GameSettings.playerKeys[14]) && ourTeam == 1)
- {
- PhotonView photonView = PhotonView.Get(this);
- photonView.RPC("Clock", PhotonTargets.All, startTime);
- }
- }
- if (currentGameMode == "INF" && ourTeam == 1 && infectTime > 0)
- {
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(Screen.width / 2 - 100 + 1, Screen.height / 2 + 150 + 1, 200, 30), "Alpha Zombie In: " + infectTime.ToString(), GameSettings.keyPressStyle);
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(Screen.width / 2 - 100, Screen.height / 2 + 150, 200, 30), "Alpha Zombie In: " + infectTime.ToString(), GameSettings.keyPressStyle);
- PhotonView photonView = PhotonView.Get(this);
- photonView.RPC("StartInf", PhotonTargets.All, infectTime);
- }
- if (eneteredBombSpot && currentGameMode == "RUSH" && ourTeam == 2 && bombPlanted == true)
- {
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(Screen.width / 2 - 100 + 1, Screen.height / 2 + 150 + 1, 200, 30), "Press '" + GameSettings.playerKeys[14].ToString() + "' to defuse bomb", GameSettings.keyPressStyle);
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(Screen.width / 2 - 100, Screen.height / 2 + 150, 200, 30), "Press '" + GameSettings.playerKeys[14].ToString() + "' to defuse bomb", GameSettings.keyPressStyle);
- if (Input.GetKey(GameSettings.playerKeys[14]) && ourTeam == 2)
- {
- Hashtable setRoomProperties = new Hashtable();
- bombPlanted = false;
- PhotonView photonView = PhotonView.Get(this);
- photonView.RPC("ClockStop", PhotonTargets.All, startTime);
- //StopCoroutine("TickCoroutine");
- rankupsfx.Stop();
- rankupsfx.PlayOneShot(firstBlood);
- setRoomProperties.Add("TeamBScore", teamBScore);
- teamBScore++;
- startTime = 45;
- }
- }
- if (eneteredBuySpot && currentGameMode == "BM")
- {
- if (Input.GetKeyDown(GameSettings.playerKeys[13]))
- {
- showBuyMenu = true;
- }
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(Screen.width / 2 - 100 + 1, Screen.height / 2 + 150 + 1, 200, 30), "Press '" + GameSettings.playerKeys[13].ToString() + "' to open Buy Menu", GameSettings.keyPressStyle);
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(Screen.width / 2 - 100, Screen.height / 2 + 150, 200, 30), "Press '" + GameSettings.playerKeys[13].ToString() + "' to open Buy Menu", GameSettings.keyPressStyle);
- }
- if (!ourPlayer || timeToPurchase > 0 && currentGameMode == "TDM")
- {
- string textTmp = "Press '" + GameSettings.playerKeys[13].ToString() + "' to open Buy Menu";
- textTmp += timeToPurchase > 0 && ourPlayer ? " - " + timeToPurchase.ToString() + " seconds left" : "";
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(Screen.width / 2 - 200 + 1, Screen.height - 135 + 1, 400, 30), textTmp, GameSettings.keyPressStyle);
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(Screen.width / 2 - 200, Screen.height - 135, 400, 30), textTmp, GameSettings.keyPressStyle);
- }
- if (!ourPlayer || timeToPurchase > 0 && currentGameMode == "RUSH")
- {
- string textTmp = "Press '" + GameSettings.playerKeys[13].ToString() + "' to open Buy Menu";
- textTmp += timeToPurchase > 0 && ourPlayer ? " - " + timeToPurchase.ToString() + " seconds left" : "";
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(Screen.width / 2 - 200 + 1, Screen.height - 135 + 1, 400, 30), textTmp, GameSettings.keyPressStyle);
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(Screen.width / 2 - 200, Screen.height - 135, 400, 30), textTmp, GameSettings.keyPressStyle);
- }
- if (!ourPlayer || timeToPurchase > 0 && currentGameMode == "BM")
- {
- string textTmp = "Press '" + GameSettings.playerKeys[13].ToString() + "' to open Buy Menu";
- textTmp += timeToPurchase > 0 && ourPlayer ? " - " + timeToPurchase.ToString() + " seconds left" : "";
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(Screen.width / 2 - 200 + 1, Screen.height - 135 + 1, 400, 30), textTmp, GameSettings.keyPressStyle);
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(Screen.width / 2 - 200, Screen.height - 135, 400, 30), textTmp, GameSettings.keyPressStyle);
- }
- if (!ourPlayer || timeToPurchase > 0 && currentGameMode == "BR")
- {
- string textTmp = "Press '" + GameSettings.playerKeys[13].ToString() + "' to open Buy Menu";
- textTmp += timeToPurchase > 0 && ourPlayer ? " - " + timeToPurchase.ToString() + " seconds left" : "";
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(Screen.width / 2 - 200 + 1, Screen.height - 135 + 1, 400, 30), textTmp, GameSettings.keyPressStyle);
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(Screen.width / 2 - 200, Screen.height - 135, 400, 30), textTmp, GameSettings.keyPressStyle);
- }
- if(dome1MoveTextActive == true)
- {
- string textTmp = "Play Area Moves In 10 Seconds";
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(Screen.width / 2 - 200 + 1, Screen.height - 190 + 1, 400, 30), textTmp, GameSettings.keyPressStyle);
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(Screen.width / 2 - 200, Screen.height - 190, 400, 30), textTmp, GameSettings.keyPressStyle);
- }
- if (dome2MoveTextActive == true)
- {
- string textTmp = "Play Area Moves In 10 Seconds";
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(Screen.width / 2 - 200 + 1, Screen.height - 190 + 1, 400, 30), textTmp, GameSettings.keyPressStyle);
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(Screen.width / 2 - 200, Screen.height - 190, 400, 30), textTmp, GameSettings.keyPressStyle);
- }
- if (!ourPlayer || timeToPurchase > 0 && currentGameMode == "SR")
- {
- string textTmp = "Press '" + GameSettings.playerKeys[13].ToString() + "' to open Buy Menu";
- GUI.color = GameSettings.textShadowColor;
- GUI.Label(new Rect(Screen.width / 2 - 200 + 1, Screen.height - 135 + 1, 400, 30), textTmp, GameSettings.keyPressStyle);
- GUI.color = GameSettings.HUDColor;
- GUI.Label(new Rect(Screen.width / 2 - 200, Screen.height - 135, 400, 30), textTmp, GameSettings.keyPressStyle);
- }
- GUI.color = Color.white;
- //Show final screen
- if (currentGameMode == "TDM")
- {
- if (currentGameStatus == 1)
- {
- GUI.color = GameSettings.teamAColor;
- GUI.Label(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 35, 350, 70), GameSettings.teamAName + " Won\n\n" + ((int)currentRoundTime).ToString(), GameSettings.finalScreenStyle);
- }
- if (currentGameStatus == 2)
- {
- GUI.color = GameSettings.teamBColor;
- GUI.Label(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 35, 350, 70), GameSettings.teamBName + " Won\n\n" + ((int)currentRoundTime).ToString(), GameSettings.finalScreenStyle);
- }
- if (currentGameStatus == 3)
- {
- GUI.color = GameSettings.drawColor;
- GUI.Label(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 35, 350, 70), "Draw\n\n" + ((int)currentRoundTime).ToString(), GameSettings.finalScreenStyle);
- }
- }
- if (currentGameMode == "FFA")
- {
- if (currentGameStatus == 3)
- {
- GUI.color = winningPlayer == null ? GameSettings.drawColor : GameSettings.teamAColor;
- GUI.Label(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 35, 350, 70), (winningPlayer == null ? "No winning player" : winningPlayer.name + " Won") + "\n\n" + ((int)currentRoundTime).ToString(), GameSettings.finalScreenStyle);
- }
- }
- if (currentGameMode == "BR")
- {
- if (currentGameStatus == 3)
- {
- GUI.color = winningPlayer == null ? GameSettings.drawColor : GameSettings.teamAColor;
- GUI.Label(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 35, 350, 70), (winningPlayer == null ? "No winning player" : winningPlayer.name + " Won") + "\n\n" + ((int)currentRoundTime).ToString(), GameSettings.finalScreenStyle);
- }
- }
- if (currentGameMode == "RUSH")
- {
- if (currentGameStatus == 1)
- {
- GUI.color = GameSettings.teamAColor;
- GUI.Label(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 35, 350, 70), GameSettings.teamAName + " Won\n\n" + ((int)currentRoundTime).ToString(), GameSettings.finalScreenStyle);
- }
- if (currentGameStatus == 2)
- {
- GUI.color = GameSettings.teamBColor;
- GUI.Label(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 35, 350, 70), GameSettings.teamBName + " Won\n\n" + ((int)currentRoundTime).ToString(), GameSettings.finalScreenStyle);
- }
- if (currentGameStatus == 3)
- {
- GUI.color = GameSettings.drawColor;
- GUI.Label(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 35, 350, 70), "Draw\n\n" + ((int)currentRoundTime).ToString(), GameSettings.finalScreenStyle);
- }
- }
- if (currentGameMode == "HOBH")
- {
- if (currentGameStatus == 1)
- {
- GUI.color = GameSettings.teamAColor;
- GUI.Label(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 35, 350, 70), GameSettings.teamAName + " Won\n\n" + ((int)currentRoundTime).ToString(), GameSettings.finalScreenStyle);
- }
- if (currentGameStatus == 2)
- {
- GUI.color = GameSettings.teamBColor;
- GUI.Label(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 35, 350, 70), GameSettings.teamBName + " Won\n\n" + ((int)currentRoundTime).ToString(), GameSettings.finalScreenStyle);
- }
- if (currentGameStatus == 3)
- {
- GUI.color = GameSettings.drawColor;
- GUI.Label(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 35, 350, 70), "Draw\n\n" + ((int)currentRoundTime).ToString(), GameSettings.finalScreenStyle);
- }
- }
- if (currentGameMode == "BM")
- {
- if (currentGameStatus == 1)
- {
- GUI.color = GameSettings.teamBColor;
- GUI.Label(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 35, 350, 70), GameSettings.teamCName + " Won\n\n" + ((int)currentRoundTime).ToString(), GameSettings.finalScreenStyle);
- }
- if (currentGameStatus == 2)
- {
- GUI.color = GameSettings.teamAColor;
- GUI.Label(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 35, 350, 70), GameSettings.teamAName + " Won\n\n" + ((int)currentRoundTime).ToString(), GameSettings.finalScreenStyle);
- }
- if (currentGameStatus == 3)
- {
- GUI.color = GameSettings.drawColor;
- GUI.Label(new Rect(Screen.width / 2 - 175, Screen.height / 2 - 35, 350, 70), "Survivors Win\n\n" + ((int)currentRoundTime).ToString(), GameSettings.finalScreenStyle);
- }
- }
- GUIStyle customButton = new GUIStyle("button");
- customButton.fontSize = 14;
- //SHow fullscreen button
- if (showScoreBoard || showOptions /*|| showBuyMenu*/)
- {
- GUI.color = Color.white;
- if (GUI.Button(new Rect(Screen.width - 105, 5, 100, 20), "Fullscreen", customButton))
- {
- os.SetFullscreen();
- }
- }
- //SHow Add CASH button
- if (showBuyMenu || showOptions /*|| showBuyMenu*/)
- {
- GUI.color = Color.white;
- }
- }
- }
- /*void startBomb()
- {
- this.StartCoroutine("TickCoroutine");
- }*/
- [PunRPC]
- void Clock(int timer)
- {
- this.StartCoroutine("TickCoroutine");
- bombPlanted = true;
- rankupsfx.Play();
- rankupsfx.loop = true;
- Debug.Log("Timer is at " + timer + bombPlanted.ToString());
- }
- [PunRPC]
- void ClockStop(int timer)
- {
- this.StopCoroutine("TickCoroutine");
- bombPlanted = false;
- timer = 45;
- startTime = 45;
- rankupsfx.Stop();
- Debug.Log("Timer is at " + timer + bombPlanted.ToString());
- }
- [PunRPC]
- void StartInf(int timer)
- {
- this.StartCoroutine("firstInfected");
- rankupsfx.Play();
- rankupsfx.loop = true;
- Debug.Log("Infect Timer is at " + timer);
- }
- IEnumerator TickCoroutine()
- {
- Bomb = GameObject.Find("BuySpot(Clone)");
- explosion = Bomb.transform.Find("explosion");
- Hashtable setRoomProperties = new Hashtable();
- int currentTeamScore = 0;
- //startTime = 124;
- while (startTime > 1)
- {
- startTime-=1;
- yield return new WaitForSeconds(1);
- //rankupsfx.loop = true;
- if (startTime == 1)
- {
- explosion.gameObject.SetActive(true);
- yield return new WaitForSeconds(2);
- Destroy(Bomb);
- bombPlanted = false;
- startTime = 0;
- teamAScore++;
- setRoomProperties.Add("TeamAScore", teamAScore);
- }
- }
- }
- //SPAWN PLAYER CONTROLLER ###############################################################################################################################################
- public void PrepareRespawn(int team, bool wasSwitched)
- {
- if (wasSwitched)
- {
- showScoreBoard = false;
- showBuyMenu = false;
- showOptions = false;
- }
- else
- {
- }
- if (team < 0)
- {
- team = Mathf.Abs(team);
- Transform targetTmp = null;
- //print ("Killer ID: " + team.ToString());
- //Clear empty slots
- for (int i = otherPlayers.Count - 1; i >= 0; i--)
- {
- if (otherPlayers[i] == null)
- {
- otherPlayers.RemoveAt(i);
- }
- else
- {
- if (otherPlayers[i].playerID == team)
- {
- targetTmp = otherPlayers[i].playerAudio.transform;
- //print ("Target player ID: " + otherPlayers[i].playerID.ToString());
- }
- }
- }
- if (ourPlayer)
- {
- welcomeCameraTransform.position = ourPlayer.thisT.position;
- if (targetTmp == null)
- {
- targetTmp = ourPlayer.playerAudio.transform;
- }
- }
- welcomeCamera.gameObject.SetActive(true);
- cameraMouseLook.AssignTarget(targetTmp);
- }
- else
- {
- if (ourPlayer)
- {
- PhotonNetwork.Destroy(ourPlayer.gameObject);
- }
- welcomeCamera.transform.position = defaultCamPos;
- welcomeCamera.transform.rotation = defaultCamRot;
- welcomeCamera.gameObject.SetActive(true);
- Hashtable setPlayerProperties = new Hashtable();
- setPlayerProperties.Add("Team", team); //0 = Spectators, 1 = teamA, 2 = teamB
- setPlayerProperties.Add("PlayerHP", (int)-1);
- PhotonNetwork.player.SetCustomProperties(setPlayerProperties);
- }
- if (currentGameMode == "BM" && ourTeam == 1)
- {
- this.StartCoroutine("PrepareRespawnCoroutine");
- playerSpawnZE = true;
- }
- if (currentGameMode == "SR" && ourTeam == 1)
- {
- this.StartCoroutine("PrepareRespawnCoroutine");
- }
- if (currentGameMode == "BM" && teamAPlayers.Count > 1)
- {
- //this.StartCoroutine("PrepareRespawnCoroutine");
- }
- if (currentGameStatus == 0 && currentGameMode == "TDM" || currentGameMode == "FFA" || currentGameMode == "BR" || currentGameMode == "RUSH" || currentGameMode == "HOBH" || currentGameMode == "BM")
- {
- //this.StopCoroutine("PrepareRespawnCoroutine");
- this.StartCoroutine("PrepareRespawnCoroutine");
- }
- if(currentGameStatus == 0 && currentGameMode == "DE" && currentRoundTime < 110)
- {
- this.StartCoroutine("PrepareRespawnCoroutine");
- }
- if (wasSwitched)
- {
- JoinedTeam(team);
- }
- if (ourPlayer.playerKilled == true && currentGameMode == "TDM")
- {
- GetTeamScores();
- recordedDeaths += 1;
- PlayerPrefs.SetInt("totalDeath", recordedDeaths);
- if (teamAScore == 75)
- {
- GetTeamScores();
- currentGameStatus = 1;
- ResetGameStatus(currentGameStatus, teamAPlayers[0]);
- }
- if (teamBScore == 75)
- {
- GetTeamScores();
- currentGameStatus = 2;
- ResetGameStatus(currentGameStatus, teamBPlayers[0]);
- }
- //Added March 1st
- //PhotonNetwork.Destroy(ourPlayer.gameObject);
- this.StartCoroutine("noSpawn");
- }
- if (ourPlayer.playerKilled == true && currentGameMode == "RUSH")
- {
- GetTeamScores();
- recordedDeaths += 1;
- PlayerPrefs.SetInt("totalDeath", recordedDeaths);
- if (currentGameMode == "RUSH" && teamAScore == 1)
- {
- GetTeamScores();
- currentGameStatus = 1;
- ResetGameStatus(currentGameStatus, teamAPlayers[0]);
- }
- if(currentGameMode == "RUSH" && currentRoundTime < 1)
- {
- GetTeamScores();
- currentGameStatus = 2;
- ResetGameStatus(currentGameStatus, teamBPlayers[0]);
- }
- if (currentGameMode == "RUSH" && teamBScore >= 7500)
- {
- GetTeamScores();
- currentGameStatus = 2;
- ResetGameStatus(currentGameStatus, teamBPlayers[0]);
- }
- this.StartCoroutine("PrepareRespawnCoroutine");
- }
- if (ourPlayer.playerKilled == true && currentGameMode == "FFA")
- {
- if (teamAScore == 1)
- {
- announcersfx.PlayOneShot(firstBlood);
- }
- recordedDeaths += 1;
- PlayerPrefs.SetInt("totalDeath", recordedDeaths);
- this.StartCoroutine("noSpawn");
- this.StopCoroutine("noSpawn");
- }
- if (ourPlayer.playerKilled == true && currentGameMode == "BR")
- {
- recordedDeaths += 1;
- PlayerPrefs.SetInt("totalDeath", recordedDeaths);
- this.StartCoroutine("PrepareRespawnCoroutine");
- PhotonNetwork.LeaveRoom();
- //lmadead = true;
- }
- if (ourPlayer.playerKilled == true && currentGameMode == "HOBH")
- {
- recordedDeaths += 1;
- PlayerPrefs.SetInt("totalDeath", recordedDeaths);
- this.StartCoroutine("LastManStandingCoroutine");
- if (teamBScore == teamAPlayers.Count)
- {
- GetTeamScores();
- currentGameStatus = 2;
- ResetGameStatus(currentGameStatus, teamBPlayers[0]);
- }
- /*
- if (teamAScore == teamBPlayers.Count)
- {
- GetTeamScores();
- currentGameStatus = 1;
- ResetGameStatus(currentGameStatus, teamAPlayers[0]);
- }
- */
- }
- }
- IEnumerator noSpawn()
- {
- Hashtable setPlayerProperties = new Hashtable();
- setPlayerProperties.Add("PlayerHP", (int)-1);
- PhotonNetwork.player.SetCustomProperties(setPlayerProperties);
- currentRespawnTime = 2;
- //Added March 2nd
- //if (ourPlayer)
- //{
- //ourPlayer.gameObject.SetActive(false);
- //}
- while (currentRespawnTime > 1)
- {
- yield return new WaitForSeconds(1);
- if (currentRespawnTime < 0)
- {
- yield return new WaitForSeconds(1);
- SpawnPlayer((int)PhotonNetwork.player.customProperties["Team"]);
- }
- }
- if (currentGameMode == "SR")
- {
- if (currentRespawnTime < 1)
- {
- timeToPurchase = 1000;
- }
- }
- }
- IEnumerator confirmedKillTime()
- {
- expireKill = 2;
- while (expireKill > 1)
- {
- expireKill--;
- yield return new WaitForSeconds(1);
- dead = false;
- }
- }
- IEnumerator firstInfected()
- {
- infectTime = Random.Range(5, 15);
- while (infectTime > 1)
- {
- infectTime--;
- yield return new WaitForSeconds(1);
- }
- }
- IEnumerator respawnInfected()
- {
- while (infectTime > 1)
- {
- infectTime--;
- yield return new WaitForSeconds(1);
- }
- SpawnPlayer(1);
- this.StopCoroutine("respawnInfected");
- }
- IEnumerator InitialprepareZombieBot()
- {
- int timeleft = 45;
- while (timeleft > 1)
- {
- timeleft--;
- yield return new WaitForSeconds(1);
- }
- //for (count = 0; count < 8; count++)
- //spawnAi();
- }
- IEnumerator prepareZombieBot()
- {
- int timeleft = 2;
- while (timeleft > 1)
- {
- timeleft--;
- yield return new WaitForSeconds(1);
- }
- for (count = 0; count < 2; count++)
- spawnAi();
- }
- IEnumerator PrepareRespawnCoroutine()
- {
- currentRespawnTime = 6;
- while (currentRespawnTime > 1)
- {
- currentRespawnTime--;
- yield return new WaitForSeconds(1);
- }
- SpawnPlayer((int)PhotonNetwork.player.customProperties["Team"]);
- if (lmadead == true)
- {
- if (teamAPlayers.Count == 1)
- {
- Debug.Log("Game Is Over! " + teamAPlayers[0].ToString() + "Won!");
- ResetGameStatus(1, teamAPlayers[0]);
- }
- }
- Debug.Log("team A" + teamAPlayers.Count.ToString());
- Debug.Log("team B" + teamBPlayers.Count.ToString());
- if (currentGameMode == "BM")
- {
- SpawnPlayer(1);
- StartCoroutine("InitialprepareZombieBot");
- }
- /*if (ourTeam == 1 && currentGameMode == "DE")
- {
- GetTeamScores();
- }
- if (ourTeam == 2 && currentGameMode == "DE")
- {
- GetTeamScores();
- }
- */
- if (currentGameMode == "SR" && ourTeam == 1)
- {
- SpawnPlayer(1);
- timeToPurchase = 1000;
- }
- }
- public IEnumerator LastManStandingCoroutine()
- {
- currentRespawnTime = 120;
- //LMADead = true;
- while (currentRespawnTime > 1)
- {
- yield return new WaitForSeconds(1);
- };
- }
- IEnumerator BattleRoyaleCoroutine()
- {
- currentRespawnTime = 1500;
- while (currentRespawnTime > 1)
- {
- yield return new WaitForSeconds(1);
- };
- }
- IEnumerator countDownClock()
- {
- TimeToStartGame = 1500;
- TimeToStartGame -= 1445;
- while (TimeToStartGame > -7)
- {
- TimeToStartGame--;
- yield return new WaitForSeconds(1);
- if(deployweapons == true)
- {
- ourPlayer.playerWeapons.currentSelectedWeapon.Deploy();
- }
- countingDown = false;
- }
- }
- IEnumerator showWeaponInfo()
- {
- infoCount = 4;
- while (infoCount > 0)
- {
- infoCount--;
- showWeaponText = true;
- yield return new WaitForSeconds(1);
- showWeaponText = false;
- infoCount = 0;
- }
- }
- public void SpawnPlayer(int team)
- {
- if (ourPlayer)
- {
- PhotonNetwork.Destroy(ourPlayer.gameObject);
- }
- spawnedPlayer = true;
- countingDown = true;
- freeforallstart = true;
- if(currentGameMode == "FFA" && freeforallstart == true)
- {
- announcersfx.PlayOneShot(ffaAudio);
- freeforallstart = false;
- }
- if (currentGameMode == "BR" && spawnedPlayer == true)
- {
- this.StartCoroutine("countDownClock");
- }
- if (team == 1 || team == 2)
- {
- if (currentGameMode == "TDM")
- {
- spawnPontTmp = team == 1 ? teamASpawnPoints[Random.Range(0, teamASpawnPoints.Count - 1)] : teamBSpawnPoints[Random.Range(0, teamBSpawnPoints.Count - 1)];
- }
- if (currentGameMode == "RUSH")
- {
- spawnPontTmp = team == 1 ? teamASpawnPoints[Random.Range(0, teamASpawnPoints.Count - 1)] : teamBSpawnPoints[Random.Range(0, teamBSpawnPoints.Count - 1)];
- }
- if (currentGameMode == "HOBH")
- {
- spawnPontTmp = team == 1 ? teamASpawnPoints[Random.Range(0, teamASpawnPoints.Count - 1)] : teamBSpawnPoints[Random.Range(0, teamBSpawnPoints.Count - 1)];
- spawnPoints = GameObject.FindGameObjectsWithTag("spawn");
- }
- if (currentGameMode == "BM")
- {
- spawnPontTmp = team == 1 ? teamASpawnPoints[Random.Range(0, teamASpawnPoints.Count - 1)] : teamBSpawnPoints[Random.Range(0, teamBSpawnPoints.Count - 1)];
- }
- if (currentGameMode == "SR")
- {
- spawnPontTmp = team == 1 ? teamASpawnPoints[Random.Range(0, teamASpawnPoints.Count - 1)] : teamBSpawnPoints[Random.Range(0, teamBSpawnPoints.Count - 1)];
- }
- if (currentGameMode == "FFA")
- {
- spawnPoints = GameObject.FindGameObjectsWithTag("spawn");
- }
- if (currentGameMode == "BR")
- {
- spawnPoints = GameObject.FindGameObjectsWithTag("brspawn");
- }
- if (currentGameMode == "TDM" || currentGameMode == "RUSH")
- {
- GameObject ourPlayerTmp = PhotonNetwork.Instantiate(playerPrefab.name, spawnPontTmp.position, spawnPontTmp.rotation, 0);
- ourPlayer = ourPlayerTmp.GetComponent<PlayerNetwork>();
- }
- if(currentGameMode == "HOBH" && ourTeam == 1) {
- GameObject ourPlayerTmp = PhotonNetwork.Instantiate(playerPrefab.name, spawnPontTmp.position, spawnPontTmp.rotation, 0);
- ourPlayer = ourPlayerTmp.GetComponent<PlayerNetwork>();
- }
- if(currentGameMode == "HOBH" && ourTeam == 2) {
- GameObject ourPlayerTmp = PhotonNetwork.Instantiate(playerPrefab2.name, spawnPoints[Random.Range(0, spawnPoints.Length)].transform.position, spawnPoint.rotation, 0);
- ourPlayer = ourPlayerTmp.GetComponent<PlayerNetwork>();
- }
- else if (currentGameMode == "BM" || currentGameMode == "SR")
- {
- GameObject ourPlayerTmp = PhotonNetwork.Instantiate(playerPrefab.name, spawnPontTmp.position, spawnPontTmp.rotation, 0);
- ourPlayer = ourPlayerTmp.GetComponent<PlayerNetwork>();
- }
- if(currentGameMode == "FFA" || currentGameMode == "BR")
- {
- GameObject ourPlayerTmp = PhotonNetwork.Instantiate(playerPrefab.name, spawnPoints[Random.Range(0, spawnPoints.Length)].transform.position, spawnPoint.rotation, 0);
- ourPlayer = ourPlayerTmp.GetComponent<PlayerNetwork>();
- }
- bm.lastSelectedWeapon = 1;
- bm.Invoke("ApplySelectedWeapons", 0.035f);
- welcomeCamera.gameObject.SetActive(false);
- this.StopCoroutine("PurchaseTimer");
- this.StartCoroutine("PurchaseTimer");
- }
- else
- {
- welcomeCameraTransform.position = defaultCamPos;
- welcomeCameraTransform.rotation = defaultCamRot;
- welcomeCamera.gameObject.SetActive(true);
- cameraMouseLook.AssignTarget(null);
- team = 0;
- }
- if (PhotonNetwork.player.customProperties["Team"] == null || (int)PhotonNetwork.player.customProperties["Team"] != team)
- {
- Hashtable setPlayerProperties = new Hashtable();
- setPlayerProperties.Add("Team", team); //0 = Spectators, 1 = teamA, 2 = teamB
- PhotonNetwork.player.SetCustomProperties(setPlayerProperties);
- }
- currentRespawnTime = -1;
- }
- IEnumerator PurchaseTimer()
- {
- //Allow some time (in seconds) to allow newly spawned player purchase weapon)
- timeToPurchase = 10;
- while (timeToPurchase > 0)
- {
- timeToPurchase--;
- yield return new WaitForSeconds(1);
- }
- }
- //SPAWN PLAYER CONTROLLE REND ############################################################################################################################################
- //PHOTON NETWORK CALLBACKS ############################################################################################################################################
- void OnLeftRoom()
- {
- //Back to MainMenu scene
- Application.LoadLevel("_WebGL_MaintMenu");
- }
- void OnPhotonPlayerPropertiesChanged(/*object[] playerAndUpdatedProps*/)
- {
- //PhotonPlayer player = playerAndUpdatedProps[0] as PhotonPlayer;
- //Hashtable props = playerAndUpdatedProps[1] as Hashtable;
- RefreshPlayerList();
- if (PhotonNetwork.player.customProperties["PlayerHP"] != null)
- {
- currentHP = (int)PhotonNetwork.player.customProperties["PlayerHP"];
- }
- //print ("Round is already at: " + ((float)PhotonNetwork.time - referenceTime).ToString() + " seconds");
- if (currentGameMode == "HOBH" && currentGameStatus == 0)
- {
- /*if ((int)teamAPlayers[0].customProperties["Kills"] >= teamBPlayers.Count)
- {
- currentGameStatus = 2;
- ResetGameStatus(currentGameStatus, teamAPlayers[0]);
- teamaplayersalive = teamAPlayers.Count;
- teambplayerslive = teamBPlayers.Count;
- }
- */
- if(teamAPlayers.Count > 0) {
- if(teamBScore == (int)teamAPlayers.Count) {
- currentGameStatus = 2;
- ResetGameStatus(currentGameStatus, teamBPlayers[0]);
- }
- }
- }
- if (currentGameMode == "RUSH" && currentGameStatus == 0)
- {
- if ((int)teamAScore == 1)
- {
- currentGameStatus = 1;
- ResetGameStatus(currentGameStatus, teamAPlayers[0]);
- PhotonView photonView = PhotonView.Get(this);
- photonView.RPC("ClockStop", PhotonTargets.All, startTime);
- }
- if(currentRoundTime < 1 && PhotonNetwork.time > 0 && referenceTime > 0)
- {
- if ((int)teamBScore == 1)
- {
- currentGameStatus = 2;
- }
- }
- }
- if (currentGameMode == "INF" && currentGameStatus == 0)
- {
- if ((int)teamBScore == teamAPlayers.Count)
- {
- currentGameStatus = 2;
- ResetGameStatus(currentGameStatus, teamAPlayers[0]);
- }
- if(currentRoundTime < 1 && PhotonNetwork.time > 0 && referenceTime > 0)
- {
- currentGameStatus = 1;
- }
- }
- if (currentGameMode == "FFA" && PhotonNetwork.isMasterClient && currentGameStatus == 0)
- {
- if (teamAPlayers.Count > 0 && (float)PhotonNetwork.time - referenceTime > 15)
- {
- if ((int)teamAPlayers[0].customProperties["Kills"] >= currentKillLimit)
- {
- int tmpGameState = 3;
- ResetGameStatus(tmpGameState, teamAPlayers[0]);
- }
- }
- }
- /*if (currentGameMode == "BR" && PhotonNetwork.isMasterClient && currentGameStatus == 0)
- {
- if (teamAPlayers.Count > 0 && (float)PhotonNetwork.time - referenceTime > 15)
- {
- if ((int)teamAPlayers[0].customProperties["Kills"] >= currentKillLimit)
- {
- int tmpGameState = 3;
- ResetGameStatus(tmpGameState, teamAPlayers[0]);
- }
- }
- }*/
- }
- void OnPhotonPlayerConnected(PhotonPlayer newPlayer)
- {
- //Display notification that player connected
- PostActivityRemote(newPlayer.name + " connected", "", "", 0, 0);
- }
- void OnPhotonPlayerDisconnected(PhotonPlayer otherPlayer)
- {
- RefreshPlayerList();
- //Display notification that player disconnected
- PostActivityRemote(otherPlayer.name + " disconnected", "", "", 0, 0);
- }
- void OnPhotonCustomRoomPropertiesChanged(/*Hashtable propertiesThatChanged*/)
- {
- GetTeamScores();
- referenceTime = (float)PhotonNetwork.room.customProperties["ReferenceTime"];
- currentGameStatus = (int)PhotonNetwork.room.customProperties["GameStatus"];
- currentGameMode = (string)PhotonNetwork.room.customProperties["GameMode"];
- startTime = (int)PhotonNetwork.room.customProperties["bombTimer"];
- //Used only for FFA mode
- if (PhotonNetwork.room.customProperties["KillLimit"] != null)
- {
- currentKillLimit = (int)PhotonNetwork.room.customProperties["KillLimit"];
- }
- if (PhotonNetwork.room.customProperties["bombTimer"] != null)
- {
- Debug.Log("Bomb Timer Set!");
- startTime = (int)PhotonNetwork.room.customProperties["bombTimer"];
- }
- //Used only for ELM mode
- if (PhotonNetwork.room.customProperties["ScoreLimit"] != null)
- {
- currentScoreLimit = (int)PhotonNetwork.room.customProperties["ScoreLimit"];
- }
- if (PhotonNetwork.room.customProperties["WinningPlayer"] != null)
- {
- winningPlayer = (PhotonPlayer)PhotonNetwork.room.customProperties["WinningPlayer"];
- }
- else
- {
- winningPlayer = null;
- }
- if (currentGameStatus == 1 || currentGameStatus == 2 || currentGameStatus == 3)
- {
- //Round ended
- this.StopCoroutine("PrepareRespawnCoroutine");
- if (previousGameStatus != currentGameStatus)
- {
- if (ourPlayer)
- {
- PhotonNetwork.Destroy(ourPlayer.gameObject);
- }
- welcomeCamera.transform.position = defaultCamPos;
- welcomeCamera.transform.rotation = defaultCamRot;
- welcomeCamera.gameObject.SetActive(true);
- showScoreBoard = false;
- if (winningPlayer != null && winningPlayer == PhotonNetwork.player)
- {
- //Wee won, add award
- StartCoroutine(AddCashDelayed());
- }
- previousGameStatus = currentGameStatus;
- }
- }
- //Round was restarted, reset Kills/Deaths and Spawn our player if needed
- if (currentGameStatus == 0 && previousGameStatus != 0)
- {
- if (PhotonNetwork.isMasterClient)
- {
- //Reset kills and deaths for every player
- StopCoroutine("ResetPlayersKillsDeaths");
- StartCoroutine("ResetPlayersKillsDeaths");
- }
- //Recheck our team
- if (PhotonNetwork.player.customProperties["Team"] != null)
- {
- ourTeam = (int)PhotonNetwork.player.customProperties["Team"];
- GameSettings.ourTeam = ourTeam;
- }
- if (ourTeam == 1 || ourTeam == 2)
- {
- SpawnPlayer(ourTeam);
- }
- previousGameStatus = 0;
- }
- }
- IEnumerator ResetPlayersKillsDeaths()
- {
- while (PhotonNetwork.playerList.Length == 0)
- {
- yield return null;
- }
- PhotonPlayer[] playersTmp = PhotonNetwork.playerList;
- Hashtable setPlayerProperties = new Hashtable();
- setPlayerProperties.Add("Kills", (int)0);
- setPlayerProperties.Add("Deaths", (int)0);
- for (int i = 0; i < playersTmp.Length; i++)
- {
- playersTmp[i].SetCustomProperties(setPlayerProperties);
- }
- }
- IEnumerator AddCashDelayed()
- {
- yield return new WaitForSeconds(0.35f);
- AddKillCash(-1);
- }
- //PHOTON NETWORK CALLBACKS END ########################################################################################################################################
- //ROOM ACTIVITY REPORTS ################################################################################################################################################
- void JoinedTeam(int team)
- {
- //team = 0 - spectators, 1 - team A, 2 - team B
- string joinedTeam = "Spectators";
- int colorRef = 0;
- if (team == 1 || team == 2)
- {
- joinedTeam = team == 1 ? GameSettings.teamAName : GameSettings.teamBName;
- colorRef = team;
- }
- photonView.RPC("PostActivityRemote", PhotonTargets.All, PhotonNetwork.playerName + " joined", "", joinedTeam, 0, colorRef);
- }
- public void ReportKill(string killedName, string weaponName, int killedTeam)
- {
- photonView.RPC("PostActivityRemote", PhotonTargets.All, PhotonNetwork.playerName, " " + ourPlayer.playerWeapons.currentSelectedWeapon.killlogWeaponIdentity, killedName, ourTeam, killedTeam);
- //if (killedTeam == 1)
- //GameSettings.rc.teamaplayersalive--;
- //if (killedTeam == 2)
- //GameSettings.rc.teambplayerslive--;
- }
- [PunRPC]
- public void PostActivityRemote(string leftText, string middleText, string rightText, int leftColorRef, int rightColorRef)
- {
- Color leftColorTmp = GameSettings.HUDColor;
- Color rightColorTmp = GameSettings.HUDColor;
- if (leftColorRef == 1 || leftColorRef == 2)
- {
- leftColorTmp = leftColorRef == 1 ? GameSettings.teamAColor : GameSettings.teamBColor;
- }
- if (rightColorRef == 1 || rightColorRef == 2)
- {
- rightColorTmp = rightColorRef == 1 ? GameSettings.teamAColor : GameSettings.teamBColor;
- }
- actionReports.Add(new ActionReport(leftText, middleText, rightText, leftColorTmp, rightColorTmp, 15));
- if (actionReports.Count > 5)
- {
- actionReports.RemoveAt(0);
- }
- }
- //ROOM ACTIVITY REPORTS END ############################################################################################################################################
- //Player HUD controllers
- public void DoHitDetector(int direction)
- {
- if (direction > 0 && direction < 5)
- {
- if (direction == 1)
- {
- hitTopFade = 1;
- }
- if (direction == 2)
- {
- hitBottomFade = 1;
- }
- if (direction == 3)
- {
- hitLeftFade = 1;
- }
- if (direction == 4)
- {
- hitRightFade = 1;
- }
- }
- else
- {
- hitTopFade = 1;
- hitBottomFade = 1;
- hitLeftFade = 1;
- hitRightFade = 1;
- }
- redScreenFade = 1;
- if (!doingHitDetector)
- {
- StartCoroutine(DoHitDetectorCoroutine());
- }
- }
- IEnumerator DoHitDetectorCoroutine()
- {
- doingHitDetector = true;
- while (redScreenFade > 0.01f)
- {
- redScreenFade = Mathf.Lerp(redScreenFade, 0, Time.deltaTime * 5);
- hitTopFade = Mathf.Lerp(hitTopFade, 0, Time.deltaTime * 5);
- hitBottomFade = Mathf.Lerp(hitBottomFade, 0, Time.deltaTime * 5);
- hitLeftFade = Mathf.Lerp(hitLeftFade, 0, Time.deltaTime * 5);
- hitRightFade = Mathf.Lerp(hitRightFade, 0, Time.deltaTime * 5);
- yield return null;
- }
- doingHitDetector = false;
- redScreenFade = 0;
- hitTopFade = 0;
- hitBottomFade = 0;
- hitLeftFade = 0;
- hitRightFade = 0;
- }
- public void AddKillCash(int bodyPart)
- {
- if (bodyPart < -1)
- return;
- //bodyPart 0 = head. 1 = torso, 2 = limbs
- scoreToAddTmp = "";
- if (bodyPart == -1)
- {
- }
- else
- {
- if (bodyPart == 0)
- {
- //kongregateAPI.SubmitData("Highscore", rank_xp);
- headshot_start.clip = headshot_sound;
- //announcersfx.PlayOneShot(headshot_sound);
- //Add cash for headshot
- killSteakXP += 1;
- rank_xp += 1;
- totalXP += 1;
- //string statName = "MostKills";
- //string statValue = totalXP.ToString();
- //Kongregate.SubmitStatistic(statName, statValue);
- //Debug.Log("Total XP " + statValue.ToString());
- scoreToAddTmp = "+1";
- /*if (currentGameMode == "BR")
- {
- scoreToAddTmp = "+150";
- LMACash += 150;
- timeToPurchase = 15;
- this.StartCoroutine("PurchaseTimer");
- }
- */
- PlayerPrefs.SetInt("cXP", challengeXP);
- PlayerPrefs.SetInt("GP1", totalCash);
- PlayerPrefs.SetInt("totalKill", totalXP);
- }
- else
- {
- //kongregateAPI.SubmitData("Highscore", rank_xp);
- headshot_start.clip = headshot_sound;
- headshot_start.Play();
- //Add cash for normal kill
- /*if (currentGameMode == "BM")
- {
- dead = true;
- if (dead == true)
- {
- this.StartCoroutine("confirmedKillTime");
- }
- scoreToAddTmp = "3";
- totalCash += 3;
- }
- */
- //kongregateAPI.SubmitData("MostKills", totalXP);
- //string statName = "MostKills";
- //string statValue = totalXP.ToString();
- //rank_xp += 1;
- //Kongregate.SubmitStatistic(statName, statValue);
- //Debug.Log("Total XP " + statValue.ToString());
- totalXP += 1;
- scoreToAddTmp = "+1";
- /*
- if (currentGameMode == "BR")
- {
- scoreToAddTmp = "+150";
- LMACash += 150;
- timeToPurchase = 15;
- this.StartCoroutine("PurchaseTimer");
- }
- */
- /*
- if (currentGameMode == "BM")
- {
- timeToPurchase = 3;
- scoreToAddTmp = "1";
- BMCash += 1;
- this.StartCoroutine("PurchaseTimer");
- }
- */
- PlayerPrefs.SetInt("GP1", totalCash);
- PlayerPrefs.SetInt("totalKill", totalXP);
- }
- }
- currentAddingCashColor = addingColor;
- currentTotalCashColor = addingColor;
- /*audioSource.Stop();
- audioSource.clip = cashRegisterSound;
- audioSource.Play();*/
- if (!addingKillCash && scoreToAddTmp != "")
- {
- StartCoroutine(AddKIllCashCoroutine());
- }
- }
- public void addBotCash()
- {
- timeToPurchase = 3;
- scoreToAddTmp = "1";
- this.StartCoroutine("PurchaseTimer");
- if (currentHP < 95)
- {
- currentHP += 2;
- }
- if (currentHP >= 100)
- {
- }
- }
- public void AddHealth()
- {
- Hashtable setPlayerProperties = new Hashtable();
- setPlayerProperties.Add("PlayerHP", (int)100);
- PhotonNetwork.player.SetCustomProperties(setPlayerProperties);
- //Removed
- //announcersfx.PlayOneShot(healthSFX);
- }
- //Added this void 11/10/2017
- public void damageHealth()
- {
- int currentzeHP = (int)PhotonNetwork.player.customProperties["PlayerHP"];
- currentzeHP -= 5;
- Hashtable setPlayerProperties = new Hashtable();
- setPlayerProperties.Add("PlayerHP", currentzeHP);
- PhotonNetwork.player.SetCustomProperties(setPlayerProperties);
- if (currentzeHP < 1 && teamAPlayers.Count > 1)
- {
- ourPlayer.playerKilled = true;
- StartCoroutine("LastManStandingCoroutine");
- PhotonNetwork.Destroy(ourPlayer.gameObject);
- }
- if (currentzeHP < 1 && teamAPlayers.Count == 1)
- {
- currentGameStatus = 1;
- ResetGameStatus(currentGameStatus, teamAPlayers[0]);
- }
- }
- public void SubstractCash(int type)
- {
- //Substract cash when refilling ammo or purchasing new Weapon. "type" variable used to detect whether it's secondary primay etc.
- scoreToAddTmp = "";
- if (type == -1)
- {
- //Substracting cash for refilling ammo
- if (totalCash >= 100)
- {
- scoreToAddTmp = "100";
- ourPlayer.playerWeapons.currentSelectedWeapon.wSettings.reserveBullets += 30;
- //Play buy sound
- audioSource.Stop();
- audioSource.clip = buySound;
- audioSource.Play();
- }
- }
- else
- {
- if (bm.GetWeaponCost(type) > -1)
- {
- scoreToAddTmp = bm.GetWeaponCost(type).ToString();
- audioSource.Stop();
- audioSource.clip = cashRegisterSound;
- audioSource.Play();
- }
- }
- currentAddingCashColor = substractingColor;
- currentTotalCashColor = substractingColor;
- if (!addingKillCash /*&& scoreToAddTmp != ""*/)
- {
- StartCoroutine(AddKIllCashCoroutine());
- }
- }
- public int GetCash()
- {
- Debug.Log(cm6.kreds);
- return GameSettings.cnst = totalCash;
- }
- IEnumerator AddKIllCashCoroutine()
- {
- addingKillCash = true;
- addingColorFadeTo = new Color(currentAddingCashColor.r, currentAddingCashColor.g, currentAddingCashColor.b, 0);
- while (Mathf.Abs(((Vector4)GameSettings.HUDColor).magnitude - ((Vector4)currentTotalCashColor).magnitude) > 0.01f)
- {
- currentTotalCashColor = Color.Lerp(currentTotalCashColor, GameSettings.HUDColor, Time.deltaTime * 0.5f);
- currentAddingCashColor = Color.Lerp(currentAddingCashColor, addingColorFadeTo, Time.deltaTime * 0.5f);
- yield return null;
- }
- currentAddingCashColor = addingColorFadeTo;
- currentTotalCashColor = GameSettings.HUDColor;
- addingKillCash = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement