瀏覽代碼

Damages happening

volt 1 年之前
父節點
當前提交
d34f91cd6b

+ 9 - 4
objects/obj_card/Create_0.gml

@@ -8,7 +8,7 @@ enum CARDSTATE
     TEST
 }
 
-state = STATE.INIT;
+state = CARDSTATE.INIT;
 
 colselec1 = $FF9944; // Orange
 colselec2 = $FF3310; // Red
@@ -21,9 +21,14 @@ height = 200;
 
 selected = false;
 
+// old
 name = "noname";
 desc = "none";
 
-dmg_min = 1;
-dmg_max = 3;
-dmg = 0;
+// Define card Stats
+card_stats = {
+	name : "Attack 1",
+	desc : "Basic attack",
+	dmg_nrml_min : 1,
+	dmg_nrml_max : 3
+};

+ 3 - 3
objects/obj_card/Draw_64.gml

@@ -23,7 +23,7 @@ else
 draw_set_alpha(1);
 draw_set_color(c_black);
 draw_set_halign(fa_center);
-draw_text(x+width_mid, y, name);
-var _dmg_txt = string("{0}-{1}", dmg_min, dmg_max)
+draw_text(x+width_mid, y, card_stats.name);
+var _dmg_txt = string("{0}-{1}", card_stats.dmg_nrml_min, card_stats.dmg_nrml_max);
 draw_text(x+width_mid, y+20, _dmg_txt);
-draw_text(x+width_mid, y+40, desc);
+draw_text(x+width_mid, y+40, card_stats.desc);

+ 1 - 3
objects/obj_card/Step_0.gml

@@ -12,9 +12,7 @@ switch(state)
 	break;
 	
 	case CARDSTATE.ACTIVATED:
-		dmg = irandom_range(dmg_min, dmg_max);
-		
-		state = CARDSTATE.WAIT;
+		// remove card
 	break;
 	
 	default:

+ 13 - 13
objects/obj_enemy/Create_0.gml

@@ -1,22 +1,22 @@
 /// @description init
 
-state = 0
+state = 0;
 
 // Set Position x and y
-x = get_win_midx(sprite_width)
-y = 200
+x = get_win_midx(sprite_width);
+y = 200;
 
 // Stats
-lifemax = 10
-life = 10
+lifemax = 10;
+life = 10;
 
-atk_min = 0
-atk_max = 2
-def = 0
+atk_min = 0;
+atk_max = 2;
+def = 0;
 
 // Bars Position
-_bar_x = x
-_bar_y = y
-_bar_w = 100
-_bar_h = 20
-_bar_inset = 3
+_bar_x = x;
+_bar_y = y;
+_bar_w = 100;
+_bar_h = 20;
+_bar_inset = 3;

+ 6 - 0
objects/obj_fight_scn/Create_0.gml

@@ -15,11 +15,16 @@ state = STATE.INIT;
 win_width = window_get_width();
 win_height = window_get_height();
 
+// Mobs to fight
+mobs_arr = [];
+
 // Cards in hand
 card_hand = [];
 card_selected = 0;
 card_change = 0;
 
+// Card activated action
+card_active_stats = 0;
 
 // Spawn Card
 for(i=0; i<=4; i+=1;)
@@ -44,6 +49,7 @@ mobs_nb = irandom_range(1, 4);
 for (mob_i=0; mob_i<mobs_nb; mob_i++;)
 {
 	var _mob_inst = instance_create_depth(0, 0, -500, obj_enemy)
+	array_push(mobs_arr, _mob_inst);
 	
 	with(_mob_inst)
 	{

+ 12 - 9
objects/obj_fight_scn/Step_0.gml

@@ -38,18 +38,21 @@ switch (state)
 		
 		if (keyboard_check_pressed(vk_space))
 		{
-			state = STATE.ACTIVATE;
+			var _selcard = get_selec_card(card_hand);
+			card_active_stats = card_hand[_selcard].card_stats;
+			
+			state = STATE.ATTACK;
+			card_hand[_selcard].state = CARDSTATE.ACTIVATED;
 		}
 	break;
 
-    case STATE.ACTIVATE:
-		for(i=0; i<=array_length(card_hand); i+=1;)
-		{
-			if (card_hand[i].selected == true)
-			{
-				card_hand[i].state = CARDSTATE.ACTIVATED;
-			}
-		}
+    case STATE.ATTACK:
+		var _dmg = irandom_range(card_active_stats.dmg_nrml_min,
+								card_active_stats.dmg_nrml_max);
+	
+		mobs_arr[0].life -= _dmg;
+		
+		state = STATE.SELECT;
     break;
 
     case 2:

+ 15 - 1
scripts/scr_toolset/scr_toolset.gml

@@ -22,6 +22,7 @@ function array_loop(_arr, _curr, _add){
 	return _curr
 }
 
+
 // @function							get_selec_card();
 /// @param {Array}		_hand			The array to search for
 /// @description						Return the array position of the selected card
@@ -53,12 +54,13 @@ function progressbar(_curr, _max, _width){
 	return (_width / _max) * _curr
 }
 
+
 // @function							draw_rect();
 /// @param {real}		_x				x pos
 /// @param {real}		_y				y pos
 /// @param {real}		_width			rect width
 /// @param {real}		_height			rect height
-/// @param {boolean}	_outline		With outline?
+/// @param {bool}	_outline		With outline?
 /// @description						Draw a rectangle from width and height
 function draw_rect(_x, _y, _width, _height, _outline){
 	var _x2 = (_x + _width);
@@ -67,6 +69,7 @@ function draw_rect(_x, _y, _width, _height, _outline){
 	draw_rectangle(_x, _y, _x2, _y2, _outline);
 }
 
+
 // @function							draw_rect_inset();
 /// @param {real}		_x				x pos
 /// @param {real}		_y				y pos
@@ -82,4 +85,15 @@ function draw_rect_inset(_x, _y, _width, _height, _inset = 0){
 	var _y2 = (_y + _height) - _inset;
 	
 	draw_rectangle(_x1, _y1, _x2, _y2, false);
+}
+
+
+// @function							stats_traverse();
+/// @param {Array}		_stats_map		Current value
+/// @description						Draw current width of a progress bar
+function stats_traverse(_stats_map){
+	// TODO
+	var _dmg_total = 0;
+	
+	return _dmg_total
 }