public void Setup(CharacterSetting characterSetting, CharacterType characterType, Vector2 spawnPos, int direction) { characterInstance = GameObject.Instantiate(characterSetting.prefab, spawnPos, Quaternion.identity); moveBehavior = characterInstance.GetComponent <MoveBehavior>(); healthBehavior = characterInstance.GetComponent <HealthBehavior>(); attackBehavior = characterInstance.GetComponent <AttackBehavior>(); moveBehavior.Setup(characterSetting.speed, direction); healthBehavior.Setup(characterSetting.hp); switch (characterType) { case CharacterType.ENEMY: characterInstance.gameObject.layer = LayerMask.NameToLayer("Enemy"); characterInstance.GetComponent <SortingGroup>().sortingLayerID = SortingLayer.NameToID("Enemy"); attackBehavior.Setup(characterSetting.attack, LayerMask.NameToLayer("Player")); break; case CharacterType.PLAYER: characterInstance.gameObject.layer = LayerMask.NameToLayer("Player"); characterInstance.GetComponent <SortingGroup>().sortingLayerID = SortingLayer.NameToID("Player"); attackBehavior.Setup(characterSetting.attack, LayerMask.NameToLayer("Enemy")); break; } }
public void Setup(ChestSetting chestSetting) { healthBehavior = chestInstance.GetComponent <HealthBehavior>(); healthBehavior.Setup(chestSetting.hp); }