public void onWeaponDestroy(KBEngine.Entity entity, UInt16 explodeTime)//销毁武器,添加爆炸特效 { if (gameObject == null || entity.renderObj == null || entity.className != "Weapon") { return; } UInt32 weaponModeID = ((KBEngine.Weapon)entity).uid; if (weaponModeID == 40001)//如果是激光等特效放完 { explode sript_explode = ((UnityEngine.GameObject)entity.renderObj).AddComponent <explode>(); sript_explode.Duration = explodeTime / 1.0f; entity.renderObj = null; } else { UnityEngine.GameObject.Destroy((UnityEngine.GameObject)entity.renderObj); entity.renderObj = null; CONF.conf_bullet bullet_conf = (CONF.conf_bullet)CSVHelper.Instance.GetItem("conf_bullet", weaponModeID); addEffect(entity.position, entity.direction, bullet_conf.Explode, explodeTime); } Debug.Log("World::onReqWeaponDestroyTime: " + entity.id + ",className:" + entity.className); }
void Awake() { // Register the singleton if (Instance != null) { Debug.LogError("Multiple instances of SpecialEffectsHelper!"); } Instance = this; }
public override void PlaySparksEffect() { GameObject explode_clone = GameObject.Instantiate(ship_cannon, weapon_born.transform.position, weapon_born.transform.rotation, weapon_born.transform); if (explode_clone != null) { explode sript_explode = explode_clone.AddComponent <explode>(); sript_explode.Duration = 0.8f; } }
// Use this for initialization void Start() { instance = this; if (instance == null) { instance = this; DontDestroyOnLoad(instance.gameObject); } else if (this != instance) { Destroy(this.gameObject); } // ps = GetComponent<ParticleSystem> (); }
void FireBullet() { float timeElapsed = Time.time - lastFireTime; if (timeElapsed < 1.0f / (fireRate / 60.0f)) { return; } lastFireTime = Time.time; enableMuzzleLightUntil = Time.time + 0.02f; Instantiate(muzzleFlashes [currentMuzzleFlashType], muzzleflashLocation.position, muzzleflashLocation.rotation); AudioSource ass = GetComponent <AudioSource> (); ass.Play(); // do a traceline to check what surface we hit RaycastHit hit; Physics.Linecast(muzzleflashLocation.position, muzzleflashLocation.position + muzzleflashLocation.transform.forward * 1000, out hit); if (hit.collider != null) { if (hit.collider.gameObject == null) { return; } bulletImpactCTRL.DoBulletImpact(hit.collider.gameObject, hit.point, hit.normal, Globals.GetMaterialID(hit.collider.sharedMaterial)); GameObject objectHit = hit.collider.gameObject; if (objectHit != null) { explode explodeScript = objectHit.GetComponent <explode>(); if (explodeScript != null) { explodeScript.TakeDamage(10); } } } }
public void addEffect(Vector3 position, Vector3 EulerAngle, string perfabName, UInt16 explodeTime) { GameObject explode_perfab = Resources.Load <GameObject>(perfabName); if (explode_perfab == null) { Debug.LogError(perfabName + " not found explode"); return; } GameObject explode_clone = GameObject.Instantiate(explode_perfab, position, Quaternion.Euler(EulerAngle), player.transform); explode sript_explode = explode_clone.AddComponent <explode>(); sript_explode.Duration = explodeTime / 1.0f; }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { //Playerに触れたらゲーム終了 Destroy(other.gameObject);//Playerを消す ScoreRunking sr = FindObjectOfType <ScoreRunking>(); explode ex = FindObjectOfType <explode>(); sr.ScoreAdd(); ex._SoundPlay(); Destroy(this.gameObject);//自分を消す GameManager.Flag = false; } /////////////////////////////////////////// if (other.gameObject.tag == "Road") { ET.EnemyIsFallnow = false; Debug.Log("o"); } }
void OnTriggerEnter2D(Collider2D collision) { // should still trigger when not visible in inspector // not updated in unity's inspector ////print("collided with " + collision.gameObject.name); if ((collision.gameObject.tag == "boxcar" || collision.gameObject.tag == "train") && !collision.gameObject.name.Contains("placeholder")) { bool collide_go_in_city = collision.gameObject.GetComponent <MovingObject>().in_city; if (in_city == collide_go_in_city) { if (in_city && collision.gameObject.GetComponent <MovingObject>().city != city) // collide with a train in another city { return; } if (collision.gameObject.tag == "boxcar") { if (boxcar_squad.Count > 0 && boxcar_squad[0] == collision.gameObject) //ignore coll9isions with own lead boxcar { return; } } else if (collision.gameObject.tag == "train") { collision.gameObject.GetComponent <Train>().station_track.train = null; } if (!in_city && boxcar_squad.Contains(collision.gameObject)) { Tile city_tile = (Tile)RouteManager.city_tilemap.GetTile(collision.gameObject.GetComponent <Boxcar>().tile_position); if (city_tile != null) { return; // colliding with boxcar that just left a city. technically not out of city yet. } } halt_train(false, true); GameObject explosion_go = Instantiate(explosion); GameManager.sound_manager.play_explosion(); explode explosion_anim = explosion_go.transform.GetChild(0).gameObject.GetComponent <explode>(); explosion_anim.exploded_train = this; explosion_list = new List <GameObject> { explosion_go }; explosion_go.transform.position = transform.position; explosion_go.transform.localScale = new Vector3(.2f, .2f); foreach (GameObject boxcar_go in boxcar_squad) { if (boxcar_go.GetComponent <SpriteRenderer>().enabled) { GameObject boxcar_explosion = Instantiate(explosion); explosion_list.Add(boxcar_explosion); boxcar_explosion.transform.position = boxcar_go.transform.position; } } if (collision.gameObject.tag == "boxcar") { Boxcar destroyed_boxcar = collision.gameObject.GetComponent <Boxcar>(); destroyed_boxcar.train.remove_boxcar(destroyed_boxcar.boxcar_id); GameObject other_boxcar_explosion = Instantiate(explosion); explosion_list.Add(other_boxcar_explosion); explode other_boxcar_explosion_anim = other_boxcar_explosion.transform.GetChild(0).gameObject.GetComponent <explode>(); other_boxcar_explosion_anim.exploded_boxcar = collision.gameObject.GetComponent <Boxcar>(); other_boxcar_explosion.transform.position = collision.gameObject.transform.position; other_boxcar_explosion.transform.localScale = new Vector3(.2f, .2f); } if (city != CityManager.Activated_City_Component) { hide_explosion(explosion_list); } } } }