[SerializeField]
Material mat_DissolveMaterial;
IEnumerator Dissolve()
{
float counter = 1;
while (counter > -1)
{
counter -= Time.deltaTime;
yield return new WaitForSeconds(0.01f);
mat_DissolveMaterial.SetFloat("Vector1_7C06CC4A", counter);
}
}
void FillBar(Image img, int value, int originalValue)
{
float newValue = (float)value / originalValue;
img.fillAmount = newValue;
}
IEnumerator FillWithTime(Image img, float sec)
{
float counter = 0;
while (counter < sec)
{
counter += Time.deltaTime;
img.fillAmount = counter / sec;
yield return null;
}
}
#region Public GameObjects
[SerializeField]
private GameObject go_ParticlePrefab;
#endregion
#region Private GameObjects
private ParticleSystem ps_OnHitParticleSystem;
private ParticleSystem ps_System;
#endregion
//In Start Method
ps_OnHitParticleSystem = go_ParticlePrefab.GetComponent<ParticleSystem>();
ps_System = Instantiate(ps_OnHitParticleSystem);
ps_System.transform.position = transform.position;
ps_System.transform.SetParent(transform);
//OnCollision
ps_System.Play();
- ALWAYS use descriptive Variables and Methods:
int i_PrimaryWeaponAmmo = 30;
int i_SecondaryWeaponAmmo = 40;
void Start()
{
IntializeAmmunations();
}
- Use PascalCase for Variables:
Transform t_PilotTransform;
GameObject go_PilotGameObject;
int i_PilotHP;
- Use small letters abbreviations to describe Variables
..* go_ for GameObject
..* t_ for Transform
..* i_ for int
..* Is for Bool
..* f_ for float
..* p_ for Pilot
..* titan_ for Titan
..* wep_ for Weapon
..* ability_ for Weapon
..* ui_ for anything related to UI
..* anim_ for Animator
..* audioSource_ for AudioSources
..* audioClip_ for AudioClip
..* l_ for any lists and arrays (l_go_ , l_p__)
..* _- for any static Variable (_go , _p)
Transform t_PilotTransform;
GameObject go_PilotGameObject;
int i_PilotHP;
bool IsHit;
Weapon wep_PilotPrimaryWeapon
GameObject[] l_go_Enemies
Tranforms[] l_t_TitanPositions
static Pilot __p_MainPilot
- Use PascalCase for Methods:
GetHit()
{
Debug.Log("I'm HIT");
}
WallRide()
{
}
- Use CamelCase for Methods Parameters:
GetHit(int index)
{
Debug.Log("I'm HIT" + index);
}
WallRide(Transform targetWall)
{
targetWall.position = null;
}
- Use [SerializeField] instead of public to show Variables in inspector:
[SerializeField]
private Transform t_PilotTransform;
[SerializeField]
public int i_PilotHP;
- Use regions to organise every block of your code:
#region Variables
int HP;
#endregion
-
There will be a Singleton in every script for the PlayerPilot, Use it carefully.
-
You will find your script containing regions, use them and make all your scripts similar to them, also feel free to add more regions.
-
You will find a SampleScript.cs that contains all of the required regions, you can copy it's if you are going to create a new script.
-
Everyone of us has his own Structured Sandbox (Scene) to create and test his tasks, Try sticking to the Scene Hierarichy.