public void set_dir(dir_move dir) { if(_dir != dir) { float y_r = 0.0f; switch (dir) { case dir_move.back: { y_r = 333; } break; case dir_move.front: { y_r = 160; } break; case dir_move.right: { y_r = 70; } break; case dir_move.left: { y_r = 250; } break; } Vector3 vc = new Vector3(); vc = transform.rotation.eulerAngles; vc.y = y_r; Quaternion a_temp = transform.rotation; a_temp.SetEulerAngles(vc); int length = _moles_list.Count; for (int i = 0; i < length; i ++ ) { _moles_list[i].transform.rotation = a_temp; } transform.rotation = a_temp; _Rigidbody.velocity = transform.TransformDirection(Vector3.forward * 10); } _dir = dir; }
public void move(dir_move dir) { switch (dir) { case dir_move.back: { _z = _z + 1; } break; case dir_move.front: { _z = _z - 1; } break; case dir_move.down: { _y = _y - 1; } break; case dir_move.up: { _y = _y + 1; } break; case dir_move.left: { _x = _x - 1; } break; case dir_move.right: { _x = _x + 1; } break; } }
public void move_lock_mole(dir_move dir) { move_list(_lock_mole, dir); }
protected bool move(crash_mole mole, dir_move dir) { if(mole == null) { return false; } _use_count++; int min_move_y = (int)crash_define.max_y; foreach (crash_base_obj entry in mole._crash_objs) { crash_pos pos_temp = new crash_pos(); pos_temp = entry._pos; if (min_move_y > pos_temp._y) { min_move_y = pos_temp._y; } pos_temp.move(dir); Vector3 vec = _creature.get_position(); int pos_x = transform_to_map(vec.x); int pos_y = transform_to_map(vec.y); int pos_z = transform_to_map(vec.z); if(_freezen_creature == false) { if (pos_temp._x == pos_x && pos_temp._y == pos_y && pos_temp._z == pos_z) { return false; } } if (check_pos_valid(pos_temp)) { crash_mole mole_entry = get_crash_mole_addr(pos_temp)._crash_mole; if (is_in_can_not_move_list(mole_entry) == true) { return false; } if(mole_entry == null) { continue; } else { if(mole_entry == mole) { continue; } int length = _move_mole_list.Count; bool have_mole = false; for (int i = 0; i < length; i++) { if (mole_entry == (crash_mole)_move_mole_list[i]) { have_mole = true; } } if (have_mole == true) { continue; } else { _move_mole_list.Add(mole_entry); } if (move(mole_entry, dir) == false) { foreach(crash_mole entry_temp in _move_mole_list) { add_can_not_move_list(entry_temp); } _move_mole_list.Clear(); return false; } } } else { _move_mole_list.Clear(); return false; } } return true; }
public void update_move_list(List<crash_mole> temp_list, dir_move dir) { List<crash_mole> list = new List<crash_mole>(); foreach(crash_mole entry in temp_list) { bool find = false; foreach(crash_mole entry_find in list) { if(entry_find == entry) { find = true; break; } } if(find == false) { list.Add(entry); } } temp_list = list; int count_temp = temp_list.Count; for (int i = 0; i < count_temp; i ++ ) { crash_mole obj_mole = (crash_mole)temp_list[i]; int crash_objs_count = obj_mole._crash_objs.Count; for(int j = 0; j < crash_objs_count; j ++) { crash_base_obj obj_obj = obj_mole._crash_objs[j]; _crash_moles[obj_obj._pos._x, obj_obj._pos._z, obj_obj._pos._y]._crash_mole = null; _crash_objs[obj_obj._pos._x, obj_obj._pos._z, obj_obj._pos._y]._crash_obj = null; } } for (int i = 0; i < count_temp; i++) { crash_mole obj_mole = (crash_mole)temp_list[i]; int crash_objs_count = obj_mole._crash_objs.Count; for (int j = 0; j < crash_objs_count; j++) { crash_base_obj obj_obj = (crash_base_obj)obj_mole._crash_objs[j]; obj_obj._last_pos = obj_obj._pos; obj_obj._pos.move(dir); _crash_moles[obj_obj._pos._x, obj_obj._pos._z, obj_obj._pos._y]._crash_mole = obj_obj._crash_mole; _crash_objs[obj_obj._pos._x, obj_obj._pos._z, obj_obj._pos._y]._crash_obj = obj_obj; } } }
public void next_update() { if(_record._open_record == true) { if(_creature._Creature_history.Count == 0&&_record._creature_lock != true&& _need_play_animation == false) { int count = _History._mol_history.Count; if (count > 0) { _record._frame_begin = _current_frame_count; MolMoveHistory history = _History._mol_history[count - 1]; _History._mol_history.RemoveAt(count - 1); if (history._Creature_acts.Count != 0) { _record._creature_lock = true; foreach(CreatureHistory entry in history._Creature_acts) { _creature._Creature_history.Add(entry); } } int mole_count = history.move_moles.Count; List<crash_mole> temp_list = new List<crash_mole> (); foreach(crash_mole entry in history.move_moles) { temp_list.Add(entry); } switch(history._dir) { case dir_move.back: { _last_move_dir = dir_move.front; } break; case dir_move.front: { _last_move_dir = dir_move.back; } break; case dir_move.left: { _last_move_dir = dir_move.right; } break; case dir_move.right: { _last_move_dir = dir_move.left; } break; case dir_move.down: { _last_move_dir = dir_move.up; } break; case dir_move.up: { _last_move_dir = dir_move.down; } break; } if(temp_list.Count != 0) { move_list(temp_list, _last_move_dir); } } else { _record.ready_for_record_closed(); _record.try_to_next_state (); } } } else { bool temp = need_fall_update(); if (temp == false && _need_play_animation == false && _crash_moles_list.Count != 0) { _game_state = gameState.game_playing; } if (temp) { _record.try_to_next_state (); } } }
public bool move_list(List<crash_mole> list, dir_move dir) { if (_need_play_animation == true) { return false; } _move_mole_list.Clear(); List<crash_mole> enry_list = new List<crash_mole>(); int current_count = list.Count; bool can_fall_temp = false; for (int i = 0; i < current_count; i++) { bool need_continue = false; int move_count = enry_list.Count; crash_mole cur_entry = list[i]; if (is_in_can_not_move_list(cur_entry) == true) { continue; } for (int j = 0; j < move_count; j++) { crash_mole temp_entry = enry_list[j]; if (temp_entry == cur_entry) { need_continue = true; break; } } if (need_continue == true) { continue; } _move_mole_list.Add(cur_entry); if (move(cur_entry, dir) == true) { move_count = _move_mole_list.Count; for (int j = 0; j < move_count; j++) { enry_list.Add(_move_mole_list[j]); } update_move_list(_move_mole_list, dir); } else { _can_not_move_list.Add(cur_entry); } _move_mole_list.Clear(); } _can_not_move_list.Clear(); int cur_count = enry_list.Count; if (cur_count > 0) { can_fall_temp = true; _need_play_animation = true; _last_move_dir = dir; _move_mole_list.Clear(); for (int i = 0; i < cur_count; i++) { _move_mole_list.Add(enry_list[i]); } if(_record._open_record == false&& _game_state == gameState.game_playing) { MolMoveHistory history = new MolMoveHistory(); history._dir = dir; foreach (crash_mole entry in _move_mole_list) { history.move_moles.Add(entry); } _current_frame_count++; history._mole_move_count = _current_frame_count; _History._mol_history.Add(history); } } return can_fall_temp; }
public void set_dir(dir_move dir) { if (global_instance.Instance._crash_manager.getGameState() != gameState.game_playing) { return; } if (_dir != dir) { float y_r = 0.0f; switch (dir) { case dir_move.back: { y_r = 333; } break; case dir_move.front: { y_r = 160; } break; case dir_move.right: { y_r = 70; } break; case dir_move.left: { y_r = 250; } break; } int length = _moles_list.Count; for (int i = 0; i < length; i ++ ) { Vector3 vc = new Vector3(); vc = _moles_list[i].transform.rotation.eulerAngles; vc.y = y_r; Quaternion a_temp = _moles_list[i].transform.rotation; a_temp.eulerAngles = vc; _moles_list[i].transform.rotation = a_temp; } if (isNeedRecord()) { update_set_his(); update_move_his(); } } _dir = dir; }
public bool checkDir(dir_move dir, float dis) { Vector3 vec = get_position (); Vector3 vec_1 = new Vector3 (); Vector3 vec_2 = new Vector3 (); Vector3 vec_3 = new Vector3 (); Vector3 vec_4 = new Vector3 (); switch (dir) { case dir_move.down: { dis += _col_size; vec_1.x = vec.x + _col_size; vec_2.x = vec.x - _col_size; vec_3.z = vec.z + _col_size; vec_4.z = vec.z - _col_size; vec_1.y -= dis; vec_2.y -= dis; vec_3.y -= dis; vec_4.y -= dis; } break; case dir_move.up: { dis += _col_size; vec_1.x = vec.x + _col_size; vec_2.x = vec.x - _col_size; vec_3.z = vec.z + _col_size; vec_4.z = vec.z - _col_size; vec_1.y += dis; vec_2.y += dis; vec_3.y += dis; vec_4.y += dis; } break; case dir_move.front: { dis += _col_size; vec_1.x = vec.x + _col_size; vec_2.x = vec.x - _col_size; vec_3.y = vec.y + _col_size; vec_4.y = vec.y - _col_size; vec_1.z -= dis; vec_2.z -= dis; vec_3.z -= dis; vec_4.z -= dis; } break; case dir_move.back: { dis += _col_size; vec_1.x = vec.x + _col_size; vec_2.x = vec.x - _col_size; vec_3.y = vec.y + _col_size; vec_4.y = vec.y - _col_size; vec_1.z += dis; vec_2.z += dis; vec_3.z += dis; vec_4.z += dis; } break; case dir_move.left: { dis += _col_size; vec_1.z = vec.x + _col_size; vec_2.z = vec.x - _col_size; vec_3.y = vec.y + _col_size; vec_4.y = vec.y - _col_size; vec_1.x -= dis; vec_2.x -= dis; vec_3.x -= dis; vec_4.x -= dis; } break; case dir_move.right: { dis += _col_size; vec_1.z = vec.x + _col_size; vec_2.z = vec.x - _col_size; vec_3.y = vec.y + _col_size; vec_4.y = vec.y - _col_size; vec_1.x += dis; vec_2.x += dis; vec_3.x += dis; vec_4.x += dis; } break; } bool block = false; if (global_instance.Instance._crash_manager.is_block (vec_1) || global_instance.Instance._crash_manager.is_block (vec_2) || global_instance.Instance._crash_manager.is_block (vec_3) || global_instance.Instance._crash_manager.is_block (vec_4)) { block = true; } return block; }