public void reset(edit_cy ec) { m_grid.set(ec.p.x / utils.g_grid_size, ec.p.y / utils.g_grid_size); float a = 0.9f - ec.num * 0.015f; if (a < 0.5f) { a = 0.5f; } this.GetComponent <SpriteRenderer> ().color = new Color(1, 1, 1, a); this.GetComponent <SpriteRenderer> ().sprite = ec.sp; }
public void message(s_message message) { if (message.m_type == "play_mode") { m_edit_mode.SetActive(false); m_play_mode.SetActive(true); m_rd.SetActive(true); m_rd1.SetActive(true); m_fuzhu.SetActive(false); mario_point p = (mario_point)message.m_object[0]; int world = 0; if (message.m_ints.Count > 0) { world = (int)message.m_ints[0]; } int mode = 0; if (message.m_ints.Count > 1) { mode = (int)message.m_ints[1]; } m_play_mode.GetComponent <play_mode>().reload(p, world, mode); } if (message.m_type == "close_play_mode") { m_play_mode.SetActive(false); if (mario._instance.m_game_state != e_game_state.egs_edit) { m_rd.SetActive(false); m_rd1.SetActive(false); } } if (message.m_type == "edit_mode") { m_play_mode.SetActive(false); m_edit_mode.SetActive(true); m_rd.SetActive(true); m_rd1.SetActive(true); m_fuzhu.SetActive(true); mario_point p = null; if (message.m_object.Count > 0) { p = (mario_point)message.m_object[0]; } int world = 0; if (message.m_ints.Count > 0) { world = (int)message.m_ints[0]; } m_edit_mode.GetComponent <edit_mode>().reload(p, world, m_edit_cys); m_edit_cys = new List <edit_cy>(); } if (message.m_type == "close_edit_mode") { m_edit_mode.SetActive(false); m_rd.SetActive(false); m_rd1.SetActive(false); } if (message.m_type == "first_load") { foreach (KeyValuePair <int, s_t_unit> kv in game_data._instance.m_t_unit) { s_t_unit t_unit = kv.Value; string name = t_unit.res; string cname = "unit/" + name + "/" + name; if (t_unit != null && t_unit.kfg == 1) { cname = "unit/" + name + "/1/" + name; } GameObject res = (GameObject)Resources.Load(cname); GameObject obj = (GameObject)Instantiate(res); obj.transform.parent = m_loading.transform; obj.transform.localPosition = new Vector3(0, 0, 0); obj.transform.localScale = new Vector3(1, 1, 1); } s_message mes = new s_message(); mes.m_type = "first_load_end"; mes.time = 0.3f; cmessage_center._instance.add_message(mes); } if (message.m_type == "first_load_end") { mario._instance.remove_child(m_loading); } if (message.m_type == "edit_canying") { edit_cy ec = (edit_cy)message.m_object[0]; if (m_edit_cys.Count > 0) { edit_cy cy1 = m_edit_cys[m_edit_cys.Count - 1]; float d = Mathf.Sqrt((cy1.p.x - ec.p.x) * (cy1.p.x - ec.p.x) + (cy1.p.y - ec.p.y) * (cy1.p.y - ec.p.y)); if (d < 640) { return; } } m_edit_cys.Add(ec); if (m_edit_cys.Count > 50) { m_edit_cys.RemoveAt(0); } } }
public override void tupdate() { if (m_bl[1] > 0) { m_bl[1]--; if (m_bl[1] == 0) { if (m_bl[0] == 3) { m_bl[0] = 0; m_big = 1; m_bhz.GetComponent <Animator>().Play("chixu"); } else { m_big = 0; m_yin_time = 150; m_bhz.SetActive(false); } continue_anim(); } } if (m_yin_time > 0) { m_yin_time--; if (m_yin_time % 6 == 3) { this.transform.FindChild("sprite").GetComponent <SpriteRenderer>().enabled = false; } else if (m_yin_time % 4 == 0) { this.transform.FindChild("sprite").GetComponent <SpriteRenderer>().enabled = true; } } if (play_mode._instance.m_state == 1) { if (m_win_state == 0) { m_win_state = 1; m_velocity.set(0, 0); play_anim("win"); play_mode._instance.m_die_pos = new mario_point(m_pos.x + m_world * 10000000, m_pos.y); } mario_obj obj = m_bl_objs[0]; int dx = obj.m_pos.x - m_pos.x; int dy = obj.m_pos.y + 100 - m_pos.y; if (dx < 0) { dx = dx / 10; if (dx == 0) { dx = -1; } } else if (dx > 0) { dx = dx / 10; if (dx == 0) { dx = 1; } } if (dy < 0) { dy = dy / 10; if (dy == 0) { dy = -1; } } else if (dy > 0) { dy = dy / 10; if (dy == 0) { dy = 1; } } m_pos.x += dx; m_pos.y += dy; } else if (m_is_die) { m_die_time++; if (m_die_time == 1) { play_mode._instance.m_die_pos = new mario_point(m_pos.x + m_world * 10000000, m_pos.y); mario._instance.play_mus_ex1("music/lose", false); } if (m_die_time < 50) { play_anim("die"); m_velocity.x = 0; m_velocity.y = 0; } else if (m_die_time == 50) { play_anim("die2"); m_velocity.y = 150; } else if (m_die_time < 100) { m_velocity.y -= utils.g_g; if (m_velocity.y < -160) { m_velocity.y = -160; } } else { m_is_destory = 1; } if (m_die_time == 20) { play_mode._instance.start_cha(); } } else if (!m_is_on_floor) { if (!m_edit_mode) { if (play_mode._instance.m_paqiang > 0) { play_anim("paqiang"); if (play_mode._instance.m_time % 6 == 0) { if (m_fx == mario_fx.mf_left) { play_mode._instance.effect("scyw", m_pos.x - 310, m_pos.y + 300); } else { play_mode._instance.effect("scyw", m_pos.x + 310, m_pos.y + 300); } mario._instance.play_sound_ex("sound/moca"); } } else if (play_mode._instance.m_jump_num <= 1) { if (m_velocity.y >= 0) { play_anim("jump11"); } else { play_anim("jump12"); } } else if (play_mode._instance.m_jump_num == 2) { play_anim("jump21"); } else { play_anim("jump3"); } } } else if (m_is_move) { if (!m_edit_mode) { bool flag = false; if (play_mode._instance.m_shache_time > 0) { flag = true; if (get_anim_name() != "shache") { mario._instance.play_sound_ex("sound/moca"); } play_anim("shache"); if (play_mode._instance.m_time % 6 == 0 && play_mode._instance.m_shache_time > 0) { play_mode._instance.effect("scyw", m_pos.x, m_pos.y - utils.g_grid_size / 2); } } if (!flag) { int speed = (int)(m_velocity.x * 0.7); if (speed < 0) { speed = -speed; } if (speed < 30) { speed = 30; } else if (speed > 100) { speed = 100; } if (speed <= 56) { play_anim("run", speed); } else if (speed <= 84) { play_anim("run1", speed); if (play_mode._instance.m_time % 10 == 0) { mario._instance.play_sound_ex("sound/step", 0.5f); } } else { play_anim("run2", speed); if (play_mode._instance.m_time % 8 == 0) { mario._instance.play_sound_ex("sound/step"); } } } } } else { if (!m_per_is_on_floor) { play_anim("dun"); } else if (get_anim_name() != "dun") { play_anim("stand"); } } if (!m_is_die && mario._instance.m_game_state == e_game_state.egs_edit && mario._instance.m_self.guide >= 100) { edit_cy ec = new edit_cy(); ec.fx = (int)m_fx; ec.world = m_world; ec.p = new mario_point(m_pos.x, m_pos.y); ec.sp = this.GetComponent <mario_anim>().get_sprite(); s_message mes = new s_message(); mes.m_type = "edit_canying"; mes.m_object.Add(ec); cmessage_center._instance.add_message(mes); } }