本文整理汇总了C#中GameEvent.addArgument方法的典型用法代码示例。如果您正苦于以下问题:C# GameEvent.addArgument方法的具体用法?C# GameEvent.addArgument怎么用?C# GameEvent.addArgument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameEvent
的用法示例。
在下文中一共展示了GameEvent.addArgument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StandardWarning
public static void StandardWarning(int waveNumber)
{
GameEvent ge = new GameEvent("wave_message_flash");
string message = "Wave " + waveNumber + " in " + WaveManager2.BREATHER_SECONDS + " seconds!";
ge.addArgument(message);
ge.addArgument((float)WaveManager2.BREATHER_SECONDS);
ge.addArgument(waveNumber);
EventManager.Instance().RaiseEvent(ge);
}
示例2: HitDial
public void HitDial()
{
if(currentState == state.MOVING)
return; //don't want to hit it the instant we spawn
//this is a direct HP reduction, which doesn't call any of the stuff an enemy_arrived event would- do something fancier later
GameEvent dmgEvent = new GameEvent("dial_damaged");
dmgEvent.addArgument(gameObject);
dmgEvent.addArgument(damage + lifeDrain);
EventManager.Instance().RaiseEvent(dmgEvent);
HealDamage(lifeDrain);
currentState = state.RETREATING;
radii.y = -radii.y / 2;
radii.z = diveAcc;
}
示例3: Fire
float trapArmTime; //time in seconds to arm a trap
#endregion Fields
#region Methods
public void Fire()
{
if(GamePause.paused)
return;
GameEvent nge = new GameEvent ("shot_fired");
nge.addArgument (buttonID);
EventManager.Instance ().RaiseEvent (nge);
}
示例4: KillDisplay
public static void KillDisplay(int killedSoFar,int maxEnemies, bool first)
{
GameEvent ge = new GameEvent("kill_display");
string message = killedSoFar + " out of " + maxEnemies + " defeated!";
if (first) {
message = "Scanners found " + maxEnemies + " enemies!\n" + message;
}
ge.addArgument(message);
EventManager.Instance().RaiseEvent(ge);
}
示例5: Update
public override void Update()
{
if (!moving){
base.Update();
return;
}
base.Update();
if(!sittingThere && progress > 0.5f){
sittingThere = true;
steering.allowedToMove = false;
}
if(blowingUp){
if(blastTimer.TimeElapsedSecs() >= blastDuration){
blowingUp = false;
//hurt dial
GameEvent boom = new GameEvent("dial_damaged");
boom.addArgument(this.gameObject);
boom.addArgument(blastDamage);
EventManager.Instance().RaiseEvent(boom);
//hurt boss if applicable
GameObject bossObj = GameObject.FindWithTag("Boss");
if(bossObj != null){
Boss b = bossObj.GetComponent<Boss>();
b.TakeDamage(blastDamage);
}
//hurt enemies
List<Enemy> casualties = Dial.GetAllEnemiesInZone(GetCurrentTrackID());
foreach(Enemy e in casualties){
if(e != this){
e.TakeDamage(blastDamage);
}
}
base.Die();
}
}
}
示例6: AddPieceToInventory
public void AddPieceToInventory()
{
//decide on a piece to get
string piecetype = "damage"; //placeholder
string piecerarity = "_normal";
if(rarity == 0){
piecerarity = "_normal";
}else if(rarity == 1){
piecerarity = "_rare";
}else if(rarity == 2){
piecerarity = "_super";
}
System.Random r = new System.Random ();
double dindex = r.NextDouble() * pieceTypes.Count;
int index = (int)dindex;
if(index == pieceTypes.Count){
index--;
}
piecetype = pieceTypes[index];
Debug.Log("type is " + piecetype + piecerarity);
FileLoader fl = new FileLoader (Application.persistentDataPath,"Inventory","inventory");
string json = fl.Read ();
Dictionary<string,System.Object> data = (Dictionary<string,System.Object>)Json.Deserialize (json);
List<System.Object> pieces = data["pieces"] as List<System.Object>;
foreach(System.Object piece in pieces){
Dictionary<string,System.Object> pdata = piece as Dictionary<string,System.Object>;
string filename = pdata["filename"] as string;
if(filename.Equals(piecetype + piecerarity)){
int count = (int)(long)pdata["owned"];
count++;
pdata["owned"] = (long)count;
break;
}
}
string filedata = Json.Serialize(data);
fl.Write(filedata);
GameEvent ge = new GameEvent("piece_obtained");
ge.addArgument(piecetype + piecerarity);
EventManager.Instance().RaiseEvent(ge);
}
示例7: UpdateReadout
public void UpdateReadout()
{
List<string> filenames = new List<string>();
foreach(PieceRecord pr in allPieces){
filenames.Add(pr.pc.GetFilename());
}
Dictionary<string,float> updatedDict = PieceParser.GetStatsFromGrid(filenames);
//fire off an update event
GameEvent ge = new GameEvent("readout_update");
ge.addArgument(updatedDict);
EventManager.Instance().RaiseEvent(ge);
Debug.Log ("we read the thing");
}
示例8: OnTriggerEnter2D
public void OnTriggerEnter2D(Collider2D coll)
{
if(coll.gameObject.tag == "DialCollider"){
GameEvent ge = new GameEvent("enemy_arrived");
ge.addArgument(coll.transform.parent.gameObject);
EventManager.Instance().RaiseEvent(ge);
}
if(coll.gameObject.tag == "Boss"){
Debug.Log ("dial hit boss");
//check if it's a Skizzard, which deals contact damage
Skizzard skizz = coll.gameObject.GetComponent<Skizzard>();
if(skizz != null){
skizz.HitDial();
}
}
}
示例9: HandleEvent
public void HandleEvent(GameEvent ge)
{
if (ge.type.Equals("enemy_arrived")) {
GameObject eh = (GameObject)ge.args [0];
if (eh == null || eh.Equals (null)) {
return;
}
Enemy enemy = eh.GetComponent<Enemy> ();
mostRecentAttackerFilename = enemy.GetSrcFileName();
enemy.AddToBonus ((List<System.Object>)bonusWaveDictionary ["enemies"]);
escapedEnemyCount++;
float rawDamage = enemy.GetDamage ();
int trackID = enemy.GetCurrentTrackID ();
if (shields [trackID - 1] != null) { //if this enemy's lane is shielded
int arrayInd = trackID - 1; //index of shield array to reference
GameObject shield = shields [trackID - 1];
Shield sc = shield.GetComponent<Shield> ();
float oldHP = sc.hp; //the shield's hp pre-absorbing damage
Debug.Log ("old shield HP = " + oldHP);
if (enemy.GetComponentInChildren<Saboteur>() != null) //if this enemy is a Saboteur
{
Saboteur sb = enemy.GetComponentInChildren<Saboteur>();
Destroy(shields[arrayInd]); //destroy the shield
Debug.Log("shield destroyed by saboteur");
health -= oldHP; //lose amount equal to shield HP
GameEvent hitlog = new GameEvent("enemy_finished");
hitlog.addArgument(enemy.GetSrcFileName());
hitlog.addArgument(oldHP);
EventManager.Instance().RaiseEvent(hitlog);
}
else
{
sc.hp -= rawDamage;
//shield shred effect
EnemyShield es = enemy.GetShield();
if (es != null)
{
sc.hp += (es.power * sc.shieldShred);
es.TakeDamage(es.power * sc.shieldShred);
}
else
{
Debug.Log("no enemy shield");
}
sc.UpdateHPMeter();
sc.PrintHP(); //debug
if (sc.hp <= 0.0f)
{ //if the shield's now dead
float dialDamage = (oldHP - rawDamage); //this should be a negative value or 0
sc.OnDestroyEffects(dialDamage); //shield's on-destroy effects like Blast, Life Drain, and Stun Wave
health += dialDamage; //dial takes damage (adds the negative value)
GameEvent hitlog = new GameEvent("enemy_finished");
hitlog.addArgument(enemy.GetSrcFileName());
hitlog.addArgument(-dialDamage);
EventManager.Instance().RaiseEvent(hitlog);
Destroy(shields[arrayInd]); //destroy the shield
Debug.Log("shield destroyed");
}
}
} else { //if there's no shield
health -= rawDamage;
GameEvent hitlog = new GameEvent("enemy_finished");
hitlog.addArgument(enemy.GetSrcFileName());
hitlog.addArgument(rawDamage);
EventManager.Instance().RaiseEvent(hitlog);
//Debug.Log ("damage taken, new health is " + health);
}
enemy.Die ();
}else if(ge.type.Equals("dial_damaged")){
GameObject damageSource = (GameObject)ge.args[0];
float damageAmount = (float)ge.args[1];
health -= damageAmount;
}else if(ge.type.Equals ("health_leeched")){
float healAmount = (float)ge.args[0];
health += healAmount;
if(health > maxHealth){
health = maxHealth;
}
}
}
示例10: Update
// Update is called once per frame
void Update()
{
if (INPUT_DEBUG) {
if (isdown) {
bool down = Input.GetMouseButton (0);
if (!down) {
//Debug.Log ("released!!!");
isdown = false;
GameEvent releaseEvent = new GameEvent ("mouse_release");
releaseEvent.addArgument (GetInputPosition ());
EventManager.Instance ().RaiseEvent (releaseEvent);
if(tapLengthWatcher.TimeElapsedMillis() < 200){
GameEvent tapEvent = new GameEvent("tap");
tapEvent.addArgument(GetInputPosition());
EventManager.Instance().RaiseEvent(tapEvent);
}
}
} else {
bool down = Input.GetMouseButton (0);
if (down) {
isdown = true;
GameEvent clickEvent = new GameEvent ("mouse_click");
clickEvent.addArgument (GetInputPosition ());
EventManager.Instance ().RaiseEvent (clickEvent);
tapLengthWatcher.Restart();
}
}
} else {
for(int i = 0; i < Input.touchCount; i++){
Touch t = Input.touches[i];
TouchPhase tp = lastPhase;
if(t.fingerId != 0)
tp = altPhases[t.fingerId-1];
switch(t.phase){
case TouchPhase.Began:
if(tp.Equals(TouchPhase.Began))
break; //avoid double touch events
if(t.fingerId == 0){
GameEvent clickEvent = new GameEvent ("mouse_click");
clickEvent.addArgument (GetInputPosition ());
EventManager.Instance ().RaiseEvent (clickEvent);
lastPhase = TouchPhase.Began;
//start timer for taps
tapLengthWatcher.Restart();
}else{
GameEvent clickEvent = new GameEvent ("alt_click");
clickEvent.addArgument (GetInputPosition (t.fingerId));
clickEvent.addArgument(t.fingerId);
EventManager.Instance ().RaiseEvent (clickEvent);
altPhases[t.fingerId-1] = TouchPhase.Began;
//start timer for taps
altWatchers[t.fingerId-1].Restart();
break;
}
break;
case TouchPhase.Ended:
if(tp.Equals(TouchPhase.Ended) || tp.Equals (TouchPhase.Canceled))
break; //avoid double touch events
if (t.fingerId == 0) {
GameEvent clickEvent2 = new GameEvent ("mouse_release");
clickEvent2.addArgument (GetInputPosition ());
EventManager.Instance ().RaiseEvent (clickEvent2);
lastPhase = TouchPhase.Ended;
if(tapLengthWatcher.TimeElapsedMillis() < 200){
GameEvent tapEvent = new GameEvent("tap");
tapEvent.addArgument(GetInputPosition());
EventManager.Instance().RaiseEvent(tapEvent);
}
}else{
GameEvent clickEvent2 = new GameEvent ("alt_release");
clickEvent2.addArgument (GetInputPosition (t.fingerId));
clickEvent2.addArgument(t.fingerId);
EventManager.Instance ().RaiseEvent (clickEvent2);
altPhases[t.fingerId-1] = TouchPhase.Ended;
if(altWatchers[t.fingerId-1].TimeElapsedMillis() < 200){
GameEvent tapEvent = new GameEvent("alt_tap");
tapEvent.addArgument(GetInputPosition(t.fingerId));
tapEvent.addArgument(t.fingerId);
EventManager.Instance().RaiseEvent(tapEvent);
}
}
break;
case TouchPhase.Canceled:
if(tp.Equals(TouchPhase.Ended) || tp.Equals (TouchPhase.Canceled))
break; //avoid double touch events
if (t.fingerId == 0) {
GameEvent clickEvent2 = new GameEvent ("mouse_release");
clickEvent2.addArgument (GetInputPosition ());
EventManager.Instance ().RaiseEvent (clickEvent2);
lastPhase = TouchPhase.Ended;
if(tapLengthWatcher.TimeElapsedMillis() < 200){
GameEvent tapEvent = new GameEvent("tap");
tapEvent.addArgument(GetInputPosition());
EventManager.Instance().RaiseEvent(tapEvent);
}
}else{
GameEvent clickEvent2 = new GameEvent ("alt_release");
clickEvent2.addArgument (GetInputPosition (t.fingerId));
//.........这里部分代码省略.........
示例11: Regenerate
public void Regenerate()
{
if(!leeched){
if(power >= capacity)
return;
float regen = regenSpeed;
if(slowedAmount > 0)
regen *= (1f-slowedAmount);
power += regen;
if(power > capacity)
power = capacity;
RefreshShieldColors();
}else{//leeched
float regen = regenSpeed;
if(slowedAmount > 0)
regen *= (1f-slowedAmount);
GameEvent ge = new GameEvent("health_leeched");
ge.addArgument(regen);
EventManager.Instance().RaiseEvent(ge);
RefreshShieldColors();
}
}
示例12: HandleEvent
public void HandleEvent(GameEvent ge)
{
Vector3 pos = (Vector3)ge.args[0];
if(ge.type.Equals("mouse_click")){
if(TouchIsOnMe(pos)){
//BuildDebugConsole.Flash("click event " + clicks);
clicks++;
t.Restart();
held = true;
}
}else if(ge.type.Equals("mouse_release")){
if(TouchIsOnMe(pos)){
held = false;
}
}else if(ge.type.Equals("tap")){
if(TouchIsOnMe(pos)){
GameEvent tapped = new GameEvent("template_tapped");
tapped.addArgument(this);
tapped.addArgument(pos);
EventManager.Instance().RaiseEvent(tapped);
}
}
}
示例13: Update
public void Update()
{
if(held){
if(!TouchIsOnMe(InputWatcher.GetInputPosition())){
//BuildDebugConsole.Flash("touch removed from me");
held = false;
return;
}
if(t.TimeElapsedSecs() >= 0.2f){
//BuildDebugConsole.Flash("trying to tap");
held = false;
GameEvent tapped = new GameEvent("template_tapped");
tapped.addArgument(this);
tapped.addArgument(InputWatcher.GetInputPosition());
EventManager.Instance().RaiseEvent(tapped);
Debug.Log("template tapped");
//BuildDebugConsole.Flash("template tapped");
}else{
//BuildDebugConsole.Flash(GamePause.paused + "" +t.TimeElapsedSecs());
}
}else{
//BuildDebugConsole.Flash("not being held down");
}
}
示例14: DoTheMoving
public void DoTheMoving()
{
Vector2 point = mover.PositionFromProgress(progress);
rt.anchoredPosition = new Vector2(point.x,point.y);
float distanceFromCenter = Mathf.Sqrt ((rt.anchoredPosition.x) * (rt.anchoredPosition.x) + (rt.anchoredPosition.y) * (rt.anchoredPosition.y));
if ( distanceFromCenter < DIAL_RADIUS ) {
GameEvent ge = new GameEvent("enemy_arrived");
ge.addArgument(transform.gameObject);
EventManager.Instance().RaiseEvent(ge);
}
}
示例15: DropPiece
public void DropPiece()
{
if(!canDropPiece){
return;
}
GameObject piece = Instantiate (Resources.Load ("Prefabs/MainCanvas/DroppedPiece")) as GameObject;
piece.transform.SetParent(Dial.underLayer,false);
Vector2 position = new Vector2 (rt.anchoredPosition.x, rt.anchoredPosition.y);
//angle it
float radians = (-Mathf.PI/2)+Mathf.Atan2(position.y,position.x);
piece.transform.eulerAngles = new Vector3(piece.transform.eulerAngles.x,piece.transform.eulerAngles.y,radians*Mathf.Rad2Deg);
((RectTransform)piece.transform).anchoredPosition = position;
Drop dc = piece.GetComponent<Drop> ();
dc.SetTypes(srcFileName);
System.Random r = new System.Random ();
float rng = (float)r.NextDouble() * 100; //random float between 0 and 100
//note: threshold values are exclusive, which means if timesShot is equal to it, it's considered outside the rarity threshold
bool outsideThreshold = (rarityUpWithHits && timesShot <= rareDropThreshold)
|| (!rarityUpWithHits && timesShot >= rareDropThreshold);
if (outsideThreshold) {
if(rng < normalChance){
dc.MakeRare();
}
} else {
if(rng < rareChance){
dc.MakeRare();
}
}
//piece.GetComponent<Drop> ().MakeRare ();
GameEvent ge = new GameEvent ("piece_dropped"); //in case other systems need to know about drop events
//add relevant arguments
ge.addArgument (position);
}