public void posWithoutCapabilityAndEntryMode()
        {
            var authorization = new authorization();
            authorization.reportGroup = "Planets";
            authorization.orderId = "12344";
            authorization.amount = 106;
            authorization.orderSource = orderSourceType.ecommerce;
            var pos = new pos();
            pos.cardholderId = posCardholderIdTypeEnum.pin;
            authorization.pos = pos;
            var card = new cardType();
            card.type = methodOfPaymentTypeEnum.VI;
            card.number = "4100000000000002";
            card.expDate = "1210";
            authorization.card = card; //This needs to compile

            var cb = new customBilling();
            cb.phone = "1112223333"; //This needs to compile too

            try
            {
                litle.Authorize(authorization);
                //expected exception;
            }
            catch (LitleOnlineException e)
            {
                Assert.True(e.Message.StartsWith("Error validating xml data against the schema"));
            }
        }
 public PhysicalObject(string name_, char symbol_, Color color_)
 {
     p = new pos(-1, -1);
     row = -1;
     col = -1;
     SetName(name_);
     symbol = string.FromCharCode(symbol_);
     color = color_;
     light_radius = 0;
 }
 public PhysicalObject()
 {
     p = new pos(-1, -1);
     row=-1;
     col=-1;
     name="";
     a_name="";
     the_name="";
     symbol="%";
     color=Color.White;
     light_radius = 0;
 }
 public PhysicalObject()
 {
     row = -1;
     col = -1;
     name = "";
     a_name = "";
     the_name = "";
     symbol = '%';
     color = Color.White;
     light_radius = 0;
     sprite_offset = new pos(0,1);
 }
Example #5
0
        internal override void BeginFigure(double x, double y, double? z)
        {
            var coords=new List<double>(new double[] { x, y });
            if (z.HasValue)
            {
                srsDimension=3;
                coords.Add(z.Value);
            }

            pos=new pos();
            pos.Untyped.Value=string.Join(
                " ",
                coords.Select<double, string>(d => d.ToString(CultureInfo.InvariantCulture))
            );
        }
Example #6
0
    public pos GetTouch(int ID)
    {
        pos tempPos = new pos();

        tempPos.position = Input.mousePosition;

        if(Input.GetMouseButtonDown(ID))
            tempPos.phase = iPhoneTouchPhase.Began;
        else if(Input.GetMouseButton(ID))
            tempPos.phase = iPhoneTouchPhase.Moved;

        if(Input.GetMouseButtonUp(ID))
            tempPos.phase = iPhoneTouchPhase.Ended;

        return tempPos;
    }
Example #7
0
 public static Actor ActorFromDrawingPosition(pos drawing_position)
 {
     return ActorFromDrawingPosition(drawing_position.row,drawing_position.col);
 }
        public int DirectionOf(pos obj)
        {
            int dy = Math.Abs(obj.row - row);
            int dx = Math.Abs(obj.col - col);
            if(dy == 0){
                if(col < obj.col){
                    return 6;
                }
                if(col > obj.col){
                    return 4;
                }
                else{
                    if(dx == 0){
                        return 5;
                    }
                }
            }
            if(dx == 0){
                if(row > obj.row){
                    return 8;
                }
                else{
                    if(row < obj.row){
                        return 2;
                    }
                }
            }
            if(row+col == obj.row+obj.col){ //slope is -1
                if(row > obj.row){
                    return 9;
                }
                else{
                    if(row < obj.row){
                        return 1;
                    }
                }
            }
            if(row-col == obj.row-obj.col){ //slope is 1
                if(row > obj.row){
                    return 7;
                }
                else{
                    if(row < obj.row){
                        return 3;
                    }
                }
            }
            // calculate all other dirs here
            /*.................flipped y
            ........m........
            .......l|n.......
            ........|........
            .....k..|..o.....
            ......\.|./......
            ...j...\|/...p...
            [email protected]
            ...h.../|\...b.2.
            ....../.|.\.B.3..
            .....g..|..c.4...
            ........|...5....
            .......f|d.......
            ........e........

            @-------------...
            |\;..b.2.........
            |.\.B.3..........
            |..\.4;..........
            |...\...;........
            |....\....;6.....
            |.....\.....;....
            |......\.....5;..
            rise:	run:	ri/ru:	angle(flipped y):
            b:	1	5	1/5		(obviously the dividing line should be 22.5 degrees here)
            d:	5	1	5		67.5
            f:	5	-1	-5		112.5
            h:	1	-5	-1/5		157.5
            j:	-1	-5	1/5		202.5
            l:	-5	-1	5		247.5
            n:	-5	1	-5		292.5
            p:	-1	5	-1/5		337.5
            algorithm for determining direction...			(for b)		(for 4)		(for 6)		(for 5)		(for B)
            first, determine 'major' direction - NSEW		E		E		E		E		E
            then, determine 'minor' direction - diagonals		SE		SE		SE		SE		SE
            find the ratio of d-major/d(other dir) (both positive)	1/5		3/5		5/11		7/13		2/4
            compare this number to 1/2:  if less than 1/2, major.
            if more than 1/2, minor.
            if exactly 1/2, tiebreaker.
                            major(E)	minor(SE)	major(E)	minor(SE)	tiebreak

            */
            int primary; //orthogonal
            int secondary; //diagonal
            int dprimary = Math.Min(dy,dx);
            int dsecondary = Math.Max(dy,dx);
            if(row < obj.row){ //down
                if(col < obj.col){ //right
                    secondary = 3;
                    if(dx > dy){ //slope less than 1
                        primary = 6;
                    }
                    else{ //slope greater than 1
                        primary = 2;
                    }
                }
                else{ //left
                    secondary = 1;
                    if(dx > dy){ //slope less than 1
                        primary = 4;
                    }
                    else{ //slope greater than 1
                        primary = 2;
                    }
                }
            }
            else{ //up
                if(col < obj.col){ //right
                    secondary = 9;
                    if(dx > dy){ //slope less than 1
                        primary = 6;
                    }
                    else{ //slope greater than 1
                        primary = 8;
                    }
                }
                else{ //left
                    secondary = 7;
                    if(dx > dy){ //slope less than 1
                        primary = 4;
                    }
                    else{ //slope greater than 1
                        primary = 8;
                    }
                }
            }
            int tiebreaker = primary;
            float ratio = (float)dprimary / (float)dsecondary;
            if(ratio < 0.5f){
                return primary;
            }
            else{
                if(ratio > 0.5f){
                    return secondary;
                }
                else{
                    return tiebreaker;
                }
            }
        }
        public void trackData()
        {
            var authorization = new authorization();
            authorization.id = "AX54321678";
            authorization.reportGroup = "RG27";
            authorization.orderId = "12z58743y1";
            authorization.amount = 12522L;
            authorization.orderSource = orderSourceType.retail;
            var billToAddress = new contact();
            billToAddress.zip = "95032";
            authorization.billToAddress = billToAddress;
            var card = new cardType();
            card.track = "%B40000001^Doe/JohnP^06041...?;40001=0604101064200?";
            authorization.card = card;
            var pos = new pos();
            pos.capability = posCapabilityTypeEnum.magstripe;
            pos.entryMode = posEntryModeTypeEnum.completeread;
            pos.cardholderId = posCardholderIdTypeEnum.signature;
            authorization.pos = pos;

            var response = litle.Authorize(authorization);
            Assert.AreEqual("Approved", response.message);
        }
Example #10
0
 public Tile(TileType type_,string name_,char symbol_,Color color_,bool passable_,bool opaque_,TileType? toggles_into_)
 {
     type = type_;
     name = name_;
     the_name = "the " + name;
     switch(name[0]){
     case 'a':
     case 'e':
     case 'i':
     case 'o':
     case 'u':
     case 'A':
     case 'E':
     case 'I':
     case 'O':
     case 'U':
         a_name = "an " + name;
         break;
     default:
         a_name = "a " + name;
         break;
     }
     symbol = symbol_;
     color = color_;
     passable = passable_;
     opaque = opaque_;
     seen = false;
     solid_rock = false;
     revealed_by_light = false;
     if(Is(TileType.STAIRS,TileType.CHEST,TileType.FIREPIT,TileType.POOL_OF_RESTORATION)){
         revealed_by_light = true;
     }
     light_value = 0;
     toggles_into = toggles_into_;
     inv = null;
     light_radius = 0;
     direction_exited = 0;
     if(type >= TileType.COMBAT_SHRINE && type <= TileType.STEALTH_SHRINE){
         int diff = type - TileType.COMBAT_SHRINE;
         sprite_offset = new pos(11,diff);
     }
     else{
         if(type >= TileType.FIRE_TRAP && type <= TileType.STONE_RAIN_TRAP){
             int diff = type - TileType.FIRE_TRAP;
             sprite_offset = new pos(14 + diff/16,diff%16);
         }
         else{
             if(passable){
                 sprite_offset = new pos(8,0);
             }
             else{
                 sprite_offset = new pos(0,0);
             }
             switch(type){
             case TileType.BARREL:
                 sprite_offset = new pos(12,14);
                 break;
             case TileType.BLAST_FUNGUS:
                 sprite_offset = new pos(12,5);
                 break;
             case TileType.BREACHED_WALL:
                 sprite_offset = new pos(9,0);
                 break;
             case TileType.BRUSH:
                 sprite_offset = new pos(12,0);
                 break;
             case TileType.CHASM:
                 sprite_offset = new pos(11,14);
                 break;
             case TileType.CHEST:
                 sprite_offset = new pos(10,4);
                 break;
             case TileType.CRACKED_WALL:
                 sprite_offset = new pos(0,1);
                 break;
             case TileType.DEMONIC_IDOL:
                 sprite_offset = new pos(13,1);
                 break;
             case TileType.DOOR_C:
                 sprite_offset = new pos(10,0);
                 break;
             case TileType.DOOR_O:
                 sprite_offset = new pos(10,2);
                 break;
             case TileType.FIRE_GEYSER:
                 sprite_offset = new pos(11,8);
                 break;
             case TileType.FIREPIT:
                 sprite_offset = new pos(10,12);
                 break;
             case TileType.FLOOR:
                 sprite_offset = new pos(8,0);
                 break;
             case TileType.FOG_VENT:
                 sprite_offset = new pos(11,9);
                 break;
             case TileType.GLOWING_FUNGUS:
                 sprite_offset = new pos(12,10);
                 break;
             case TileType.GRAVE_DIRT:
                 sprite_offset = new pos(12,13);
                 break;
             case TileType.GRAVEL:
                 sprite_offset = new pos(10,15);
                 break;
             case TileType.ICE:
                 sprite_offset = new pos(11,11);
                 break;
             case TileType.JUNGLE:
                 sprite_offset = new pos(0,0); //unused
                 break;
             case TileType.POISON_BULB:
                 sprite_offset = new pos(13,0);
                 break;
             case TileType.POISON_GAS_VENT:
                 sprite_offset = new pos(11,10);
                 break;
             case TileType.POOL_OF_RESTORATION:
                 sprite_offset = new pos(13,5);
                 break;
             case TileType.POPPY_FIELD:
                 sprite_offset = new pos(12,4);
                 break;
             case TileType.RUBBLE:
                 sprite_offset = new pos(10,14);
                 break;
             case TileType.STAIRS:
                 sprite_offset = new pos(13,6);
                 break;
             case TileType.STALAGMITE:
                 sprite_offset = new pos(10,13);
                 break;
             case TileType.STANDING_TORCH:
                 sprite_offset = new pos(12,15);
                 break;
             case TileType.STATUE:
                 sprite_offset = new pos(10,8);
                 break;
             case TileType.STONE_SLAB:
                 sprite_offset = new pos(11,12);
                 break;
             case TileType.TOMBSTONE:
                 sprite_offset = new pos(12,12);
                 break;
             case TileType.VINE:
                 sprite_offset = new pos(0,8);
                 break;
             case TileType.WALL:
             case TileType.HIDDEN_DOOR:
                 sprite_offset = new pos(0,0);
                 break;
             case TileType.WATER:
                 sprite_offset = new pos(0,4);
                 break;
             case TileType.WAX_WALL:
                 sprite_offset = new pos(0,12);
                 break;
             }
         }
     }
 }
Example #11
0
 public static void SetMapCursor(pos p,bool from_status_bar)
 {
     if(!internal_map_cursor.Equals(p)){
         internal_map_cursor = p;
         status_hover = from_status_bar;
         DisplayStatusBarObjects();
     }
 }
 public int EstimatedEuclideanDistanceFromX10(pos p)
 {
     return EstimatedEuclideanDistanceFromX10(p.row,p.col);
 }
		public static void AnimateStorm(pos origin,int radius,int num_frames,int num_per_frame,colorchar ch){
			for(int i=0;i<num_frames;++i){
				List<pos> cells = new List<pos>();
				List<pos> nearby = origin.PositionsWithinDistance(radius);
				for(int j=0;j<num_per_frame;++j){
					cells.Add(nearby.RemoveRandom());
				}
				Screen.AnimateMapCells(cells,ch);
			}
		}
Example #14
0
 public static Tile TileFromDrawingPosition(pos drawing_position)
 {
     return TileFromDrawingPosition(drawing_position.row,drawing_position.col);
 }
Example #15
0
 public void AddPillars(int percent_chance_per_room)
 {
     //currently does 50% 'pillar', 25% 'statue', and 25% 'other', where relevant.
     ForEachRectangularRoom((start_r,start_c,end_r,end_c) => {
         if(PercentChance(percent_chance_per_room)){
             int height = end_r - start_r + 1;
             int width = end_c - start_c + 1;
             if(height > 3 || width > 3){
                 List<PillarArrangement> layouts = new List<PillarArrangement>();
                 if(height % 2 == 1 && width % 2 == 1){
                     layouts.Add(PillarArrangement.Single);
                 }
                 if((height % 2 == 1 || width % 2 == 1) && height != 4 && width != 4){
                     layouts.Add(PillarArrangement.Row);
                 }
                 if(height >= 5 && width >= 5){
                     layouts.Add(PillarArrangement.Corners);
                 }
                 if(height > 2 && width > 2 && height != 4 && width != 4){
                     layouts.Add(PillarArrangement.Full);
                 }
                 if((width % 2 == 1 && width >= 5) || (height % 2 == 1 && height >= 5)){
                     layouts.Add(PillarArrangement.StatueEdges);
                 }
                 if(layouts.Count == 0 || CoinFlip()){ //otherwise they're too common
                     layouts.Add(PillarArrangement.StatueCorners);
                 }
                 if(layouts.Count > 0){
                     CellType pillar = CellType.Pillar;
                     /*switch(Roll(4)){ //this part should be done later. Until then, they should remain pillars.
                     case 1:
                     case 2:
                         pillar = CellType.Pillar;
                         break;
                     case 3:
                         pillar = CellType.Statue;
                         break;
                     case 4:
                         pillar = CellType.OtherRoomFeature;
                         break;
                     }*/
                     switch(layouts.Random()){
                     case PillarArrangement.Single:
                         map[(start_r + end_r)/2,(start_c + end_c)/2] = pillar;
                         break;
                     case PillarArrangement.Row:
                     {
                         bool vertical;
                         if(width % 2 == 1 && height % 2 == 0){
                             vertical = true;
                         }
                         else{
                             if(height % 2 == 1 && width % 2 == 0){
                                 vertical = false;
                             }
                             else{
                                 vertical = CoinFlip();
                             }
                         }
                         if(vertical){
                             if(height % 2 == 1){
                                 for(int i=start_r+1;i<=end_r-1;i+=2){
                                     map[i,(start_c + end_c)/2] = pillar;
                                 }
                             }
                             else{
                                 int offset = 0;
                                 if(height % 4 == 0){
                                     offset = Roll(2) - 1;
                                 }
                                 for(int i=start_r+1+offset;i<(start_r + end_r)/2;i+=2){
                                     map[i,(start_c + end_c)/2] = pillar;
                                 }
                                 for(int i=end_r-1-offset;i>(start_r + end_r)/2+1;i-=2){
                                     map[i,(start_c + end_c)/2] = pillar;
                                 }
                             }
                         }
                         else{
                             if(width % 2 == 1){
                                 for(int i=start_c+1;i<=end_c-1;i+=2){
                                     map[(start_r + end_r)/2,i] = pillar;
                                 }
                             }
                             else{
                                 int offset = 0;
                                 if(width % 4 == 0){
                                     offset = Roll(2) - 1;
                                 }
                                 for(int i=start_c+1+offset;i<(start_c + end_c)/2;i+=2){
                                     map[(start_r + end_r)/2,i] = pillar;
                                 }
                                 for(int i=end_c-1-offset;i>(start_c + end_c)/2+1;i-=2){
                                     map[(start_r + end_r)/2,i] = pillar;
                                 }
                             }
                         }
                         break;
                     }
                     case PillarArrangement.Corners:
                     {
                         int v_offset = 0;
                         int h_offset = 0;
                         if(height % 4 == 0){
                             v_offset = Roll(2) - 1;
                         }
                         if(width % 4 == 0){
                             h_offset = Roll(2) - 1;
                         }
                         map[start_r + 1 + v_offset,start_c + 1 + h_offset] = pillar;
                         map[start_r + 1 + v_offset,end_c - 1 - h_offset] = pillar;
                         map[end_r - 1 - v_offset,start_c + 1 + h_offset] = pillar;
                         map[end_r - 1 - v_offset,end_c - 1 - h_offset] = pillar;
                         break;
                     }
                     case PillarArrangement.Full:
                     {
                         int v_offset = 0;
                         int h_offset = 0;
                         if(height % 4 == 0){
                             v_offset = Roll(2) - 1;
                         }
                         if(width % 4 == 0){
                             h_offset = Roll(2) - 1;
                         }
                         int half_r = (start_r + end_r)/2;
                         int half_c = (start_c + end_c)/2;
                         int half_r_offset = (start_r + end_r + 1)/2;
                         int half_c_offset = (start_c + end_c + 1)/2;
                         for(int i=start_r+1+v_offset;i<half_r;i+=2){
                             for(int j=start_c+1+h_offset;j<half_c;j+=2){
                                 map[i,j] = pillar;
                             }
                         }
                         for(int i=start_r+1+v_offset;i<half_r;i+=2){
                             for(int j=end_c-1-h_offset;j>half_c_offset;j-=2){
                                 map[i,j] = pillar;
                             }
                         }
                         for(int i=end_r-1-v_offset;i>half_r_offset;i-=2){
                             for(int j=start_c+1+h_offset;j<half_c;j+=2){
                                 map[i,j] = pillar;
                             }
                         }
                         for(int i=end_r-1-v_offset;i>half_r_offset;i-=2){
                             for(int j=end_c-1-h_offset;j>half_c_offset;j-=2){
                                 map[i,j] = pillar;
                             }
                         }
                         if((width+1) % 4 == 0){
                             if(height % 2 == 1){
                                 for(int i=start_r+1;i<=end_r-1;i+=2){
                                     map[i,half_c] = pillar;
                                 }
                             }
                             else{
                                 int offset = 0;
                                 if(height % 4 == 0){
                                     offset = Roll(2) - 1;
                                 }
                                 for(int i=start_r+1+offset;i<half_r;i+=2){
                                     map[i,half_c] = pillar;
                                 }
                                 for(int i=end_r-1-offset;i>half_r_offset;i-=2){
                                     map[i,half_c] = pillar;
                                 }
                             }
                         }
                         if((height+1) % 4 == 0){
                             if(width % 2 == 1){
                                 for(int i=start_c+1;i<=end_c-1;i+=2){
                                     map[half_r,i] = pillar;
                                 }
                             }
                             else{
                                 int offset = 0;
                                 if(width % 4 == 0){
                                     offset = Roll(2) - 1;
                                 }
                                 for(int i=start_c+1+offset;i<half_c;i+=2){
                                     map[half_r,i] = pillar;
                                 }
                                 for(int i=end_c-1-offset;i>half_c_offset;i-=2){
                                     map[half_r,i] = pillar;
                                 }
                             }
                         }
                         break;
                     }
                     case PillarArrangement.StatueCorners:
                         map[start_r,start_c] = CellType.Statue;
                         map[start_r,end_c] = CellType.Statue;
                         map[end_r,start_c] = CellType.Statue;
                         map[end_r,end_c] = CellType.Statue;
                         break;
                     case PillarArrangement.StatueEdges:
                     {
                         map[start_r,start_c] = CellType.Statue;
                         map[start_r,end_c] = CellType.Statue;
                         map[end_r,start_c] = CellType.Statue;
                         map[end_r,end_c] = CellType.Statue;
                         if(width % 2 == 1 && width > 3){
                             int half_c = (start_c + end_c)/2;
                             int corridors = new pos(start_r,half_c).CardinalAdjacentPositions().Where(x => BoundsCheck(x) && map[x].IsCorridorType()).Count;
                             if(corridors == 0){
                                 map[start_r,half_c] = CellType.Statue;
                             }
                             corridors = new pos(end_r,half_c).CardinalAdjacentPositions().Where(x => BoundsCheck(x) && map[x].IsCorridorType()).Count;
                             if(corridors == 0){
                                 map[end_r,half_c] = CellType.Statue;
                             }
                         }
                         if(height % 2 == 1 && height > 3){
                             int half_r = (start_r + end_r)/2;
                             int corridors = new pos(half_r,start_c).CardinalAdjacentPositions().Where(x => BoundsCheck(x) && map[x].IsCorridorType()).Count;
                             if(corridors == 0){
                                 map[half_r,start_c] = CellType.Statue;
                             }
                             corridors = new pos(half_r,end_c).CardinalAdjacentPositions().Where(x => BoundsCheck(x) && map[x].IsCorridorType()).Count;
                             if(corridors == 0){
                                 map[half_r,end_c] = CellType.Statue;
                             }
                         }
                         break;
                     }
                     default:
                         break;
                     }
                 }
             }
         }
         return true;
     });
 }
Example #16
0
 public static void SetMapOffset(int x,int y)
 {
     int dx = x - map_offset.col;
     int dy = y - map_offset.row;
     map_offset = new pos(y,x);
     G.terrain.SetOffsetInPixels(map_offset.col + 7,map_offset.row + 40);
     G.undead.SetOffsetInPixels(map_offset.col + 11,map_offset.row - 21);
     G.living.SetOffsetInPixels(map_offset.col + 11,map_offset.row - 21);
     foreach(IMouseTarget t in dragged_objects){
         t.Move(dx,dy);
     }
 }
Example #17
0
 public static Tile GetTile(pos p)
 {
     return GetTile(p.row,p.col);
 }
Example #18
0
 public static Actor GetActor(pos p)
 {
     return GetActor(p.row,p.col);
 }
Example #19
0
 public void AlterRooms(int no_change_freq,int add_pillars_freq,int cross_room_freq,int cave_widen_freq,int cave_fill_freq)
 {
     List<int> modification = new List<int>();
     for(int i=0;i<no_change_freq;++i){
         modification.Add(0);
     }
     for(int i=0;i<add_pillars_freq;++i){
         modification.Add(1);
     }
     for(int i=0;i<cross_room_freq;++i){
         modification.Add(2);
     }
     for(int i=0;i<cave_widen_freq;++i){
         modification.Add(3);
     }
     for(int i=0;i<cave_fill_freq;++i){
         modification.Add(4);
     }
     if(modification.Count == 0){
         return;
     }
     ForEachRectangularRoom((start_r,start_c,end_r,end_c) => {
         int mod = modification.Random();
         switch(mod){
         case 0:
             return true;
         case 1:
         {
             int height = end_r - start_r + 1;
             int width = end_c - start_c + 1;
             if(height > 3 || width > 3){
                 List<PillarArrangement> layouts = new List<PillarArrangement>();
                 if(height % 2 == 1 && width % 2 == 1){
                     layouts.Add(PillarArrangement.Single);
                 }
                 if((height % 2 == 1 || width % 2 == 1) && height != 4 && width != 4){
                     layouts.Add(PillarArrangement.Row);
                 }
                 if(height >= 5 && width >= 5){
                     layouts.Add(PillarArrangement.Corners);
                 }
                 if(height > 2 && width > 2 && height != 4 && width != 4){
                     layouts.Add(PillarArrangement.Full);
                 }
                 if((width % 2 == 1 && width >= 5) || (height % 2 == 1 && height >= 5)){
                     layouts.Add(PillarArrangement.StatueEdges);
                 }
                 if(layouts.Count == 0 || CoinFlip()){ //otherwise they're too common
                     layouts.Add(PillarArrangement.StatueCorners);
                 }
                 if(layouts.Count > 0){
                     CellType pillar = CellType.Pillar;
                     switch(layouts.Random()){
                     case PillarArrangement.Single:
                         map[(start_r + end_r)/2,(start_c + end_c)/2] = pillar;
                         break;
                     case PillarArrangement.Row:
                     {
                         bool vertical;
                         if(width % 2 == 1 && height % 2 == 0){
                             vertical = true;
                         }
                         else{
                             if(height % 2 == 1 && width % 2 == 0){
                                 vertical = false;
                             }
                             else{
                                 vertical = CoinFlip();
                             }
                         }
                         if(vertical){
                             if(height % 2 == 1){
                                 for(int i=start_r+1;i<=end_r-1;i+=2){
                                     map[i,(start_c + end_c)/2] = pillar;
                                 }
                             }
                             else{
                                 int offset = 0;
                                 if(height % 4 == 0){
                                     offset = Roll(2) - 1;
                                 }
                                 for(int i=start_r+1+offset;i<(start_r + end_r)/2;i+=2){
                                     map[i,(start_c + end_c)/2] = pillar;
                                 }
                                 for(int i=end_r-1-offset;i>(start_r + end_r)/2+1;i-=2){
                                     map[i,(start_c + end_c)/2] = pillar;
                                 }
                             }
                         }
                         else{
                             if(width % 2 == 1){
                                 for(int i=start_c+1;i<=end_c-1;i+=2){
                                     map[(start_r + end_r)/2,i] = pillar;
                                 }
                             }
                             else{
                                 int offset = 0;
                                 if(width % 4 == 0){
                                     offset = Roll(2) - 1;
                                 }
                                 for(int i=start_c+1+offset;i<(start_c + end_c)/2;i+=2){
                                     map[(start_r + end_r)/2,i] = pillar;
                                 }
                                 for(int i=end_c-1-offset;i>(start_c + end_c)/2+1;i-=2){
                                     map[(start_r + end_r)/2,i] = pillar;
                                 }
                             }
                         }
                         break;
                     }
                     case PillarArrangement.Corners:
                     {
                         int v_offset = 0;
                         int h_offset = 0;
                         if(height % 4 == 0){
                             v_offset = Roll(2) - 1;
                         }
                         if(width % 4 == 0){
                             h_offset = Roll(2) - 1;
                         }
                         map[start_r + 1 + v_offset,start_c + 1 + h_offset] = pillar;
                         map[start_r + 1 + v_offset,end_c - 1 - h_offset] = pillar;
                         map[end_r - 1 - v_offset,start_c + 1 + h_offset] = pillar;
                         map[end_r - 1 - v_offset,end_c - 1 - h_offset] = pillar;
                         break;
                     }
                     case PillarArrangement.Full:
                     {
                         int v_offset = 0;
                         int h_offset = 0;
                         if(height % 4 == 0){
                             v_offset = Roll(2) - 1;
                         }
                         if(width % 4 == 0){
                             h_offset = Roll(2) - 1;
                         }
                         int half_r = (start_r + end_r)/2;
                         int half_c = (start_c + end_c)/2;
                         int half_r_offset = (start_r + end_r + 1)/2;
                         int half_c_offset = (start_c + end_c + 1)/2;
                         for(int i=start_r+1+v_offset;i<half_r;i+=2){
                             for(int j=start_c+1+h_offset;j<half_c;j+=2){
                                 map[i,j] = pillar;
                             }
                         }
                         for(int i=start_r+1+v_offset;i<half_r;i+=2){
                             for(int j=end_c-1-h_offset;j>half_c_offset;j-=2){
                                 map[i,j] = pillar;
                             }
                         }
                         for(int i=end_r-1-v_offset;i>half_r_offset;i-=2){
                             for(int j=start_c+1+h_offset;j<half_c;j+=2){
                                 map[i,j] = pillar;
                             }
                         }
                         for(int i=end_r-1-v_offset;i>half_r_offset;i-=2){
                             for(int j=end_c-1-h_offset;j>half_c_offset;j-=2){
                                 map[i,j] = pillar;
                             }
                         }
                         if((width+1) % 4 == 0){
                             if(height % 2 == 1){
                                 for(int i=start_r+1;i<=end_r-1;i+=2){
                                     map[i,half_c] = pillar;
                                 }
                             }
                             else{
                                 int offset = 0;
                                 if(height % 4 == 0){
                                     offset = Roll(2) - 1;
                                 }
                                 for(int i=start_r+1+offset;i<half_r;i+=2){
                                     map[i,half_c] = pillar;
                                 }
                                 for(int i=end_r-1-offset;i>half_r_offset;i-=2){
                                     map[i,half_c] = pillar;
                                 }
                             }
                         }
                         if((height+1) % 4 == 0){
                             if(width % 2 == 1){
                                 for(int i=start_c+1;i<=end_c-1;i+=2){
                                     map[half_r,i] = pillar;
                                 }
                             }
                             else{
                                 int offset = 0;
                                 if(width % 4 == 0){
                                     offset = Roll(2) - 1;
                                 }
                                 for(int i=start_c+1+offset;i<half_c;i+=2){
                                     map[half_r,i] = pillar;
                                 }
                                 for(int i=end_c-1-offset;i>half_c_offset;i-=2){
                                     map[half_r,i] = pillar;
                                 }
                             }
                         }
                         break;
                     }
                     case PillarArrangement.StatueCorners:
                         map[start_r,start_c] = CellType.Statue;
                         map[start_r,end_c] = CellType.Statue;
                         map[end_r,start_c] = CellType.Statue;
                         map[end_r,end_c] = CellType.Statue;
                         break;
                     case PillarArrangement.StatueEdges:
                     {
                         map[start_r,start_c] = CellType.Statue;
                         map[start_r,end_c] = CellType.Statue;
                         map[end_r,start_c] = CellType.Statue;
                         map[end_r,end_c] = CellType.Statue;
                         if(width % 2 == 1 && width > 3){
                             int half_c = (start_c + end_c)/2;
                             int corridors = new pos(start_r,half_c).CardinalAdjacentPositions().Where(x => BoundsCheck(x) && map[x].IsCorridorType()).Count;
                             if(corridors == 0){
                                 map[start_r,half_c] = CellType.Statue;
                             }
                             corridors = new pos(end_r,half_c).CardinalAdjacentPositions().Where(x => BoundsCheck(x) && map[x].IsCorridorType()).Count;
                             if(corridors == 0){
                                 map[end_r,half_c] = CellType.Statue;
                             }
                         }
                         if(height % 2 == 1 && height > 3){
                             int half_r = (start_r + end_r)/2;
                             int corridors = new pos(half_r,start_c).CardinalAdjacentPositions().Where(x => BoundsCheck(x) && map[x].IsCorridorType()).Count;
                             if(corridors == 0){
                                 map[half_r,start_c] = CellType.Statue;
                             }
                             corridors = new pos(half_r,end_c).CardinalAdjacentPositions().Where(x => BoundsCheck(x) && map[x].IsCorridorType()).Count;
                             if(corridors == 0){
                                 map[half_r,end_c] = CellType.Statue;
                             }
                         }
                         break;
                     }
                     default:
                         break;
                     }
                 }
             }
             return true;
         }
         case 2:
         {
             int height = end_r - start_r + 1;
             int width = end_c - start_c + 1;
             if(height < 4 || width < 4){ //nothing happens until we get above 4x4
                 return true;
             }
             int rows_to_convert = Roll((height/2)-1);
             int cols_to_convert = Roll((width/2)-1);
             if(rows_to_convert == 1 && cols_to_convert == 1){
                 return true;
             }
             List<pos> blocked = new List<pos>();
             for(int i=start_r;i<=end_r;++i){
                 for(int j=start_c;j<=end_c;++j){
                     if((i < start_r + rows_to_convert || i > end_r - rows_to_convert) && (j < start_c + cols_to_convert || j > end_c - cols_to_convert)){
                         pos p = new pos(i,j);
                         foreach(pos neighbor in p.CardinalAdjacentPositions()){
                             if(map[neighbor].IsCorridorType()){
                                 blocked.Add(p);
                             }
                         }
                         map[i,j] = CellType.Wall;
                     }
                 }
             }
             blocked.Randomize();
             foreach(pos p in blocked){
                 bool done = false;
                 foreach(pos neighbor in p.CardinalAdjacentPositions()){
                     if(map[neighbor].IsRoomType()){
                         map[p] = CellType.RoomInterior;
                         done = true;
                         break;
                     }
                 }
                 if(!done){
                     List<int> valid_dirs = new List<int>();
                     foreach(int dir in U.FourDirections){
                         pos next = p.PosInDir(dir);
                         while(next.row >= start_r && next.row <= end_r && next.col >= start_c && next.col <= end_c){
                             if(next.CardinalAdjacentPositions().Any(x=>map[x].IsRoomType())){
                                 valid_dirs.Add(dir);
                                 break;
                             }
                             next = next.PosInDir(dir);
                         }
                     }
                     int valid_dir = valid_dirs.RandomOrDefault();
                     pos next2 = p.PosInDir(valid_dir);
                     List<pos> new_corridor = new List<pos>{p};
                     while(true){
                         new_corridor.Add(next2);
                         if(next2.CardinalAdjacentPositions().Any(x=>map[x].IsRoomType())){
                             break;
                         }
                         next2 = next2.PosInDir(valid_dir);
                     }
                     foreach(pos p2 in new_corridor){
                         map[p2] = CellType.RoomInterior;
                     }
                 }
             }
             return true;
         }
         case 3:
         {
             List<pos> list = map.PositionsWhere(x=>x.row >= start_r && x.row <= end_r && x.col >= start_c && x.col <= end_c);
             PosArray<CellType> old_map = new PosArray<CellType>(H,W);
             foreach(pos p in list){
                 old_map[p] = map[p];
                 map[p] = CellType.Wall;
             }
             PosArray<bool> rock = new PosArray<bool>(H,W);
             for(int i=0;i<H;++i){
                 for(int j=0;j<W;++j){
                     pos p = new pos(i,j);
                     rock[p] = true;
                     if(BoundsCheck(i,j,false)){
                         foreach(pos neighbor in p.AdjacentPositionsClockwise()){
                             if(map[neighbor] != CellType.Wall){
                                 rock[p] = false;
                                 break;
                             }
                         }
                     }
                 }
             }
             foreach(pos p in list){
                 map[p] = CellType.RoomInterior; //todo: might this step be extraneous?
             }
             List<pos> frontier = new List<pos>();
             {
                 PosArray<bool> in_list = new PosArray<bool>(H,W);
                 foreach(pos p in list){
                     in_list[p] = true;
                 }
                 for(int i=0;i<H;++i){
                     for(int j=0;j<W;++j){
                         pos p = new pos(i,j);
                         if(in_list[p]){
                             foreach(pos neighbor in p.PositionsAtDistance(1,in_list)){
                                 if(!in_list[neighbor]){
                                     frontier.Add(p);
                                     break;
                                 }
                             }
                         }
                     }
                 }
             }
             int fail_counter = 0;
             int num_added = 0;
             bool finished = false;
             while(!finished){
                 if(frontier.Count == 0 || num_added >= 30){ //todo check this value
                     finished = true;
                     break;
                 }
                 pos f = frontier.RemoveRandom();
                 foreach(pos neighbor in f.CardinalAdjacentPositions()){
                     if(!BoundsCheck(neighbor,false) || !rock[neighbor.row,neighbor.col]){
                         ++fail_counter; //this might now be unreachable
                         if(!BoundsCheck(neighbor,false)){
                             fail_counter += 25; //fail quicker when against the edge of the map to prevent ugliness
                         } //however, this doesn't actually fail as quickly as it should - i've overlooked something.
                         if(fail_counter >= 50){
                             finished = true;
                             break;
                         }
                     }
                     else{
                         if(map[neighbor] != CellType.RoomInterior){
                             map[neighbor] = CellType.RoomInterior;
                             ++num_added;
                             bool add_neighbor = true;
                             foreach(pos n2 in neighbor.CardinalAdjacentPositions()){
                                 if(!BoundsCheck(n2,false) || !rock[n2.row,n2.col]){
                                     add_neighbor = false;
                                     ++fail_counter; //this might now be unreachable
                                     if(!BoundsCheck(neighbor,false)){
                                         fail_counter += 25; //fail quicker when against the edge of the map to prevent ugliness
                                     } //however, this doesn't actually fail as quickly as it should - i've overlooked something.
                                     if(fail_counter >= 50){
                                         finished = true;
                                     }
                                     break;
                                 }
                             }
                             if(finished){
                                 break;
                             }
                             if(add_neighbor){
                                 frontier.Add(neighbor);
                             }
                         }
                     }
                 }
             }
             foreach(pos p in list){
                 map[p] = old_map[p];
             }
             return true;
         }
         case 4:
         {
             List<pos> list = map.PositionsWhere(x=>x.row >= start_r && x.row <= end_r && x.col >= start_c && x.col <= end_c);
             Dungeon room = new Dungeon((end_r - start_r) + 3,(end_c - start_c) + 3); //includes borders
             List<pos> map_exits = list.Where(x=>x.CardinalAdjacentPositions().Any(y=>map[y].IsCorridorType())); //grab the positions from list that have any adjacent corridor-type cells
             if(map_exits.Count < 2){
                 return true;
             }
             List<pos> room_exits = new List<pos>();
             foreach(pos exit in map_exits){
                 room_exits.Add(new pos(exit.row-start_r+1,exit.col-start_c+1));
             }
             int tries = 0;
             while(true){
                 room.FillWithRandomWalls(25);
                 room.ApplyCellularAutomataXYRule(3);
                 room.ConnectDiagonals();
                 room.RemoveDeadEndCorridors();
                 room.RemoveUnconnectedAreas();
                 bool exits_open = true;
                 foreach(pos p in room_exits){
                     if(!room[p].IsPassable()){
                         exits_open = false;
                     }
                 }
                 if(exits_open){
                     for(int i=start_r;i<=end_r;++i){
                         for(int j=start_c;j<=end_c;++j){
                             if(list.Contains(new pos(i,j))){
                                 map[i,j] = room[(i-start_r)+1,(j-start_c)+1];
                             }
                         }
                     }
                     break;
                 }
                 ++tries;
                 if(tries > 50){
                     return false;
                 }
             }
             return true;
         }
         default:
             break;
         }
         return true;
     });
 }
Example #20
0
 public bool AddRockFormations(int percent_chance_per_room,int minimum_distance_from_wall)
 {
     return ForEachRoom(list => {
         if(PercentChance(percent_chance_per_room)){
             int start_r = list.WhereLeast(x=>x.row)[0].row;
             int end_r = list.WhereGreatest(x=>x.row)[0].row;
             int start_c = list.WhereLeast(x=>x.col)[0].col;
             int end_c = list.WhereGreatest(x=>x.col)[0].col;
             Dungeon room = new Dungeon((end_r - start_r) + 3,(end_c - start_c) + 3); //includes borders
             while(true){
                 room.FillWithRandomWalls(25);
                 room.ApplyCellularAutomataXYRule(3);
                 for(int i=start_r;i<=end_r;++i){
                     for(int j=start_c;j<=end_c;++j){
                         pos p = new pos(i,j);
                         if(!p.PositionsWithinDistance(minimum_distance_from_wall-1,room.map).All(x=>list.Contains(x))){ //todo: I probably broke this.
                             room[i-start_r+1,j-start_c+1] = CellType.RoomInterior;
                         }
                     }
                 }
                 room.ConnectDiagonals();
                 room.RemoveDeadEndCorridors();
                 room.RemoveUnconnectedAreas();
                 for(int i=start_r;i<=end_r;++i){
                     for(int j=start_c;j<=end_c;++j){
                         if(list.Contains(new pos(i,j))){
                             map[i,j] = room[(i-start_r)+1,(j-start_c)+1];
                         }
                     }
                 }
                 break;
             }
         }
         return true;
     });
 }
 public int DistanceFrom(pos p)
 {
     return DistanceFrom(p.row,p.col);
 }
Example #22
0
 public static bool BoundsCheck(pos p,bool disallow_map_edges = false)
 {
     return BoundsCheck(p.row,p.col,disallow_map_edges);
 }
		public static void AnimateStorm(pos origin,int radius,int num_frames,int num_per_frame,string c,Color color){
			AnimateStorm(origin,radius,num_frames,num_per_frame,new colorchar(c,color));
		}
Example #24
0
 public static void ChangeMapOffset(int dx,int dy)
 {
     map_offset = new pos(map_offset.row + dy,map_offset.col + dx);
     G.terrain.SetOffsetInPixels(map_offset.col + 7,map_offset.row + 40);
     G.undead.SetOffsetInPixels(map_offset.col + 11,map_offset.row - 21);
     G.living.SetOffsetInPixels(map_offset.col + 11,map_offset.row - 21);
     foreach(IMouseTarget t in dragged_objects){
         t.Move(dx,dy);
     }
 }
 void MouseMoveHandler(object sender,MouseMoveEventArgs args)
 {
     if(MouseUI.IgnoreMouseMovement){
         return;
     }
     int row;
     int col;
     if(FullScreen){
         row = (int)(args.Y - ClientRectangle.Height * ((1.0f - screen_multiplier_h)*0.5f)) / cell_h; //todo: give this its own var?
         col = (int)(args.X - ClientRectangle.Width * ((1.0f - screen_multiplier_w)*0.5f)) / cell_w;
     }
     else{
         row = args.Y / cell_h;
         col = args.X / cell_w;
     }
     switch(MouseUI.Mode){
     case MouseMode.Targeting:
     {
         int map_row = row - Global.MAP_OFFSET_ROWS;
         int map_col = col - Global.MAP_OFFSET_COLS;
         Button b = MouseUI.GetButton(row,col);
         if(MouseUI.Highlighted != null && MouseUI.Highlighted != b){
             MouseUI.RemoveHighlight();
         }
         if(args.XDelta == 0 && args.YDelta == 0){
             return; //don't re-highlight immediately after a click
         }
         if(b != null){
             if(b != MouseUI.Highlighted){
                 MouseUI.Highlighted = b;
                 colorchar[,] array = new colorchar[b.height,b.width];
                 for(int i=0;i<b.height;++i){
                     for(int j=0;j<b.width;++j){
                         array[i,j] = Screen.Char(i + b.row,j + b.col);
                         array[i,j].bgcolor = Color.Blue;
                     }
                 }
                 Screen.UpdateGLBuffer(b.row,b.col,array);
             }
         }
         else{
             if(!Input.KeyPressed){
                 if(!MouseUI.mouselook_objects.BoundsCheck(row,col)){
                     //UI.MapCursor = new pos(-1,-1);
                     Input.KeyPressed = true;
                     ConsoleKey key = ConsoleKey.F22;
                     Input.LastKey = new ConsoleKeyInfo(Input.GetChar(key,false),key,false,false,false);
                 }
                 else{
                     if(map_row >= 0 && map_row < Global.ROWS && map_col >= 0 && map_col < Global.COLS){
                         if(map_row != UI.MapCursor.row || map_col != UI.MapCursor.col){
                             UI.MapCursor = new pos(map_row,map_col);
                             Input.KeyPressed = true;
                             ConsoleKey key = ConsoleKey.F21;
                             Input.LastKey = new ConsoleKeyInfo(Input.GetChar(key,false),key,false,false,false);
                         }
                     }
                     else{
                         PhysicalObject o = MouseUI.mouselook_objects[row,col];
                         if(o != null){
                             if(!o.p.Equals(UI.MapCursor)){
                                 UI.SetMapCursor(o.p,map_col < 0);
                                 Input.KeyPressed = true;
                                 ConsoleKey key = ConsoleKey.F21;
                                 Input.LastKey = new ConsoleKeyInfo(Input.GetChar(key,false),key,false,false,false);
                             }
                         }
                         else{ // off the map, and not hovering over a status bar object
                             if(map_row != UI.MapCursor.row || map_col != UI.MapCursor.col){
                                 //UI.MapCursor = new pos(map_row,map_col);
                                 Input.KeyPressed = true;
                                 ConsoleKey key = ConsoleKey.F22;
                                 Input.LastKey = new ConsoleKeyInfo(Input.GetChar(key,false),key,false,false,false);
                             }
                         }
                     }
                 }
             }
             /*if(!Input.KeyPressed && (map_row != UI.MapCursor.row || map_col != UI.MapCursor.col) && !KeyIsDown(Key.LControl) && !KeyIsDown(Key.RControl)){
                 UI.MapCursor = new pos(map_row,map_col);
                 Input.KeyPressed = true;
                 if(map_row >= 0 && map_row < Global.ROWS && map_col >= 0 && map_col < Global.COLS){
                     ConsoleKey key = ConsoleKey.F21;
                     Input.LastKey = new ConsoleKeyInfo(Input.GetChar(key,false),key,false,false,false);
                 }
                 else{
                     ConsoleKey key = ConsoleKey.F22;
                     Input.LastKey = new ConsoleKeyInfo(Input.GetChar(key,false),key,false,false,false);
                 }
             }*/
         }
         break;
     }
     case MouseMode.Directional:
     {
         int map_row = row - Global.MAP_OFFSET_ROWS;
         int map_col = col - Global.MAP_OFFSET_COLS;
         if(map_row >= 0 && map_row < Global.ROWS && map_col >= 0 && map_col < Global.COLS){
             int dir = Actor.player.DirectionOf(new pos(map_row,map_col));
             pos p = Actor.player.p.PosInDir(dir);
             Button dir_b = MouseUI.GetButton(Global.MAP_OFFSET_ROWS + p.row,Global.MAP_OFFSET_COLS + p.col);
             if(MouseUI.Highlighted != null && MouseUI.Highlighted != dir_b){
                 MouseUI.RemoveHighlight();
             }
             if(dir_b != null && dir_b != MouseUI.Highlighted){
                 MouseUI.Highlighted = dir_b;
                 colorchar[,] array = new colorchar[1,1];
                 array[0,0] = Screen.Char(Global.MAP_OFFSET_ROWS + p.row,Global.MAP_OFFSET_COLS + p.col);
                 array[0,0].bgcolor = Color.Blue;
                 Screen.UpdateGLBuffer(dir_b.row,dir_b.col,array);
             }
         }
         else{
             if(MouseUI.Highlighted != null){
                 MouseUI.RemoveHighlight();
             }
         }
         break;
     }
     default:
     {
         Button b = MouseUI.GetButton(row,col);
         if(MouseUI.Highlighted != null && MouseUI.Highlighted != b){
             MouseUI.RemoveHighlight();
         }
         if(args.XDelta == 0 && args.YDelta == 0){
             return; //don't re-highlight immediately after a click
         }
         if(b != null && b != MouseUI.Highlighted){
             MouseUI.Highlighted = b;
             colorchar[,] array = new colorchar[b.height,b.width];
             for(int i=0;i<b.height;++i){
                 for(int j=0;j<b.width;++j){
                     array[i,j] = Screen.Char(i + b.row,j + b.col);
                     array[i,j].bgcolor = Color.Blue;
                 }
             }
             Screen.UpdateGLBuffer(b.row,b.col,array);
         }
         else{
             if(MouseUI.Mode == MouseMode.Map){
                 if(!MouseUI.mouselook_objects.BoundsCheck(row,col)){
                     UI.MapCursor = new pos(-1,-1);
                     break;
                 }
                 PhysicalObject o = MouseUI.mouselook_objects[row,col];
                 int map_row = row - Global.MAP_OFFSET_ROWS;
                 int map_col = col - Global.MAP_OFFSET_COLS;
                 if(MouseUI.VisiblePath && o == null){
                     if(map_row >= 0 && map_row < Global.ROWS && map_col >= 0 && map_col < Global.COLS){
                         o = Actor.M.tile[map_row,map_col];
                     }
                 }
                 if(MouseUI.mouselook_current_target != null && (o == null || !o.p.Equals(MouseUI.mouselook_current_target.p))){
                     MouseUI.RemoveMouseover();
                 }
                 if(o == null){
                     UI.MapCursor = new pos(-1,-1);
                 }
                 else{
                     if(MouseUI.mouselook_current_target == null || !o.p.Equals(MouseUI.mouselook_current_target.p)){
                         UI.SetMapCursor(o.p,map_col < 0);
                         MouseUI.mouselook_current_target = o;
                         bool description_on_right = false;
                         int max_length = MouseUI.MaxDescriptionBoxLength;
                         if(o.col <= 32){
                             description_on_right = true;
                         }
                         List<colorstring> desc_box = null;
                         Actor a = o as Actor;
                         if(a != null){
                             desc_box = Actor.MonsterDescriptionBox(a,true,max_length);
                         }
                         else{
                             Item i = o as Item;
                             if(i != null){
                                 desc_box = UI.ItemDescriptionBox(i,true,true,max_length);
                             }
                         }
                         if(desc_box != null){
                             int h = desc_box.Count;
                             int w = desc_box[0].Length();
                             MouseUI.mouselook_current_desc_area = new System.Drawing.Rectangle(description_on_right? Global.COLS - w : 0,0,w,h);
                             int player_r = Actor.player.row;
                             int player_c = Actor.player.col;
                             colorchar[,] array = new colorchar[h,w];
                             if(description_on_right){
                                 for(int i=0;i<h;++i){
                                     for(int j=0;j<w;++j){
                                         array[i,j] = desc_box[i][j];
                                         if(i == player_r && j + Global.COLS - w == player_c){
                                             Screen.CursorVisible = false;
                                             player_r = -1; //to prevent further attempts to set CV to false
                                         }
                                     }
                                 }
                                 Screen.UpdateGLBuffer(Global.MAP_OFFSET_ROWS,Global.MAP_OFFSET_COLS + Global.COLS - w,array);
                             }
                             else{
                                 for(int i=0;i<h;++i){
                                     for(int j=0;j<w;++j){
                                         array[i,j] = desc_box[i][j];
                                         if(i == player_r && j == player_c){
                                             Screen.CursorVisible = false;
                                             player_r = -1;
                                         }
                                     }
                                 }
                                 Screen.UpdateGLBuffer(Global.MAP_OFFSET_ROWS,Global.MAP_OFFSET_COLS,array);
                             }
                         }
                         if(MouseUI.VisiblePath){
                             if(o != Actor.player && o.p.Equals(Actor.player.p)){
                                 MouseUI.mouse_path = new List<pos>{o.p};
                             }
                             else{
                                 MouseUI.mouse_path = Actor.player.GetPlayerTravelPath(o.p);
                                 if(MouseUI.mouse_path.Count == 0){
                                     foreach(Tile t in Actor.M.TilesByDistance(o.row,o.col,true,true)){
                                         if(t.passable){
                                             MouseUI.mouse_path = Actor.player.GetPlayerTravelPath(t.p);
                                             break;
                                         }
                                     }
                                 }
                             }
                             pos box_start = new pos(0,0);
                             int box_h = -1;
                             int box_w = -1;
                             if(desc_box != null){
                                 box_h = desc_box.Count;
                                 box_w = desc_box[0].Length();
                                 if(description_on_right){
                                     box_start = new pos(0,Global.COLS - box_w);
                                 }
                             }
                             foreach(pos p in MouseUI.mouse_path){
                                 if(desc_box != null && p.row < box_start.row + box_h && p.row >= box_start.row && p.col < box_start.col + box_w && p.col >= box_start.col){
                                     continue;
                                 }
                                 colorchar cch = Screen.MapChar(p.row,p.col);
                                 cch.bgcolor = Color.DarkGreen;
                                 if(cch.color == Color.DarkGreen){
                                     cch.color = Color.Black;
                                 }
                                 //Game.gl.UpdateVertexArray(p.row+Global.MAP_OFFSET_ROWS,p.col+Global.MAP_OFFSET_COLS,text_surface,0,(int)cch.c);
                                 Game.gl.UpdateVertexArray(p.row+Global.MAP_OFFSET_ROWS,p.col+Global.MAP_OFFSET_COLS,text_surface,0,(int)cch.c,cch.color.GetFloatValues(),cch.bgcolor.GetFloatValues());
                             }
                             if(MouseUI.mouse_path != null && MouseUI.mouse_path.Count == 0){
                                 MouseUI.mouse_path = null;
                             }
                         }
                     }
                 }
             }
         }
         break;
     }
     }
 }
Example #26
0
        // line = 151, colunm = 110
        public void AnimeSPrite(ref KeyboardState keyboard)
        {
            if (vie > 0)
            {
                if (keyboard.IsKeyDown(Keys.Left)) //court vers la gauche
                {
                    this.Effects = SpriteEffects.FlipHorizontally;
                    dir = true;
                    if (!in_air)
                    {
                        current = walk;
                    }
                    else
                        if (keyboard.IsKeyUp(Keys.Space)) //phase descendante
                        {
                            current = fall;
                        }
                        else                              //phase ascendante
                        {
                            current = jump;
                        }
                }
                else if (keyboard.IsKeyDown(Keys.Right)) //court vers la droite
                {
                    dir = false;
                    this.Effects = SpriteEffects.None;
                    if (!in_air)
                    {
                        current = walk;
                    }
                    else
                        if (keyboard.IsKeyUp(Keys.Space)) //phase descendante
                        {
                            current = fall;
                        }
                        else                              //phase ascendante
                        {
                            current = jump;
                        }
                }
                else if (keyboard.IsKeyDown(Keys.X)) //attaque
                {
                    current = atk;
                }
                else if (keyboard.IsKeyUp(Keys.Space) && chute ^ jump_off) //saut phase descendante
                {
                    current = fall;
                }
                else
                    if (!in_air)
                    {
                        current = walk;
                    }
                    else
                        if (keyboard.IsKeyUp(Keys.Space)) //phase descendante
                        {
                            current = fall;
                        }
                        else                              //phase ascendante
                        {
                            current = jump;
                        }

                if ((keyboard.IsKeyUp(Keys.Left) && keyboard.IsKeyUp(Keys.Right) && keyboard.IsKeyUp(Keys.X) && !in_air) ||
                (keyboard.IsKeyDown(Keys.Left) && keyboard.IsKeyDown(Keys.Right))) //cas ou aucune touche n est appuyée ou touche gauche et droite ensemble : ne fais rien
                {
                    current = idle;
                }
                if (current.lstart != last.lstart || current.cstart != last.cstart || current.cend != last.cend)
                {
                    FrameColumn = current.cstart;
                    FrameLine = current.lstart;
                }
                Animated();
            }
            else
            {
                if (timer_dead == 199)
                {
                    FrameColumn = die.cstart;
                    FrameLine = die.lstart ;
                }
                if (FrameColumn != die.cend  && this.Timer == this.AnimationSpeed)
                {
                    this.Timer = 0;
                    this.FrameColumn++;
                }
                this.Timer++;
            }
            last = current;
        }
Example #27
0
 public void CheckForSpriteUpdate()
 {
     //makes walls face the right way, for instance.
     switch(type){
     case TileType.WALL:
     case TileType.HIDDEN_DOOR:
         if(row < ROWS-1 && M.tile[row+1,col].seen && !M.tile[row+1,col].IsVisuallyWall()){
             sprite_offset = new pos(2,0);
         }
         else{
             bool side_wall = false;
             if(col > 0){
                 if(row < ROWS-1 && M.tile[row+1,col-1].seen && !M.tile[row+1,col-1].IsVisuallyWall()){
                     side_wall = true;
                 }
                 if(!side_wall && M.tile[row,col-1].seen && !M.tile[row,col-1].IsVisuallyWall()){
                     side_wall = true;
                 }
             }
             if(!side_wall && col < COLS-1){
                 if(row < ROWS-1 && M.tile[row+1,col+1].seen && !M.tile[row+1,col+1].IsVisuallyWall()){
                     side_wall = true;
                 }
                 if(!side_wall && M.tile[row,col+1].seen && !M.tile[row,col+1].IsVisuallyWall()){
                     side_wall = true;
                 }
             }
             if(side_wall){
                 sprite_offset = new pos(1,0);
             }
             else{
                 sprite_offset = new pos(0,0);
             }
         }
         break;
     case TileType.CRACKED_WALL:
         if(row < ROWS-1 && M.tile[row+1,col].seen && !M.tile[row+1,col].IsVisuallyWall()){
             sprite_offset = new pos(2,1);
         }
         else{
             bool side_wall = false;
             if(col > 0){
                 if(row < ROWS-1 && M.tile[row+1,col-1].seen && !M.tile[row+1,col-1].IsVisuallyWall()){
                     side_wall = true;
                 }
                 if(!side_wall && M.tile[row,col-1].seen && !M.tile[row,col-1].IsVisuallyWall()){
                     side_wall = true;
                 }
             }
             if(!side_wall && col < COLS-1){
                 if(row < ROWS-1 && M.tile[row+1,col+1].seen && !M.tile[row+1,col+1].IsVisuallyWall()){
                     side_wall = true;
                 }
                 if(!side_wall && M.tile[row,col+1].seen && !M.tile[row,col+1].IsVisuallyWall()){
                     side_wall = true;
                 }
             }
             if(side_wall){
                 sprite_offset = new pos(1,1);
             }
             else{
                 sprite_offset = new pos(0,1);
             }
         }
         break;
     case TileType.DOOR_C:
         if(!M.tile[row+1,col].passable || !M.tile[row-1,col].passable){
             sprite_offset = new pos(10,0);
         }
         else{
             sprite_offset = new pos(10,1);
         }
         break;
     case TileType.DOOR_O:
         if(!M.tile[row+1,col].passable || !M.tile[row-1,col].passable){
             sprite_offset = new pos(10,2);
         }
         else{
             sprite_offset = new pos(10,3);
         }
         break;
     }
 }
Example #28
0
        public sprite_broillon(Texture2D n_textture, Rectangle n_rectangle, Collision n_collision, ContentManager Content, char type)
        {
            test = Content.Load<Texture2D>("ListBoxBG");
            texture = n_textture;
            rectangle_C = new Rectangle(n_rectangle.X + 49, n_rectangle.Y + 4, 30, n_rectangle.Height);
            rectangle = n_rectangle;
            poid = 10;
            in_air = false;
            jump_off = false;
            collision = n_collision;
            impulse = 150;
            pos_marche = rectangle.Y;
            marchell = Content.Load<Song>("hero//jogging");
            MediaPlayer.Play(marchell);

            this.FrameLine = 1;
            this.FrameColumn = 1;
            this.Timer = 0;
            vie = 100;

            upsidedown = 10;
            atq = false;
            longattaque = 17;
            dead = false;
            timer_dead = 200;

            if (type == '2')
            {
                colunm = 151;
                line = 110;
                largeurX = 22;
                hauteurY = 40;
                decallageX = 50;
                decallageY = 34;
                idle = new pos(1, 1, 4);
                walk = new pos(1, 5, 10);
                atk = new pos(9, 5, 10);
                die = new pos(3, 5, 9);
                jump = new pos(2, 8, 8);
                fall = new pos(2, 9, 9);

            }
            else
            {
                colunm = 125;
                line = 93;
                largeurX = 17;
                hauteurY = 50;
                decallageX = 55;
                decallageY = 31;
                idle = new pos(1, 1, 3);
                walk = new pos(2, 1, 3);
                atk = new pos(8, 1, 3);
                die = new pos(6, 1, 5);
                jump = new pos(3, 1, 2);
                fall = new pos(5, 1, 3);
            }
            current = fall;
            last = current;
        }
 public colorchar this[pos p]
 {
     get{
         return memory[p];
     }
     set{
         if(!memory[p].Equals(value)){
             memory[p] = value;
             if(!NoUpdate){
                 UpdateSurface(p.col + p.row * memory.objs.GetLength(1)); //todo: can UpdateSurface get a 2d version?
             }
         }
     }
 }
Example #30
0
 public static void PlaceUnitsByInitiative(List<Actor> units,int corner)
 {
     List<Actor> ordered_units = new List<Actor>(units);
     ordered_units.Sort((f1,f2) => {
         int init_order = f1.initiative.CompareTo(f2.initiative);
         if(init_order == 0){
             return units.IndexOf(f1).CompareTo(units.IndexOf(f2)); //lower index in 'units', lower index in this list.
         }
         return -init_order; //lower initiative, higher index in this list.
     });
     int placement_n = 0;
     int p_row = 0;
     while(ordered_units.Count > 0){
         Actor ac = ordered_units.RemoveLast();
         pos p = new pos(p_row,placement_n - p_row).Rotate(corner);
         M.actor[p] = ac;
         ac.p = p;
         ++p_row;
         if(p_row > placement_n){
             ++placement_n;
             p_row = 0;
         }
     }
 }