public static LootAnimation InstantiateAnimation(Transform looter, GameObject lootItemModel, Vector3 lootItemPosition, LootAnimationSettings settings) { if (looter == null) { Debug.LogError($"{nameof(looter)}의 값이 null일 수는 없습니다"); return(null); } if (lootItemModel == null) { Debug.LogError($"{nameof(lootItemModel)}의 값이 null일 수는 없습니다"); return(null); } if (settings == null) { Debug.LogError($"{nameof(settings)}의 값이 null일 수는 없습니다"); return(null); } GameObject emptyObject = new GameObject($"{nameof(LootAnimation)} {lootItemModel.name}"); LootAnimation lootAnimation = emptyObject.AddComponent <LootAnimation>(); var cloneLootItem = Instantiate(lootItemModel, lootItemPosition, Quaternion.identity, emptyObject.transform); var colider = cloneLootItem.GetComponent <SphereCollider>(); if (colider != null) { colider.enabled = false; } lootAnimation.looter = looter; lootAnimation.lootItem = cloneLootItem; lootAnimation.settings = settings; lootAnimation.phase1Progress = lootAnimation.phase2Progress = lootAnimation.phase3Progress = 0f; lootAnimation.startPosition = lootItemPosition; lootAnimation.startScale = lootItemModel.transform.localScale; lootAnimation.randomFloatingOffset = new Vector3(UnityEngine.Random.Range(-settings.RandomRange.x, settings.RandomRange.x), UnityEngine.Random.Range(-settings.RandomRange.y, settings.RandomRange.y), UnityEngine.Random.Range(-settings.RandomRange.z, -settings.RandomRange.z)); return(lootAnimation); }
private void PlayLootAnimation(int looterViewId, string lootItemName, Vector3 lootItemPosition) { var looterPhotonView = PhotonView.Find(looterViewId); if (looterPhotonView == null) { Debug.LogWarning($"해당 id와 일치하는 {nameof(photonView)}를 찾을 수 없습니다, {nameof(looterViewId)}: {looterViewId}"); return; } if (ItemDataCollection.Instance.ItemDataByName.TryGetValue(lootItemName, out var lootItemData) == false) { Debug.LogWarning($"해당 이름의 {nameof(ItemData)}가 {nameof(ItemDataCollection)}에 없습니다, {nameof(lootItemName)}: {lootItemName}"); return; } var lootAnimation = LootAnimation.InstantiateAnimation(looterPhotonView.transform, lootItemData.Model, lootItemPosition, lootAnimationSettings); if (lootAnimation != null) { lootAnimation.transform.parent = transform; } }