#pragma strict
static var charge : int = 0;
var collectSound : AudioClip;
//HUD
var hudCharge : Texture2D[];
var chargeHudGUI : GUITexture;
//Generator
var meterCharge : Texture[];
var meter : Renderer;
//Matches
private var haveMatches : boolean = false;
var matchGUIprefab : GUITexture;
private var matchGUI : GUITexture;
var fireEmitters : ParticleEmitter[];
var TextHints : GUIText;
function Start ()
{
charge = 0;
}
function Update ()
{
}
function CellPickup()
{
AudioSource.PlayClipAtPoint(collectSound, transform.position);
charge++;
chargeHudGUI.texture = hudCharge[charge];
meter.material.mainTexture = meterCharge[charge];
HUDon();
}
function HUDon()
{
if(!chargeHudGUI.enabled)
{
chargeHudGUI.enabled = true;
}
}
function MatchPickup()
{
haveMatches = true;
AudioSource.PlayClipAtPoint(collectSound, transform.position);
var matchHUD : GUITexture = Instantiate(matchGUIprefab, Vector3(0.15,0.1,0),transform.rotation);
matchGUI = matchHUD;
}
function OnControllerColliderHit(col : ControllerColliderHit)
{
if(col.gameObject.name == "campfire")
{
if(haveMatches)
{
LightFire(col.gameObject);
}
else
{
TextHints.SendMessage("ShowHint", "i could use this campfire to signal for help... \n if only i could light it");
}
}
}
function LightFire(campfire : GameObject)
{
fireEmitters = campfire.GetComponentsInChildren(ParticleEmitter);
for(var emitter : ParticleEmitter in fireEmitters)
{
emitter.emit = true;
}
campfire.audio.Play();
Destroy(matchGUI);
haveMatches=false;
}
我是第一个遇到问题,说不能从源类型转换为目标类型,然后我添加了 pragma strict ,现在我在标题中收到错误,现在我正在写更多,因为可爱的网站认为那没有解释得够多了。