void GameEnd() { playerData = playerDataObject.GetComponent <PlayerDataScript>(); gameCompleteObject.SetActive(true); gameCompleteText = gameCompleteObject.GetComponent <Text>(); int successAmount = (int)playerData.allSuccessRate; int levelScore = (int)playerData.playerScore; //JS int levelHits = (int)playerData.allSuccessfulHits; //JS int levelMisses = (int)playerData.allUnsuccessfulHits; //JS int levelAllHits = (int)playerData.allHits; //JS float missAmount = (100f / levelAllHits) * levelMisses; //JS //gameCompleteText.text = ("Congratulations! You completed the event with " + successAmount.ToString() + "% accuracy and have earned " + successAmount.ToString() + " coins!"); gameOptions = gameOptionsObject.GetComponent <GameOptionsScript>(); //Grab the game data gameOptions.playerSoftCash += successAmount; playerDets.softCurrency += successAmount; playerDets.score += levelScore; levelCompletePanel.SetActive(true); //JS levelEndScoreText.text = levelScore.ToString(); //JS levelEndPerfectsText.text = (levelHits.ToString() + "(" + successAmount.ToString() + "%)"); //JS levelEndMissesText.text = (levelMisses.ToString() + "(" + missAmount.ToString() + "%)"); //JS levelEndRewardText.text = (successAmount.ToString()); // Cat needs to go to trigger Win here }
// Use this for initialization void Start() { clickDetect = GetComponent <ClickDetectScript>(); // Grab the click detection attached to this object holdDetect = GetComponent <HoldDetectScript>(); // Grab the hold detection attached to this object dataObject = GameObject.FindGameObjectWithTag("Timer"); //Grab the object that contains the data playerData = dataObject.GetComponent <PlayerDataScript>(); //Grab player data gameTimer = dataObject.GetComponent <GameTimerScript>(); //Grab timer data timeSpawned = gameTimer.timer; //Sync object timer to game time holdAnim = animHolder.GetComponent <Animator>(); feedbackAnimator = feedbackObject.GetComponent <Animator>(); feedbackExploAnimator = feedbackExploObject.GetComponent <Animator>(); //The following lines establish which level difficulty this button belongs to based on naming conventions //and then assigns the appropriate speedMod theSet = theParent.transform.parent.gameObject; theSetName = theSet.transform.name; if (theSetName != "GameManagerObject") { theSetValue = theSetName[5]; setNumber = int.Parse(theSetValue.ToString()); speedMod = speedMods[setNumber - 1]; } else { speedMod = 1f; } timeToDie *= speedMod; timeToClick *= speedMod; timeToHold *= speedMod; baseTimeForGood *= speedMod; holdAnim.speed = (1 / speedMod); }
// Use this for initialization void Start () { data = DataScript.data; player = PlayerDataScript.playerData; guiInfo = GUIInfo.guiInfo; }
public float diffMod; //Multiplier for game difficulty // Use this for initialization void Start() { gameOptionsObject = GameObject.FindGameObjectWithTag("GameOptions"); //Grab the object that contains the options data gameOptions = gameOptionsObject.GetComponent <GameOptionsScript>(); //Grab the game data gameTimerObject = GameObject.FindGameObjectWithTag("Timer"); //Grab the object that contains the options data playerData = gameTimerObject.GetComponent <PlayerDataScript>(); //Grab the game data diffMod = 0.5f; playerData.numPieces = pieceSpawnTime.Length + 1; playerData.numProceed = Mathf.RoundToInt(playerData.numPieces * 0.5f); //Loop for each object in the set for (int i = pieceSpawnTime.Length - 1; i >= 0; i--) { GameObject levelSet = Instantiate(buttonTypes[pieceType[i]], gameObject.transform, false) as GameObject; //levelSet.transform.SetParent(gameObject.transform, false); //levelSet.transform.localScale = new Vector3(1, 1, 1); levelSet.transform.localPosition = pieceLocation[i]; objectActivate = levelSet.GetComponent <ObjectActivateScript>(); objectActivate.spawnTimer = pieceSpawnTime[i]; levelSet.transform.localEulerAngles = pieceRotation[i]; } }
public void loadGame() { PlayerDataScript data = SaveScript.loadPlayer(); playerLvl = data.level; playerHealth = data.health; playerMana = data.mana; playerExp = data.experience; storyCount = data.storyCount; quests = data.quests; spells = data.spells; items = data.items; itemQuant = data.itemQuant; scene = data.scene; newGameBool = data.newGame; Vector3 position; position.x = data.position[0]; position.y = data.position[1]; position.z = data.position[2]; playerScript.transform.position = position; lvlFade0.FadeToLevel(scene); }
void Start() { playerData = this; data = DataScript.data; SetPlayerState(false); //disables the player by default }
//start a new game function public void newSave() { PlayerDataScript data = gameObject.AddComponent <PlayerDataScript> (); SavePlayer(data); Destroy(data); }
private void Start() { playerData = GetComponent <PlayerDataScript>(); playerUI = GameObject.Find("Player" + playerData.PlayerIndex + "UI"); playerNameText = playerUI.transform.Find("Player" + playerData.PlayerIndex + "Name").GetComponent <TMPro.TextMeshProUGUI>(); playerDamageText = playerUI.transform.Find("Player" + playerData.PlayerIndex + "Damage").GetComponent <TMPro.TextMeshProUGUI>(); playerDamageText.text = "0 %"; playerLifeText = playerUI.transform.Find("Player" + playerData.PlayerIndex + "Life").GetComponent <TMPro.TextMeshProUGUI>(); playerLifeText.text = "Life : " + GetComponent <PlayerLifeSystem>().LifeRemaining; }
// Use this for initialization void Awake() { try{ playerDatascript = GameObject.Find("Player Data Manager").GetComponent <PlayerDataScript> (); saveLoadManager = GameObject.Find("Player Data Manager").GetComponentInChildren <SaveLoadManager> (); } catch (Exception e) { print("Cannot find player data script: Restart from \"Start\" Scene."); } }
void Awake() { //initialise the player game object playerDataScript = GameObject.Find("Player Data Manager").GetComponent <PlayerDataScript>(); if (playerDataScript == null) { print("ERROR - cannot find playerDataScript in saveloadmanager"); } }
// private void Start() { onGround = true; playerData = GetComponent <PlayerDataScript>(); animator = body.GetComponentInChildren <Animator>(); rb = GetComponent <Rigidbody>(); currentTimeBeforeRandomInput = timeBeforeRandomInput; // controller = GetComponent<CharacterController>(); }
public static void savePlayer(OmnisceneScript player) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/player.saveData"; FileStream stream = new FileStream(path, FileMode.Create); PlayerDataScript data = new PlayerDataScript(player); formatter.Serialize(stream, data); stream.Close(); }
// Use this for initialization void Start() { clickDetect = GetComponent <ClickDetectScript>(); // Grab the click detection attached to this object holdDetect = GetComponent <HoldDetectScript>(); // Grab the hold detection attached to this object dataObject = GameObject.FindGameObjectWithTag("Timer"); //Grab the object that contains the data gameCam = GameObject.FindGameObjectWithTag("UICam").GetComponent <Camera>(); playerData = dataObject.GetComponent <PlayerDataScript>(); //Grab player data gameTimer = dataObject.GetComponent <GameTimerScript>(); //Grab timer data timeSpawned = gameTimer.timer; //Sync object timer to game time feedbackAnimator = feedbackObject.GetComponent <Animator>(); // Grab the animator for the feedback object feedbackExploAnimator = feedbackExploObject.GetComponent <Animator>(); }
public void SavePlayer(PlayerDataScript player) { BinaryFormatter bf = new BinaryFormatter(); FileStream stream = new FileStream(Application.dataPath + "/player.sav", FileMode.Create); //"/zSaves/player.sav" // pass in the data of the player so that the class below can handle and store the player attributes // into the stats array PlayerData data = new PlayerData(player); bf.Serialize(stream, data); stream.Close(); }
private int diceRollValue = 0; // should be 1 (minimum) through 6 (maximum) // Use this for initialization void Start() { currentPhaseDone = false; gameOver = false; HelperScript.enableRoads = false; // public static variable HelperScript.enableSettlements = false; // public static variable hexList = gameObject.GetComponent <MapDataScript>().LoadMapData(); UIControllerScript = Camera.main.GetComponent <PlayerUIController>(); if (hexList != null) { foreach (HexDataScript hexData in hexList) { GameObject newHex = (GameObject)Instantiate(hexPrefab, hexData.hexDataPosition, Quaternion.identity); newHex.name = hexData.hexDataName; newHex.GetComponent <HexPrefabData>().SetHexName(newHex.name); newHex.GetComponent <HexPrefabData>().SetHexNumber(hexData.hexDataNumber); newHex.GetComponent <HexPrefabData>().SetHexResourceType(hexData.hexDataResourceType); } } playerList = new List <PlayerDataScript>(); PlayerDataScript tempPlayerData = new PlayerDataScript(); if (HelperScript.playerName != null && HelperScript.playerName.Length > 0) { tempPlayerData.playerName = HelperScript.playerName; } else { tempPlayerData.playerName = "Guest Player"; } tempPlayerData.playerNumber = playerList.Count + 1; tempPlayerData.playerColor = "Yellow"; // HelperScript.playerColor tempPlayerData.playerHexList = new List <HexDataScript>(); tempPlayerData.playerPhase = "Phase0"; playerList.Add(tempPlayerData); Debug.Log("Player Count: " + playerList.Count.ToString()); foreach (PlayerDataScript playerData in playerList) { playerData.LogPlayerData(); } settList = new List <SettDataScript>(); roadList = new List <RoadDataScript>(); currentPhase = 0; currentSubphase = "None"; RunGame(); } // end method Start
// Update is called once per frame void Update() { if (!linkedItem.activeSelf && !wasSpawned) //If the linked item is not active and never was activated { dataScript = timerObject.GetComponent <PlayerDataScript>(); if (gameTimer.timer * dataScript.speedMultiplier > actualTimer) { linkedItem.SetActive(true); artObject.SetActive(true); //JS wasSpawned = true; } } }
void Start() { inventoryContentsArray = new ArrayList(); //find the persisted data playerDataScript = GameObject.Find("Player Data Manager").GetComponent <PlayerDataScript> (); itemData = GameObject.Find("ItemData").GetComponent <ItemData> (); //calculate the current player capcity currentPlayerCapacity = 0; /*--------------Item Generation below---------------*/ //Initialise all items here and add the item to the shop: /*chips*/ //Initialise all items here and add the item to the shop: /*chips*/ chip1 = itemData.chip1; addInventory(chipInventoryGridPanel, chip1, chip1.itemIndex, CHIP, chip1.buttonName); chip2 = itemData.chip2; addInventory(chipInventoryGridPanel, chip2, chip2.itemIndex, CHIP, chip2.buttonName); chip3 = itemData.chip3; addInventory(chipInventoryGridPanel, chip3, chip3.itemIndex, CHIP, chip3.buttonName); chip4 = itemData.chip4; addInventory(chipInventoryGridPanel, chip4, chip4.itemIndex, CHIP, chip4.buttonName); /*skills*/ skill1 = itemData.skill1; addInventory(skillsInventoryGridPanel, skill1, skill1.itemIndex, SKILL, skill1.buttonName); skill2 = itemData.skill2; addInventory(skillsInventoryGridPanel, skill2, skill2.itemIndex, SKILL, skill2.buttonName); /*skins*/ skin1 = itemData.skin1; addInventory(skinsInventoryGridPanel, skin1, skin1.itemIndex, SKIN, skin1.buttonName); skin2 = itemData.skin2; addInventory(skinsInventoryGridPanel, skin2, skin2.itemIndex, SKIN, skin2.buttonName); skin3 = itemData.skin3; addInventory(skinsInventoryGridPanel, skin3, skin3.itemIndex, SKIN, skin3.buttonName); skin4 = itemData.skin4; addInventory(skinsInventoryGridPanel, skin4, skin4.itemIndex, SKIN, skin4.buttonName); skin5 = itemData.skin5; addInventory(skinsInventoryGridPanel, skin5, skin5.itemIndex, SKIN, skin5.buttonName); //dont let any item content show when the shop button is pressed inventoryButton.onClick.AddListener(() => closeContent()); }
void EvaluateAndSpawnNext(int currentDifficulty, int chosenSection) { playerData = playerDataObject.GetComponent <PlayerDataScript>(); if (playerData.successRate < 50f) { playerData.successfulHits = 0; playerData.unsuccessfulHits = 0; } else { advance = true; playerData.successfulHits = 0; playerData.unsuccessfulHits = 0; } GenerateLevel(currentDifficulty, chosenSection); }
public static PlayerDataScript loadPlayer() { string path = Application.persistentDataPath + "/player.saveData"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); PlayerDataScript data = formatter.Deserialize(stream) as PlayerDataScript; stream.Close(); return(data); } else { Debug.LogError("Save file not found in " + path); return(null); } }
// Use this for initialization void Start() { playerDataScript = GameObject.Find("Player Data Manager").GetComponent <PlayerDataScript> (); try { int fileExists = saveLoadManager.loadAll(); //if file doesnt exist or player did not complete the tutorial, then grey out the continue button and dont make it interactable //also do not show the pop up panel (panel which asks if you are erasing saves) if (fileExists == 0 || playerDataScript.mapsCompleted == 0) { showPopUpPanel = false; // dont show the pop up panel continueButton.GetComponent <Button> ().interactable = false; continueButton.GetComponent <Button> ().image.color = new Color(0.6f, 0.6f, 0.6f, 0.6f); } } catch (Exception e) { print("Old save not compatible, please make new save from camp."); } allStartUIPanels = new ArrayList(); allStartUIPanels.Add(startPanel); allStartUIPanels.Add(mainMenuPanel); allStartUIPanels.Add(deleteSavePanel); audioSource = GetComponent <AudioSource> (); //set all panels to false, other than the start Panel to true closeAllPanels(); startPanel.SetActive(true); if (showPopUpPanel == false) { //dont show pop up panel newGameButton.onClick.AddListener(() => noPopUpPanel()); } else { newGameButton.onClick.AddListener(() => openAndClosePopUp(deleteSavePanel)); } }
// Use this for initialization void Start() { data = DataScript.data; //loads the data script targetArmy = data.armyData; //loads the army data player = data.playerData; //loads the player data int targetArmySize = targetArmy.GetArmySize(); //number of party members in player's party targetArray = new GameObject[targetArmySize + 1]; //create an array of targets including the player //set elements of the target array to player and party for (int i = 0; i < targetArmySize; i++) { //targetArray[i] = targetArmy.partySoldiers[i]; } //set the final element to the player targetArray[targetArray.Length - 1] = player.getPlayerObject(); }
// Use this for initialization void Start() { playerDataScript = GameObject.Find("Player Data Manager").GetComponent <PlayerDataScript> (); allTutorialPanels.Add(campTutorialPanel); allTutorialPanels.Add(campShopTutorialPanel); allTutorialPanels.Add(campInventoryTutorialPanel); closeTutorialPanels(); if (playerDataScript.hasDoneCampTutorial == false) { SwitchToPanel.activatePanel(campTutorialPanel, allTutorialPanels); playerDataScript.hasDoneCampTutorial = true; } //set on click listener for shop and inventory button to show tutorial shopButton.onClick.AddListener(() => shopTutorial()); inventoryButton.onClick.AddListener(() => inventoryTutorial()); inventoryButton2.onClick.AddListener(() => inventoryTutorial()); }
void Start() { try{ playerDataScript = GameObject.Find("Player Data Manager").GetComponent <PlayerDataScript>(); }catch (Exception e) { print("ERROR - could not find Player Data Manager"); } //Item (name, info, cost, capacity, buttonName, itemIndex); //Initialise all items here and add the item to the shop: /*chips*/ chip1 = new Item("Chip 1 - Invulnerablilty Cooldown", "+0.5 sec extra invincibility cooldown when damaged", 1500, 1 , "Cooldown", 0); chip2 = new Item("Chip 2 - Player +1", "+1 additional Player which does 25% of the players damage", 4000, 2 , "Player +1", 1); chip3 = new Item("Chip 3 - extra Player +1", "+1 additional Player which does 25% of the players damage", 4500, 2 , "Player +1", 2); chip4 = new Item("Chip 4 - Player +7", "You are basically a god, +7 additional Players which does 25% of the players damage", 99999, 5 , "Player +7", 3); /*skills*/ skill1 = new Item("Skill 1 - Laser beam", "Shoots a laser beam, lots of damage", 8000, 4 , "Laser beam", 0); skill2 = new Item("Skill 2 - Saber launcher", "Throws a light saber from a galaxy far far away...", 4000, 4 , "Saber launcher", 1); /*skins*/ skin1 = new Item("Skin 1 - Shadow Skin", "You will be corrupted...", 3000, 0 , "Shadow", 0); skin2 = new Item("Skin 2 - Toxic waste Skin", "Time to detox?", 9999, 0 , "Toxic waste", 1); skin3 = new Item("Skin 3 - Japan pack Skin", "Japan!", 5000, 0 , "Japan pack", 2); skin4 = new Item("Skin 4 - Camo Skin", "You will be camoflauged...", 1, 0 , "Camo", 3); skin5 = new Item("Skin 5 - Player's Ghost", "You will vindicate them...", 33333, 0 , "Player's Ghost", 4); }
//NOTE: whenever a constructor is changed all other constructors must also be changed //all the data we are saving from the script //constructor 1 - all the data we want to save from an existing player data script public PlayerData(PlayerDataScript playerDataScript) { mapsCompleted = playerDataScript.mapsCompleted; currencyAmount = playerDataScript.currencyAmount; itemCapacity = playerDataScript.itemCapacity; hasDoneCampTutorial = playerDataScript.hasDoneCampTutorial; hasDoneCampShopTutorial = playerDataScript.hasDoneCampShopTutorial; hasDoneCampInventoryTutorial = playerDataScript.hasDoneCampInventoryTutorial; chips = new int[playerDataScript.CHIP_NUM]; skills = new int[playerDataScript.SKILL_NUM]; skins = new int[playerDataScript.SKIN_NUM]; hasEquipchips = new bool[playerDataScript.CHIP_NUM]; hasEquipskills = new bool[playerDataScript.SKILL_NUM]; hasEquipSkins = new bool[playerDataScript.SKIN_NUM]; for (int i = 0; i < playerDataScript.CHIP_NUM; i++) { chips[i] = playerDataScript.chipsList[i]; hasEquipchips[i] = playerDataScript.hasEquipchips[i]; } for (int i = 0; i < playerDataScript.SKILL_NUM; i++) { skills [i] = playerDataScript.skillsList [i]; hasEquipskills[i] = playerDataScript.hasEquipskills[i]; } for (int i = 0; i < playerDataScript.SKIN_NUM; i++) { skins [i] = playerDataScript.skinsList [i]; hasEquipSkins[i] = playerDataScript.hasEquipSkins[i]; } }
public void LoadPersistentData() { GameController.instance.DataStorage.PlayerInfo.ItemIDs.Clear(); string path = Application.persistentDataPath + "/player.fun"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); string message = formatter.Deserialize(stream) as string; Debug.Log(message); PlayerDataScript data = JsonUtility.FromJson <PlayerDataScript>(message); saveContainer = JsonUtility.FromJson <SaveContainer>(message); Debug.Log(saveContainer); if (SpawnStuff == true) { LoadOldPlayerData(saveContainer); LoadGlobalStats(saveContainer); //jeszcze ładowanie odblokowanych itemków jak będzie LoadItemsData(saveContainer); } stream.Close(); //return null; //return data; } else { Debug.Log("NoData"); //return null; } }
void Awake() { playerData = GameObject.FindGameObjectWithTag ("GameController").GetComponent<PlayerDataScript> (); }
private void Start() { playerData = transform.parent.GetComponent <PlayerDataScript>(); currentStunTimer = stunTimer; }
float comboAnimFloat; //JS // Use this for initialization void Start() { dataObject = GameObject.FindGameObjectWithTag("Timer"); //Grab the object that contains the data playerData = dataObject.GetComponent <PlayerDataScript>(); //Grab player data screenFXAnimator = GetComponent <Animator>(); //JS }
// Use this for initialization void Start() { currentPhaseDone = false; gameOver = false; HelperScript.enableRoads = false; // public static variable HelperScript.enableSettlements = false; // public static variable hexList = gameObject.GetComponent<MapDataScript>().LoadMapData(); UIControllerScript = Camera.main.GetComponent<PlayerUIController>(); if (hexList != null) { foreach (HexDataScript hexData in hexList) { GameObject newHex = (GameObject)Instantiate(hexPrefab, hexData.hexDataPosition, Quaternion.identity); newHex.name = hexData.hexDataName; newHex.GetComponent<HexPrefabData>().SetHexName(newHex.name); newHex.GetComponent<HexPrefabData>().SetHexNumber(hexData.hexDataNumber); newHex.GetComponent<HexPrefabData>().SetHexResourceType(hexData.hexDataResourceType); } } playerList = new List<PlayerDataScript>(); PlayerDataScript tempPlayerData = new PlayerDataScript(); if (HelperScript.playerName != null && HelperScript.playerName.Length > 0) tempPlayerData.playerName = HelperScript.playerName; else tempPlayerData.playerName = "Guest Player"; tempPlayerData.playerNumber = playerList.Count + 1; tempPlayerData.playerColor = "Yellow"; // HelperScript.playerColor tempPlayerData.playerHexList = new List<HexDataScript>(); tempPlayerData.playerPhase = "Phase0"; playerList.Add(tempPlayerData); Debug.Log("Player Count: " + playerList.Count.ToString()); foreach (PlayerDataScript playerData in playerList) { playerData.LogPlayerData(); } settList = new List<SettDataScript>(); roadList = new List<RoadDataScript>(); currentPhase = 0; currentSubphase = "None"; RunGame(); }
void Start() { networkManager = GetComponent<NetworkManagerScript>(); playerData = GetComponent<PlayerDataScript>(); }
public int LoadGame() { GameController.instance.DataStorage.PlayerInfo.ItemIDs.Clear(); string path = Application.persistentDataPath + "/player.fun"; if (File.Exists(path)) { BinaryFormatter formatter = new BinaryFormatter(); FileStream stream = new FileStream(path, FileMode.Open); string message = formatter.Deserialize(stream) as string; //Debug.Log(message); PlayerDataScript data = JsonUtility.FromJson <PlayerDataScript>(message); saveContainer = JsonUtility.FromJson <SaveContainer>(message); if (saveContainer.playerData.CanLoad) { Debug.Log(saveContainer); if (SpawnStuff == true) { try { LoadPlayer(saveContainer); LoadRooms(saveContainer); LoadEnemies(saveContainer); //LoadWeapons(saveContainer); LoadItems(saveContainer); LoadGlobalStats(saveContainer); LoadRoundStats(saveContainer); LoadOldPlayerData(saveContainer); LoadEnvironment(saveContainer); //Debug.Log("save system 1"); //Debug.Log("save system 2"); stream.Close(); return(0); } catch (Exception e) { stream.Close(); Debug.LogException(e); return(3); } //Debug.Log("save system 3"); //Debug.Log("save system 4"); //Debug.LogFormat("Loaded game at {0}. Stream was {1}", Time.time, stream.CanRead); } else { return(3); } } else { Debug.Log("Could not load. Player was dead or in tutorial"); stream.Close(); //Debug.LogFormat("Loaded game at {0}. Stream was {1}", Time.time, stream.CanRead); return(1); } //return null; //return data; } else { Debug.Log("NoData"); return(2); //return null; } }
// Update is called once per frame void Update() { gameTimer = dataObject.GetComponent <GameTimerScript>(); // update timer clickDetect = GetComponent <ClickDetectScript>(); // Grab the click detection attached to this object holdDetect = GetComponent <HoldDetectScript>(); // Grab the hold detection attached to this object playerData = dataObject.GetComponent <PlayerDataScript>(); //Grab player data scoreMultiplier = playerData.multiplier; if (clickDetect.wasClicked && holdDetect.isHeld) //If it has been clicked and is being held down { wasHeld = true; //Logs that the object has been hit timeHeld += Time.deltaTime; if (startedPlaying) { holdAnim.speed = (1 / speedMod); audioObject.SetActive(true); } if (!startedPlaying) { holdAnim.SetBool("Held", true); startedPlaying = true; audioObject.SetActive(true); } } if (!clickDetect.wasClicked && wasHeld) //JS If it has been clicked and is released { holdAnim.speed = 0; //JS audioObject.SetActive(false); clickDetect.touchDetect = false; } /* * * if(wasHeld && !holdDetect.isHeld) // If the player held over, but released * { * //This should mostly be used to report a failed click/clean up unused objects * playerData.unsuccessfulHits++; //Log failed hit in data * * //Debug.Log("Object should die here"); * Destroy(theParent); * } */ if (gameTimer.timer > timeSpawned + timeToDie && timeHeld == 0f) //If the object has outlasted its live timer and it was never charged { //This should mostly be used to report a failed click/clean up unused objects playerData.unsuccessfulHits++; //Log failed hit in data playerData.allUnsuccessfulHits++; playerData.setUnsuccessfulHits++; //Debug.Log("Object should die here"); feedbackObject.SetActive(true); //Activate the feedback object feedbackExploObject.SetActive(true); feedbackExploAnimator.SetTrigger("Miss"); audioObject.SetActive(false); feedbackAnimator.SetTrigger("Miss"); playerData.playerCombo = 0; gameObject.SetActive(false); //Deactivate the target object } if (gameTimer.timer > timeSpawned + timeToDie && timeHeld > 0f && timeHeld <= baseTimeForGood) //If the object has outlasted its live but it got charged a bit { //This should mostly be used to report a failed click/clean up unused objects playerData.unsuccessfulHits++; //Log failed hit in data playerData.allUnsuccessfulHits++; playerData.setUnsuccessfulHits++; //Debug.Log("Object should die here"); feedbackObject.SetActive(true); //Activate the feedback object audioObject.SetActive(false); feedbackExploObject.SetActive(true); feedbackExploAnimator.SetTrigger("Bad"); feedbackAnimator.SetTrigger("Bad"); playerData.playerCombo = 0; playerData.playerScore += (50 * scoreMultiplier); gameObject.SetActive(false); //Deactivate the target object } if (gameTimer.timer > timeSpawned + timeToDie && timeHeld > baseTimeForGood) //If the object has outlasted its live but it got charged a lot { //This should mostly be used to report a failed click/clean up unused objects playerData.successfulHits++; //Log failed hit in data playerData.allSuccessfulHits++; playerData.setSuccessfulHits++; //Debug.Log("Object should die here"); feedbackObject.SetActive(true); //Activate the feedback object audioObject.SetActive(false); feedbackExploObject.SetActive(true); feedbackExploAnimator.SetTrigger("Good"); feedbackAnimator.SetTrigger("Good"); playerData.playerCombo++; playerData.playerScore += (200 * scoreMultiplier); gameObject.SetActive(false); //Deactivate the target object } if (timeHeld >= timeToHold) //If it has been held long enough { //This is where we do stuff after the object has been clicked playerData.successfulHits++; //Log successful hit in data // Debug.Log("We clicked it reddit"); playerData.allSuccessfulHits++; playerData.setSuccessfulHits++; feedbackObject.SetActive(true); //Activate the feedback object feedbackExploObject.SetActive(true); feedbackExploAnimator.SetTrigger("Perfect"); feedbackAnimator.SetTrigger("Perfect"); audioObject.SetActive(false); playerData.playerCombo++; playerData.playerScore += (400 * scoreMultiplier); gameObject.SetActive(false); //Deactivate the target object } if (gameTimer.timer > timeSpawned + timeToClick) { //Shouldn't actually need this check, should be handled inside the "Was clicked" part, but hey! //Debug.Log("THIS WAS THE CLICK MOMENT"); } }
// Update is called once per frame void Update() { gameTimer = dataObject.GetComponent <GameTimerScript>(); // update timer clickDetect = GetComponent <ClickDetectScript>(); // Grab the click detection attached to this object holdDetect = GetComponent <HoldDetectScript>(); // Grab the hold detection attached to this object playerData = dataObject.GetComponent <PlayerDataScript>(); //Grab player data scoreMultiplier = playerData.multiplier; if (clickDetect.wasClicked && holdDetect.isHeld) //If it has been clicked and is being held down { wasHeld = true; //Logs that the object has been hit } if (keepGoing) { SlideObject(); oncePerFrame = true; } if (wasHeld && !keepGoing) { if (!oncePerFrame) { audioObject.SetActive(true); SlideObject(); } } if (wasHeld && !holdDetect.isHeld && !keepGoing) // If the player held over, but released { //This should mostly be used to report a failed click/clean up unused objects playerData.unsuccessfulHits++; //Log failed hit in data playerData.allUnsuccessfulHits++; playerData.setUnsuccessfulHits++; playerData.playerCombo = 0; //Debug.Log("Object should die here"); feedbackObject.SetActive(true); //Activate the feedback object feedbackExploObject.SetActive(true); audioObject.SetActive(false); //Deactivate the button sound object feedbackObject.transform.eulerAngles = new Vector3(0, 0, -theParent.transform.rotation.z); feedbackExploObject.transform.eulerAngles = new Vector3(0, 0, -theParent.transform.rotation.z); feedbackAnimator.SetTrigger("Bad"); feedbackExploAnimator.SetTrigger("Bad"); sliderGraphicsParent.SetActive(false); //Deactivate the target object } if (holdDetect.isHeld && clickDetect.wasClicked) //If it has been clicked and is being held down { timeHeld += Time.deltaTime; } if (gameTimer.timer > timeSpawned + timeToDie) //If the object has outlasted its live timer { //This should mostly be used to report a failed click/clean up unused objects playerData.unsuccessfulHits++; //Log failed hit in data playerData.allUnsuccessfulHits++; playerData.setUnsuccessfulHits++; playerData.playerCombo = 0; //Debug.Log("Object should die here"); feedbackObject.SetActive(true); //Activate the feedback object feedbackExploObject.SetActive(true); audioObject.SetActive(false); //Deactivate the button sound object feedbackObject.transform.eulerAngles = new Vector3(0, 0, -theParent.transform.rotation.z); feedbackExploObject.transform.eulerAngles = new Vector3(0, 0, -theParent.transform.rotation.z); feedbackAnimator.SetTrigger("Bad"); feedbackExploAnimator.SetTrigger("Bad"); sliderGraphicsParent.SetActive(false); //Deactivate the target object } if (moveFinished) //If it has been held long enough { //This is where we do stuff after the object has been clicked playerData.successfulHits++; //Log successful hit in data // Debug.Log("We clicked it reddit"); playerData.allSuccessfulHits++; playerData.setSuccessfulHits++; playerData.playerCombo++; playerData.playerScore += (400 * scoreMultiplier); feedbackObject.SetActive(true); //Activate the feedback object feedbackExploObject.SetActive(true); audioObject.SetActive(false); //Deactivate the button sound object feedbackObject.transform.eulerAngles = new Vector3(0, 0, -theParent.transform.rotation.z); feedbackExploObject.transform.eulerAngles = new Vector3(0, 0, -theParent.transform.rotation.z); feedbackAnimator.SetTrigger("Perfect"); feedbackExploAnimator.SetTrigger("Perfect"); sliderGraphicsParent.SetActive(false); //Deactivate the target object } if (gameTimer.timer > timeSpawned + timeToClick) { //Shouldn't actually need this check, should be handled inside the "Was clicked" part, but hey! //Debug.Log("THIS WAS THE CLICK MOMENT"); } }
// Update is called once per frame void Update() { gameTimer = dataObject.GetComponent <GameTimerScript>(); // update timer clickDetect = GetComponent <ClickDetectScript>(); // Grab the click detection attached to this object playerData = dataObject.GetComponent <PlayerDataScript>(); //Grab player data scoreMultiplier = playerData.multiplier; if (clickDetect.wasClicked) //If it has been clicked { //This is where we do stuff after the object has been clicked playerData.successfulHits++; //Log successful hit in data /* JS Needs to instantiate HitFeedbackArt prefab at parent's transform and set animator's trigger "Bad", "Good" or "Perfect", or "Miss" * Tried to be smart and set trigger here while HitFeedbackArt was child to this object, of course it got destroyed :~( */ // Debug.Log("We clicked it reddit"); playerData.allSuccessfulHits++; playerData.setSuccessfulHits++; if (gameTimer.timer - realTimeSpawned >= baseTimeToPerfectLow && gameTimer.timer - realTimeSpawned <= baseTimeToPerfectHigh) { feedbackObject.SetActive(true); //Activate the feedback object feedbackExploObject.SetActive(true); audioObject.SetActive(true); feedbackAnimator.SetTrigger("Perfect"); feedbackExploAnimator.SetTrigger("Perfect"); playerData.playerCombo++; playerData.playerScore += (400 * scoreMultiplier); gameObject.SetActive(false); //Deactivate the target object } else if (gameTimer.timer - realTimeSpawned > baseTimeToGoodBeforeLow & gameTimer.timer - realTimeSpawned < baseTimeToPerfectLow || gameTimer.timer - realTimeSpawned > baseTimeToPerfectHigh && gameTimer.timer - realTimeSpawned < baseTimeToGoodAfterHigh) { feedbackObject.SetActive(true); //Activate the feedback object feedbackExploObject.SetActive(true); feedbackAnimator.SetTrigger("Good"); feedbackExploAnimator.SetTrigger("Good"); audioObject.SetActive(true); playerData.playerCombo++; playerData.playerScore += (200 * scoreMultiplier); gameObject.SetActive(false); //Deactivate the target object } else { feedbackObject.SetActive(true); //Activate the feedback object feedbackExploObject.SetActive(true); feedbackAnimator.SetTrigger("Bad"); feedbackExploAnimator.SetTrigger("Bad"); audioObject.SetActive(true); playerData.playerCombo = 0; playerData.playerScore += (50 * scoreMultiplier); gameObject.SetActive(false); //Deactivate the target object } //It's likely we need to pass some data to the feedbackObject before setting it to false, we'll want the feedbackObject to delete the parent when it's done being all flashy } if (gameTimer.timer > timeSpawned + timeToDie) //If the object has outlasted its live timer { //This should mostly be used to report a failed click/clean up unused objects playerData.unsuccessfulHits++; //Log failed hit in data /* JS Again needs to instantiate HitFeedbackArt with trigger "Miss" * */ //Debug.Log("Object should die here"); playerData.allUnsuccessfulHits++; playerData.setUnsuccessfulHits++; feedbackObject.SetActive(true); //Activate the feedback object feedbackExploObject.SetActive(true); feedbackAnimator.SetTrigger("Miss"); feedbackExploAnimator.SetTrigger("Miss"); playerData.playerCombo = 0; gameObject.SetActive(false); //Deactivate the target object } if (gameTimer.timer > timeSpawned + timeToClick) { //Shouldn't actually need this check, should be handled inside the "Was clicked" part, but hey! //Debug.Log("THIS WAS THE CLICK MOMENT"); } }
void Start() { networkManager = GetComponent<NetworkManagerScript>(); mainMenu = GetComponent<MainMenuScript>(); gameManager = GetComponent<GameManagerScript>(); playerData = GetComponent<PlayerDataScript>(); menuManager = GetComponent<MenuManager>(); hud = GetComponent<HUDScript>(); chatRoom = GetComponent<ChatRoomScript>(); // column rects Horizontal start Vert Start Width Height firstCol = new Rect( 12, 50, Screen.width/3 - 18, Screen.height - 50); secCol = new Rect( Screen.width/3 + 6, 50, Screen.width/3 - 68, Screen.height - 50); thirdCol = new Rect( 2*Screen.width/3 - 44, 50, Screen.width/3 + 32, Screen.height - 50); //the list of teams, as strings List<Team> teams = Team.GetTeamList(); teamList = new string[teams.Count]; for(int x = 0; x < teams.Count; x++) { teamList[x] = teams[x].name; } }
// Use this for initialization void Start() { platformManager = GetComponent<PlatformManagerScript>(); networkManager = GetComponent<NetworkManagerScript>(); spawnManager = GetComponent<SpawnManagerScript>(); menuManager = GetComponent<MenuManager>(); lobby = GetComponent<GameLobbyScript>(); mainMenu = GetComponent<MainMenuScript>(); playerData = GetComponent<PlayerDataScript>(); gameIsActive = false; }
void Start() { playerData = GetComponent<PlayerDataScript>(); }
void GenerateNextSetDetails(int gameDifficulty) { playerData = playerDataObject.GetComponent <PlayerDataScript>(); if (gameDifficulty == 1) { //Evaluate player's success relative to the target for this difficulty if (playerData.setSuccessRate > easySuccessTarget) { currentDifficulty++; if ((playerData.setSuccessRate + lastSectionSuccessRate) / 2 > easySuccessTarget) { currentDifficulty++; } lastSectionSuccessRate = playerData.setSuccessRate; if (currentDifficulty > 8) //Protect against going out of range { currentDifficulty = 8; } } if (playerData.setSuccessRate < (easySuccessTarget - 5)) { currentDifficulty--; if ((playerData.setSuccessRate + lastSectionSuccessRate) / 2 < easySuccessTarget && lastSectionSuccessRate != 0) { currentDifficulty--; } lastSectionSuccessRate = playerData.setSuccessRate; if (currentDifficulty < 1) //Protect against going out of range { currentDifficulty = 1; } } //Next, grab a level set number based on how many exist for the chosen difficulty switch (currentDifficulty) { case 1: chosenSection = Random.Range(0, level1Sets.Length); break; case 2: chosenSection = Random.Range(0, level2Sets.Length); break; case 3: chosenSection = Random.Range(0, level3Sets.Length); break; case 4: chosenSection = Random.Range(0, level4Sets.Length); break; case 5: chosenSection = Random.Range(0, level5Sets.Length); break; case 6: chosenSection = Random.Range(0, level6Sets.Length); break; case 7: chosenSection = Random.Range(0, level7Sets.Length); break; case 8: chosenSection = Random.Range(0, level8Sets.Length); break; } } if (gameDifficulty == 2) { //Evaluate player's success relative to the target for this difficulty if (playerData.setSuccessRate > (mediumSuccessTarget + 5)) { currentDifficulty++; if ((playerData.setSuccessRate + lastSectionSuccessRate) / 2 > mediumSuccessTarget) { currentDifficulty++; } lastSectionSuccessRate = playerData.setSuccessRate; if (currentDifficulty > 8) //Protect against going out of range { currentDifficulty = 8; } } if (playerData.setSuccessRate < (mediumSuccessTarget - 10)) { currentDifficulty--; if ((playerData.setSuccessRate + lastSectionSuccessRate) / 2 < mediumSuccessTarget && lastSectionSuccessRate != 0) { currentDifficulty--; } lastSectionSuccessRate = playerData.setSuccessRate; if (currentDifficulty < 1) //Protect against going out of range { currentDifficulty = 1; } } //Next, grab a level set number based on how many exist for the chosen difficulty switch (currentDifficulty) { case 1: chosenSection = Random.Range(0, level1Sets.Length); break; case 2: chosenSection = Random.Range(0, level2Sets.Length); break; case 3: chosenSection = Random.Range(0, level3Sets.Length); break; case 4: chosenSection = Random.Range(0, level4Sets.Length); break; case 5: chosenSection = Random.Range(0, level5Sets.Length); break; case 6: chosenSection = Random.Range(0, level6Sets.Length); break; case 7: chosenSection = Random.Range(0, level7Sets.Length); break; case 8: chosenSection = Random.Range(0, level8Sets.Length); break; } } if (gameDifficulty == 3) { //Evaluate player's success relative to the target for this difficulty if (playerData.setSuccessRate > hardSuccessTarget + 10) { currentDifficulty++; if ((playerData.setSuccessRate + lastSectionSuccessRate) / 2 > hardSuccessTarget) { currentDifficulty++; } lastSectionSuccessRate = playerData.setSuccessRate; if (currentDifficulty > 8) //Protect against going out of range { currentDifficulty = 8; } } if (playerData.setSuccessRate < (hardSuccessTarget - 10)) { currentDifficulty--; if ((playerData.setSuccessRate + lastSectionSuccessRate) / 2 < hardSuccessTarget && lastSectionSuccessRate != 0) { currentDifficulty--; } lastSectionSuccessRate = playerData.setSuccessRate; if (currentDifficulty < 1) //Protect against going out of range { currentDifficulty = 1; } } //Next, grab a level set number based on how many exist for the chosen difficulty switch (currentDifficulty) { case 1: chosenSection = Random.Range(0, level1Sets.Length); break; case 2: chosenSection = Random.Range(0, level2Sets.Length); break; case 3: chosenSection = Random.Range(0, level3Sets.Length); break; case 4: chosenSection = Random.Range(0, level4Sets.Length); break; case 5: chosenSection = Random.Range(0, level5Sets.Length); break; case 6: chosenSection = Random.Range(0, level6Sets.Length); break; case 7: chosenSection = Random.Range(0, level7Sets.Length); break; case 8: chosenSection = Random.Range(0, level8Sets.Length); break; } } playerData.setSuccessfulHits = 0; playerData.setUnsuccessfulHits = 0; }
// Use this for initialization void Start() { playerDataScript = GameObject.Find("Player Data Manager").GetComponent <PlayerDataScript> (); /*--------------Item Generation below---------------*/ //Initialise all Maps here and add them to the vending machine: /*Maps*/ int mapsCompleted = playerDataScript.mapsCompleted; /*show map tutorial*/ if (mapsCompleted >= 0) { createNewMap("Tutorial", 0, "_TutorialLevel"); } /*show map 1*/ if (mapsCompleted >= 1) { createNewMap("Map 1", 1, "level1"); } /*show map 2*/ if (mapsCompleted >= 2) { createNewMap("Map 2", 2, "level2"); } /*show map 3*/ if (mapsCompleted >= 3) { createNewMap("Map 3", 3, "level3"); } /*show map 4*/ if (mapsCompleted >= 4) { createNewMap("Map 4", 4, "level4"); } /*show map 5*/ if (mapsCompleted >= 5) { createNewMap("Map 5", 5, "level5"); } /*show map 6*/ if (mapsCompleted >= 6) { createNewMap("Map 6", 6, "level6"); } /*show map 7*/ if (mapsCompleted >= 7) { createNewMap("Map 7", 7, "level7"); } /*show map 8*/ if (mapsCompleted >= 8) { createNewMap("Map 8", 8, "level8"); } /*show map 9*/ if (mapsCompleted >= 9) { createNewMap("Map 9", 9, "level9"); } // /*show map 10*/ // if (mapsCompleted >= 10) { // // createNewMap ("Map 10", 10, "level10"); // } }
void Awake() { jumpCount = totalJumps = GameSettings.standardJumpCount; abilities = new List<Ability>(); GameObject game = GameObject.FindGameObjectWithTag("GameController"); hud = game.GetComponent<HUDScript>(); scoreMenu = game.GetComponent<ScoreMenuScript>(); networkManager = game.GetComponent<NetworkManagerScript>(); playerData = game.GetComponent<PlayerDataScript>(); nameDisplay = transform.Find("CharacterNameDisplay").GetComponent<CharacterNameDisplayScript>(); }