Game Development Reference
In-Depth Information
botHealth -= (10 + (100 — botShield)/5.0);
if(botHealth < 0) botHealth = 0;
if(botShield < 0) botShield = 0;
health.InputValue = botHealth;
shield.InputValue = botShield;
//set alpha color of shield relative to shield strength
GameObject.Find("Shield").renderer.material.color =
Color(1,0,0,botShield/200.0);
}
function UpdateStatus()
{
if(botHealth == 100 && botShield == 100) return;
//don't bother updating
if(botHealth > 100) botHealth = 100;
if(botShield > 100) botShield = 100;
if(Time.fixedTime > lastUpdate + updateTime)
{
if(botHealth < 100)
botHealth += 5;
if(botShield < 100)
botShield += 10;
GameObject.Find("Shield").renderer.material.color =
Color(1,0,0,botShield/200.0);
health.InputValue = botHealth;
shield.InputValue = botShield;
moodValue = fuzzyEngine.Defuzzify();
lastUpdate = Time.fixedTime;
}
}
function Start()
{
health = new LinguisticVariable("Health");
health.MembershipFunctionCollection.Add (
new MembershipFunction("Bad", 0, 0, 20, 40));
health.MembershipFunctionCollection.Add (
new MembershipFunction("Moderate", 30, 50, 60, 80));
health.MembershipFunctionCollection.Add (
new MembershipFunction("Good", 70, 90, 100, 100));
shield = new LinguisticVariable("Shield");
shield.MembershipFunctionCollection.Add (
new MembershipFunction("Low", 0, 0, 10, 50));
shield.MembershipFunctionCollection.Add (
new MembershipFunction("Medium", 20, 50, 60, 80));
shield.MembershipFunctionCollection.Add (
new MembershipFunction("High", 40, 80, 100, 100));
Search Nedrilad ::




Custom Search