Update Ability to Change Difficulty Scale Type
This commit is contained in:
		
							parent
							
								
									31b445bc82
								
							
						
					
					
						commit
						b4273b69f3
					
				| @ -2568,6 +2568,7 @@ MonoBehaviour: | |||||||
|   m_Name:  |   m_Name:  | ||||||
|   m_EditorClassIdentifier:  |   m_EditorClassIdentifier:  | ||||||
|   time: {fileID: 542591968} |   time: {fileID: 542591968} | ||||||
|  |   difficultyType: 1 | ||||||
|   incrementDifficultyInSeconds: 30 |   incrementDifficultyInSeconds: 30 | ||||||
|   incrementAmountInSeconds: 25 |   incrementAmountInSeconds: 25 | ||||||
| --- !u!1 &1019999843 | --- !u!1 &1019999843 | ||||||
|  | |||||||
| @ -148,7 +148,7 @@ SortingGroup: | |||||||
|   m_Enabled: 1 |   m_Enabled: 1 | ||||||
|   m_SortingLayerID: 0 |   m_SortingLayerID: 0 | ||||||
|   m_SortingLayer: 0 |   m_SortingLayer: 0 | ||||||
|   m_SortingOrder: -6 |   m_SortingOrder: 1 | ||||||
| --- !u!1 &8759752071964469198 | --- !u!1 &8759752071964469198 | ||||||
| GameObject: | GameObject: | ||||||
|   m_ObjectHideFlags: 0 |   m_ObjectHideFlags: 0 | ||||||
|  | |||||||
| @ -2,27 +2,40 @@ using System.Collections; | |||||||
| using System.Collections.Generic; | using System.Collections.Generic; | ||||||
| using UnityEngine; | using UnityEngine; | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| public class DifficultyScale : MonoBehaviour | public class DifficultyScale : MonoBehaviour | ||||||
| { | { | ||||||
|     public GameObject time; |     public GameObject time; | ||||||
|  |     public TypeOfDifficulty difficultyType; | ||||||
|     [SerializeField] private int incrementDifficultyInSeconds = 30; |     [SerializeField] private int incrementDifficultyInSeconds = 30; | ||||||
|     [SerializeField] private int incrementAmountInSeconds = 25; |     [SerializeField] private int incrementAmountInSeconds = 25; | ||||||
|     private int currentDifficultyLevel = 0; |     private int currentDifficultyLevel = 0; | ||||||
| 
 |     public enum TypeOfDifficulty | ||||||
|     // Start is called before the first frame update |  | ||||||
|     void Start() |  | ||||||
|     { |     { | ||||||
| 
 |         Exponential, | ||||||
|  |         Constant | ||||||
|     } |     } | ||||||
| 
 |  | ||||||
|     // Update is called once per frame |     // Update is called once per frame | ||||||
|     void Update() |     void Update() | ||||||
|     { |     { | ||||||
|  |         switch (difficultyType) | ||||||
|  |         { | ||||||
|  |             case TypeOfDifficulty.Exponential: | ||||||
|                 if (((Mathf.FloorToInt(time.GetComponent<UITimer>().time) - (incrementAmountInSeconds * currentDifficultyLevel)) / incrementDifficultyInSeconds) == 1) |                 if (((Mathf.FloorToInt(time.GetComponent<UITimer>().time) - (incrementAmountInSeconds * currentDifficultyLevel)) / incrementDifficultyInSeconds) == 1) | ||||||
|                 { |                 { | ||||||
|                     currentDifficultyLevel++; |                     currentDifficultyLevel++; | ||||||
|                     incrementDifficultyInSeconds += incrementAmountInSeconds; |                     incrementDifficultyInSeconds += incrementAmountInSeconds; | ||||||
|                     this.GetComponent<ObjectCreatorArea>().spawnInterval = this.GetComponent<ObjectCreatorArea>().spawnInterval * 0.5f; |                     this.GetComponent<ObjectCreatorArea>().spawnInterval = this.GetComponent<ObjectCreatorArea>().spawnInterval * 0.5f; | ||||||
|                 } |                 } | ||||||
|  |                 break; | ||||||
|  |             case TypeOfDifficulty.Constant: | ||||||
|  |                 if ((Mathf.FloorToInt(time.GetComponent<UITimer>().time) >= (incrementDifficultyInSeconds * (currentDifficultyLevel + 1)))) | ||||||
|  |                 { | ||||||
|  |                     currentDifficultyLevel++; | ||||||
|  |                     this.GetComponent<ObjectCreatorArea>().spawnInterval = this.GetComponent<ObjectCreatorArea>().spawnInterval * 0.5f; | ||||||
|  |                 } | ||||||
|  |                 break; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user