예제 #1
0
 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);
     }
 }
예제 #2
0
    //===========================================================
    #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>();
    }
예제 #3
0
    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;
    }
예제 #4
0
    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;
    }
예제 #5
0
    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";
        }
    }
예제 #6
0
    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;
        }
    }
예제 #7
0
	//===========================================================
	#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>();
	}