Ok so I have done a complete revamp to the script including all of the changes made via suggestions in this question and another I have. The new and improved script is below. The only thing I think I need at this point to get it working is how do I call the textures in the array to replace First Texture, Second Texture, Third Texture, and Fourth Texture?
var textureArray : Texture2D[];
var damageAmount = int;
var healAmount = int;
var ammoAmount = int;
var pointAmount = int;
var damageDelay : float = 1;
var healDelay : float = 1;
var interval:float = 10;
var myTimer: float = 10;
private var nextDamageAllowed : float;
private var nextHealAllowed : float;
private var nextAmmoAllowed : float;
private var nextPointAllowed : float;
function Update ()
{
if(myTimer > 0)
{
myTimer -= Time.deltaTime;
}
if(myTimer <= 0)
{
randomNumber = Random.Range(0, textureArray.length);
renderer.material.mainTexture = textureArray[randomNumber];
myTimer += interval;
}
}
//When player enters trigger hurt them if the hurtTexture is active
function OnTriggerEnter(thecollision : Collider)
{
if(theCollision.gameObject.tag == "Player" && First Texture)
{
GiveDamage;
} else if (theCollision.gameObject.tag == "Player" && Second Texture) {
//when player enters trigger heal them if the healTexture is active
GiveHeal;
} else if (theCollision.gameObject.tag == "Player" && Third Texture) {
//when player enters trigger give them ammo if the AmmoTexture is active
GiveAmmo;
} else if (theCollision.gameObject.tag == "Player" && Fourth Texture) {
//when player enters trigger give them points if the PointTexture is active
GivePoints;
}
}
//when player stands on trigger hurt them periodically if the HurtTexture is active
function OnTriggerStay(thecollision : Collider)
{
if (theCollision.gameObject.tag == "Player" && First Texture)
{
GivePeriodicDamage;
} else if (theCollision.gameObject.tag == "Player" && Second Texture) {
//when player stands on trigger heal them periodically if the healTexture is active
GivePeriodicHeal;
} else if (theCollision.gameObject.tag == "Player" && Third Texture) {
//when player stands on trigger give them ammo periodically if the AmmoTexture is active
GivePeriodicAmmo;
} else if (theCollision.gameObject.tag == "Player" && Fourth Texture) {
//when player stands on trigger give them points periodically if the PointTexture is active
GivePeriodicPoints;
}
}
//Function to damage player for OnTriggerEnter
function GiveDamage()
{
SendMessage("ApplyDamage", damageAmount, SendMessageOptions, DontRequireReceiver);
}
//Function to heal player for OnTriggerenter
function GiveHeal()
{
SendMessage("Heal", healAmount, SendMessageOptions, DontRequireReceiver);
}
//Function to give ammo to player for OnTriggerEnter
function GiveAmmo()
{
gunScript.clips += ammoAmount;
}
//Function to give points to player for OnTriggerEnter
function GivePoints()
{
PointManager.points += pointAmount;
}
//Function to hurt player for OnTriggerstay
function GivePeriodicDamage()
{
if(Time.time > nextDamageAllowed)
{
SendMessage("ApplyDamage", damageAmount, SendMessageOptions, DontRequireReceiver);
nextDamageAllowed = Time.time + damageDelay;
}
}
//Function to heal player for OnTriggerStay
function GivePeriodicHeal()
{
if(Time.time > nextHealAllowed)
{
SendMessage("Heal", healAmount, SendMessageOptions, DontRequireReceiver);
nextHealAllowed = Time.time + healDelay;
}
}
//Function to give ammo to player for OnTriggerStay
function GivePeriodicAmmo()
{
if(Time.time > nextAmmoAllowed)
{
gunScript.clips += ammoAmount;
nextAmmoAllowed = Time.time + ammoDelay;
}
}
//Function to give points to player for OnTriggerStay
function GivePeriodicPoints()
{
if(Time.time > nextPointAllowed)
{
PointManager.points += pointAmount;
nextPointAllowed = Time.time + pointDelay;
}
}
Ok I have posted the full script that the original portion belongs to in the original post (for formating reasons). I need to know how to replace HurtTexture, HealTexture, AmmoTexture, and PointTexture with the textures in the array since I no longer have functions for them...
– Ajaxx84