public void initDead(float posx, float posy, int x) { GameObject expObject = new GameObject(); explosion expl = expObject.AddComponent <explosion> (); Vector3 posv = new Vector3(posx, posy, 0); expl.transform.position = posv; expl.init(posv, x); }
public void initDead() { GameObject expObject = new GameObject(); explosion expl = expObject.AddComponent <explosion> (); Vector3 posv = new Vector3(transform.position.x, transform.position.y, 0); expl.transform.position = posv; expl.init(posv, 5); }
public void initHit(float posx, float posy, int x) { if (this.getHealth() >= 0) { GameObject expObject = new GameObject(); explosion expl = expObject.AddComponent <explosion> (); Vector3 posv = new Vector3(posx, posy, 0); expl.transform.position = posv; expl.init(posv, x); } }
public void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.tag == "FriendlyBullet") { BasicBullet bullet = collision.GetComponent <BasicBullet>(); hurt((int)bullet.damage); // plays hurt sound AudioClip audio = Resources.Load <AudioClip>("bullet_impact_body_flesh_02"); this.GetComponent <AudioSource>().PlayOneShot(audio); Destroy(collision.gameObject); } else if (collision.gameObject.tag == "FriendlyExplosion") { explosion explosionObj = collision.GetComponent <explosion>(); hurt((int)explosionObj.damage); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Player") { //Application.LoadLevel(Application.loadedLevelName); //PlatformerCharacter2D sn = gameObject.GetComponent<PlatformerCharacter2D>(); Die = GameObject.FindObjectOfType(typeof(destroyPlatform)) as destroyPlatform; Die.Destroy (); explode = GameObject.FindObjectOfType(typeof(explosion)) as explosion; explode.Example (); explode.Example (); explode.Example (); //explode = GameObject.FindGameObjectWithTag(Explosion); //explode.SetActive(true); Debug.Log ("holy hell"); } }
public MineSweeperControl(int ButtonsX, int ButtonsY, double Mines, Assets MyAssets) { var sndclick = new click(); var sndflag = new flag(); var sndexplosion = new explosion(); this.MyAssets = MyAssets; this.Alive = true; this.Mines = Mines; if (this.Mines > 0.8) this.Mines = 0.8; this.ButtonsX = ButtonsX; this.ButtonsY = ButtonsY; Control.style.backgroundColor = Color.Gray; Control.style.SetSize(Width, Height); Control.style.position = IStyle.PositionEnum.relative; for (int x = 0; x < ButtonsX; x++) for (int y = 0; y < ButtonsY; y++) { var btn = new MineButton().AddTo(Buttons); btn.MouseDownChanged += v => { if (!Alive) return; if (v) { if (LookingForMines != null) LookingForMines(); } else { if (DoneLookingForMines != null) DoneLookingForMines(); } }; btn.Source = MyAssets.button; btn.MouseDownSource = MyAssets.empty; btn.Control.AttachTo(Control); btn.MoveTo(x, y); var NearbyButtons = from i in Buttons where i.IsNearTo(btn) select i; var NearbyMines = from i in NearbyButtons where i.IsMined select i; var NearbyFlags = from i in NearbyButtons where i.Source == MyAssets.flag select i; var NearbyNonFlags = from i in NearbyButtons where i.Source != MyAssets.flag select i; var IdleButtons = from i in Buttons where i.Source != MyAssets.flag where !MyAssets.numbers.Contains(i.Source) select i; Action Resolve = delegate { foreach (var v in NearbyNonFlags) { v.RaiseClick(); } }; btn.ContextClick += delegate { sndflag.play(); sndflag = new flag(); if (MyAssets.numbers.Contains(btn.Source)) { if (NearbyMines.Count() == NearbyFlags.Count()) { Resolve(); CheckIdle(IdleButtons); } return; } if (btn.Source == MyAssets.button) btn.Source = MyAssets.flag; else if (btn.Source == MyAssets.flag) btn.Source = MyAssets.question; else if (btn.Source == MyAssets.question) btn.Source = MyAssets.button; if (MinesFoundChanged != null) MinesFoundChanged(); CheckIdle(IdleButtons); }; //sndclick.load(); btn.Click += delegate { btn.Enabled = false; sndclick.play(); sndclick = new click(); //sndclick.load(); if (btn.IsMined) { // end of game foreach (var v in from i in Buttons where !i.IsMined where i.Source == MyAssets.flag select i) { v.Source = MyAssets.notmine; } foreach (var v in from i in Buttons where i.IsMined where i != btn select i) { v.Source = MyAssets.mine; } btn.Source = MyAssets.mine_found; DisableButtons(); Alive = false; sndexplosion.play(); sndexplosion = new explosion(); if (Bang != null) Bang(); } else { // how many mines are near me? var MineCount = NearbyMines.Count(); btn.Source = MyAssets.numbers[MineCount]; if (MineCount == 0) { Resolve(); CheckIdle(IdleButtons); } } }; } AttachMinesToButtons(); }
public MineSweeperControl(int ButtonsX, int ButtonsY, double Mines, Assets MyAssets) { var sndclick = new click(); var sndflag = new flag(); var sndexplosion = new explosion(); this.MyAssets = MyAssets; this.Alive = true; this.Mines = Mines; if (this.Mines > 0.8) { this.Mines = 0.8; } this.ButtonsX = ButtonsX; this.ButtonsY = ButtonsY; Control.style.backgroundColor = Color.Gray; Control.style.SetSize(Width, Height); Control.style.position = IStyle.PositionEnum.relative; for (int x = 0; x < ButtonsX; x++) { for (int y = 0; y < ButtonsY; y++) { var btn = new MineButton().AddTo(Buttons); btn.MouseDownChanged += v => { if (!Alive) { return; } if (v) { if (LookingForMines != null) { LookingForMines(); } } else { if (DoneLookingForMines != null) { DoneLookingForMines(); } } }; btn.Source = MyAssets.button; btn.MouseDownSource = MyAssets.empty; btn.Control.AttachTo(Control); btn.MoveTo(x, y); var NearbyButtons = from i in Buttons where i.IsNearTo(btn) select i; var NearbyMines = from i in NearbyButtons where i.IsMined select i; var NearbyFlags = from i in NearbyButtons where i.Source == MyAssets.flag select i; var NearbyNonFlags = from i in NearbyButtons where i.Source != MyAssets.flag select i; var IdleButtons = from i in Buttons where i.Source != MyAssets.flag where !MyAssets.numbers.Contains(i.Source) select i; Action Resolve = delegate { foreach (var v in NearbyNonFlags) { v.RaiseClick(); } }; btn.ContextClick += delegate { sndflag.play(); sndflag = new flag(); if (MyAssets.numbers.Contains(btn.Source)) { if (NearbyMines.Count() == NearbyFlags.Count()) { Resolve(); CheckIdle(IdleButtons); } return; } if (btn.Source == MyAssets.button) { btn.Source = MyAssets.flag; } else if (btn.Source == MyAssets.flag) { btn.Source = MyAssets.question; } else if (btn.Source == MyAssets.question) { btn.Source = MyAssets.button; } if (MinesFoundChanged != null) { MinesFoundChanged(); } CheckIdle(IdleButtons); }; //sndclick.load(); btn.Click += delegate { btn.Enabled = false; sndclick.play(); sndclick = new click(); //sndclick.load(); if (btn.IsMined) { // end of game foreach (var v in from i in Buttons where !i.IsMined where i.Source == MyAssets.flag select i) { v.Source = MyAssets.notmine; } foreach (var v in from i in Buttons where i.IsMined where i != btn select i) { v.Source = MyAssets.mine; } btn.Source = MyAssets.mine_found; DisableButtons(); Alive = false; sndexplosion.play(); sndexplosion = new explosion(); if (Bang != null) { Bang(); } } else { // how many mines are near me? var MineCount = NearbyMines.Count(); btn.Source = MyAssets.numbers[MineCount]; if (MineCount == 0) { Resolve(); CheckIdle(IdleButtons); } } }; } } AttachMinesToButtons(); }
// Use this for initialization public void init(explosion owner) { //beign this.owner = owner; transform.parent = owner.transform; // Set the model's parent to the gem. transform.localPosition = new Vector3(0, 0, 0); // Center the model on the parent. //name = "Bullet Model"; // Name the object. mat = GetComponent <Renderer>().material; mat.shader = Shader.Find("Sprites/Default"); // Tell the renderer that our textures have transparency. // Get the material component of this quad object. int type = owner.type; if (type == 1) { // when a player his hit mat.mainTexture = Resources.Load <Texture2D> ("Textures/playerhit"); } else if (type == 2) { // when boss is hit mat.mainTexture = Resources.Load <Texture2D> ("Textures/bosshit"); transform.localScale = new Vector3(5f, 5f, 1); } else if (type == 3) { // when boss is hit by special bullet // yellow mat.mainTexture = Resources.Load <Texture2D> ("Textures/bosshitsp"); transform.localScale = new Vector3(5f, 5f, 1); } else if (type == 4) { // when player dies //reddish mat.mainTexture = Resources.Load <Texture2D> ("Textures/playerdead"); transform.localScale = new Vector3(3f, 3f, 1); } else if (type == 5) { // when boss dies //whitish mat.mainTexture = Resources.Load <Texture2D> ("Textures/bossdead"); transform.localScale = new Vector3(4f, 4f, 1); } // if (this.owner.name == "Bullet") { // mat.mainTexture = Resources.Load<Texture2D> ("Textures/playerbullet"); // Set the texture. Must be in Resources folder. // //mat.color = new Color(1,1,1); // } else if (this.owner.name == "SpecialBullet") { // mat.mainTexture = Resources.Load<Texture2D> ("Textures/specialBullet"); // Set the texture. Must be in Resources folder. // //mat.color = new Color(1,0,0); // } //this.transform.rotation = new Quaternion(owner.transform.rotation .x,owner.transform.rotation.y,owner.transform.rotation.z,owner.transform.rotation.w); //end }