Exemplo n.º 1
0
        private void Update()
        {
            // Do nothing if game paused
            if (GameManager.IsGamePaused)
            {
                return;
            }

            // Do nothing if paralyzed
            if (entityBehaviour.Entity.IsParalyzed)
            {
                mobileBillboard.IsIdle = false;
                return;
            }

            // Must have a navgrid assigned
            if (!cityNavigation)
            {
                // Try to get navgrid from current player location
                // This is for mobiles dropped directly into world from editor
                // May be removed once fully runtime as intended
                if (!triedPlayerLocation)
                {
                    DaggerfallLocation playerLocation = GameManager.Instance.StreamingWorld.CurrentPlayerLocationObject;
                    if (playerLocation)
                    {
                        cityNavigation   = playerLocation.GetComponent <CityNavigation>();
                        transform.parent = playerLocation.transform;
                        ChangeState(MobileStates.SeekingTile);
                    }
                    triedPlayerLocation = true;
                }

                return;
            }

            // Go idle if near player
            distanceToPlayer = GameManager.Instance.PlayerMotor.DistanceToPlayer(transform.position);
            bool withinIdleDistance  = (distanceToPlayer < idleDistance);
            bool playerStandingStill = GameManager.Instance.PlayerMotor.IsStandingStill;
            bool sheathed            = GameManager.Instance.WeaponManager.Sheathed;
            bool invisible           = GameManager.Instance.PlayerEntity.IsInvisible;
            bool inBeastForm         = GameManager.Instance.PlayerEntity.IsInBeastForm;

            bool wantsToStop = playerStandingStill && withinIdleDistance && sheathed && !invisible && !inBeastForm;

            // greatly reduce # of calls to AreEnemiesNearby() by short-circuit evaluation
            if (wantsToStop && !GameManager.Instance.AreEnemiesNearby())
            {
                wantsToStop = true;
            }
            else
            {
                wantsToStop = false;
            }

            if (!wantsToStop && mobileBillboard.IsIdle)
            {
                // Switch animation state back to moving
                mobileBillboard.IsIdle = false;
                currentMobileState     = MobileStates.MovingForward;
            }
            else if (wantsToStop && !mobileBillboard.IsIdle)
            {
                // Switch animation state to idle
                mobileBillboard.IsIdle = true;
                currentMobileState     = MobileStates.Idle;
            }

            // Update based on current state
            switch (currentMobileState)
            {
            case MobileStates.SeekingTile:
                SeekingTile();
                break;

            case MobileStates.MovingForward:
                MovingForward();
                break;

            case MobileStates.Idle:
                // Do nothing for now
                break;
            }
        }
Exemplo n.º 2
0
        private void Update()
        {
            // Do nothing if game paused
            if (GameManager.IsGamePaused)
            {
                return;
            }

            // Do nothing if paralyzed
            if (entityBehaviour.Entity.IsParalyzed)
            {
                mobileBillboard.IsIdle = false;
                return;
            }

            // Must have a navgrid assigned
            if (!cityNavigation)
            {
                // Try to get navgrid from current player location
                // This is for mobiles dropped directly into world from editor
                // May be removed once fully runtime as intended
                if (!triedPlayerLocation)
                {
                    DaggerfallLocation playerLocation = GameManager.Instance.StreamingWorld.CurrentPlayerLocationObject;
                    if (playerLocation)
                    {
                        cityNavigation   = playerLocation.GetComponent <CityNavigation>();
                        transform.parent = playerLocation.transform;
                        ChangeState(MobileStates.SeekingTile);
                    }
                    triedPlayerLocation = true;
                }

                return;
            }

            // Go idle if near player
            distanceToPlayer = GameManager.Instance.PlayerMotor.DistanceToPlayer(transform.position);
            bool playerStandingStill = GameManager.Instance.PlayerMotor.IsStandingStill;

            if (!playerStandingStill && mobileBillboard.IsIdle)
            {
                // Switch animation state back to moving
                mobileBillboard.IsIdle = false;
                currentMobileState     = MobileStates.MovingForward;
            }
            else if (playerStandingStill && !mobileBillboard.IsIdle && distanceToPlayer < idleDistance)
            {
                // Switch animation state to idle
                mobileBillboard.IsIdle = true;
                currentMobileState     = MobileStates.Idle;
            }

            // Update based on current state
            switch (currentMobileState)
            {
            case MobileStates.SeekingTile:
                SeekingTile();
                break;

            case MobileStates.MovingForward:
                MovingForward();
                break;

            case MobileStates.Idle:
                // Do nothing for now
                break;
            }
        }
        // Update is called once per frame
        void Update()
        {
            if (!Minimap.MinimapInstance.minimapActive)
            {
                return;
            }

            //if player is outside and the streaming world is ready/generated for play setup building indicators.
            if (Minimap.changedLocations)
            {
                if (GameManager.Instance.PlayerGPS.HasCurrentLocation && GameManager.Instance.PlayerGPS.CurrentLocation.Loaded && GameManager.Instance.StreamingWorld.CurrentPlayerLocationObject.Summary.LocationName != GameManager.Instance.PlayerGPS.CurrentLocation.Name)
                {
                    return;
                }

                blockArray        = null;
                buildingDirectory = null;
                //setup a new empty array based on the size of the locations child blocks. This ensures dynamic resizing for the location.
                blockArray = new DaggerfallRMBBlock[GameManager.Instance.StreamingWorld.CurrentPlayerLocationObject.transform.childCount];
                //grab the rmbblock objects from the location object for use.
                blockArray = GameManager.Instance.StreamingWorld.CurrentPlayerLocationObject.GetComponentsInChildren <DaggerfallRMBBlock>();
                //grab the building direction object so we can figure out what the individual buildings are based on their key value.
                buildingDirectory = GameManager.Instance.StreamingWorld.CurrentPlayerLocationObject.GetComponentInChildren <BuildingDirectory>();
                //start to loop through blocks from the block array created above.
                CityNavigation currentCityNav = GameManager.Instance.StreamingWorld.GetCurrentCityNavigation();


                if (GameManager.Instance.IsPlayerInside || buildingDirectory == null || currentCityNav == null || buildingDirectory.BuildingCount == 0)
                {
                    Debug.Log("No Buildings/Navigation found!");
                }
                else
                {
                    currentLocation = GameManager.Instance.PlayerGPS.CurrentLocation.Name;
                    UpdateMarkers();
                    markersGenerated = false;
                }


                if (currentLocation != lastLocation)
                {
                    lastLocation         = currentLocation;
                    generatedPositionUID = GameManager.Instance.PlayerGPS.CurrentMapPixel.X + GameManager.Instance.PlayerGPS.CurrentMapPixel.Y;
                }
                else
                {
                    currentPositionUID = GameManager.Instance.PlayerGPS.CurrentMapPixel.X + GameManager.Instance.PlayerGPS.CurrentMapPixel.Y;
                    if (currentPositionUID != generatedPositionUID)
                    {
                        foreach (GameObject combinedMarker in combinedMarkerList)
                        {
                            combinedMarker.SetActive(false);
                        }
                    }
                    else if (currentPositionUID == generatedPositionUID)
                    {
                        foreach (GameObject combinedMarker in combinedMarkerList)
                        {
                            combinedMarker.SetActive(true);
                        }
                    }
                }

                Minimap.changedLocations = false;
            }

            if (generatingMarkers && !markersGenerated)
            {
                foreach (GameObject marker in buildingInfoCollection)
                {
                    if (marker.GetComponent <BuildingMarker>() != null)
                    {
                        BuildingMarker markerInstance = marker.GetComponent <BuildingMarker>();

                        if (!markerInstance.generatedMarker && markersGenerated)
                        {
                            markersGenerated = false;
                        }
                        else
                        {
                            markersGenerated = true;
                        }
                    }
                }
            }
            else if (generatingMarkers && markersGenerated)
            {
                StartCoroutine(Example());
                generatingMarkers = false;
            }
        }