|
|
|
|
|
|
|
|
|
|
public override void Awake(StateMachine stateMachine) |
|
|
|
{ |
|
|
|
_dropRewardConfig = stateMachine.GetComponent<Damageable>().DropableRewardConfig; |
|
|
|
_dropRewardConfig = stateMachine.GetComponent<Damageable>().DroppableRewardConfig; |
|
|
|
_currentTransform = stateMachine.transform; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
DropAllRewards(_currentTransform.position); |
|
|
|
} |
|
|
|
|
|
|
|
private void DropAllRewards(Vector3 postion) |
|
|
|
private void DropAllRewards(Vector3 position) |
|
|
|
{ |
|
|
|
// Drop items
|
|
|
|
foreach (DropGroup dropGroup in _dropRewardConfig.DropGroups) |
|
|
|
|
|
|
{ |
|
|
|
DropOneReward(dropGroup, postion); |
|
|
|
DropOneReward(dropGroup, position); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void DropOneReward(DropGroup dropGroup, Vector3 postion) |
|
|
|
private void DropOneReward(DropGroup dropGroup, Vector3 position) |
|
|
|
{ |
|
|
|
float dropDice = Random.value; |
|
|
|
float _currentRate = 0.0f; |
|
|
|
|
|
|
|
|
|
|
float randAngle = Random.value * Mathf.PI * 2; |
|
|
|
GameObject collectibleItem = GameObject.Instantiate(itemPrefab, |
|
|
|
postion + itemPrefab.transform.localPosition + |
|
|
|
position + itemPrefab.transform.localPosition + |
|
|
|
_dropRewardConfig.ScatteringDistance * (Mathf.Cos(randAngle) * Vector3.forward + Mathf.Sin(randAngle) * Vector3.right), |
|
|
|
Quaternion.identity); |
|
|
|
collectibleItem.GetComponent<CollectibleItem>().SetItem(item); |