public void CreateHitSpark(BoxCollider2D col1, BoxCollider2D col2, bool wasTargetDamaged = false, int targetHealth = 0) { Vector2 position = RexMath.GetColliderOverlapCenter(col1, col2); Type type = (wasTargetDamaged) ? Type.DamagedSpark : Type.NotDamagedSpark; CreateHitSparkAtPosition(position, type); }
public void CreateHitSparkAtPosition(Vector2 position, Type type) { RexParticle spark = (type == Type.DamagedSpark) ? damagedSparkPool.Spawn().GetComponent <RexParticle>() : notDamagedSparkPool.Spawn().GetComponent <RexParticle>(); spark.transform.position = position; spark.transform.localEulerAngles = new Vector3(0, 0, RexMath.RandomFloat(0, 360)); spark.Play(); }
void Start() { if (moveTowards.willMoveTowardsX || moveTowards.willMoveTowardsY) { if (moveTowards.isEnabled) { moveTowards.transformToMoveTowards = GameManager.Instance.player.transform; } } if (startingMovement.willFacePlayerAtStart) { FacePlayer(); if (GameManager.Instance.player) //If we turn to face something, make sure our startingDirection is set to the direction we face { if (startingMovement.horizontal != Direction.Horizontal.Neutral) { if (GameManager.Instance.player.transform.position.x < transform.position.x) { startingMovement.horizontal = Direction.Horizontal.Left; } else { startingMovement.horizontal = Direction.Horizontal.Right; } } if (startingMovement.vertical != Direction.Vertical.Neutral) { if (GameManager.Instance.player.transform.position.y < transform.position.y) { startingMovement.vertical = Direction.Vertical.Down; } else { startingMovement.vertical = Direction.Vertical.Up; } } if (moveTowards.usePlayerAsTarget) { moveTowards.transformToMoveTowards = GameManager.Instance.player.transform; } } } if (slots.controller) { slots.controller.SetAxis(new Vector2((int)startingMovement.horizontal, (int)startingMovement.vertical)); } attacks.currentFrameBetweenAttacks = RexMath.RandomInt(attacks.minFramesBetweenAttacks, attacks.maxFramesBetweenAttacks); jump.currentFrameBetweenJumps = jump.framesBetweenJumps; }
protected void CheckForAttacks() { if (attacks.attackToPerform != null) { attacks.currentFrameBetweenAttacks--; if (attacks.currentFrameBetweenAttacks <= 0) { attacks.currentFrameBetweenAttacks = RexMath.RandomInt(attacks.minFramesBetweenAttacks, attacks.maxFramesBetweenAttacks); attacks.attackToPerform.Begin(); } } }
public void Show() { string message = "READY"; if (messages.Count > 0) { int random = RexMath.RandomInt(0, messages.Count - 1); message = messages[random]; } textMesh.text = message; StartCoroutine("ShowCoroutine"); }