| 1234567891011121314151617181920212223242526272829303132333435363738 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace ShotSimulator.Tool
- {
- public static class ExtensionMethod
- {
- public static Vector3Int ToVector3Int(this Vector3 value)
- {
- return new Vector3Int((int)value.x, (int)value.y, (int)value.z);
- }
- public static List<Vector3> GetGameObjectWorldPosition<T>(this List<T> objs) where T : MonoBehaviour
- {
- List<Vector3> positions = new List<Vector3>();
- for (int i = 0; i < objs.Count; i++)
- {
- positions.Add(objs[i].transform.position);
- }
- return positions;
- }
- public static void FisherYatesShuffle<T>(this IList<T> list)
- {
- int listCount = list.Count;
- while (listCount > 1)
- {
- listCount--;
- int randomIndex = Random.Range(0, listCount);
- T value = list[randomIndex];
- list[randomIndex] = list[listCount];
- list[listCount] = value;
- }
- }
- }
- }
|