/// <summary> /// looks for the level was loaded event. /// </summary> void OnLevelWasLoaded() { if (Application.loadedLevelName == "NewGame") { current = Application.loadedLevelName; } if (Application.loadedLevelName == "Game") { GameObject objGame = GameObject.FindGameObjectWithTag("Constant"); StoredInformation storedIn = objGame.GetComponent <StoredInformation>(); if ((Application.loadedLevelName == "NewGame") || (previos == "NewGame")) { position.x = 1133.947f; position.y = 377.0055f; position.z = 3224.786f; storedIn.positionOnScreen = position; } else if ((storedIn.positionOnScreen.x != 0) && (storedIn.positionOnScreen.y != 0) && (storedIn.positionOnScreen.z != 0)) { position = storedIn.positionOnScreen; } else { position.x = 1133.947f; position.y = 377.0055f; position.z = 3224.786f; storedIn.positionOnScreen = position; } SetCharacterPosition(); } }
// Use this for initialization void Start() { GameObject constantStorage = GameObject.FindGameObjectWithTag("Constant"); StoredInformation obj = constantStorage.GetComponent <StoredInformation>(); levelUp = obj.level; }
/// <summary> /// Addjusts the current health. /// </summary> /// <param name="adj">Adj.</param> /// <param name="type">Type.</param> public void AddjustCurrentHealth(int adj, string type) { GameObject[] Enemies = GameObject.FindGameObjectsWithTag("Enemy2"); constant = GameObject.FindGameObjectWithTag("Constant"); constantStored = constant.GetComponent<StoredInformation>(); player= GameObject.FindGameObjectsWithTag("Player2"); playerStored = player[constantStored.playerNumber-1].GetComponent<BattleAttackDisplay>(); /// <summary> /// Player information.cs /// Title: Hack & Slash RPG - A Unity3D Game Engine Tutorial | BurgZerg Arcade. [Online].; /// Author: Laliberte P. /// Date: 2013 October 24. /// Available from: http://www.burgzergarcade.com/hack-slash-rpg-unity3d-game-engine-tutorial /// inspired idea from tutorial but modified for my own use /// </summary> if(type=="plus"){ curHealth += adj; } if(type=="minus"){ curHealth -= adj; } if (curHealth <= 0){ Destroy(Enemies[playerStored.EnemyNumber]); } if (curHealth > maxHealth) curHealth = maxHealth; }
private void Awake() { gameManager = GameManager.instance; storedinfo = gameManager.GetComponent <StoredInformation>(); ActiveScenes(); }
/// <summary> /// Adds the enemy number. /// </summary> /// <param name="num">Number.</param> public void AddEnemyNumber(int num) { GameObject objGame = GameObject.FindGameObjectWithTag("Constant"); StoredInformation storedIN = objGame.GetComponent <StoredInformation>(); storedIN.enemyRemoval = num; }
/// <summary> /// Adds the player position after battle. /// </summary> /// <param name="playerPositionAfterBattle">Player position after battle.</param> public void AddPlayerPositionAfterBattle(Vector3 playerPositionAfterBattle) { GameObject objGame = GameObject.FindGameObjectWithTag("Constant"); StoredInformation storedIN = objGame.GetComponent <StoredInformation>(); storedIN.positionOnScreen = playerPositionAfterBattle; }
/// <summary> /// Adds the player to scene. /// </summary> /// <param name="fighting">Fighting.</param> public void AddPlayerToScene(int fighting) { GameObject objGame = GameObject.FindGameObjectWithTag("Constant"); StoredInformation storedIN = objGame.GetComponent <StoredInformation>(); storedIN.playerNumber = fighting; }
void Awake() { // playerInfo.Awake(); constVar = GameObject.FindGameObjectWithTag("Constant"); stored = constVar.GetComponent <StoredInformation>(); //timeToAttack = Random.Range(0,80); }
// Use this for initialization void Start() { constant = GameObject.FindGameObjectWithTag("Constant"); constantStored = constant.GetComponent<StoredInformation>(); maxHealth = constantStored._vitalValue[0]/1.5f; //curHealth = constantStored._vitalValue[0]/1.5f; curHealth =0; }
void Awake() { // playerInfo.Awake(); constVar= GameObject.FindGameObjectWithTag("Constant"); stored = constVar.GetComponent<StoredInformation>(); //timeToAttack = Random.Range(0,80); }
/// <summary> /// Start this instance. /// </summary> void Start() { desiredPlayer = GameObject.FindGameObjectsWithTag("Player2"); battle = desiredPlayer[0].GetComponent <BattleTimeScript>(); constVar = GameObject.FindGameObjectWithTag("Constant"); stored = constVar.GetComponent <StoredInformation>(); attacking = new PlayerAttack(); attackingWithMagic = new MagicAttack(); }
// Use this for initialization void Start() { constant = GameObject.FindGameObjectWithTag("Constant"); constantStored = constant.GetComponent <StoredInformation>(); maxHealth = constantStored._vitalValue[0] / 1.5f; //curHealth = constantStored._vitalValue[0]/1.5f; curHealth = 0; }
/// <summary> /// Characters name. /// </summary> /// <param name="chName">Ch name.</param> public void CharacterName(string chName) { GameObject objGame = GameObject.FindGameObjectWithTag("Constant"); StoredInformation storedIN = objGame.GetComponent <StoredInformation>(); characterName = chName; storedIN.characterName = chName; initiliseConstantVariables(); }
// Update is called once per frame void Update() { GameObject[] enemyObjects = GameObject.FindGameObjectsWithTag("Enemy2"); GameObject constantStorage = GameObject.FindGameObjectWithTag("Constant"); StoredInformation obj = constantStorage.GetComponent <StoredInformation>(); if ((enemyObjects.Length == 0) && (!flag)) { if (obj.enemyTypeNumber == 0) { enemyExperience = 25; moneyGained = 25; } if (obj.enemyTypeNumber == 1) { enemyExperience = 20; moneyGained = 20; } if (obj.enemyTypeNumber == 2) { enemyExperience = 15; moneyGained = 15; } for (int cnt = 0; cnt < obj.level; cnt++) { enemyExperience = (int)(enemyExperience * 1.01f); moneyGained = (int)(moneyGained * 1.2f); } if (obj.experience == 0) { obj.experience = 100; } if (addFlag) { myexp = obj.experience + enemyExperience; obj.moneyTotal += moneyGained; obj.check = myexp; oldLevel = obj.nextLevel; addFlag = false; flag = true; } Debug.Log(myexp); } if (flag) { if (Input.GetKeyUp("joystick button 3")) { Application.LoadLevel("Game"); addFlag = true; flag = false; } } }
// Use this for initialization void Start() { Time.timeScale = 1; item = GameObject.FindGameObjectsWithTag("Item"); weapon = GameObject.FindGameObjectsWithTag("Weapon"); magic = GameObject.FindGameObjectsWithTag("Magic"); player = GameObject.FindGameObjectWithTag("Player"); money = new MoneySystem(); info = new StoredInformation(); }
void Awake() { constVar = GameObject.FindGameObjectWithTag("Constant"); stored = constVar.GetComponent <StoredInformation>(); curHealth = stored._vitalValue[0]; maxHealth = stored._vitalValue[0]; healthBarLength = new float[stored.playerNumber]; for (int cnt = 0; cnt > stored.playerNumber; cnt++) { healthBarLength[cnt] = (Screen.width / 4) * (curHealth / (float)maxHealth); } healthBarLength1 = (Screen.width / 4); }
void Awake() { constVar= GameObject.FindGameObjectWithTag("Constant"); stored = constVar.GetComponent<StoredInformation>(); attackBarLength = new float[stored.playerNumber]; check = new bool[stored.playerNumber]; //timeToAttack = Random.Range(0,80); for(int cnt =0; cnt > stored.playerNumber; cnt++){ attackBarLength[cnt] = (Screen.width / 6) * (timeToAttack / (float)attackTime); } attackBarLength1 = (Screen.width / 6); }
void Awake() { constVar = GameObject.FindGameObjectWithTag("Constant"); stored = constVar.GetComponent <StoredInformation>(); attackBarLength = new float[stored.playerNumber]; check = new bool[stored.playerNumber]; //timeToAttack = Random.Range(0,80); for (int cnt = 0; cnt > stored.playerNumber; cnt++) { attackBarLength[cnt] = (Screen.width / 6) * (timeToAttack / (float)attackTime); } attackBarLength1 = (Screen.width / 6); }
public byte[] Serialize(Component component) { using (new UnitySerializer.SerializationSplitScope()) { var renderer = (Renderer)component; var si = new StoredInformation(); si.Enabled = renderer.enabled; if ((Store = renderer.GetComponent <StoreMaterials> ()) != null) { si.materials = renderer.materials.ToList(); } var data = UnitySerializer.Serialize(si); Store = null; return(data); } }
void OnGUI() { GameObject constantStorage = GameObject.FindGameObjectWithTag("Constant"); StoredInformation obj = constantStorage.GetComponent <StoredInformation>(); GameObject[] enemyObjects = GameObject.FindGameObjectsWithTag("Enemy2"); if (enemyObjects.Length == 0) { GUI.BeginGroup(new Rect(((Screen.width / 2) - (buttonGroupWidth / 2)), ((Screen.height / 2) - (buttonGroupHeight / 2)), buttonGroupWidth, buttonGroupHeight)); GUI.enabled = false; int height = (int)buttonGroupHeight / 6; GUI.Label(new Rect(0, 0, buttonGroupWidth, buttonGroupHeight), "", place); labels.alignment = TextAnchor.MiddleCenter; labels.fontSize = 24; labels.normal.textColor = new Color(255, 255, 255); int count = 0; GUI.Label(new Rect(0, count, buttonGroupWidth / 1.5f, heightOfButton), "Current Experience", labels); GUI.Label(new Rect(buttonGroupWidth / 1.5f, count, buttonGroupWidth / 3, heightOfButton), myexp.ToString(), labels); count += heightOfButton; GUI.Label(new Rect(0, count, buttonGroupWidth / 1.5f, heightOfButton), "Experience Gained", labels); GUI.Label(new Rect(buttonGroupWidth / 1.5f, count, buttonGroupWidth / 3, heightOfButton), enemyExperience.ToString(), labels); if (levelUp < obj.level) { count += heightOfButton; GUI.Label(new Rect(0, count, buttonGroupWidth / 1.5f, heightOfButton), "Level up!!", labels); GUI.Label(new Rect(buttonGroupWidth / 1.5f, count, buttonGroupWidth / 3, heightOfButton), obj.level.ToString(), labels); } count += heightOfButton; GUI.Label(new Rect(0, count, buttonGroupWidth / 1.5f, heightOfButton), "Money Gained", labels); GUI.Label(new Rect(buttonGroupWidth / 1.5f, count, buttonGroupWidth / 3, heightOfButton), moneyGained.ToString(), labels); count += heightOfButton; GUI.Label(new Rect(0, count, buttonGroupWidth / 1.5f, heightOfButton), "CurrentMoney", labels); GUI.Label(new Rect(buttonGroupWidth / 1.5f, count, buttonGroupWidth / 3, heightOfButton), obj.moneyTotal.ToString(), labels); GUI.Button(new Rect(buttonGroupWidth / 6, buttonGroupHeight - heightOfButton, buttonGroupWidth / 1.5f, heightOfButton), "To continue press", labels); sty.alignment = TextAnchor.MiddleRight; GUI.Button(new Rect(buttonGroupWidth / 6, buttonGroupHeight - heightOfButton, buttonGroupWidth / 1.5f, heightOfButton), text, sty); GUI.EndGroup(); } }
void OnGUI() { if (paused) { GameObject con = GameObject.FindGameObjectWithTag("Constant"); GameObject player = GameObject.FindGameObjectWithTag("Player"); GUI.BeginGroup(new Rect(((Screen.width / 2) - (buttonGroupWidth / 2)), ((Screen.height / 2) - (buttonGroupHeight / 2)), buttonGroupWidth, buttonGroupHeight)); if (GUI.Button(new Rect(0, 0, widthOfButton, heightOfButton), "Resume")) { paused = enableDisablePauseScreen(); } if (GUI.Button(new Rect(0, 60, widthOfButton, heightOfButton), "Main Menu")) { Application.LoadLevel("Main Menu"); Destroy(con); Destroy(player); } if (GUI.Button(new Rect(0, 120, widthOfButton, heightOfButton), "Save Game")) { StoredInformation st = con.GetComponent <StoredInformation>(); info.SaveData(); } if (GUI.Button(new Rect(0, 180, widthOfButton, heightOfButton), "Load Game")) { if (Application.loadedLevelName == "Game") { Destroy(player); //Destroy(this); Application.LoadLevel("Game"); } info.LoadData(); } if (GUI.Button(new Rect(0, 240, widthOfButton, heightOfButton), "Quit Game")) { Application.Quit(); } GUI.EndGroup(); } }
/// <summary> /// Raises the trigger enter event. /// brings on about the battle simulations while telling the program the correct enemy to send into battle /// </summary> /// <param name="playerInRange">Player in range.</param> void OnTriggerEnter(Collider playerInRange) { GameObject player = GameObject.FindGameObjectWithTag("Player"); GameObject constVar = GameObject.FindGameObjectWithTag("Constant"); GameObject[] Enemies = GameObject.FindGameObjectsWithTag("Enemy2"); float prev = 1000000; int num = 0; for (int cnt = 0; cnt < Enemies.Length; cnt++) { if (Vector3.Distance(player.transform.position, Enemies[cnt].transform.position) < prev) { prev = Vector3.Distance(player.transform.position, Enemies[cnt].transform.position); num = cnt; } } int enemyfight = 0; if (Enemies[num].name == "CaveWorm(Clone)") { enemyfight = 0; } if (Enemies[num].name == "Monster2Prefab(Clone)") { enemyfight = 1; } if (Enemies[num].name == "spider(Clone)") { enemyfight = 2; } StoredInformation stored = constVar.GetComponent <StoredInformation>(); if (playerInRange.gameObject.tag == "Player") { stored.AddEnemyToScene(enemyfight); stored.AddPlayerPositionAfterBattle(player.transform.position); stored.AddEnemyNumber(num); Application.LoadLevel("Battle Simulation"); Destroy(player); } }
// Use this for initialization private void Awake() { gameManager = GameManager.instance; info = gameManager.GetComponent <LevelManager>(); scoreScript = Score.instance; currentScene = SceneManager.GetActiveScene(); storedinfo = gameManager.GetComponent <StoredInformation>(); sceneName = currentScene.name; themePanel = info.themePanel; stuntPanel = info.stuntPanel; // ActiveScenes(); }
void Generate() { positions = new GameObject[Enmy.Length]; int enemyNumb; if (Application.loadedLevelName == "Game") { GameObject constVar = GameObject.FindGameObjectWithTag("Constant"); StoredInformation stored = constVar.GetComponent <StoredInformation>(); for (int cnt = 0; cnt < Enmy.Length; cnt++) { enemyNumb = Random.Range(0, 3); if (Vector3.Distance(stored.positionOnScreen, Enmy[cnt].transform.position) > 20) { Enmy[cnt] = Instantiate(enemylisting[enemyNumb], Enmy[cnt].transform.position, Quaternion.identity) as GameObject; } else { Destroy(Enmy[cnt]); } } } if (Application.loadedLevelName == "Battle Simulation") { GameObject constVar = GameObject.FindGameObjectWithTag("Constant"); StoredInformation stored = constVar.GetComponent <StoredInformation>(); int EnemyAmount = Random.Range(1, 3); for (int cnt = 0; cnt < Enmy.Length; cnt++) { enemyNumb = stored.enemyTypeNumber; if (cnt <= EnemyAmount) { Enmy[cnt] = Instantiate(enemylisting[enemyNumb], Enmy[cnt].transform.position, Quaternion.AngleAxis(210, new Vector3(0, 1, 0))) as GameObject; } } } }
/// <summary> /// Adds the items. /// </summary> /// <param name="chName">Ch name.</param> /// <param name="itemPower">Item power.</param> public void addItems(string chName, string itemPower) { GameObject objGame = GameObject.FindGameObjectWithTag("Constant"); StoredInformation stored = objGame.GetComponent <StoredInformation>(); if (itemAmount == 0) { itemAmount = 1; } else { itemAmount++; } stored.itemsNameArray.Add(chName); stored.itemsContentArray.Add(itemPower); stored.items = new string[stored.itemsNameArray.Count]; stored.itemsNameArray.CopyTo(stored.items); stored.itemId = new string[stored.itemsContentArray.Count]; stored.itemsContentArray.CopyTo(stored.itemId); }
void Generate() { int playerNumb; GameObject constVar = GameObject.FindGameObjectWithTag("Constant"); StoredInformation stored = constVar.GetComponent <StoredInformation>(); int playerAmount = Random.Range(1, 3); for (int cnt = 0; cnt < Players.Length; cnt++) { playerNumb = stored.playerNumber; if (cnt < playerAmount - 1) { Players[cnt] = Instantiate(playerlisting[cnt], Players[cnt].transform.position, Quaternion.AngleAxis(37.47f, new Vector3(0, 1, 0))) as GameObject; Players[cnt].name = stored.characterName; Players[cnt].tag = "Player2"; } } PlayerBattle = GameObject.FindGameObjectsWithTag("Player2"); }
void Awake() { instance = this; gameManager = GameManager.instance; storedinfo = gameManager.GetComponent <StoredInformation>(); levelManagerScript = gameManager.GetComponent <LevelManager>(); budget.text = information.budget.ToString(); endbudget.text = information.budget.ToString(); thebudget = information.budget; currentCost.text = thecurrentCost.ToString(); endCost.text = thecurrentCost.ToString(); thecurrentCost = information.currentCost; storedinfo.totalBudget += information.budget; color = currentCost.color; //// find fix for replaying and score//// if (information.stuntEnd == true) { storedinfo.totalBudget -= thebudget; storedinfo.totalStuntCost -= thecurrentCost; thecurrentCost = 0; storedinfo.stuntEnd -= stuntEnd; } }
/// <summary> /// Loads data from json file /// </summary> private void LoadInput() { string filepath = Application.dataPath + gameDataProjectFilePath; if (File.Exists(filepath)) { string dataAsJson = File.ReadAllText(filepath); if (dataAsJson != null) { storage = JsonUtility.FromJson <StoredInformation>(dataAsJson); } } else { storage = new StoredInformation(); } if (storage.configurations.Count > 0) { return; } storage.configurations = DefaultAxes; }
/// <summary> /// Addjusts the current health. /// </summary> /// <param name="adj">Adj.</param> /// <param name="type">Type.</param> public void AddjustCurrentHealth(int adj, string type) { GameObject[] Enemies = GameObject.FindGameObjectsWithTag("Enemy2"); constant = GameObject.FindGameObjectWithTag("Constant"); constantStored = constant.GetComponent <StoredInformation>(); player = GameObject.FindGameObjectsWithTag("Player2"); playerStored = player[constantStored.playerNumber - 1].GetComponent <BattleAttackDisplay>(); /// <summary> /// Player information.cs /// Title: Hack & Slash RPG - A Unity3D Game Engine Tutorial | BurgZerg Arcade. [Online].; /// Author: Laliberte P. /// Date: 2013 October 24. /// Available from: http://www.burgzergarcade.com/hack-slash-rpg-unity3d-game-engine-tutorial /// inspired idea from tutorial but modified for my own use /// </summary> if (type == "plus") { curHealth += adj; } if (type == "minus") { curHealth -= adj; } if (curHealth <= 0) { Destroy(Enemies[playerStored.EnemyNumber]); } if (curHealth > maxHealth) { curHealth = maxHealth; } }
/// <summary> /// Start this instance. /// </summary> void Start() { desiredPlayer =GameObject.FindGameObjectsWithTag("Player2"); battle = desiredPlayer[0].GetComponent<BattleTimeScript>(); constVar =GameObject.FindGameObjectWithTag("Constant"); stored = constVar.GetComponent<StoredInformation>(); attacking = new PlayerAttack(); attackingWithMagic = new MagicAttack(); }
/// <summary> /// Initilises the variables. /// </summary> public void initiliseConstantVariables() { for (int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++) { _primaryAttribute [cnt] = ((AttributeName)cnt).ToString(); _primaryAttributeValues[cnt] = info.GetPrimaryAttribute(cnt).AdjustedBaseValue; } for (int i = 0; i < Enum.GetValues(typeof(VitalName)).Length; i++) { _vital[i] = ((VitalName)i).ToString(); _vitalValue[i] = info.GetVitals(i).AdjustedBaseValue; } for (int i = 0; i < Enum.GetValues(typeof(ManaName)).Length; i++) { _mana[i] = ((ManaName)i).ToString(); _manaValue[i] = info.GetMana(i).AdjustedBaseValue; } for (int i = 0; i < Enum.GetValues(typeof(AttackName)).Length; i++) { _attack[i] = ((AttackName)i).ToString(); _attackValue[i] = info.GetAttack(i).AdjustedBaseValue; } for (int i = 0; i < Enum.GetValues(typeof(DefenceName)).Length; i++) { _defence[i] = ((DefenceName)i).ToString(); _defenceValue[i] = info.GetDefence(i).AdjustedBaseValue; } positionOnScreen.x = PlayerPrefs.GetFloat("Position - x"); positionOnScreen.y = PlayerPrefs.GetFloat("Position - y"); positionOnScreen.z = PlayerPrefs.GetFloat("Position - z"); GameObject objGame = GameObject.FindGameObjectWithTag("Constant"); StoredInformation storedIN = objGame.GetComponent <StoredInformation>(); moneyTotal = 0; money = new MoneySystem(); if (Application.loadedLevelName == "NewGame") { level = 1; experience = 100; storedIN.level = 1; storedIN.experience = 100; storedIN.nextLevelvalue = experience * 1.2f; storedIN.nextLevel = (int)(experience * 1.2f); nextLevelvalue = experience * 1.2f; nextLevel = (int)(experience * 1.2f); moneyTotal = money.StarterMoney(); storedIN.moneyTotal = moneyTotal; } else if ((PlayerPrefs.GetInt("Money") != null) || (PlayerPrefs.GetInt("Money") != 0)) { moneyTotal = PlayerPrefs.GetInt("Money"); storedIN.moneyTotal = moneyTotal; level = PlayerPrefs.GetInt("Level"); experience = PlayerPrefs.GetInt("Experience"); storedIN.experience = experience; storedIN.level = level; if (level == 0) { level = 1; storedIN.level = 1; storedIN.experience = 100; experience = 100; } } else if (moneyTotal == 0) { moneyTotal = money.StarterMoney(); storedIN.moneyTotal = moneyTotal; } else { moneyTotal = PlayerPrefs.GetInt("Money"); storedIN.moneyTotal = moneyTotal; } info.StatUpdate(); _vitalValue = info.VitalUpdate(); _attackValue = info.AttackUpdate(); _defenceValue = info.DefenceUpdate(); _manaValue = info.ManaUpdate(); if (characterName == String.Empty) { characterName = PlayerPrefs.GetString("Player Name"); storedIN.characterName = PlayerPrefs.GetString("Player Name"); } itemsNameArray = new ArrayList(); itemsContentArray = new ArrayList(); }
Point GetDirection(Agent argSubj) { //Check, if already have a target Agent target = null; foreach (var kvp in argSubj.CurrentMemory.StoredAgents) { if (kvp.Value.Exists(i => { if (i.StoredInfo.GetType() == typeof(TargetInfo)) { return((i.StoredInfo as TargetInfo).IsTarget); } return(false); })) { if (Agent.Distance(argSubj, kvp.Key) < Math.Sqrt(2)) { //Target already reached and should be deleted //Better do do it in feedback kvp.Value.Remove(kvp.Value.First(i => { if (i.StoredInfo.GetType() == typeof(TargetInfo)) { return((i.StoredInfo as TargetInfo).IsTarget); } return(false); })); } else { target = kvp.Key; } } } if (target != null) { //Has a proper target return(target.CurrentLocation.Coords); } //Find new target Random rnd = new Random(); int n = rnd.Next(0, argSubj.CurrentVision.CurrentViewAgents.Where(i => { return(!i.CurrentLocation.HasOwner); }).Count() - 1); target = argSubj.CurrentVision.CurrentViewAgents.Where(i => { return(!i.CurrentLocation.HasOwner); }).ToList()[n]; if (target != null) { //new target was selected //Updating memory, better have proper methods of memory for this and do it in feedback StoredInformation info = new StoredInformation(); info.StoredInfo = new TargetInfo(true); if (argSubj.CurrentMemory.StoredAgents.ContainsKey(target)) { argSubj.CurrentMemory.StoredAgents[target].Add(info); } else { List <StoredInformation> temp = new List <StoredInformation>(); temp.Add(info); argSubj.CurrentMemory.StoredAgents.Add(target, temp); } return(target.CurrentLocation.Coords); } return(new Point()); }
// Use this for initialization void Start() { info = new StoredInformation(); Time.timeScale=1; }
void Awake() { constVar= GameObject.FindGameObjectWithTag("Constant"); stored = constVar.GetComponent<StoredInformation>(); curHealth = stored._vitalValue[0]; maxHealth = stored._vitalValue[0]; healthBarLength = new float[stored.playerNumber]; for(int cnt =0; cnt > stored.playerNumber; cnt++){ healthBarLength[cnt] = (Screen.width / 4) * (curHealth / (float)maxHealth); } healthBarLength1 = (Screen.width / 4); }
// Use this for initialization void Start() { Time.timeScale=1; item = GameObject.FindGameObjectsWithTag("Item"); weapon = GameObject.FindGameObjectsWithTag("Weapon"); magic = GameObject.FindGameObjectsWithTag("Magic"); player = GameObject.FindGameObjectWithTag("Player"); money = new MoneySystem(); info = new StoredInformation(); }
void OnGUI() { if (ShopMenu) { open.fontSize = Screen.width / 23; shopStatus = "Press O to open"; GUI.Label(new Rect(0, 0, 300, 30), shopStatus, open); shopOpen = true; } if (paused) { shopStatus = ""; if (shopAssistantType == "buy") { buyingStuff(); moneySize.fontSize = (int)(Screen.height / 30); GameObject objGame = GameObject.FindGameObjectWithTag("Constant"); StoredInformation storedIN = objGame.GetComponent <StoredInformation>(); GUI.Label(new Rect((((Screen.width / 2) - (groupWidth / 2))), (((Screen.height / 2) - (groupHeight / 2)) - (Screen.height / 23)), Screen.width, Screen.height), "Total Money : " + storedIN.moneyTotal, moneySize); if ((!money.test) && (shopPurchase)) { boughtOrNOt = "Not enough money to buy"; } else { boughtOrNOt = ""; } if ((money.test) && (shopPurchase)) { boughtOrNOt = "Item Bought"; } else { boughtOrNOt = ""; } GUI.Label(new Rect((Screen.width / 2), (((Screen.height / 2) - (groupHeight / 2)) - (Screen.height / 23)), Screen.width, Screen.height), boughtOrNOt, moneySize); GUI.BeginGroup(new Rect(((Screen.width / 2) - (groupWidth / 2)), ((Screen.height / 2) - (groupHeight / 2)), Screen.width, Screen.height)); int startingPosLeft = 0; int StartingPosTop = 0; int itemPrice = 0; ga = GameObject.FindGameObjectsWithTag(shopType); string details = ""; bool buyingAttempt; for (int cnt = 0; cnt < fileReading._name.Length; cnt++) { if ((ga[counter].GetComponent <ReadAFile>()._name[cnt] != null) && (ga[counter].GetComponent <ReadAFile>()._name[cnt] != "")) { if (shopType == "Magic") { details = "Ability"; } if (shopType == "Weapon") { details = "Power"; } if (shopType == "Item") { details = "Recovers"; } if (GUI.Button(new Rect(startingPosLeft, StartingPosTop, widthOfButton, buttonHeight), "Name : " + ga[counter].GetComponent <ReadAFile>()._name[cnt] + "\r\n " + details + " : " + ga[counter].GetComponent <ReadAFile>()._id[cnt] + "\r\n Price : " + ga[counter].GetComponent <ReadAFile>()._price[cnt])) { itemPrice = int.Parse(ga[counter].GetComponent <ReadAFile>()._price[cnt]); if ((storedIN.moneyTotal - itemPrice) > -1) { money.processMoney("minus", itemPrice); if (money.test) { storedIN.moneyTotal -= itemPrice; info.addItems(ga[counter].GetComponent <ReadAFile>()._name[cnt], ga[counter].GetComponent <ReadAFile>()._id[cnt]); boughtOrNOt = "Item Purchased"; shopPurchase = true; } else { GUI.Label(new Rect(((Screen.width / 2) - (groupWidth / 2)), ((Screen.height / 2) - (groupHeight / 2)) - 100, Screen.width, Screen.height), " Not enough money to buy"); shopPurchase = true; } } } } startingPosLeft += widthOfButton; if (startingPosLeft >= groupWidth) { startingPosLeft = 0; StartingPosTop += buttonHeight + 20; } } GUI.EndGroup(); } if (shopAssistantType == "sell") { sellBits(); } } }
// Update is called once per frame void Update() { enemyObjects = GameObject.FindGameObjectsWithTag("Enemy2"); if (enemyObjects.Length != 0) { GameObject constVar = GameObject.FindGameObjectWithTag("Constant"); StoredInformation stored = constVar.GetComponent <StoredInformation>(); int counter = stored.BattlePosition; MagicAttack pl; GameObject[] obj = GameObject.FindGameObjectsWithTag("Player2"); pl = obj[counter].GetComponent <MagicAttack>(); enemyObjects = GameObject.FindGameObjectsWithTag("Enemy2"); BattleAttackDisplay battleAttack = obj[counter].GetComponent <BattleAttackDisplay>(); funTimes = battleAttack.EnemyNumber; EnemyTarget = enemyObjects[funTimes]; if (EnemyTarget == null) { EnemyTarget = enemyObjects[funTimes + 1]; } if (attempt) { EnemyTarget = enemyObjects[funTimes]; EnemyHealth attackEnemy = EnemyTarget.GetComponent <EnemyHealth>(); attackType = battleAttack.attackType; if (attackType == "Fire") { initialiseParticles = Instantiate(particles[0], EnemyTarget.transform.position, Quaternion.identity) as GameObject; initialiseParticles.name = "Fire"; attackEnemy.AddjustCurrentHealth(stored._manaValue[0], "minus"); } if (attackType == "Wind") { initialiseParticles = Instantiate(particles[1], EnemyTarget.transform.position, Quaternion.identity) as GameObject; initialiseParticles.name = "Wind"; attackEnemy.AddjustCurrentHealth(stored._manaValue[1], "minus"); } if (attackType == "Ice") { initialiseParticles = Instantiate(particles[2], EnemyTarget.transform.position, Quaternion.identity) as GameObject; initialiseParticles.name = "Ice"; attackEnemy.AddjustCurrentHealth(stored._manaValue[2], "minus"); } if (attackType == "Water") { attackEnemy.AddjustCurrentHealth(stored._manaValue[3], "minus"); initialiseParticles = Instantiate(particles[3], EnemyTarget.transform.position, Quaternion.identity) as GameObject; initialiseParticles.name = "Water"; } if (attackType == "Lightning") { initialiseParticles = Instantiate(particles[4], EnemyTarget.transform.position, Quaternion.identity) as GameObject; initialiseParticles.name = "Lightning"; attackEnemy.AddjustCurrentHealth(stored._manaValue[4], "minus"); } pl.attempt = false; BattleTimeScript batTimeScript = obj[counter].GetComponent <BattleTimeScript>(); batTimeScript.timeToAttack1 = 0; animation.Play("idle"); } } }
// Update is called once per frame void Update() { enemyObjects = GameObject.FindGameObjectsWithTag("Enemy2"); if (enemyObjects.Length != 0) { GameObject constVar = GameObject.FindGameObjectWithTag("Constant"); StoredInformation stored = constVar.GetComponent <StoredInformation>(); int counter = stored.BattlePosition; PlayerAttack playerAttack; GameObject[] obj = GameObject.FindGameObjectsWithTag("Player2"); playerAttack = obj[counter].GetComponent <PlayerAttack>(); enemyObjects = GameObject.FindGameObjectsWithTag("Enemy2"); BattleAttackDisplay bat = obj[counter].GetComponent <BattleAttackDisplay>(); fighterNumber = bat.EnemyNumber; EnemyTarget = enemyObjects[fighterNumber]; if (EnemyTarget == null) { EnemyTarget = enemyObjects[fighterNumber + 1]; } if (characterTransform == null) { characterTransform = transform; } if (attemptAttack) { Quaternion rot; Vector3 lookRotate = EnemyTarget.transform.position - characterTransform.position; rot = Quaternion.Slerp(characterTransform.rotation, Quaternion.LookRotation(lookRotate), 3 * Time.deltaTime); characterTransform.rotation = rot; characterTransform = GameObject.FindGameObjectWithTag("Player2").transform; Vector3 charPosition = new Vector3(characterTransform.forward.x * 8 * Time.deltaTime, 0, characterTransform.forward.z * 8 * Time.deltaTime); characterTransform.position += charPosition; animation.Play("Run"); } if (Vector3.Distance(characterTransform.position, EnemyTarget.transform.position) <= 1) { EnemyTarget = enemyObjects[fighterNumber]; EnemyHealth attackEnemy = EnemyTarget.GetComponent <EnemyHealth>(); attackType = bat.attackType; if (attackType == "Attack") { attackEnemy.AddjustCurrentHealth(stored._attackValue[0], "minus"); } if (attackType == "FireAttack") { initialiseParticles = Instantiate(particles[0], EnemyTarget.transform.position, Quaternion.identity) as GameObject; initialiseParticles.name = "Fire"; attackEnemy.AddjustCurrentHealth(stored._attackValue[1], "minus"); } if (attackType == "IceAttack") { attackEnemy.AddjustCurrentHealth(stored._attackValue[2], "minus"); initialiseParticles = Instantiate(particles[1], EnemyTarget.transform.position, Quaternion.identity) as GameObject; initialiseParticles.name = "Ice"; } if (attackType == "LightningAttack") { initialiseParticles = Instantiate(particles[2], EnemyTarget.transform.position, Quaternion.identity) as GameObject; initialiseParticles.name = "Lightning"; attackEnemy.AddjustCurrentHealth(stored._attackValue[3], "minus"); } playerAttack.attemptAttack = false; GameObject[] atemptingChange = GameObject.FindGameObjectsWithTag("PlayerBattle"); obj[counter].transform.position = atemptingChange[counter].transform.position; BattleTimeScript batTimeScript = obj[counter].GetComponent <BattleTimeScript>(); batTimeScript.timeToAttack1 = 0; animation.Play("idle"); } } }