Пример #1
0
    void Start()
    {
        if (UnityEngine.XR.WSA.HolographicSettings.IsDisplayOpaque == false)
        {
            Debug.Log("Not an immersive display so we'll use spatial mapping instead of this fake world");
            Destroy(this.gameObject);
            return;
        }

        playspace = PlayspaceManager.Instance;
    }
Пример #2
0
 void Start()
 {
     m_playspaceManager = PlayspaceManager.Instance;
     m_currentMission   = new Mission1();
     //
     // Single-color, flat-shaded material. HoloToolkit/Vertex Lit Configurable
     // appears optimized to compile down to only the variant defined by
     // keywords. I'm not sure how Unity translates e.g. the editor color
     // "Enabled" tick box to _USECOLOR_ON but apparently it somehow does. Unity
     // manual seems to imply that "#pragma shader_feature X" will not include
     // unused variants of the shader in a build. If this code stops working,
     // may need to use a dummy asset with these material settings somewhere?
     //
     //flatMaterial = new Material(Shader.Find("HoloToolkit/Vertex Lit Configurable"));
     //flatMaterial.EnableKeyword("_USECOLOR_ON");
     //flatMaterial.DisableKeyword("_USEMAINTEX_ON");
     //flatMaterial.DisableKeyword("_USEEMISSIONTEX_ON");
 }
Пример #3
0
    private void PlaceEnemies()
    {
        PlayspaceManager pm = PlayspaceManager.Instance;

        string placementName;

        Vector3 agent1Size  = Footprint.Measure(agentPrefab1);
        float   agent1Width = Mathf.Max(agent1Size.x, agent1Size.z);

        for (int i = 0; i < 3; i++)
        {
            TaskManager.Instance.Schedule(
                () =>
            {
                Vector3 position;
                if (pm.TryPlaceOnPlatform(out position, 0.25f, 1.5f, 1.5f * agent1Width))
                {
                    return(() =>
                    {
                        NavMeshHit hit;
                        if (NavMesh.SamplePosition(position, out hit, 2, NavMesh.AllAreas))
                        {
                            position = hit.position;
                        }
                        GameObject agent = Instantiate(agentPrefab1, position, Quaternion.identity);
                        SetTarget(agent, playerHelicopter);
                    });
                }
                return(null);
            });
        }

        Vector3 agent2Size  = Footprint.Measure(agentPrefab2);
        float   agent2Width = Mathf.Max(agent2Size.x, agent2Size.z);

        for (int i = 0; i < 2; i++)
        {
            TaskManager.Instance.Schedule(
                () =>
            {
                Vector3 position;
                Quaternion rotation;
                if (pm.TryPlaceOnPlatform(out position, 0.25f, 1.5f, 1.5f * agent2Width))
                {
                    return(() =>
                    {
                        NavMeshHit hit;
                        if (NavMesh.SamplePosition(position, out hit, 2, NavMesh.AllAreas))
                        {
                            position = hit.position;
                        }
                        GameObject agent = Instantiate(agentPrefab2, position, Quaternion.identity);
                        SetTarget(agent, playerHelicopter);
                    });
                }
                else if (pm.TryPlaceOnFloor(out placementName, out position, out rotation, agent2Size))
                {
                    return(() =>
                    {
                        NavMeshHit hit;
                        if (NavMesh.SamplePosition(position, out hit, 2, NavMesh.AllAreas))
                        {
                            position = hit.position;
                        }
                        GameObject agent = Instantiate(agentPrefab2, position, rotation);
                        SetTarget(agent, playerHelicopter);
                    });
                }
                return(null);
            });
        }

        Vector3 agent3Size  = Footprint.Measure(agentPrefab3);
        float   agent3Width = Mathf.Max(agent3Size.x, agent3Size.z);

        for (int i = 0; i < 1; i++)
        {
            TaskManager.Instance.Schedule(
                () =>
            {
                Vector3 position;
                Quaternion rotation;
                if (pm.TryPlaceOnPlatform(out position, 0.25f, 1.5f, 1.5f * agent3Width))
                {
                    return(() =>
                    {
                        NavMeshHit hit;
                        if (NavMesh.SamplePosition(position, out hit, 2, NavMesh.AllAreas))
                        {
                            position = hit.position;
                        }
                        GameObject agent = Instantiate(agentPrefab3, position, Quaternion.identity);
                        SetTarget(agent, playerHelicopter);
                    });
                }
                else if (pm.TryPlaceOnFloor(out placementName, out position, out rotation, agent3Size))
                {
                    return(() =>
                    {
                        NavMeshHit hit;
                        if (NavMesh.SamplePosition(position, out hit, 2, NavMesh.AllAreas))
                        {
                            position = hit.position;
                        }
                        GameObject agent = Instantiate(agentPrefab3, position, rotation);
                        SetTarget(agent, playerHelicopter);
                    });
                }
                return(null);
            });
        }

        Vector3 enemyHelicopter1Size = Footprint.Measure(enemyHelicopterPrefab1.gameObject);

        for (int i = 0; i < 1; i++)
        {
            TaskManager.Instance.Schedule(
                () =>
            {
                Vector3 position;
                Quaternion rotation;
                List <PlayspaceManager.Rule> rules = new List <PlayspaceManager.Rule>()
                {
                    PlayspaceManager.Rule.Nearby(m_besiegedBuildingPosition, 0f, 0.25f)
                };
                if (pm.TryPlaceInAir(out position, out rotation, enemyHelicopter1Size, rules))
                {
                    return(() =>
                    {
                        HelicopterEnemy enemyHelicopter = Instantiate(enemyHelicopterPrefab1, position, rotation);
                        SetTarget(enemyHelicopter.gameObject, playerHelicopter);
                    });
                }
                return(() => { Debug.Log("Failed to place enemy helicopter"); });
            });
        }
    }