/// <summary> /// Optimized Heightmap, using cells to optimize process of drawing and modifying. /// The heightmap is divided into cells which are each surrounded by a bounding box and /// hidden if they are outside of the field of view or too far away. The bounding boxes /// are also used to speed up the ray detection test when making modifications to the terrain. /// </summary> /// <param name="divisions">Size of the map, ex: 256x256</param> /// <param name="cellsize">The size of a single quad, ex: 50x50</param> /// <param name="cellDivisions">Number of quads in each heightmap cell, ex: 16x16</param> public Optimized_Heightmap(GraphicsDevice graphicsDevice, Point divisions, Vector2 cellsize, Point cellDivisions) { this.size = divisions; this.cellSize = cellsize; this.cellDivisions = cellDivisions; //basicEffect = new BasicEffect(graphicsDevice, null); //basicEffect.VertexColorEnabled = true; effect = Editor.content.Load<Effect>(@"content\shaders\opt_heightmap"); effectParams = new EffectParams(ref effect, "TransformWireframe"); int w = (int)((float)divisions.X / (float)cellDivisions.X); int h = (int)((float)divisions.Y / (float)cellDivisions.Y); cell = new HeightmapCell[w, h]; //Build the cells for (int y = 0; y < w; y++) { for (int x = 0; x < h; x++) { //get the adjacent cells (max 3) : [0,0],[0,1],[1,0] HeightmapCell[,] adjacent_cell = new HeightmapCell[2, 2]; if (x > 0) adjacent_cell[0, 1] = cell[x - 1, y]; if (y > 0) adjacent_cell[1, 0] = cell[x, y - 1]; if (x > 0 && y > 0) adjacent_cell[0, 0] = cell[x - 1, y - 1]; cell[x, y] = new HeightmapCell(graphicsDevice, new Point(x, y), cellDivisions, cellsize, adjacent_cell); } } HeightmapCell.Tri collisionTri = cell[0,0].triangle[0]; testTri = new Triangle(collisionTri.p1, collisionTri.p2, collisionTri.p3, Color.White); }
public IEnumerator OverTimeEffect(EffectParams effectParams) { for (var i = effectParams.duration; i > 0; i++) { currentHealth -= effectParams.damage; yield return(new WaitForSecondsRealtime(1f)); } }
protected override void ApplyEffect(EffectParams parameters) { var go = Instantiate(objectToSpawn, parameters.Target.transform.position, oriented? parameters.Target.transform.rotation : Quaternion.identity); if (lifeTime > 0) { Destroy(go, lifeTime); } }
protected void OnTargetReached(Effects effect, EffectParams effectParams) { FindBlastTargets(); RegisterTargetListeners(); OnHit(effect, effectParams); ClearListeners(); Instantiate(particle, transform.position, Quaternion.identity); Destroy(gameObject); }
IEnumerator WaitingForMoveRingOverEffectToFinish(EffectParams parameters) { while (overPinAnimation.isPlaying) { yield return(0); } //object go down on pin PositionateRingOnPin(parameters.ring, parameters.pin, parameters.ringIndex, true); }
void FixedUpdate() { var distance = Vector2.Distance(transform.localPosition, _targetPosition); if (distance < radius) { var effectParams = new EffectParams(); effectParams.damage = baseDamage; OnTargetReached(Effects.Damage, effectParams); } }
/// <summary> /// Shallow copy of an effect /// </summary> /// <param name="paramsCopy">Parameters to copy</param> public void ShallowCopy(ref EffectParams paramsCopy) { if (paramsCopy == null) { paramsCopy = new EffectParams(); } paramsCopy.Intensity = Intensity; paramsCopy.Vector = Vector; paramsCopy.Color = Color; paramsCopy.ShaderIndex = ShaderIndex; }
/// <summary> /// Get a copy of the current effect states /// </summary> /// <param name="paramsCopy">Parameters to copy</param> public void CopyState(ref RetroBlitEffects.EffectParams[] paramsCopy) { if (paramsCopy == null) { paramsCopy = new EffectParams[mParams.Length]; } for (int i = 0; i < paramsCopy.Length; i++) { mParams[i].ShallowCopy(ref paramsCopy[i]); } }
#pragma warning restore 0414 /// <summary> /// Initialize the subsystem /// </summary> /// <param name="api">Reference to subsystem wrapper</param> /// <returns>True if successful</returns> public bool Initialize(RetroBlitAPI api) { mRetroBlitAPI = api; for (int i = 0; i < mParams.Length; i++) { mParams[i] = new EffectParams(); } EffectReset(); return(true); }
protected void SetLid(Vector2 center, Vector2 edge, bool flip, EffectParams param) { Vector2 norm = new Vector2(edge.Y - center.Y, -(edge.X - center.X)); if (flip) { norm = -norm; } float dist = Vector2.Dot(norm, center); Vector4 plane = new Vector4(norm.X, norm.Y, dist, center.X); Parameter(param).SetValue(plane); }
void OnTargetReached() { // Removes itself from enemy OnDeath event handler. _enemyController.OnDeath -= OnTargetDeath; // Calls OnHit event with the damage value to be taken. var effectParams = new EffectParams(); effectParams.damage = baseDamage; if (target != null) { OnHit(Effects.Damage, effectParams); } // Instantiates impact particles. Instantiate(particle, target.transform.position, Quaternion.identity); // Destroys self. Destroy(gameObject); }
/** * Animation effect to move the ring over the pin **/ public void MoveRingOverPinEffect(SelectableRing ring, int pinIndex) { //Pin position Vector3 expectedPosition = pins[pinIndex].transform.position; //Y based on the pin height expectedPosition.y = pinHeightReference.position.y; //Coroutine params EffectParams effectParams = new EffectParams(); effectParams.ring = ring; effectParams.pin = pins[pinIndex]; effectParams.ringIndex = pins[pinIndex].ringCount(); overPinAnimation.destination = expectedPosition; overPinAnimation.target = ring.transform; overPinAnimation.Play(); StartCoroutine("WaitingForMoveRingOverEffectToFinish", effectParams); }
private void OnCollisionEnter(Collision collision) { IDamagable damagable = collision.collider.GetComponent <IDamagable>(); if (damagable != null) { if (damage > 0) { var result = damagable.TakeDamage(damage); if (result == TakeDamageResult.Destroy) { Destroy(gameObject); } else if (result == TakeDamageResult.Stuck) { transform.parent = collision.transform; Destroy(this); Destroy(GetComponent <Rigidbody>()); Destroy(GetComponent <Collider>()); } } IEffectedDamagable effectedDamagable = damagable as IEffectedDamagable; if (effectedDamagable != null) { EffectParams parameters = new EffectParams(collision.gameObject, effectedDamagable); foreach (var effect in effects) { if (!effectedDamagable.IgnoresEffect(effect)) { EffectHandler.Instance.ApplyEffect(effect, parameters); } } } } }
private static EffectParameter Parameter(EffectParams param) { return(effectCache.Parameter((int)param)); }
public static void ApplyEffect(EffectParams effectParams) { Debug.Log("Example effect was applied to " + effectParams.Target.name); }
public void TakeHit(Effects?effect, EffectParams effectParams) { Action <EffectParams> runEffect = _effectList[effect.ToString()]; runEffect(effectParams); }
protected abstract void ApplyEffect(EffectParams parameters);
protected static EffectParameter Parameter(EffectParams param) { return(effectCache.Parameter((int)param)); }