Пример #1
0
    void GhostPositionViz()
    {
        int currentLap = trackInfo.CurrentLap();

        if (ghostMarkers.Count < currentLap)
        {
            GameObject  go     = Instantiate(ghostMarkerPrefab, Vector3.zero, Quaternion.identity, ghostMarkersRoot);
            GhostMarker marker = go.GetComponent <GhostMarker>();
            marker.markerText.text = "LAP " + currentLap;
            ghostMarkers.Add(marker);
        }

        for (int i = 0; i < ghostMarkers.Count; i++)
        {
            int positionIndex = trackInfo.GetGhostPosition(i);

            if (DataPoints.IsValidIndex(positionIndex))
            {
                Vector3 pos = DataPoints.GetPoint(positionIndex).GetPosition();
                ghostMarkers[i].transform.position = pos;
            }

            ghostMarkers[i].gameObject.SetActive(i + 1 != currentLap);
        }
    }
Пример #2
0
        private void CreateContent()
        {
            IsLoading = true;

            // Create the player and add to the DynamicSprites.
            var playerSheet    = SpriteSheet.CreateNew(MainGame, "Temp/PirateGirlSheet", 1, 16);
            var playerAnimArgs = new AnimArgs(9, 1, 0.2f, AnimationState.None);

            Player          = new Player(MainGame, playerSheet, playerAnimArgs);
            Player.Altitude = 1;
            DynamicSprites.Add(Player);

            // Instantiate ghost marker with its default texture and add it to DynamicSprites. Image is null at this point, but will be set
            // by CubeDesignerViewModel.OnMainGameLoaded() as soon as SunbirdMBGame's constructor resolves.
            GhostMarker = new GhostMarker(MainGame, SpriteSheet.CreateNew(MainGame, "Temp/TopFaceSelectionMarker"))
            {
                DrawPriority = 1
            };
            DynamicSprites.Add(GhostMarker);

            ClickAnimation = new Sprite(MainGame, SpriteSheet.CreateNew(MainGame, "Temp/WalkTargetAnimation", 1, 7))
            {
                Alpha = 0.8f
            };
            DynamicSprites.Add(ClickAnimation);

            IsLoading             = false;
            MainGame.CurrentState = this;

            Peripherals.ScrollWheelUp   += Peripherals_ScrollWheelUp;
            Peripherals.ScrollWheelDown += Peripherals_ScrollWheelDown;
        }
Пример #3
0
        private GMap.NET.PointLatLng CreateGhostPoint(int index, GMap.NET.PointLatLng point, GMapRoute route)
        {
            GhostMarker g = new GhostMarker(point);

            _routeOverlay.Markers.Add(g);

            GhostPoint ghostPoint = new GhostPoint(index, g);

            if (_ghostPointDictionary.ContainsKey(route) == false)
            {
                _ghostPointDictionary.Add(route, new List <GhostPoint>());
            }
            _ghostPointDictionary[route].Add(ghostPoint);
            return(point);
        }
Пример #4
0
        private void LoadContentFromFile()
        {
            IsLoading = true;
            // Most time is spent here...
            var XmlData = Serializer.ReadXML <MapBuilder>(MapBuilderSerializer, saveFilePath);

            // Variable assignment here:
            Altitude          = XmlData.Altitude;
            WalkableTileTable = XmlData.WalkableTileTable;
            LayerMap          = XmlData.LayerMap;
            DynamicSprites    = XmlData.DynamicSprites;

            bool createNewGhostMarker = false;

            for (int i = 0; i < DynamicSprites.Count(); i++)
            {
                Sprite sprite = DynamicSprites[i];
                if (sprite is Player player)
                {
                    Player = player;
                }
                else if (sprite is GhostMarker ghostMarker)
                {
                    GhostMarker = ghostMarker;
                }
                else if (sprite.Animator?.SpriteSheet?.TexturePath == "Temp/WalkTargetAnimation")
                {
                    ClickAnimation = sprite;
                }

                // Load content can fail if the content file for the sprite no longer exists.
                try { sprite.LoadContent(MainGame); }
                catch (Exception e)
                {
                    e.Message.Log();
                    if (sprite is GhostMarker ghostMarker)
                    {
                        // If the content file was required for the ghost marker, remove the current ghost marker and get ready to make a new one.
                        createNewGhostMarker = true;
                        DynamicSprites.Remove(ghostMarker);
                    }
                    i--;
                }
            }

            if (createNewGhostMarker)
            {
                // The content file for the ghost marker was removed, so make a new one and add it to the layer map.
                GhostMarker = new GhostMarker(MainGame, SpriteSheet.CreateNew(MainGame, "Temp/TopFaceSelectionMarker"))
                {
                    DrawPriority = 1
                };
                DynamicSprites.Add(GhostMarker);
            }

            List <Coord3D> purgedSprites  = new List <Coord3D>();
            List <Coord3D> decoReferences = new List <Coord3D>();

            foreach (var layerMapItem in LayerMap)
            {
                var sprite = layerMapItem.Value;
                if (sprite is DecoReference)
                {
                    decoReferences.Add(layerMapItem.Key);
                }
                // Load content can fail if the content file for the sprite no longer exists.
                try { sprite.LoadContent(MainGame); }
                catch (Exception e)
                {
                    e.Message.Log();
                    if (sprite is Deco deco)
                    {
                        foreach (var coord in deco.OccupiedCoords)
                        {
                            purgedSprites.Add(coord);
                        }
                    }
                    else
                    {
                        purgedSprites.Add(layerMapItem.Key);
                    }
                }
            }
            foreach (var coord in purgedSprites)
            {
                LayerMap.Remove(coord);
            }
            foreach (var coord in decoReferences)
            {
                DecoReference decoReference = LayerMap[coord] as DecoReference;
                decoReference.Reference = (Deco)LayerMap[decoReference.ReferenceCoord];
            }

            IsLoading             = false;
            MainGame.CurrentState = this;

            Peripherals.ScrollWheelUp   += Peripherals_ScrollWheelUp;
            Peripherals.ScrollWheelDown += Peripherals_ScrollWheelDown;
        }