private void DeathExplosion() { if (deathExplosion != null) { ParticleUtils.PlayParticle(deathExplosion, transform.position); } }
public void AddParticle(string internalPath) { // adds pcf files and finds its dependencies string externalPath = FindExternalFile(internalPath); if (externalPath == String.Empty) { CompilePalLogger.LogLineColor($"Failed to find particle manifest file {internalPath}", Brushes.Red); return; } if (AddFile(internalPath, externalPath)) { PCF pcf = ParticleUtils.ReadParticle(externalPath); pcfcount++; foreach (string mat in pcf.MaterialNames) { AddTexture(mat); } foreach (string model in pcf.ModelNames) { AddModel(model); } } else { CompilePalLogger.LogLineColor($"Failed to find particle manifest file {internalPath}", Brushes.Red); return; } }
public void SetDecoration(string itemID, bool isPlacedFromDecoMode) { // Do one last check if (!CanPlaceDecoration(itemID)) { Debug.LogError("Illegal deco placement for " + itemID + " on node " + gameObject); return; } if (nodeType == DecorationTypes.Wallpaper) // Wallpapers always needs to be removed { RemoveDecoration(); } else if (HasDecoration()) // If there was already a decoration here, remove it { RemoveDecoration(); } placedDecoID = itemID; // update the save data with the new decoration id DataManager.Instance.GameData.Decorations.PlacedDecorations[nodeID] = itemID; // Notify inventory logic that this item is being used InventoryManager.Instance.UsePetItem(itemID); _SetDecoration(itemID, isPlacedFromDecoMode); // Play a sound DecorationItem itemDeco = (DecorationItem)DataLoaderItems.GetItem(itemID); if (isPlacedFromDecoMode) { if (itemDeco.DecorationType == DecorationTypes.Poster || itemDeco.DecorationType == DecorationTypes.Wallpaper) { AudioManager.Instance.PlayClip("decoPlacePaper"); } else { AudioManager.Instance.PlayClip("decoPlaceFurniture"); } // play an FX Vector3 particlePos = transform.position; string particlePrefabName = Constants.GetConstant <string>("Deco_PlaceParticle"); ParticleUtils.CreateParticle(particlePrefabName, particlePos); } //Check for badge unlock int totalNumOfDecorations = DataManager.Instance.GameData.Decorations.PlacedDecorations.Count; BadgeManager.Instance.CheckSeriesUnlockProgress(BadgeType.Decoration, totalNumOfDecorations, true); }
private void CleanTriggerAndDestroy() { isCleaned = true; DegradationLogic.Instance.ClearDegradationTrigger(this); // send out callback if (OnTriggerCleaned != null) { OnTriggerCleaned(this, EventArgs.Empty); } // play an FX ParticleUtils.CreateParticle("DegradationPoof", gameObject.transform.position); Destroy(gameObject); }
public void IndicateHit() { if (hitParticle != null) { ParticleUtils.PlayParticle(hitParticle, gameObject.transform.position, transform); } if (hitSprites.Length > 0) { ChangeSprite(); } if (colorActive) { ChangeColor(); } if (colorFlashActive) { if (!colorFlashInvoked) { colorFlashInvoked = true; initialColor = spriteRenderer.color; InvokeRepeating(nameof(FlashColor), 0, Time.deltaTime); } else { colorToChange = flashColor; colorFlashTimer = 0; } } if (soundEffect != null) { AudioSource.PlayClipAtPoint(soundEffect, spaceship.cameraPosition, soundEffectVolume); } if (hitBackgroundObject != null) { if (!backgroundChangeInvoked) { backgroundChangeInvoked = true; initialBackgroundAlpha = hitIndicatorImage.color.a; InvokeRepeating(nameof(ChangeIndicatorBackgroundColor), 0, Time.deltaTime); } } }
//--------------------------------------------------- // OnCut() // When this trigger gets cut. vHit is the 2d location // where the trigger was precisely hit. //--------------------------------------------------- public void OnCut(Vector2 vHit) { // if this object was already cut, return. This is possible because some objects use multiple primitive colliders if (isCut) { return; } // mark the object as cut isCut = true; // play a sound (if it exists) if (!string.IsNullOrEmpty(strSoundHit)) { AudioManager.Instance.PlayClip(strSoundHit, variations: soundHitVariations); } // also create a little explosion particle FX where the user's finger was Vector3 vPosWorld = Camera.main.ScreenToWorldPoint(new Vector3(vHit.x, vHit.y, 10)); vPosWorld.z = goHitFX.transform.position.z; ParticleUtils.CreateParticle(goHitFX, vPosWorld); if (goHitFX2 != null) { ParticleUtils.CreateParticle(goHitFX2, vPosWorld); } // Directional particle spawn if (goHitDirectionFX != null) { GameObject dirParticle = ParticleUtils.CreateParticle(goHitDirectionFX, vPosWorld); Vector2 trailMoveDelta = NinjaGameManager.Instance.GetTrailDeltaMove(); dirParticle.GetComponent <XYComponentRotateObject>().x = trailMoveDelta.x; dirParticle.GetComponent <XYComponentRotateObject>().y = trailMoveDelta.y; } if (NinjaTriggerCut != null) { NinjaTriggerCut(this, EventArgs.Empty); } // call child behaviour _OnCut(); }
void GenerateCurve() { Queue <FrameDate> frames; List <Transform> wayPoints = new List <Transform>(); List <PathNode> pathnodes = new List <PathNode>(nodes.Values); pathnodes.Sort((a, b) => { return(a.Index.CompareTo(b.Index)); }); int count = pathnodes.Count; for (int i = 0; i < count; ++i) { if (i == 0) { psystem.transform.position = pathnodes[i].Node.position; psystem.transform.eulerAngles = Vector3.zero; } if (pathnodes[i].Node) { wayPoints.Add(pathnodes[i].Node); } } //至少要两个点 if (wayPoints.Count > 1) { float distance = ParticleUtils.CalculateDirection(wayPoints, out frames); AnimationCurve curve_X; AnimationCurve curve_Y; AnimationCurve curve_Z; float lifeTime = distance / psystem.startLifetime; ParticleUtils.MakeCurve(frames, distance, lifeTime, out curve_X, out curve_Y, out curve_Z); var vel = psystem.velocityOverLifetime; vel.enabled = true; vel.space = ParticleSystemSimulationSpace.Local; vel.x = new ParticleSystem.MinMaxCurve(lifeTime, curve_X); vel.y = new ParticleSystem.MinMaxCurve(lifeTime, curve_Y); vel.z = new ParticleSystem.MinMaxCurve(lifeTime, curve_Z); } }
public void AddParticle(string internalPath) { // adds pcf files and finds its dependencies string externalPath = FindExternalFile(internalPath); PCF pcf = ParticleUtils.ReadParticle(externalPath); if (AddFile(internalPath, externalPath)) { pcfcount++; foreach (string mat in pcf.MaterialNames) { AddTexture(mat); } foreach (string model in pcf.ModelNames) { AddModel(model); } } }
public void DrawPath(List <Vector3> points) { Queue <FrameDate> frames; float distance = ParticleUtils.CalculateDirection(points, out frames); particle.transform.position = points[0]; AnimationCurve curve_X; AnimationCurve curve_Y; AnimationCurve curve_Z; float lifeTime = distance / particle.startLifetime; ParticleUtils.MakeCurve(frames, distance, lifeTime, out curve_X, out curve_Y, out curve_Z); var vel = particle.velocityOverLifetime; vel.enabled = true; vel.space = ParticleSystemSimulationSpace.Local; vel.x = new ParticleSystem.MinMaxCurve(lifeTime, curve_X); vel.y = new ParticleSystem.MinMaxCurve(lifeTime, curve_Y); vel.z = new ParticleSystem.MinMaxCurve(lifeTime, curve_Z); }