/// <summary> /// Set hthe color of an item. /// </summary> /// <param name="color"></param> public void SetColor(RayColor color) { Color = color; var _image = this.GetComponentInChildren <Image>(); var _text = this.GetComponentInChildren <Text>(); _text.text = Color.GetName(); _image.color = Color.GetColor(); }
/// <summary> /// Change the color of an item. /// </summary> public void ChangeColor() { Debug.LogWarning(Color.GetName()); if (GameManager.Instance != null) { GameManager.Instance.SetSelectedItemColor(Color); GameManager.Instance.HideColorPanel(); } else if (LevelEditorTD.Instance != null) { LevelEditorTD.Instance.SetSelectedItemColor(Color); LevelEditorTD.Instance.HideColorPanel(); } }
/// <summary> /// Deal the damage to an ennemy. /// </summary> /// <param name="enemy"></param> private void Damage(Component enemy) { var enemyBehaviour = enemy.GetComponent <EnemyBehaviour>(); if (enemyBehaviour == null) { return; } var damage = CalculateDamage(enemyBehaviour.Color); enemyBehaviour.Life -= damage; Debug.Log(string.Format("{0} bullet hit a {1} enemy causing {2} damage ({3} remaining)", Color.GetName(), enemyBehaviour.Color.GetName(), damage, enemyBehaviour.Life )); }