コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (isHoldingHoe)
        {
            currentMousePos = getCurrentMousePos();
            if ((!currentMousePos.Equals(previousMousePos) || changedHolding) && farmingTileMap.GetTile(currentMousePos) != null && canTile)
            {
                if (!hasClicked)
                {
                    farmingTileMap.SetTile(previousMousePos, previousTile);
                }
                previousMousePos = currentMousePos;
                previousTile     = (Tile)farmingTileMap.GetTile(currentMousePos);
                farmingTileMap.SetTile(currentMousePos, dirtTile);
                hasClicked          = false;
                this.changedHolding = false;
            }

            if (Input.GetMouseButtonDown(0) && farmingTileMap.GetTile(currentMousePos) != null && canTile)
            {
                farmingTileMap.SetTile(currentMousePos, dirtTile);
                hasClicked = true;
            }
            if (Input.GetMouseButtonDown(1) && farmingTileMap.GetTile(currentMousePos) != null && canTile)
            {
                farmingTileMap.SetTile(currentMousePos, standardTile);
                hasClicked = true;
            }
        }

        if (isHoldingSeed)
        {
            currentMousePos = getCurrentMousePos();
            if ((!currentMousePos.Equals(previousMousePos) || changedHolding) && (farmingTileMap.GetTile(currentMousePos) == dirtTile || farmingTileMap.GetTile(currentMousePos) == sunFlowerDirtTile) && canTile)
            {
                if (!hasClicked)
                {
                    farmingTileMap.SetTile(previousMousePos, previousTile);
                }

                previousMousePos = currentMousePos;
                previousTile     = (Tile)farmingTileMap.GetTile(currentMousePos);
                farmingTileMap.SetTile(currentMousePos, sunFlowerDirtTile);
                hasClicked          = false;
                this.changedHolding = false;
            }

            if (Input.GetMouseButtonDown(0) && previousTile == dirtTile && canTile)
            {
                Debug.Log("CLICKED");
                farmingTileMap.SetTile(currentMousePos, sunFlowerDirtTile);
                hasClicked = true;
            }
            if (Input.GetMouseButtonDown(1) && farmingTileMap.GetTile(currentMousePos) != null && canTile)
            {
                farmingTileMap.SetTile(currentMousePos, dirtTile);
                hasClicked = true;
            }
        }
    }
コード例 #2
0
        private void ProcessBest()
        {
            float      shortestDist = (distanceFromStartToTarget * maxDistToTravelMultiplier) + maxDistToTravelAfterDirect;
            Vector3Int bestPos      = FailedPos;

            foreach (var tile in open)
            {
                if (tile.Value.g + tile.Value.h < shortestDist)
                {
                    bestPos      = tile.Key;
                    shortestDist = tile.Value.g + tile.Value.h;
                }
            }

            Heuristics parent;

            open.TryGetValue(bestPos, out parent);

            if (Distance(((Vector3)bestPos), targetLocation) <= range)
            {
                PathComplete(bestPos);
                status = Status.succeeded;
                return;
            }

            if (bestPos.Equals(FailedPos))
            {
                status = Status.failed;
            }

            ProcessTile(bestPos);
        }
コード例 #3
0
 void Death(Vector3Int pos, MoveType moveType)
 {
     if ((moveType == MoveType.diagonal) && (pos.Equals(grid.LocalToCell(this.transform.localPosition))))
     {
         Destroy(this.gameObject);
     }
 }
コード例 #4
0
ファイル: Packet.cs プロジェクト: pedronave/ttl
    // Update is called once per frame
    void Update()
    {
        Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);

        if (Input.GetMouseButtonDown(0))
        {
            if (grid.WorldToCell(mousePos).Equals(grid.WorldToCell(transform.position)))
            {
                // Reset
                selected = true;
                path.Clear();
                path = new Path(grid.WorldToCell(mousePos), pathTilemap, pathTile);
            }
        }

        if (Input.GetMouseButtonUp(0) && selected)
        {
            selected = false;
        }

        if (Input.GetMouseButton(0) && selected)
        {
            // Register path
            Vector3Int mouseCell = grid.WorldToCell(mousePos);
            if (!mouseCell.Equals(lastMouseCell) && boundsTilemap.cellBounds.Contains(mouseCell))
            {
                path.AddDestination(mouseCell);
                lastMouseCell = mouseCell;
            }
        }

        positions = path.PathPositions();
    }
コード例 #5
0
    public void CheckForPlayer()
    {
        PlayerController player = GameManager.Instance.Player;
        Vector3Int       rel    = player.Position - Position;

        if (Mathf.Abs(Vector3.Dot(rel, Direction) - rel.magnitude) > float.Epsilon)
        {
            return;
        }
        Vector3Int pos       = Position;
        Map        map       = GameManager.Instance.Map;
        Vector3Int dir       = new Vector3Int((int)Direction.x, (int)Direction.y, 0);
        int        remaining = 5;

        while (!pos.Equals(player.Position))
        {
            if (map.IsSolid(pos) || remaining == 0)
            {
                return;
            }
            pos       += dir;
            remaining -= 1;
        }
        GameManager.Instance.GameOver();
    }
コード例 #6
0
ファイル: Pipe.cs プロジェクト: pedronave/ttl
    // Start is called before the first frame update
    void Start()
    {
        gm = FindObjectOfType <GameManager>();
        sr = GetComponent <SpriteRenderer>();

        gm.tickElapsed += Tick;

        float zRotation = transform.rotation.eulerAngles.z;

        if (cell.Equals(new Vector3Int(int.MinValue, int.MinValue, int.MinValue)))
        {
        }

        label.transform.rotation = Quaternion.identity;
        label.GetComponent <SpriteRenderer>().sprite = packet.sprite;
    }
コード例 #7
0
ファイル: LightManager.cs プロジェクト: Blastinghavoc/UniVox
 /// <summary>
 /// Returns true if the chunk is the center of the neighbourhood, or is
 /// fully generated
 /// </summary>
 /// <returns></returns>
 private bool ChunkWritable(Vector3Int chunkId, ChunkNeighbourhood neighbourhood)
 {
     if (chunkId.Equals(neighbourhood.center.ChunkID))
     {
         return(true);
     }
     //Only writable if fully generated and not outside world limits
     return(chunkManager.IsChunkFullyGenerated(chunkId) && !chunkManager.WorldLimits.ChunkOutsideVerticalLimits(chunkId));
 }
コード例 #8
0
 void FixedUpdate()
 {
     // Ignore player that placed this bomb until he leaves the cell
     if (!playerLeft && !cell.Equals(player.GetComponent <BombSpawner>().GetCell()))
     {
         playerLeft = true;
         Physics2D.IgnoreCollision(player.GetComponent <CircleCollider2D>(), GetComponent <BoxCollider2D>(), false);
     }
 }
コード例 #9
0
 public void PickUp(Vector3Int position)
 {
     if (position.Equals(MapController.currentMap.GetComponent <Grid>().WorldToCell(transform.position)))
     {
         if (Inventory.instance.Add(item))
         {
             Destroy(transform.gameObject);
         }
     }
 }
コード例 #10
0
        private static bool NodeIsNeighbour(Vector3Int inNode, Vector3Int inOtherNode)
        {
            // Same Node
            if (inNode.Equals(inOtherNode))
            {
                return(false);
            }

            return(Mathf.Abs(inNode.x - inOtherNode.x) + Mathf.Abs(inNode.y - inOtherNode.y) == 1);
        }
コード例 #11
0
        public void OnChunkGeneratedWithLightWithNeighbourFullyGenerated(int hm)
        {
            var vp            = Vector3Int.zero;
            var lampPos       = vp;
            var neighbourhood = neighbourhoodFor(ref vp);

            //act as if this voxel was generated as part of the chunk
            neighbourhood.SetVoxel(vp.x, vp.y, vp.z, lampId);

            heightMapYValue = hm;

            //generate another chunk next to this one, the light should spill in from the zero chunk
            var tstChunkId = new Vector3Int(-1, 0, 0);

            RunLightingGeneration(tstChunkId);
            lightManager.Update();

            //run the generation action for the zero chunk
            RunLightingGeneration(neighbourhood.center.ChunkID);
            lightManager.Update();

            //PrintSlice(neighbourhood, 0);

            ///Should have propagated the lamp light only within the center chunk
            ///and the newly added chunk
            for (int z = -maxIntensity; z <= maxIntensity; z++)
            {
                for (int y = -maxIntensity; y <= maxIntensity; y++)
                {
                    for (int x = -maxIntensity; x <= maxIntensity; x++)
                    {
                        var pos        = new Vector3Int(x, y, z);
                        var expectedLv = new LightValue()
                        {
                            Sun = (hm < 0) ? maxIntensity : 0
                        };
                        expectedLv.Dynamic = math.max(maxIntensity - pos.ManhattanMagnitude(), 0);

                        if (!insideChunkId(pos, Vector3Int.zero) && !insideChunkId(pos, tstChunkId))
                        {
                            expectedLv.Dynamic = 0;
                            expectedLv.Sun     = 0;
                        }

                        if (pos.Equals(lampPos))
                        {//This is where the lamp is, lamps are opaque to sunlight
                            expectedLv.Sun = 0;
                        }

                        Assert.AreEqual(expectedLv, neighbourhood.GetLight(x, y, z),
                                        $"Light value not as expected for position {x},{y},{z}");
                    }
                }
            }
        }
コード例 #12
0
    private void getTileFromMousePos()
    {
        Vector3Int mousePos = GetMousePosition();

        if (!mousePos.Equals(previousMousePos))
        {
            m_uiTilemap.SetTile(previousMousePos, null);
            m_uiTilemap.SetTile(mousePos, hoverTile);
            previousMousePos = mousePos;
        }
    }
コード例 #13
0
        public void GetSetSizeTest()
        {
            GridMap.Instance.SetSize(new Vector3Int(5, 5, 5));
            Vector3Int size = new Vector3Int(10, 10, 10);

            Assert.AreNotEqual(size, GridMap.Instance.GetSize()); // reality check

            GridMap.Instance.SetSize(size);

            Assert.IsTrue(size.Equals(GridMap.Instance.GetSize()));
        }
コード例 #14
0
ファイル: Map.cs プロジェクト: wildrabbit/ld45-daedalus
    public bool ExistsPlayerWalkablePath(Vector3Int from, Vector3Int to)
    {
        List <Vector3Int> path = new List <Vector3Int>();

        if (from.Equals(to))
        {
            return(true); // Trivial, don't waste time
        }
        PathUtils.FindPath(this, from, to, (coords) => TestPlayerWalkable(coords) || coords.Equals(to), ref path);
        return(path.Count >= 2);
    }
コード例 #15
0
    void JumpSnake()
    {
        Snake snake                    = app.model.snake;
        InteractiveElement head        = snake.GetSnakesHead();
        Vector3Int         newPosition = GetMirrorPosition(head.position);

        if (!newPosition.Equals(head.position))
        {
            head.position = newPosition;
            app.Notify(SnakeNotifications.TryInteractSnake);
        }
    }
コード例 #16
0
    public void Vector3IntTest()
    {
        //arrange
        Vector3Int original = new Vector3Int(1, 2, 3);

        //act
        saveFile.Set("vector3int", original);
        Vector3Int deserialized = saveFile.Get <Vector3Int>("vector3int");

        //assert
        Assert.IsTrue(original.Equals(deserialized));
    }
コード例 #17
0
 public override bool Equals(object obj)
 {
     return(obj is GenerationParameters parameters &&
            offset.Equals(parameters.offset) &&
            frequency.Equals(parameters.frequency) &&
            heighFactor == parameters.heighFactor &&
            heightExponential == parameters.heightExponential &&
            noiseIterations == parameters.noiseIterations &&
            waterLevel == parameters.waterLevel &&
            snowLevel == parameters.snowLevel &&
            treeChance == parameters.treeChance &&
            size.Equals(parameters.size));
 }
コード例 #18
0
    /// <summary>
    /// Metodo para comprobar si la casilla esta disponible
    /// </summary>
    /// <param name="p1"></param>
    /// <returns></returns>
    private bool availableTile(Vector3Int p1)
    {
        bool available = true;

        for (int i = 0; i < characters.Length && available; ++i)
        {
            if (p1.Equals(tilemap.WorldToCell(characters[i].transform.position)))
            {
                available = false;
            }
        }
        return(available);
    }
コード例 #19
0
    void Update()
    {
        // Mouse over -> highlight tile
        Vector3Int mousePos = GetMousePosition();

        if (!mousePos.Equals(previousMousePos))
        {
            Tilemap interactive = tm.Interactables_Map;
            interactive.SetTile(new Vector3Int(previousMousePos.x, previousMousePos.y, 0), null); // Remove old hoverTile
            interactive.SetTile(new Vector3Int(mousePos.x, mousePos.y, 0), tm.HighLight);
            previousMousePos = mousePos;
        }


        if (Input.GetMouseButton(0))
        {
            Tilemap pathmap = tm.Ground_Map;

            string startPos = (int)startPosition.x + "," + (int)startPosition.y;
            string endPos   = mousePos.x + "," + mousePos.y;

            if (startPos != endPos)
            {
                debugPath = pf.FindPath(pf.nodes, new PathNode((int)startPosition.x, (int)startPosition.y), pf.nodes[mousePos.x, mousePos.y]);
                makeDebugPath(debugPath);

                GameObject player = GameObject.FindGameObjectWithTag("Player");
                player.transform.position = pathmap.CellToWorld(new Vector3Int((int)startPosition.x, (int)startPosition.y, 0)) + new Vector3(0, 0.75f, 0);
                PathNode[]        dest = debugPath.ToArray();
                CharacterMovement cc   = player.GetComponent <CharacterMovement>();
                Debug.Log("mousePos : " + mousePos);
                cc.setPath(dest);
            }
        }

        if (Input.GetMouseButton(1))
        {
            Tilemap pathmap  = tm.Ground_Map;
            Tilemap debugmap = tm.Debug_Map;
            debugmap.SetTile(new Vector3Int((int)startPosition.x, (int)startPosition.y, 0), null);
            startPosition.x = mousePos.x;
            startPosition.y = mousePos.y;
            debugmap.SetTile(new Vector3Int(mousePos.x, mousePos.y, 0), tm.HighLight);


            GameObject player = GameObject.FindGameObjectWithTag("Player");
            player.transform.position = pathmap.CellToWorld(new Vector3Int(mousePos.x, mousePos.y, 0)) + new Vector3(0, 0.75f, 0);
            CharacterMovement cc = player.GetComponent <CharacterMovement>();
            cc.setPath(null);
        }
    }
コード例 #20
0
 public override bool Equals(object obj)
 {
     if (obj is Connection)
     {
         Connection other = (Connection)obj;
         if (startTile.Equals(other.startTile) && endTile.Equals(other.endTile))
         {
             return(true);
         }
         else if (startTile.Equals(other.endTile) && endTile.Equals(other.startTile))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
コード例 #21
0
ファイル: HexUtils.cs プロジェクト: SirGavin/MyRepo
    public static bool AreNeighbors(Vector3Int tile1, Vector3Int tile2)
    {
        int parity = tile1.y & 1;
        List <Vector2Int> directions = parity == 0 ? NeighborDirections : OffsetNeighborDirections;

        for (int i = 0; i < directions.Count; i++)
        {
            Vector2Int direction = directions[i];
            if (tile2.Equals(new Vector3Int(tile1.x + direction.x, tile1.y + direction.y, tile1.z)))
            {
                return(true);
            }
        }

        return(false);
    }
コード例 #22
0
    /// <summary>
    /// Ayuda visual para el ataque
    /// </summary>
    public void attack()
    {
        Vector3Int currentPosition = tilemap.WorldToCell(currentChar.transform.position);

        attackArea = currentChar.getMoveArea(currentPosition);
        BoundsInt.PositionEnumerator tiles = attackArea.allPositionsWithin;
        tiles = tiles.GetEnumerator();
        while (tiles.MoveNext())
        {
            if (!currentPosition.Equals(tiles.Current))
            {
                tilemap.RemoveTileFlags(tiles.Current, TileFlags.LockColor);
                tilemap.SetColor(tiles.Current, new Color(1, 0, 0, 0.8f));
            }
        }
    }
コード例 #23
0
ファイル: Player.cs プロジェクト: Erox7/Erox-Adventure
 public void TakeDamage(Vector3Int position, float damage, Vector2 orientation)
 {
     if (position.Equals(gl.WorldToCell(transform.position)))
     {
         hp -= damage;
         gameObject.transform.Translate(orientation);
         if (hp <= 0)
         {
             GlobalEventManager.Instance.DecreaseHp(hp + damage);
             Lose();
         }
         else
         {
             GlobalEventManager.Instance.DecreaseHp(damage);
         }
     }
 }
コード例 #24
0
    /// <summary>
    /// trouver la position optimale autour de la cible
    /// </summary>
    /// <param name="playerPosition"></param>
    void SetOptimalPositionArroundTarget(Vector3Int playerPosition)
    {
        canTargetAGroup = false;
        choosedAbility  = unitData.abilities[0];
        if (unitData.abilities.Select(x => x is Taunt).Where(y => y == true).Any())
        {
            if (Random.Range(0, 2) == 0)
            {
                var taunts = unitData.abilities.Where(x => (x is Taunt)).ToList();
                choosedAbility = taunts.ElementAt(Random.Range(0, taunts.Count()));
            }
        }

        List <Vector3Int> pos = new List <Vector3Int>();

        pos.Add(new Vector3Int(playerPosition.x, playerPosition.y + 1, 0));
        pos.Add(new Vector3Int(playerPosition.x, playerPosition.y - 1, 0));
        pos.Add(new Vector3Int(playerPosition.x + 1, playerPosition.y, 0));
        pos.Add(new Vector3Int(playerPosition.x - 1, playerPosition.y, 0));

        //Chercher la position la plus proche et dont l'IA a assez de point d'action pour se rendre et attaquer
        do
        {
            Vector3Int optimalPosition = pos[0];
            for (int i = 0; i < pos.Count; i++)
            {
                if (Vector3Int.Distance(optimalPosition, positionGrid) > Vector3Int.Distance(pos[i], positionGrid))
                {
                    optimalPosition = pos[i];
                }
            }
            target = optimalPosition;

            pos.Remove(optimalPosition);
        } while (pos.Count >= 1 && (!MorePointAction(true)) && !target.Equals(positionGrid));
        //si la position précédente trouvée n'était pas accessible, choisir une habilité Buff s'il y en a
        if (!MorePointAction(true))
        {
            if (unitData.abilities.Select(x => x is Buff).Where(y => y == true).Any())
            {
                var lines = unitData.abilities.Where(x => (x is Buff)).ToList();
                choosedAbility = lines.ElementAt(Random.Range(0, lines.Count()));
            }
        }
    }
コード例 #25
0
        public override bool IsValidTile(Vector3Int gridPos, World world, City city)
        {
            Vector3[] checks      = new Vector3[] { new Vector3(-1, 0), new Vector3(-0.5f, 0.75f), new Vector3(0.5f, 0.75f), new Vector3(1, 0), new Vector3(0.5f, -0.75f), new Vector3(-0.5f, -0.75f) };
            bool      validBorder = false;

            foreach (Vector3 check in checks)
            {
                Vector3Int      checkPos = world.WorldToCell(world.CellToWorld(gridPos) + check);
                ConstructedTile tile     = world.GetConstructedTile(checkPos);
                if (checkPos.Equals(city.Position) || (tile != null && tile.City == city && tile.Type.Equals("District")))
                {
                    validBorder = true;
                    break;
                }
            }

            return(validBorder && !invalidTiles.Contains(world.GetTerrainTile(gridPos).name));
        }
コード例 #26
0
    public void update_vehicle_board(GameObject[,] vehicle_board, GameObject game_object, Vector3Int unadjusted_position, Vector3Int unadjusted_prev_position)
    {
        // note the OFFSET by 1 in xy direction to include negative tile positions in the board. This board is updated outside city and inside city, up to the boarding position (not after dont ask me why)
        Vector3Int position      = new Vector3Int(unadjusted_position.x + 1, unadjusted_position.y + 1, unadjusted_position.z);
        Vector3Int prev_position = new Vector3Int(unadjusted_prev_position.x + 1, unadjusted_prev_position.y + 1, unadjusted_prev_position.z);

        try
        {
            bool initial_vector = prev_position.Equals(new Vector3Int(-1, -1, -1));
            if (!initial_vector)
            {
                if (vehicle_board[prev_position.x, prev_position.y] == null)
                {
                    //print("WARNING. Gameobject " + game_object.name + " not found in previous position " + prev_position);
                }
                else
                {
                    if (vehicle_board[prev_position.x, prev_position.y] == game_object) // only remove gameobject references to itself
                    {
                        vehicle_board[prev_position.x, prev_position.y] = null;
                    }
                }
            }
            bool       in_city          = game_object.GetComponent <MovingObject>().in_city;
            GameObject city_object      = CityManager.instance.get_city(new Vector2Int(position.x, position.y));
            string     destination_type = TrainRouteManager.get_destination_type(unadjusted_position, in_city);
            if (destination_type == "city") // if vehicle arriving at city is a boxcar, don't update tile
            {
                if (game_object.tag == "train")
                {
                    vehicle_board[position.x, position.y] = game_object;                           // only trains should be in cities, it stores a list of attached boxcars
                }
            }
            else
            {
                vehicle_board[position.x, position.y] = game_object;
                ////print("Update Vehicle Board with object " + game_object.name + " to position " + position);
            }
        }
        catch (IndexOutOfRangeException e)
        {
            //print(e.Message + " Position: " + position);
        }
    }
コード例 #27
0
    public void CheckViewDistance(Vector3Int pPlayerCoord)
    {
        List <Vector3Int> previouslyActiveChunks = new List <Vector3Int>(activeChunks);

        for (int x = pPlayerCoord.x - Settings.Get.ViewDistanceInChunks; x <= pPlayerCoord.x + Settings.Get.ViewDistanceInChunks; x++)
        {
            for (int z = pPlayerCoord.z - Settings.Get.ViewDistanceInChunks; z <= pPlayerCoord.z + Settings.Get.ViewDistanceInChunks; z++)
            {
                Vector3Int c         = new Vector3Int(x, 0, z);
                bool       isInWorld = IsChunkInWorld(c);
                //Debug.Log($"{x},{z} isInWorld = {isInWorld}, player at {playerCoord}");
                if (isInWorld)
                {
                    if (chunks[x, z] == null)
                    {
                        chunks[x, z] = new Chunk(c, false);
                        chunksToCreate.Add(c);
                    }
                    else if (!chunks[x, z].IsActive)
                    {
                        chunks[x, z].IsActive = true;
                        activeChunks.Add(c);
                    }
                }

                for (int i = 0; i < previouslyActiveChunks.Count; i++)
                {
                    Vector3Int prevC = previouslyActiveChunks[i];
                    if (prevC.Equals(c))
                    {
                        previouslyActiveChunks.RemoveAt(i);
                    }
                }
            }
        }

        foreach (var ch in previouslyActiveChunks)
        {
            chunks[ch.x, ch.z].IsActive = false;
            activeChunks.Remove(ch);
        }
    }
コード例 #28
0
    protected override void EnterPattern(GameObject gameObject, AnimalData animalData)
    {
        Vector3Int[] destinations = GameManager.Instance.m_foodSourceManager.GetFoodSourcesLocationWithSpecies(FoodSpeciesName);
        Vector3Int   destination  = new Vector3Int(-1, -1, -1);

        if (destinations != null)
        {
            // Shuffle destinations
            Vector3Int temp;
            for (int i = 0; i < destinations.Length; i++)
            {
                int random = Random.Range(i, destinations.Length);
                temp                 = destinations[i];
                destinations[i]      = destinations[random];
                destinations[random] = destinations[i];
            }

            // Get a valid destination
            foreach (Vector3Int potentialDestination in destinations)
            {
                if (animalData.animal.PopulationInfo.AccessibleLocations.Contains(potentialDestination))
                {
                    destination = potentialDestination;
                    break;
                }
            }

            if (destination.Equals(new Vector3Int(-1, -1, -1)))
            {
                int locationIndex = animalData.animal.PopulationInfo.random.Next(0, animalData.animal.PopulationInfo.AccessibleLocations.Count);
                destination = animalData.animal.PopulationInfo.AccessibleLocations[locationIndex];
            }

            AnimalPathfinding.PathRequestManager.RequestPath(base.TileDataController.WorldToCell(gameObject.transform.position), destination, animalData.animal.MovementController.AssignPath, animalData.animal.PopulationInfo.Grid);
        }
        else
        {
            // If the edible food doesn't exist, just go to a random food (or whatever ItemType destination is set to)
            base.EnterPattern(gameObject, animalData);
        }
    }
コード例 #29
0
ファイル: World.cs プロジェクト: ja003/GD_assignment
    void Update()
    {
        PlayerCoord = CoordConvertor.GetChunkCoord(Player.transform.position);

        if (!PlayerCoord.Equals(playerLastCoord))
        {
            playerLastCoord = PlayerCoord;
            ChunksController.CheckViewDistance(PlayerCoord);
        }

        ChunksController.CreateNextChunk();

        if (Input.GetKeyDown(KeyCode.F3))
        {
            DebugScreen.gameObject.SetActive(!DebugScreen.gameObject.activeSelf);
        }

        if (Input.GetKeyDown(KeyCode.F1))
        {
            SaveSystem.SaveWorld(WorldData);
        }
    }
コード例 #30
0
ファイル: PathAlgorithm.cs プロジェクト: Tableu/COVID-Game
    //Basic algorithm that returns a path between two points. Returns null if no path is found.
    private List <Vector3Int> FindPath(List <Vector3Int> path, Vector3Int start, Vector3Int end)
    {
        path.Add(start);
        if (start.Equals(end))
        {
            return(path);
        }
        var moves = GetMoves(start);

        foreach (var move in moves)
        {
            if (path.Contains(move))
            {
                continue;
            }
            var result = FindPath(path, move, end);
            if (result != null)
            {
                return(result);
            }
        }
        return(null);
    }