Esempio n. 1
0
 public override List <Vector2> generate()
 {
     base.positions = new List <Vector2>(getSize());
     for (int i = 0; i < base.positions.Capacity; i++)
     {
         base.positions.Add(PositionGenerator.getInstance().generateSpawn());
     }
     return(base.generate());
 }
        protected virtual bool checkPosition(Vector2 desiredPosition, Vector2 startPosition, out Vector2 lastPosition)
        {
            bool isSafe = PositionGenerator.getInstance().isPositionSafe(desiredPosition);

            if (isSafe)
            {
                this.positions.Add(desiredPosition);
                lastPosition = desiredPosition;
            }
            else
            {
                lastPosition = startPosition;
            }
            return(isSafe);
        }
Esempio n. 3
0
        public override List <Vector2> generate()
        {
            int eachBranchesNodeCount = getSize();

            base.positions = new List <Vector2>(eachBranchesNodeCount * 2 + 1);
            Vector2 centreNode = PositionGenerator.getInstance().generateSpawn(markGeneratedPosition: false);

            base.positions.Add(centreNode);
            Vector2 lastPosition = centreNode;
            Vector2 desiredPosition;
            int     direction = 1;

            if (base.RAND.Next(0, 2) == 1)
            {
                direction = -1;
            }

            // hoizontal
            for (int i = 0; i < eachBranchesNodeCount; i++)
            {
                desiredPosition = Vector2.Add(lastPosition, new Vector2(direction * Constants.TILE_SIZE, 0f));
                if (!base.checkPosition(desiredPosition, centreNode, out lastPosition))
                {
                    break;
                }
            }

            direction = 1;
            if (base.RAND.Next(0, 2) == 1)
            {
                direction = -1;
            }

            // vertical
            lastPosition = centreNode;
            for (int i = 0; i < eachBranchesNodeCount; i++)
            {
                desiredPosition = Vector2.Add(lastPosition, new Vector2(0f, direction * Constants.TILE_SIZE));
                if (!base.checkPosition(desiredPosition, centreNode, out lastPosition))
                {
                    break;
                }
            }
            return(base.generate());
        }
        public override List <Vector2> generate()
        {
            int eachBranchesNodeCount = getSize();

            base.positions = new List <Vector2>(eachBranchesNodeCount * 4 + 1);
            Vector2 centreNode = PositionGenerator.getInstance().generateSpawn(markGeneratedPosition: false);

            base.positions.Add(centreNode);
            Vector2 lastPosition = centreNode;
            Vector2 desiredPosition;

            // horizontal branches
            for (int j = -1; j <= 2; j += 2)
            {
                lastPosition = centreNode;
                for (int i = 0; i < eachBranchesNodeCount; i++)
                {
                    desiredPosition = Vector2.Add(lastPosition, new Vector2(0f, j * Constants.TILE_SIZE));
                    if (!base.checkPosition(desiredPosition, centreNode, out lastPosition))
                    {
                        break;
                    }
                }
            }

            // vertical branches
            for (int j = -1; j <= 2; j += 2)
            {
                lastPosition = centreNode;
                for (int i = 0; i < eachBranchesNodeCount; i++)
                {
                    desiredPosition = Vector2.Add(lastPosition, new Vector2(j * Constants.TILE_SIZE, 0f));
                    if (!base.checkPosition(desiredPosition, centreNode, out lastPosition))
                    {
                        break;
                    }
                }
            }
            return(base.generate());
        }
        public override List <Vector2> generate()
        {
            base.positions = new List <Vector2>(getSize());
            Vector2 centreNode = PositionGenerator.getInstance().generateSpawn(markGeneratedPosition: false);

            base.positions.Add(centreNode);
            Vector2 lastPosition;
            Vector2 desiredPosition;

            for (int j = -1; j <= 2; j += 2)
            {
                lastPosition = centreNode;
                for (int i = 0; i < base.positions.Capacity / 2; i++)
                {
                    desiredPosition = Vector2.Add(lastPosition, new Vector2(j * Constants.TILE_SIZE, 0f));
                    if (!base.checkPosition(desiredPosition, centreNode, out lastPosition))
                    {
                        break;
                    }
                }
            }
            return(base.generate());
        }
 public virtual List <Vector2> generate()
 {
     PositionGenerator.getInstance().markPositions(this.positions, false);
     return(this.positions);
 }