private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("EnemySpark")) { SparkController spark = collision.gameObject.GetComponent <SparkController>(); if (spark.energy - energy <= 0) { Destroy(collision.gameObject); } if (energy - spark.energy <= 0) { Destroy(gameObject); } energy -= spark.energy; } else if (collision.gameObject.CompareTag("PlayerCore")) { CoreController playerCore = collision.gameObject.GetComponent <CoreController>(); playerCore.GetDamage(energy); Destroy(gameObject); } else if (collision.gameObject.CompareTag("EnemyCore")) { EnemyCoreController enemyCore = collision.gameObject.GetComponent <EnemyCoreController>(); enemyCore.GetDamage(energy); Destroy(gameObject); } }
//=========================================================== #endregion #region UNITY_METHODS //=========================================================== private void Start() { audio = GetComponents <AudioSource>(); audioLoop = audio[0]; audioStep = audio[1]; sparkleController = transform.FindChild("Sparks", true).GetComponent <SparkController>(); sparkleController.gameObject.SetActive(false); anim = GetComponent <Animator>(); }
IEnumerator CreateSpark() { yield return(new WaitForSeconds(Random.Range(0f, 2f))); SparkController spark = Instantiate(sparkController, spawnPoint.position, Quaternion.identity); spark.SetEnergy(RndSparkCharge()); spark.track = tracks[Random.Range(0, 3)]; isRunningCoroutine = false; }
private void InstantiateSpark() { GameObject spark = Instantiate(sparkPrefab, waypoints[0].position, waypoints[0].rotation, transform); SparkController controller = spark.GetComponent <SparkController>(); controller.wayPointList = waypoints; controller.player = player; controller.speed = speed; controller.bridge = bridge; controller.gap = gap; controller.endWayPoint = endWayPoint; }
private void OnMouseDown() { int sparkPrice = economyManager.BuySpark(); if (sparkPrice != 0) { SparkController spark = Instantiate(sparkPrefab, spawnPoint.position, Quaternion.identity); spark.SetEnergy(sparkPrice); spark.track = track; spark.transform.tag = "PlayerSpark"; } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("EnemySpark")) { Debug.Log("Hey yo"); SparkController spark = collision.gameObject.GetComponent <SparkController>(); if (spark.energy - energy <= 0) { Destroy(collision.gameObject); } if (energy - spark.energy <= 0) { Destroy(gameObject); } energy -= spark.energy; } }
//=========================================================== #endregion #region UNITY_METHODS //=========================================================== private void Start() { audio = GetComponents<AudioSource>(); audioLoop = audio[0]; audioStep = audio[1]; sparkleController = transform.FindChild("Sparks", true).GetComponent<SparkController>(); sparkleController.gameObject.SetActive(false); anim = GetComponent<Animator>(); }