示例#1
0
        public void OnAwake()
        {
            KickStarter.navigationManager.OnAwake();

            // Turn off all NavMesh objects
            NavigationMesh[] navMeshes = FindObjectsOfType(typeof(NavigationMesh)) as NavigationMesh[];
            foreach (NavigationMesh _navMesh in navMeshes)
            {
                if (navMesh != _navMesh)
                {
                    _navMesh.TurnOff();
                }
            }

            if (navMesh)
            {
                navMesh.TurnOn();
            }

            stateChangeHooks = GetStateChangeHooks(GetComponents(typeof(IStateChange)));

            if (defaultSound != null)
            {
                defaultAudioSource = defaultSound.GetComponent <AudioSource>();
            }
        }
示例#2
0
        public void OnAwake(NavigationMesh defaultNavMesh)
        {
            navigationEngine = null;
            ResetEngine();

            // Turn off all NavMesh objects
            NavigationMesh[] navMeshes = FindObjectsOfType(typeof(NavigationMesh)) as NavigationMesh[];
            foreach (NavigationMesh _navMesh in navMeshes)
            {
                if (defaultNavMesh != _navMesh)
                {
                    _navMesh.TurnOff();
                }
            }

            if (navigationEngine == null || navigationEngine.RequiresNavMeshGameObject)
            {
                if (defaultNavMesh != null)
                {
                    defaultNavMesh.TurnOn();
                }
                else if (navigationEngine != null)
                {
                    AC.Char[] allChars = FindObjectsOfType(typeof(AC.Char)) as AC.Char[];
                    if (allChars.Length > 0)
                    {
                        ACDebug.LogWarning("No NavMesh set. Characters will not be able to PathFind until one is defined - please choose one using the Scene Manager.");
                    }
                }
            }
        }
示例#3
0
        private void UnloadNavMesh(int navMeshInt, SceneSettings sceneSettings)
        {
            NavigationMesh navMesh = Serializer.returnComponent <NavigationMesh> (navMeshInt, sceneSettings.gameObject);

            if (navMesh && sceneSettings && sceneSettings.navigationMethod != AC_NavigationMethod.UnityNavigation)
            {
                if (sceneSettings.navMesh)
                {
                    NavigationMesh oldNavMesh = sceneSettings.navMesh;
                    oldNavMesh.TurnOff();
                }

                navMesh.TurnOn();
                sceneSettings.navMesh = navMesh;

                // Bugfix: Need to cycle this otherwise weight caching doesn't always work
                navMesh.TurnOff();
                navMesh.TurnOn();
            }
        }
示例#4
0
        private void UnloadNavMesh(int navMeshInt)
        {
            NavigationMesh navMesh = Serializer.returnComponent <NavigationMesh> (navMeshInt);

            if (navMesh && KickStarter.sceneSettings && KickStarter.sceneSettings.navigationMethod != AC_NavigationMethod.UnityNavigation)
            {
                if (KickStarter.sceneSettings.navMesh)
                {
                    NavigationMesh oldNavMesh = KickStarter.sceneSettings.navMesh;
                    oldNavMesh.TurnOff();
                }

                //navMesh.collider.GetComponent <NavigationMesh>().TurnOn ();
                navMesh.TurnOn();
                KickStarter.sceneSettings.navMesh = navMesh;
            }
        }
示例#5
0
        private void Awake()
        {
            // Turn off all NavMesh objects
            NavigationMesh[] navMeshes = FindObjectsOfType(typeof(NavigationMesh)) as NavigationMesh[];
            foreach (NavigationMesh _navMesh in navMeshes)
            {
                if (navMesh != _navMesh)
                {
                    _navMesh.TurnOff();
                }
            }

            // Turn on default NavMesh if using MeshCollider method
            if (navMesh && (navMesh.GetComponent <Collider>() || navMesh.GetComponent <Collider2D>()))
            {
                navMesh.TurnOn();
            }
        }
示例#6
0
        override public float Run()
        {
            if (sceneSetting == SceneSetting.DefaultNavMesh)
            {
                if (KickStarter.sceneSettings.navigationMethod == AC_NavigationMethod.PolygonCollider && changeNavMeshMethod == ChangeNavMeshMethod.ChangeNumberOfHoles && hole != null)
                {
                    NavigationMesh currentNavMesh = KickStarter.sceneSettings.navMesh;

                    if (holeAction == InvAction.Add)
                    {
                        currentNavMesh.AddHole(hole);
                    }
                    else if (holeAction == InvAction.Remove)
                    {
                        currentNavMesh.RemoveHole(hole);
                    }
                    else if (holeAction == InvAction.Replace)
                    {
                        currentNavMesh.AddHole(hole);
                        currentNavMesh.RemoveHole(replaceHole);
                    }
                }
                else if (newNavMesh != null)
                {
                    NavigationMesh oldNavMesh = KickStarter.sceneSettings.navMesh;
                    oldNavMesh.TurnOff();
                    newNavMesh.TurnOn();
                    KickStarter.sceneSettings.navMesh = newNavMesh;

                    // Bugfix: Need to cycle this otherwise weight caching doesn't always work
                    newNavMesh.TurnOff();
                    newNavMesh.TurnOn();

                    if (newNavMesh.GetComponent <ConstantID>() == null)
                    {
                        ACDebug.LogWarning("Warning: Changing to new NavMesh with no ConstantID - change will not be recognised by saved games.");
                    }
                }
            }
            else if (sceneSetting == SceneSetting.DefaultPlayerStart && playerStart)
            {
                KickStarter.sceneSettings.defaultPlayerStart = playerStart;

                if (playerStart.GetComponent <ConstantID>() == null)
                {
                    ACDebug.LogWarning("Warning: Changing to new default PlayerStart with no ConstantID - change will not be recognised by saved games.");
                }
            }
            else if (sceneSetting == SceneSetting.SortingMap && sortingMap)
            {
                KickStarter.sceneSettings.sortingMap = sortingMap;
                KickStarter.sceneSettings.UpdateAllSortingMaps();

                if (sortingMap.GetComponent <ConstantID>() == null)
                {
                    ACDebug.LogWarning("Warning: Changing to new SortingMap with no ConstantID - change will not be recognised by saved games.");
                }
            }
            else if (sceneSetting == SceneSetting.TintMap && tintMap)
            {
                KickStarter.sceneSettings.tintMap = tintMap;

                // Reset all FollowSortingMap components
                FollowTintMap[] followTintMaps = FindObjectsOfType(typeof(FollowTintMap)) as FollowTintMap[];
                foreach (FollowTintMap followTintMap in followTintMaps)
                {
                    followTintMap.ResetTintMap();
                }

                if (tintMap.GetComponent <ConstantID>() == null)
                {
                    ACDebug.LogWarning("Warning: Changing to new TintMap with no ConstantID - change will not be recognised by saved games.");
                }
            }
            else if (sceneSetting == SceneSetting.OnLoadCutscene)
            {
                KickStarter.sceneSettings.cutsceneOnLoad = cutscene;

                if (cutscene.GetComponent <ConstantID>() == null)
                {
                    ACDebug.LogWarning("Warning: Changing to Cutscene On Load with no ConstantID - change will not be recognised by saved games.");
                }
            }
            else if (sceneSetting == SceneSetting.OnStartCutscene)
            {
                KickStarter.sceneSettings.cutsceneOnStart = cutscene;

                if (cutscene.GetComponent <ConstantID>() == null)
                {
                    ACDebug.LogWarning("Warning: Changing to Cutscene On Start with no ConstantID - change will not be recognised by saved games.");
                }
            }

            return(0f);
        }
        override public float Run()
        {
            if (sceneSetting == SceneSetting.DefaultNavMesh)
            {
                if (sceneSettings.navigationMethod == AC_NavigationMethod.PolygonCollider && changeNavMeshMethod == ChangeNavMeshMethod.ChangeNumberOfHoles && hole != null)
                {
                    NavigationMesh currentNavMesh = sceneSettings.navMesh;

                    if (holeAction == InvAction.Add)
                    {
                        currentNavMesh.AddHole(hole);
                    }
                    else if (holeAction == InvAction.Remove)
                    {
                        currentNavMesh.RemoveHole(hole);
                    }
                    else if (holeAction == InvAction.Replace)
                    {
                        currentNavMesh.AddHole(hole);
                        currentNavMesh.RemoveHole(replaceHole);
                    }
                }
                else if (newNavMesh != null)
                {
                    NavigationMesh oldNavMesh = sceneSettings.navMesh;
                    oldNavMesh.TurnOff();
                    newNavMesh.TurnOn();
                    sceneSettings.navMesh = newNavMesh;

                    // Bugfix: Need to cycle this otherwise weight caching doesn't always work
                    newNavMesh.TurnOff();
                    newNavMesh.TurnOn();

                    if (newNavMesh.GetComponent <ConstantID>() == null)
                    {
                        ACDebug.LogWarning("Warning: Changing to new NavMesh with no ConstantID - change will not be recognised by saved games.", newNavMesh);
                    }
                }

                // Recalculate pathfinding characters
                foreach (Char _character in KickStarter.stateHandler.Characters)
                {
                    _character.RecalculateActivePathfind();
                }
            }
            else if (sceneSetting == SceneSetting.DefaultPlayerStart && playerStart)
            {
                sceneSettings.defaultPlayerStart = playerStart;

                if (playerStart.GetComponent <ConstantID>() == null)
                {
                    ACDebug.LogWarning("Warning: Changing to new default PlayerStart with no ConstantID - change will not be recognised by saved games.", playerStart);
                }
            }
            else if (sceneSetting == SceneSetting.SortingMap && sortingMap)
            {
                sceneSettings.sortingMap = sortingMap;
                sceneSettings.UpdateAllSortingMaps();

                if (sortingMap.GetComponent <ConstantID>() == null)
                {
                    ACDebug.LogWarning("Warning: Changing to new SortingMap with no ConstantID - change will not be recognised by saved games.", sortingMap);
                }
            }
            else if (sceneSetting == SceneSetting.TintMap && tintMap)
            {
                sceneSettings.tintMap = tintMap;

                // Reset all FollowSortingMap components
                FollowTintMap[] followTintMaps = FindObjectsOfType(typeof(FollowTintMap)) as FollowTintMap[];
                foreach (FollowTintMap followTintMap in followTintMaps)
                {
                    followTintMap.ResetTintMap();
                }

                if (tintMap.GetComponent <ConstantID>() == null)
                {
                    ACDebug.LogWarning("Warning: Changing to new TintMap with no ConstantID - change will not be recognised by saved games.", tintMap);
                }
            }
            else if (sceneSetting == SceneSetting.OnLoadCutscene)
            {
                sceneSettings.cutsceneOnLoad = cutscene;

                if (sceneSettings.actionListSource == ActionListSource.AssetFile)
                {
                    ACDebug.LogWarning("Warning: As the Scene Manager relies on asset files for its cutscenes, changes made with the 'Scene: Change setting' Action will not be felt.");
                }
                else if (cutscene != null && cutscene.GetComponent <ConstantID>() == null)
                {
                    ACDebug.LogWarning("Warning: Changing to Cutscene On Load with no ConstantID - change will not be recognised by saved games.", cutscene);
                }
            }
            else if (sceneSetting == SceneSetting.OnStartCutscene)
            {
                sceneSettings.cutsceneOnStart = cutscene;

                if (sceneSettings.actionListSource == ActionListSource.AssetFile)
                {
                    ACDebug.LogWarning("Warning: As the Scene Manager relies on asset files for its cutscenes, changes made with the 'Scene: Change setting' Action will not be felt.");
                }
                else if (cutscene != null && cutscene.GetComponent <ConstantID>() == null)
                {
                    ACDebug.LogWarning("Warning: Changing to Cutscene On Start with no ConstantID - change will not be recognised by saved games.", cutscene);
                }
            }

            return(0f);
        }