PageRenderTime 50ms CodeModel.GetById 39ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/Scripts/Glow.js

http://acid-and-base.googlecode.com/
JavaScript | 95 lines | 82 code | 13 blank | 0 comment | 28 complexity | 3630b6c25d3b8235e90d7875e0e789eb MD5 | raw file
 1enum PlayerType { Red = 0, Acid = 1, Base = 2}
 2private var inRangeRed : boolean;
 3private var inRangeBase : boolean;
 4private var inRangeAcid : boolean;
 5private var emitter : ParticleEmitter;
 6
 7
 8function Start () {
 9emitter = GetComponentInChildren(ParticleEmitter);
10}
11
12function Update(){
13	var mcontrol : MasterController_edit = GameObject.Find("Master Controller Light").GetComponent(MasterController_edit);
14	switch(mcontrol.getActivePlayer()) {
15		case PlayerType.Red:
16			if(inRangeRed)
17				emitter.emit = true;
18			else
19				emitter.emit = false;
20			break;
21			
22		case PlayerType.Acid:
23			if(inRangeAcid)
24				emitter.emit = true;
25			else
26				emitter.emit = false;
27			break;
28			
29		case PlayerType.Base:
30			if(inRangeBase)
31				emitter.emit = true;
32			else
33				emitter.emit = false;
34			break;
35			
36		default:
37			break;
38	}
39}
40
41function OnTriggerEnter(col : Collider){
42	if(col.tag == "Player") {
43		var property : Properties = col.GetComponent(Properties);
44		if(property == null)
45			inRangeRed = true;
46        else if(property.abType == AcidOrBase.Base)
47			inRangeBase = true;
48        else if(property.abType == AcidOrBase.Acid)
49			inRangeAcid = true;
50		}
51} 
52
53
54function OnTriggerStay(col : Collider){
55	if(col.tag == "Player") {
56		var mcontrol : MasterController_edit = GameObject.Find("Master Controller Light").GetComponent(MasterController_edit);
57		switch(mcontrol.getActivePlayer()) {
58			case PlayerType.Red:
59				if(inRangeRed)
60					emitter.emit = true;
61				else
62					emitter.emit = false;
63				break;
64				
65			case PlayerType.Acid:
66				if(inRangeAcid)
67					emitter.emit = true;
68				else
69					emitter.emit = false;
70				break;
71				
72			case PlayerType.Base:
73				if(inRangeBase)
74					emitter.emit = true;
75				else
76					emitter.emit = false;
77				break;
78				
79			default:
80				break;
81		}
82	}
83}
84
85function OnTriggerExit(col : Collider){
86	if(col.tag == "Player") {
87		var property : Properties = col.GetComponent(Properties);
88		if(property == null)
89			inRangeRed = false;
90        else if(property.abType == AcidOrBase.Base)
91			inRangeBase = false;
92        else if(property.abType == AcidOrBase.Acid)
93			inRangeAcid = false;
94		}
95}