//Finds River Flow Direction Based on Inspector
    private Vector3 GetRiverFlowDirection(RiverDirection direction)
    {
        Vector3 riverDirection = Vector3.zero;

        switch (direction)
        {
        case RiverDirection.North:
            riverDirection = Vector3.forward * Time.deltaTime * riverSpeed;
            break;

        case RiverDirection.East:
            riverDirection = Vector3.right * Time.deltaTime * riverSpeed;
            break;

        case RiverDirection.South:
            riverDirection = Vector3.back * Time.deltaTime * riverSpeed;
            break;

        case RiverDirection.West:
            riverDirection = Vector3.left * Time.deltaTime * riverSpeed;
            break;

        default:
            Debug.Log("This direction does not exist!");
            break;
        }
        return(riverDirection);
    }
Exemplo n.º 2
0
        public bool BridgeOnPosition(int position, RiverDirection riverDirection)
        {
            if (riverDirection == RiverDirection.horizontal)
            {
                foreach (int bridgeposition in BridgePositionsHorizontal)
                {
                    if (bridgeposition == position)
                    {
                        return(true);
                    }
                }
            }

            else if (riverDirection == RiverDirection.vertical)
            {
                foreach (int bridgeposition in BridgePositionsVertical)
                {
                    if (bridgeposition == position)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 3
0
        public bool BridgeOnPosition(int position, RiverDirection riverDirection)
        {
            if (riverDirection == RiverDirection.horizontal)
            {
                foreach (int bridgeposition in BridgePositionsHorizontal)
                {
                    if (bridgeposition == position)
                    {
                        return true;
                    }
                }
            }

            else if (riverDirection == RiverDirection.vertical)
            {
                foreach (int bridgeposition in BridgePositionsVertical)
                {
                    if (bridgeposition == position)
                    {
                        return true;
                    }
                }
            }

            return false;
        }
Exemplo n.º 4
0
 public static RiverDirection ReverseDirection(RiverDirection r)
 {
     switch (r)
     {
         case RiverDirection.EAST_TO_WEST: return RiverDirection.WEST_TO_EAST;
         case RiverDirection.WEST_TO_EAST: return RiverDirection.EAST_TO_WEST;
         case RiverDirection.NORTH_TO_SOUTH: return RiverDirection.SOUTH_TO_NORTH;
         case RiverDirection.SOUTH_TO_NORTH: return RiverDirection.NORTH_TO_SOUTH;
         default: return 0;
     }
 }
Exemplo n.º 5
0
        public RiverCrossingCreator(int MapWidth, int MapHeight)
        {
            TheRiverDirection = SetRiverDirection(MapWidth, MapHeight);

            //Console.WriteLine("Richtung: {0}", TheRiverDirection.ToString());
            SetRiverDimensions(MapWidth, MapHeight);

            if (TheRiverDirection == RiverDirection.horizontal)
            {
                SetBridges(TheRiverDirection, MapWidth);
            }

            else
            {
                SetBridges(TheRiverDirection, MapHeight);
            }
        }
Exemplo n.º 6
0
        public RiverCrossingCreator(int MapWidth, int MapHeight)
        {
            TheRiverDirection = SetRiverDirection(MapWidth, MapHeight);

            //Console.WriteLine("Richtung: {0}", TheRiverDirection.ToString());
            SetRiverDimensions(MapWidth, MapHeight);

            if (TheRiverDirection == RiverDirection.horizontal)
            {
                SetBridges(TheRiverDirection, MapWidth);
            }

            else
            {
                SetBridges(TheRiverDirection, MapHeight);
            }
        }
Exemplo n.º 7
0
        private void SetBridges(RiverDirection TheRiverDirection, int Distance)
        {
            int bridgeAmount;

            if (Distance <= 15)
            {
                bridgeAmount = 2;
            }
            else
            {
                Random rnd    = new Random();
                int[]  values = new int[] { 2, 3, 3, 4 };

                bridgeAmount = values[rnd.Next(0, values.Length)];
            }

            int counter = 0;

            if (TheRiverDirection == RiverDirection.horizontal)
            {
                BridgePositionsHorizontal = new int[bridgeAmount];
                for (int i = 0; i < bridgeAmount; i++)
                {
                    BridgePositionsHorizontal[i] = -10;
                }

                Random rnd           = new Random();
                bool   wrongassigned = false;

                while (true)
                {
                    int tempValue = rnd.Next(0, Distance);

                    foreach (int compvalue in BridgePositionsHorizontal)
                    {
                        if (compvalue == tempValue - 1 || compvalue == tempValue + 1 || compvalue == tempValue)
                        {
                            wrongassigned = true;
                        }
                    }

                    if (!wrongassigned)
                    {
                        BridgePositionsHorizontal[counter] = tempValue;
                        counter++;
                    }
                    wrongassigned = false;

                    if (counter == bridgeAmount)
                    {
                        break;
                    }
                }
            }

            else
            {
                BridgePositionsVertical = new int[bridgeAmount];
                for (int i = 0; i < bridgeAmount; i++)
                {
                    BridgePositionsVertical[i] = -10;
                }
                Random rnd           = new Random();
                bool   wrongassigned = false;

                while (true)
                {
                    int tempValue = rnd.Next(0, Distance);

                    foreach (int compvalue in BridgePositionsVertical)
                    {
                        if (compvalue == tempValue - 1 || compvalue == tempValue + 1 || compvalue == tempValue)
                        {
                            wrongassigned = true;
                        }
                    }

                    if (!wrongassigned)
                    {
                        BridgePositionsVertical[counter] = tempValue;
                        counter++;
                    }
                    wrongassigned = false;

                    if (counter == bridgeAmount)
                    {
                        break;
                    }
                }
            }
        }
Exemplo n.º 8
0
        private void SetBridges(RiverDirection TheRiverDirection, int Distance)
        {
            int bridgeAmount;

            if (Distance <= 15)
            {
                bridgeAmount = 2;
            }
            else
            {
                Random rnd = new Random();
                int[] values = new int[] { 2, 3, 3, 4 };

                bridgeAmount = values[rnd.Next(0, values.Length)];
            }

            int counter = 0;

            if (TheRiverDirection == RiverDirection.horizontal)
            {
                BridgePositionsHorizontal = new int[bridgeAmount];
                for (int i = 0; i < bridgeAmount; i++)
                {
                    BridgePositionsHorizontal[i] = -10;
                }

                Random rnd = new Random();
                bool wrongassigned = false;

                while (true)
                {
                    int tempValue = rnd.Next(0, Distance);

                    foreach (int compvalue in BridgePositionsHorizontal)
                    {
                        if (compvalue == tempValue - 1 || compvalue == tempValue + 1 || compvalue == tempValue)
                        {
                            wrongassigned = true;
                        }
                    }

                    if (!wrongassigned)
                    {
                        BridgePositionsHorizontal[counter] = tempValue;
                        counter++;
                    }
                    wrongassigned = false;

                    if (counter == bridgeAmount)
                    {
                        break;
                    }
                }
            }

            else
            {
                BridgePositionsVertical = new int[bridgeAmount];
                for (int i = 0; i < bridgeAmount; i++)
                {
                    BridgePositionsVertical[i] = -10;
                }
                Random rnd = new Random();
                bool wrongassigned = false;

                while (true)
                {
                    int tempValue = rnd.Next(0, Distance);

                    foreach (int compvalue in BridgePositionsVertical)
                    {
                        if (compvalue == tempValue - 1 || compvalue == tempValue + 1 || compvalue == tempValue)
                        {
                            wrongassigned = true;
                        }
                    }

                    if (!wrongassigned)
                    {
                        BridgePositionsVertical[counter] = tempValue;
                        counter++;
                    }
                    wrongassigned = false;

                    if (counter == bridgeAmount)
                    {
                        break;
                    }
                }
            }
        }