////////////////////////////////////方法实现////////////////////////////////////////// private void Awake() { #if !UNITY_EDITOR try { #endif for (var i = 0; i < mSFXChannelsCount; ++i) { mSFXChannel[i] = new MyAudioSource(); mSFXChannel[i].m_uID = -1; mSFXChannel[i].m_AudioSource = gameObject.AddComponent <AudioSource>(); } mBGAudioSource.m_AudioSource = gameObject.AddComponent <AudioSource>(); mBGAudioSource.m_uID = -1; mSoundClipPools = new SoundClipPools(); #if !UNITY_EDITOR } catch (Exception ex) { Logger.Error(ex.ToString()); } #endif }
protected new void Awake() { base.Awake(); Audio = GetComponent <MyAudioSource>(); (coll = GetComponent <Collider2D>()).enabled = false; (rend = GetComponent <SpriteRenderer>()).enabled = false; rend.sprite = colorlib.GetSpriteColored(vars.teamcolor, rend.sprite, colorlib.colortochange); cooldownTimer = 1f; }
protected new void Awake() { base.Awake(); _audio = GetComponent <MyAudioSource>(); (_coll = GetComponent <Collider2D>()).enabled = false; (_rend = GetComponent <SpriteRenderer>()).enabled = false; OrbitSpawnAttackState s1 = new OrbitSpawnAttackState(_ASM, this); OrbitClearingAttackState s2 = new OrbitClearingAttackState(_ASM, this); s1.SetTargetStates(s2); _ASM.InitializeWithStates(new InactiveEnabledDisableAttackState(_ASM, this), s1); }
////////////////////////////////////·½·¨ÊµÏÖ////////////////////////////////////////// void Awake() { DontDestroyOnLoad(this.gameObject); for (int i = 0; i < m_SFXChannelsCount; ++i) { m_SFXChannel[i] = new MyAudioSource(); m_SFXChannel[i].m_uID = -1; m_SFXChannel[i].m_AudioSource = gameObject.AddComponent <AudioSource>() as AudioSource; } m_BGAudioSource.m_AudioSource = gameObject.AddComponent <AudioSource>() as AudioSource; m_BGAudioSource.m_uID = -1; m_SoundClipPools = new SoundClipPools(); }
//赋值 private void SetAudioSource(MyAudioSource audioSource, SoundClip clip, float volumeFactor) { if (clip == null) { Logger.Error("Error Clip null, please resolve"); return; } audioSource.m_AudioSource.clip = clip.Audioclip; audioSource.m_AudioSource.volume = clip.mVolume * volumeFactor * mSfxVolume * 10; audioSource.m_AudioSource.spread = clip.mSpread; audioSource.m_AudioSource.priority = clip.mPriority; audioSource.m_AudioSource.panLevel = clip.mPanLevel; audioSource.m_AudioSource.minDistance = clip.mMinDistance; audioSource.m_AudioSource.loop = clip.mIsLoop; audioSource.m_uID = clip.mUID; }
protected new void Awake() { base.Awake(); coll = GetComponent <PolygonCollider2D>(); rend = GetComponent <SpriteRenderer>(); anim = GetComponent <MyAnimator>(); Audio = GetComponent <MyAudioSource>(); coll.enabled = false; rend.enabled = false; enabled = false; points = new Vector2[6]; //activate = pushplayerinput; cooldownTimer = 1f; }
//¸³Öµ private void SetAudioSource(ref MyAudioSource audioSource, SoundClip clip, float volumeFactor) { if (clip == null) { LogModule.ErrorLog("Error Clip null, please resolve"); return; } audioSource.m_AudioSource.clip = clip.Audioclip; audioSource.m_AudioSource.volume = clip.m_volume * volumeFactor * m_sfxVolume; audioSource.m_AudioSource.spread = clip.m_spread; audioSource.m_AudioSource.priority = clip.m_priority; audioSource.m_AudioSource.spatialBlend = clip.m_panLevel; audioSource.m_AudioSource.minDistance = clip.m_minDistance; audioSource.m_AudioSource.loop = clip.m_isLoop; audioSource.m_uID = clip.m_uID; }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.transform == movars.transform) { return; } Collider2D collider = collision.collider; aboutcollisions collparameters = collider.GetComponent <aboutcollisions>(); if (rules.collisiondamage(this, collparameters, ((chargingAI)vars).damage)) { MyAudioSource audio = collider.GetComponent <MyAudioSource>(); if (audio != null) { collider.GetComponent <MyAudioSource>().AudioQueue[0].Enqueue(collision.transform.position); } vars.lifevars.life = 0f; } }
protected new void Awake() { base.Awake(); _coll = GetComponent <PolygonCollider2D>(); _rend = GetComponent <SpriteRenderer>(); _anim = GetComponent <MyAnimator>(); _audio = GetComponent <MyAudioSource>(); _coll.enabled = false; _rend.enabled = false; enabled = false; PushingSmallState s1 = new PushingSmallState(_ASM, this); PushingBigState s2 = new PushingBigState(_ASM, this); s1.SetTargetStates(s2); _ASM.InitializeWithStates(new InactiveBaseAttackState(_ASM), s1); }
void OnTriggerEnter2D(Collider2D collision) { if (collision.transform == movars.transform) { return; } /* if (collision.transform != globalvariables.playergameobject.transform.GetChild(0)) * { * Debug.Log("hmm", collision.gameObject); * }*/ aboutcollisions collparameters = collision.GetComponent <aboutcollisions>(); if (rules.collisiondamage(this, collparameters, ((chargingAI)AIvars).damage)) { MyAudioSource audio = collision.GetComponent <MyAudioSource>(); if (audio != null) { collision.GetComponent <MyAudioSource>().AudioQueue[0].Enqueue(collision.transform.position); } AIvars.lifevars.life = 0f; } }
void ProcessTurn() { if (TimeEngine == CradleOfTime.ready_to_process_turn) { // if (map.timegrid.beatgrid[0, 0]) // { TimeEngine = CradleOfTime.waiting_for_player; return; // } } TimeEngine = CradleOfTime.processing_other_actors; //effects and mobs get to act //stop being scared of "foreach": think of all the other shitty garbage you are creating //DEBUGGING THING //player.hp = 60; //HP CHEAT DEBUG //foreach (var debugMob in map.moblist)//there's a mob in the moblist //{ // if (map.itemgrid[debugMob.posx, debugMob.posy] == null)//the map's itemlist at the mob's position is null // { // log.Printline("BUG: mob at " + debugMob.posx + " " + debugMob.posy + " " + debugMob.archetype.name); // log.Printline("where player at " + player.posx + " " + player.posy); // } //} //END DEBUGGING THING //bool dirty= false; ////wizard walls //foreach(var f in map.walllist) //{ // f.bombcount--; // if (f.bombcount == 0) // { // dirty = true; // map.itemgrid[f.bombx, f.bomby] = null; // map.passable[f.bombx, f.bomby] = true; // map.blocks_sight[f.bombx, f.bomby] = false; // } //} //if (dirty) //{ // map.walllist.RemoveAll(x => x.bombcount == 0); // //redo FoV // doplayerfovandlights(); // dirty = false; //} //city stuff foreach (var cc in map.citylist) { cc.takeaturn(); } //bombs //foreach (var f in map.bomblist) //{ // f.bombcount++; // if (f.bombcount >= 5) // { // dirty = true; // log.Printline("Boom! The bomb explodes!", Color.red); // int x = f.bombx; int y = f.bomby; // map.itemgrid[x, y] = null; // map.passable[x, y] = true;//fixing bug of invisible mobs, one hopes // //do explosion and damage. set off other bombs // detonate(x, y); // } // f.tile = Etilesprite.ITEM_BOMB_LIT_1 + (f.bombcount - 1); //} //if (dirty) { // map.bomblist.RemoveAll(x => x.bombcount >= 5); // dirty = false; //} //fire //foreach(var f in map.firelist) //{ // map.onfire[f.x, f.y]--; // if (map.onfire[f.x, f.y] < 0) // { // map.onfire[f.x, f.y] = null; // map.bloodgrid[f.x, f.y] = null;//blood is "used up" by the fire // dirty = true; // } //} //if (dirty) // map.firelist.RemoveAll(z => map.onfire[z.x, z.y] == null); //mobs player.mob.usedDEFthisturn = false; foreach (var f in map.moblist) { for (int dodgynewbury = 0; dodgynewbury < f.archetype.moves; dodgynewbury++) { MobGetsToAct(f); } } //add any new mobs created this turn. if (map.newmoblist.Count > 0) { map.moblist.AddRange(map.newmoblist); map.newmoblist.Clear(); } //check for mob hp so dead foreach (var f in map.moblist) { //if you can't afford heroes they have to go if (f.citythatownsit == null) { player.gold -= f.archetype.upkeepgold; if (player.gold < 0) { player.gold = 0; log.Printline("You can't afford to pay " + f.archetype.name + ".", Color.red); log.Printline(f.archetype.name + " sadly has to leave."); map.killoffamob(f); continue; } } //if(f.dead_currently==true && f.hp < -4) //{ // //corpse has taken enough damage. we remove it. this stops corpses blocking doors // //and means you can prevent zombie apocalypse by killing corpses // f.tile = Etilesprite.EMPTY; // map.passable[f.posx, f.posy] = true; // map.itemgrid[f.posx, f.posy] = null; //} if (f.dead_currently == false && f.hp <= 0) { log.Printline("The " + f.archetype.name + " dies.", new Color(0.6f, 0, 0)); if (f.tile == Etilesprite.UNITS_BARBARIAN_CHAMPION) { player.score += 10; } else if (f.tile == Etilesprite.UNITS_BARBARIAN_LORD) { player.score += 50; } f.speed = 0; f.dead_currently = true; f.hp = 0; //newly added. Even if you smack a mob for 10 damage when it has 1hp its corpse should take 5 damage to make disappear // if (f.archetype.tile_dead != Etilesprite.EMPTY) //if the type of mob has a sprite for its dead state // { // f.tile = f.archetype.tile_dead; //mob's display tile = what it should be for dead // map.itemgrid[f.posx, f.posy].tile = f.tile;//crash // } // else { map.killoffamob(f, true); //f.tile = Etilesprite.EMPTY; //map.passable[f.posx, f.posy] = true; //map.itemgrid[f.posx, f.posy] = null; // } //if (map.itemgrid[f.posx, f.posy] == null) // log.Printline("BUG: itemgrid null in mob death"); // Debug.Log("error map thing in mob dies thing"); } } //remove all really dead mobs. these are things like snow golem and undead mobs that go to nothing //int b4 = map.moblist.Count; map.moblist.RemoveAll(x => x.tile == Etilesprite.EMPTY); //if (b4 != map.moblist.Count) Debug.Log("removed somethnig");//was just checking it was actually working if (player.hp <= 0) { log.Printline("You have failed to protect civilization", Color.magenta); log.Printline("from the scourge of the barbarians.", Color.magenta); TimeEngine = CradleOfTime.dormant; gamestate = Egamestate.gameover; MyAudioSource.Stop(); return; } player.turns++; TimeEngine = CradleOfTime.ready_to_process_turn; }