Пример #1
0
    public void LoadNeutralPatrol()
    {
        ground_level        = transform.position.y - (transform.localScale.y / 2);
        initial_position    = new Vector3(transform.position.x, ground_level, transform.position.z);
        initial_orientation = transform.rotation;

        // Patrols initialization
        if (!neutral_patrol.static_patrol)
        {
            if (neutral_patrol.path_attached != null)
            {
                // ---- Neutral patrol initialization for editor ----
                Transform[] path = neutral_patrol.path_attached.transform.getChilds();
                if (path.Length > 0)
                {
                    Patrol tmp_patrol = new Patrol(path.Length, PATROL_TYPE.NEUTRAL);

                    for (int i = 0; i < path.Length; ++i)
                    {
                        tmp_patrol.path[i]   = path[i].transform.position;
                        tmp_patrol.path[i].y = ground_level;

                        if (neutral_patrol.Length > i)
                        {
                            tmp_patrol.stop_times[i]       = neutral_patrol.stop_times[i];
                            tmp_patrol.trigger_movement[i] = neutral_patrol.trigger_movement[i];
                            tmp_patrol.recieve_trigger[i]  = neutral_patrol.recieve_trigger[i];
                        }
                    }

                    neutral_patrol.Set(tmp_patrol);
                }
                else
                {
                    Debug.Log("Error loading NEUTRAL PATROL: The patrol must contain more than one waypoint (use Static toggle instead).");
                }
            }
            else
            {
                Debug.Log("Error loading NEUTRAL PATROL: There is no GameObject attached!");
            }
        }
    }