public void ApplyDamage(Collider2D collider) { IProjectile projectile = collider.transform.gameObject.GetComponent <IProjectile>(); health -= projectile.GetDamage(); if (health <= 0) { StopBlinking(); lootDropper.Drop(enemyDifficulty, transform.localPosition); Level level = GameObject.Find("Level").GetComponent <Level>(); level.EnemyKilled(scoreValue); StartCoroutine(StartDeathAnimation(true)); } else { StopBlinking(); StartCoroutine(StartDamageAnimation()); } if (projectile.ShouldBeDestroyed()) { Destroy(collider.transform.gameObject); } }
public override void OnInspectorGUI() { DrawDefaultInspector(); if (!EditorApplication.isPlaying) { return; } LootDropper myScript = (LootDropper)target; _amount = EditorGUILayout.IntField("Amount", _amount); if (GUILayout.Button("Drop")) { myScript.Drop(_amount); Debug.Log("Dropped " + _amount); } var totalChance = myScript.ItemDefinitions.Sum(x => x.Chance).ToString(); EditorGUILayout.LabelField("Total Weight: ", totalChance); if (GUILayout.Button("Random Item")) { var item = myScript.GetRandomItem(); Debug.Log("Random Item:"); Debug.Log(JsonUtility.ToJson(item)); } }
private void DestroySelf() { LootDropper dropper = GetComponent <LootDropper>(); if (dropper != null) { dropper.Drop(); } Destroy(this.gameObject); }