1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
-
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class TankGroup : MonoBehaviour
- {
- public static List<TankGroup> tankGroups;
- public LayerMask mask;
- public int groupID = 0;
- public float keepDistance = 10, keepWeight = 1;
- public float targetCloseDistance = 20, targetWeight = 1.25f, moveWeight = 0.8f;
-
- private void Awake()
- {
-
-
- AddGroup(this.gameObject.GetComponent<TankGroup>());
- }
- public Vector3 targetPosition
- {
-
- get { return transform.position; }
- }
- public static void AddGroup(TankGroup group)
- {
- if (tankGroups == null)
- tankGroups = new List<TankGroup>();
- if (!tankGroups.Contains(group))
- tankGroups.Add(group);
- }
- public static TankGroup GetTankGroup(int index)
- {
- tankGroups = new List<TankGroup>(Object.FindObjectsOfType(typeof(TankGroup)) as TankGroup[]);
- for (int i = 0; i < tankGroups.Count; i++)
- if (tankGroups[i].groupID == index)
- return tankGroups[i];
- throw new System.Exception("groupID not find");
- }
- private void OnDisable()
- {
- tankGroups.Clear();
- }
-
-
-
-
- }
|