示例#1
0
 private void Awake()
 {
     if (instance)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
     }
 }
示例#2
0
    /// <summary>
    /// Occurs when script is loaded and adds all graves to m_graveSpots
    /// </summary>
    private void Awake()
    {
        if (_instance == null || _instance != this)
        {
            _instance = this;
        }
        else
        {
            Destroy(this);
        }

        m_graveSpots = GameObject.FindGameObjectsWithTag("Grave");
        Setup();
    }
示例#3
0
    GraveManager GetClosestAvailableGrave()
    {
        GraveManager bestTarget         = null;
        float        closestDistanceSqr = Mathf.Infinity;
        Vector3      currentPosition    = transform.position;

        foreach (GraveManager potentialTarget in GameManager.instance.allGraves)
        {
            if (potentialTarget.isDeath)
            {
                continue;
            }

            Vector3 directionToTarget = potentialTarget.transform.position - currentPosition;
            float   dSqrToTarget      = directionToTarget.sqrMagnitude;

            if (dSqrToTarget < closestDistanceSqr)
            {
                closestDistanceSqr = dSqrToTarget;
                bestTarget         = potentialTarget;
            }
        }
        return(bestTarget);
    }
示例#4
0
 // Use this for initialization
 void Start()
 {
     gm = this;
 }