Example #1
0
        protected void GetComputedLandType(
            IntRect area,
            ref int[,] subAreaInt,
            int maxValue,
            out LandTransition landtransition)
        {
            bool[,] subAreaBool = new bool[3, 3];

            landtransition = LandTransition.NONE;

            if (subAreaInt[1, 1] < maxValue)
            {
                for (int y = 0; y < 3; y++)
                {
                    for (int x = 0; x < 3; x++)
                    {
                        if (subAreaInt[y, x] <= subAreaInt[1, 1])
                        {
                            subAreaBool[y, x] = false;
                        }
                        else
                        {
                            subAreaBool[y, x] = true;
                        }
                    }
                }

                landtransition = ALandLayerGenerator.GetLandTransitionFrom(ref subAreaBool);
            }
        }
Example #2
0
    IEnumerator throwAtTarget(Transform target)
    {
        transform.position = target.transform.position + InitialRelativePosition;
        transform.rotation = Quaternion.Euler(0, 0, RandomExtra.Range(AngleRange));

        var landTarget  = target.transform.position + (Vector3)(Random.insideUnitCircle * MaxDistanceFromTarget);
        var throwDir    = (Vector2)landTarget - (Vector2)transform.position;
        var throwTarget = landTarget - (Vector3)throwDir.normalized * Random.Range(0, LandTravel);

        ThrowTransition.FlashFromTo(transform.position, throwTarget);

        while (ThrowTransition.Transitioning)
        {
            transform.position = ThrowTransition.Value;
            yield return(null);
        }

        transform.position = throwTarget;

        LandTransition.FlashFromTo(transform.position, landTarget);

        while (LandTransition.Transitioning)
        {
            transform.position = LandTransition.Value;
            yield return(null);
        }

        transform.position = landTarget;
    }
        private void GetComputedLandType(
            ALandLayerGenerator altitudeLandLayerGenerator,
            IntRect area,
            int i, int j,
            out LandType landType,
            out LandType secondType,
            out LandTransition landtransition)
        {
            bool[,] subAreaBool = new bool[3, 3];
            int[,] subAreaInt   = new int[3, 3];

            int maxValue = int.MinValue;
            int minValue = int.MaxValue;

            for (int y = -1; y < 2; y++)
            {
                for (int x = -1; x < 2; x++)
                {
                    int power = altitudeLandLayerGenerator.GetComputedPowerAt(j + x, i + y);

                    int currentValue = (int)this.GetLandTypeFromPower(power);

                    maxValue = Math.Max(maxValue, currentValue);

                    minValue = Math.Min(minValue, currentValue);

                    subAreaInt[y + 1, x + 1] = currentValue;
                }
            }

            landType       = (LandType)subAreaInt[1, 1];
            landtransition = LandTransition.NONE;
            secondType     = landType;

            if (subAreaInt[1, 1] != maxValue)
            {
                for (int y = 0; y < 3; y++)
                {
                    for (int x = 0; x < 3; x++)
                    {
                        if (subAreaInt[y, x] != maxValue)
                        {
                            subAreaBool[y, x] = false;
                        }
                        else
                        {
                            subAreaBool[y, x] = true;
                        }
                    }
                }

                landtransition = ALandLayerGenerator.GetLandTransitionFrom(ref subAreaBool);

                if (landtransition != LandTransition.NONE)
                {
                    secondType = (LandType)maxValue;
                }
            }
        }
Example #4
0
        public ALandObject(int positionX, int positionY, int positionZ)
        {
            this.Position = new Vector2i(positionX, positionY);

            this.Altitude = positionZ;

            this.LandTransition = LandTransition.NONE;
        }
Example #5
0
        public override ILandObject Clone(LandTransition wallLandTransition)
        {
            if (wallLandTransition != LandTransition.NONE)
            {
                GrassElementLandObject grassLandObject = new GrassElementLandObject(this.Position.X, this.Position.Y, this.Altitude, this.LandGrassType, this.ElementIndex);

                return(grassLandObject);
            }
            return(null);
        }
        public override ILandObject Clone(LandTransition wallLandTransition)
        {
            if (wallLandTransition != LandTransition.NONE)
            {
                MountainElementLandObject mountainLandObject = new MountainElementLandObject(this.Position.X, this.Position.Y, this.Altitude, this.LandMountainType, this.ElementIndex);

                return(mountainLandObject);
            }
            return(null);
        }
Example #7
0
        public static LandTransition ReverseLandTransition(LandTransition landTransition)
        {
            int[,] matrix = LandTransitionHelper.GetMatrixFromLandTransition(landTransition);

            int[,] reverseMatrix = new int[, ]
            {
                { matrix[0, 0] == 1 ? 0 : 1, matrix[0, 1] == 1 ? 0 : 1 },
                { matrix[1, 0] == 1 ? 0 : 1, matrix[1, 1] == 1 ? 0 : 1 }
            };

            return(LandTransitionHelper.GetLandTransitionFromMatrix(reverseMatrix));
        }
Example #8
0
        public override ILandObject Clone(LandTransition wallLandTransition)
        {
            LandTransition landTransitionOverWall = this.GetLandTransitionOverWall(wallLandTransition);

            if (landTransitionOverWall != LandTransition.NONE)
            {
                AltitudeLandObject altitudeLandObject = new AltitudeLandObject(this.Position.X, this.Position.Y, this.Altitude, this.landType);
                altitudeLandObject.SetLandTransition(landTransitionOverWall);

                return(altitudeLandObject);
            }
            return(null);
        }
Example #9
0
        public override ILandObject Clone(LandTransition wallLandTransition)
        {
            LandTransition landTransitionOverWall = this.GetLandTransitionOverWall(wallLandTransition);

            if (landTransitionOverWall != LandTransition.NONE)
            {
                MountainLandObject grassLandObject = new MountainLandObject(this.Position.X, this.Position.Y, this.Altitude, this.LandMountainType);
                grassLandObject.SetTransition(landTransitionOverWall);

                return(grassLandObject);
            }
            return(null);
        }
Example #10
0
        public static int[,] GetMatrixFromLandTransition(LandTransition landTransition)
        {
            switch (landTransition)
            {
            case LandTransition.NONE:
                return(FULL_MATRIX);

            case LandTransition.RIGHT:
                return(RIGHT_MATRIX);

            case LandTransition.LEFT:
                return(LEFT_MATRIX);

            case LandTransition.TOP:
                return(TOP_MATRIX);

            case LandTransition.BOT:
                return(BOT_MATRIX);

            case LandTransition.TOP_LEFT:
                return(TOP_LEFT_MATRIX);

            case LandTransition.BOT_LEFT:
                return(BOT_LEFT_MATRIX);

            case LandTransition.TOP_RIGHT:
                return(TOP_RIGHT_MATRIX);

            case LandTransition.BOT_RIGHT:
                return(BOT_RIGHT_MATRIX);

            case LandTransition.TOP_INT_LEFT:
                return(TOP_INT_LEFT_MATRIX);

            case LandTransition.BOT_INT_LEFT:
                return(BOT_INT_LEFT_MATRIX);

            case LandTransition.TOP_INT_RIGHT:
                return(TOP_INT_RIGHT_MATRIX);

            case LandTransition.BOT_INT_RIGHT:
                return(BOT_INT_RIGHT_MATRIX);
            }

            return(NONE_MATRIX);
        }
Example #11
0
        public static LandTransition IntersectionLandTransition(LandTransition mainLandTransition, LandTransition secondLandTransition)
        {
            int[,] matrix1 = LandTransitionHelper.GetMatrixFromLandTransition(mainLandTransition);

            int[,] matrix2 = LandTransitionHelper.GetMatrixFromLandTransition(secondLandTransition);
            //if (secondLandTransition != LandTransition.NONE)
            //{
            //    matrix2 = LandTransitionHelper.GetMatrixFromLandTransition(secondLandTransition);
            //}
            //else
            //{
            //    matrix2 = FULL_MATRIX;
            //}

            int[,] intersectionMatrix = new int[, ]
            {
                { (matrix1[0, 0] == 1 && matrix1[0, 0] == matrix2[0, 0]) ? 1 : 0, (matrix1[0, 1] == 1 && matrix1[0, 1] == matrix2[0, 1]) ? 1 : 0 },
                { (matrix1[1, 0] == 1 && matrix1[1, 0] == matrix2[1, 0]) ? 1 : 0, (matrix1[1, 1] == 1 && matrix1[1, 1] == matrix2[1, 1]) ? 1 : 0 }
            };

            return(LandTransitionHelper.GetLandTransitionFromMatrix(intersectionMatrix));
        }
Example #12
0
        public static void GetComputedLandType(
            ALandLayerGenerator generator,
            IntRect area,
            int i, int j,
            out int mountainType,
            out int secondType,
            out LandTransition landtransition,
            out LandTransition secondLandtransition)
        {
            bool[,] subAreaBool = new bool[3, 3];
            int[,] subAreaInt   = new int[3, 3];

            int maxValue = int.MinValue;
            int minValue = int.MaxValue;

            for (int y = -1; y < 2; y++)
            {
                for (int x = -1; x < 2; x++)
                {
                    int currentValue = generator.GetComputedPowerAt(j + x, i + y);

                    maxValue = Math.Max(maxValue, currentValue);

                    minValue = Math.Min(minValue, currentValue);

                    subAreaInt[y + 1, x + 1] = currentValue;
                }
            }

            mountainType         = subAreaInt[1, 1];
            landtransition       = LandTransition.NONE;
            secondLandtransition = LandTransition.NONE;
            secondType           = mountainType;

            if (subAreaInt[1, 1] != maxValue)
            {
                int primaryType = -1;
                for (int y = 0; y < 3; y++)
                {
                    for (int x = 0; x < 3; x++)
                    {
                        if (subAreaInt[y, x] != maxValue)
                        {
                            subAreaBool[y, x] = false;

                            if (subAreaInt[y, x] != -1)
                            {
                                primaryType = subAreaInt[y, x];
                            }
                        }
                        else
                        {
                            subAreaBool[y, x] = true;
                        }
                    }
                }

                secondLandtransition = ALandLayerGenerator.GetLandTransitionFrom(ref subAreaBool);

                if (secondLandtransition != LandTransition.NONE)
                {
                    secondType = maxValue;
                }

                if (subAreaInt[1, 1] == -1 && primaryType != -1)
                {
                    mountainType = primaryType;

                    for (int y = 0; y < 3; y++)
                    {
                        for (int x = 0; x < 3; x++)
                        {
                            if (subAreaInt[y, x] != primaryType)
                            {
                                subAreaBool[y, x] = false;
                            }
                            else
                            {
                                subAreaBool[y, x] = true;
                            }
                        }
                    }

                    landtransition = ALandLayerGenerator.GetLandTransitionFrom(ref subAreaBool);
                }
            }
        }
Example #13
0
 public void SetTransition(LandTransition landTransition)
 {
     this.LandTransition = landTransition;
 }
Example #14
0
 public static LandTransition InverseLandTransition(LandTransition landTransition)
 {
     return(LandTransitionHelper.ReverseLandTransition(landTransition));
 }
Example #15
0
 public LandTransition GetLandTransitionOverWall(LandTransition wallLandTransition)
 {
     return(LandTransitionHelper.IntersectionLandTransition(wallLandTransition, this.LandTransition));
 }
Example #16
0
        protected IntRect GetTransitionTextureCoord(LandTransition landTransition)
        {
            IntRect result = new IntRect(0, 0, 1, 1);

            switch (landTransition)
            {
            case LandTransition.TOP:
                result.Left = 1;
                result.Top  = 1;
                break;

            case LandTransition.RIGHT:
                result.Left = 2;
                result.Top  = 2;
                break;

            case LandTransition.BOT:
                result.Left = 1;
                result.Top  = 3;
                break;

            case LandTransition.LEFT:
                result.Left = 0;
                result.Top  = 2;
                break;

            case LandTransition.TOP_LEFT:
                result.Left = 0;
                result.Top  = 1;
                break;

            case LandTransition.TOP_RIGHT:
                result.Left = 2;
                result.Top  = 1;
                break;

            case LandTransition.BOT_LEFT:
                result.Left = 0;
                result.Top  = 3;
                break;

            case LandTransition.BOT_RIGHT:
                result.Left = 2;
                result.Top  = 3;
                break;

            case LandTransition.TOP_INT_LEFT:
                result.Left = 3;
                result.Top  = 0;
                break;

            case LandTransition.TOP_INT_RIGHT:
                result.Left = 3;
                result.Top  = 1;
                break;

            case LandTransition.BOT_INT_LEFT:
                result.Left = 3;
                result.Top  = 2;
                break;

            case LandTransition.BOT_INT_RIGHT:
                result.Left = 3;
                result.Top  = 3;
                break;
            }

            result.Left   *= 2 * MainWindow.MODEL_TO_VIEW;
            result.Top    *= 2 * MainWindow.MODEL_TO_VIEW;
            result.Width  *= 2 * MainWindow.MODEL_TO_VIEW;
            result.Height *= 2 * MainWindow.MODEL_TO_VIEW;

            return(result);
        }
Example #17
0
 public override ILandObject Clone(LandTransition wallLandTransition)
 {
     return(null);
 }
Example #18
0
 public abstract ILandObject Clone(LandTransition wallLandTransition);
Example #19
0
 void Awake()
 {
     ThrowTransition.AttachMonoBehaviour(this);
     LandTransition.AttachMonoBehaviour(this);
 }