public void CreateLooseBall(Vector2 start, Vector2 vel) { // ai msg { if (_prev_ball_owner != null) { _prev_ball_owner.Msg_LostBall(); _prev_ball_owner = null; } } GameObject neu_obj = Util.proto_clone(proto_looseBall); LooseBall rtv = neu_obj.GetComponent <LooseBall>(); rtv.sim_initialize(start, vel); m_looseBalls.Add(rtv); }
public void PickupLooseBall(LooseBall looseball, GenericFootballer tar) { m_looseBalls.Remove(looseball); this.catch_particle_at(looseball.transform.position); if (this.get_footballer_team(tar) == Team.PlayerTeam) { m_playerTeamFootballersWithBall.Add(tar); tar._current_mode = GenericFootballer.GenericFootballerMode.Idle; tar.set_wait_delay(15); } else { this.m_enemyTeamFootballersWithBall.Add(tar); tar._current_mode = GenericFootballer.GenericFootballerMode.Idle; tar.set_wait_delay(15); } // ai msg { BotBase new_ball_owner = tar.GetComponent <BotBase>(); if (_prev_ball_owner != null) { _prev_ball_owner.Msg_LostBall(); } new_ball_owner.Msg_GotBall(); _prev_ball_owner = new_ball_owner; } if (__commentary_last_team_to_own_ball == Team.PlayerTeam) { if (__commentary_last_team_to_own_ball == this.get_footballer_team(tar)) { m_commentaryManager.notify_event(CommentaryEvent.PassComplete); } else if (__commentary_last_team_to_own_ball != this.get_footballer_team(tar) && new Vector3(looseball._vel.x, looseball._vel.y, looseball._vz).magnitude > 1) { m_commentaryManager.notify_event(CommentaryEvent.Interception, true); } } Destroy(looseball.gameObject); }
public void sim_update() { bool do_possibly_spawn_notice_particle = false; Vector3 current_ball_pos = Main.LevelController.currentBallPosition(); Vector3 target_pos = transform.position; if (current_ball_pos.magnitude != 0) { if (!m_RefereeGameBounds.OverlapPoint(current_ball_pos)) { if (_self_mode == RefereeMode.Bottom && current_ball_pos.y < _center.y) { target_pos = current_ball_pos; do_possibly_spawn_notice_particle = true; } else if (_self_mode == RefereeMode.Top && current_ball_pos.y > _center.y) { target_pos = current_ball_pos; do_possibly_spawn_notice_particle = true; } else { target_pos = new Vector3(current_ball_pos.x, _basepos.y, _basepos.z); _notice_particle_delay_ct = 0; } } else { target_pos = new Vector3(current_ball_pos.x, _basepos.y + (_self_mode == RefereeMode.Top?40:-40), _basepos.z); _notice_particle_delay_ct = 0; } } else { _notice_particle_delay_ct = 0; } if (do_possibly_spawn_notice_particle) { _notice_particle_delay_ct -= 1; if (_notice_particle_delay_ct <= 0) { Main.LevelController.m_commentaryManager.notify_event(CommentaryEvent.OutOfBounds); Main.LevelController.ref_notice_particle_at(transform.position + new Vector3(0, 120, 0)); _notice_particle_delay_ct = 150; } } float speed = _movespeed * Util.dt_scale; Vector3 delta = Util.vec_sub(target_pos, transform.position); if (delta.magnitude < speed) { transform.position = target_pos; } else { Vector3 dir = delta.normalized; float mag = delta.magnitude; dir.Scale(Util.valv(speed)); transform.position = Util.vec_add(transform.position, dir); } for (int i = 0; i < Main.LevelController.m_looseBalls.Count; i++) { LooseBall itr = Main.LevelController.m_looseBalls[i]; if (Vector3.Distance(itr.transform.position, this.transform.position) < 40 && itr._vel.magnitude < 0.1f) { itr._vz = 3; itr._z = 0; Main.AudioController.PlayEffect("sfx_throw"); if (_self_mode == RefereeMode.Top) { if (itr.transform.position.x < _left_goal_line.x) { itr._vel = Util.vec_scale((new Vector2(1, Util.rand_range(-0.15f, 0))).normalized, 4); } else if (itr.transform.position.x > _right_goal_line.x) { itr._vel = Util.vec_scale((new Vector2(-1, Util.rand_range(-0.15f, 0))).normalized, 4); } else { itr._vel = Util.vec_scale((new Vector2(Util.rand_range(-1, 1), -1)).normalized, 4); } } else { if (itr.transform.position.x < _left_goal_line.x) { itr._vel = Util.vec_scale((new Vector2(1, Util.rand_range(0, 0.15f))).normalized, 4); } else if (itr.transform.position.x > _right_goal_line.x) { itr._vel = Util.vec_scale((new Vector2(-1, Util.rand_range(0, 0.15f))).normalized, 4); } else { itr._vel = Util.vec_scale((new Vector2(Util.rand_range(-1, 1), 1)).normalized, 4); } } } } }
public void Update() { if (Main.PanelManager.CurrentPanelId != PanelIds.Game) { return; } this.update_mouse_point(); m_commentaryManager.i_update(); float mouse_target_anim_speed = 0.3f; if (m_currentMode == LevelControllerMode.GoalZoomOut) { UiPanelGame.inst._fadein.set_target_alpha(1); Main.GameCamera.SetTargetPos(_goalzoomoutfocuspos); Main.GameCamera.SetTargetZoom(300); m_enemyGoal.spawn_confetti(); m_particles.i_update(this); if (UiPanelGame.inst._fadein.is_transition_finished()) { this.ResetLevel(); Main.PanelManager.ChangeCurrentPanel(PanelIds.Tv); } } else if (m_currentMode == LevelControllerMode.GamePlay) { Team ball_owner_team = this.get_footballer_team(this.nullableCurrentFootballerWithBall()); if (ball_owner_team != Team.None) { __commentary_last_team_to_own_ball = ball_owner_team; } _time_remaining = Math.Max(0, _time_remaining - TimeSpan.FromSeconds(Time.deltaTime).Ticks); if (_time_remaining <= 0) { m_currentMode = LevelControllerMode.GoalZoomOut; Main._current_repeat_reason = RepeatReason.Timeout; UiPanelGame.inst.show_popup_message(2); _goalzoomoutfocuspos = Main.GameCamera.GetCurrentPosition(); return; } m_particles.i_update(this); if (m_playerTeamFootballersWithBall.Count > 0) { Main.GameCamera.SetTargetPos(m_playerTeamFootballersWithBall[0].transform.position); if (Input.GetMouseButton(0)) { Main.GameCamera.SetTargetZoom(600); } else { Main.GameCamera.SetTargetZoom(500); } if (Input.GetMouseButton(0)) { Main.GameCamera.SetManualOffset(new Vector3(0, 0, 0)); } else { Main.GameCamera.SetManualOffset(new Vector3(150, 0, 0)); } } else { Main.GameCamera.SetTargetPos(this.GetLastMousePointInBallBounds()); Main.GameCamera.SetTargetZoom(600); Main.GameCamera.SetManualOffset(new Vector3(0, 0, 0)); } mouse_target_anim_speed = 2.0f; mouse_target_icon_set_alpha(1.0f); //m_mouseTargetIcon.SetActive(true); Vector3 mouse_pt = GetLastMousePointInBallBounds(); m_mouseTargetIcon.transform.position = mouse_pt; m_mouseTargetIcon.transform.localScale = Util.valv(50.0f); for (int i = m_looseBalls.Count - 1; i >= 0; i--) { LooseBall itr = this.m_looseBalls[i]; itr.sim_update(); } for (int i = this.m_playerTeamFootballers.Count - 1; i >= 0; i--) { GenericFootballer itr = this.m_playerTeamFootballers[i]; itr.sim_update(); } for (int i = 0; i < this.m_enemyTeamFootballers.Count; i++) { GenericFootballer itr = this.m_enemyTeamFootballers[i]; itr.sim_update(); } if (Input.GetKey(KeyCode.Space)) { for (int i = 0; i < this.m_playerTeamFootballers.Count; i++) { GenericFootballer itr = this.m_playerTeamFootballers[i]; itr.timeout_start(); } m_currentMode = LevelControllerMode.Timeout; m_timeoutSelectedFootballer = null; Main.Pause(PauseFlags.TimeOut); m_commentaryManager.notify_tutorial_just_pressed_space(); Main.AudioController.PlayEffect("sfx_pause"); UiPanelGame.inst.bgm_audio_set_paused_mode(true); } for (int i = m_looseBalls.Count - 1; i >= 0; i--) { LooseBall itr = this.m_looseBalls[i]; if (m_enemyGoal.box_collider().OverlapPoint(itr.transform.position)) { this.blood_anim_at(itr.transform.position); m_looseBalls.Remove(itr); this.enemy_goal_score(itr.transform.position); Destroy(itr.gameObject); m_enemyGoal.play_eat_anim(40); Main.AudioController.PlayEffect("sfx_checkpoint"); } if (m_playerGoal.box_collider().OverlapPoint(itr.transform.position)) { this.blood_anim_at(itr.transform.position); m_looseBalls.Remove(itr); this.player_goal_score(itr.transform.position); Destroy(itr.gameObject); m_playerGoal.play_eat_anim(40); UiPanelGame.inst._chats.clear_messages(); Main.AudioController.PlayEffect("sfx_checkpoint"); } } m_bottomReferee.sim_update(); m_topReferee.sim_update(); } else if (m_currentMode == LevelControllerMode.Timeout) { Vector3 screen = Main.GameCamera.GetComponent <Camera>().WorldToScreenPoint(this.GetLastMousePointInBallBounds()); screen.z = 0; Vector3 mouse_to_center_delta = Util.vec_sub( screen, new Vector2(Screen.width / 2, Screen.height / 2)); float mmouse_move_rad = (Screen.width + Screen.height) / 2.0f * 0.25f; if (mouse_to_center_delta.magnitude > mmouse_move_rad) { Vector3 n_mouse_to_center_delta = mouse_to_center_delta.normalized; Vector3 tar_delta = Util.vec_scale(n_mouse_to_center_delta, (mouse_to_center_delta.magnitude - mmouse_move_rad) * 0.3f); Main.GameCamera.SetTargetPos(Util.vec_add(Main.GameCamera.GetCurrentPosition(), tar_delta)); } else { Main.GameCamera.SetTargetPositionToCurrent(); } Main.GameCamera.SetManualOffset(new Vector3(0, 0, 0)); Main.GameCamera.SetTargetZoom(800); Vector3 mouse_pt = GetLastMousePointInBallBounds(); GenericFootballer select_tar = this.IsPointTouchFootballer(mouse_pt, m_playerTeamFootballers); if (!Input.GetMouseButton(0) && select_tar != null && select_tar.can_take_commands()) { mouse_target_icon_set_alpha(0.4f); //m_mouseTargetIcon.SetActive(false); select_tar.SetSelectedForAFrame(); } else { mouse_target_icon_set_alpha(1.0f); //m_mouseTargetIcon.SetActive(true); } m_mouseTargetIcon.transform.position = mouse_pt; m_mouseTargetIcon.transform.localScale = Util.valv(75.0f); for (int i = 0; i < this.m_playerTeamFootballers.Count; i++) { GenericFootballer itr = this.m_playerTeamFootballers[i]; itr.timeout_update(); } keyboard_switch_timeout_selected_footballer(); Vector2 click_pt; if (this.IsClickAndPointDown(out click_pt)) { GenericFootballer clicked_footballer = IsPointTouchFootballer(click_pt, m_playerTeamFootballers); if (clicked_footballer != null) { m_timeoutSelectedFootballer = clicked_footballer; } } else if (this.IsClickAndPoint(out click_pt)) { if (m_timeoutSelectedFootballer != null && !this.footballer_has_ball(m_timeoutSelectedFootballer)) { m_commentaryManager.notify_tutorial_command_issued(); click_pt = this.point_to_within_goallines_point(m_timeoutSelectedFootballer.transform.position, click_pt); m_timeoutSelectedFootballer.CommandMoveTo(click_pt); } } if (!Input.GetKey(KeyCode.Space)) { m_currentMode = LevelControllerMode.GamePlay; for (int i = 0; i < this.m_playerTeamFootballers.Count; i++) { GenericFootballer itr = this.m_playerTeamFootballers[i]; itr.timeout_end(); } Main.Unpause(PauseFlags.TimeOut); Main.AudioController.PlayEffect("sfx_unpause"); UiPanelGame.inst.bgm_audio_set_paused_mode(false); } } else if (m_currentMode == LevelControllerMode.Opening) { mouse_target_anim_speed = 2.0f; //m_mouseTargetIcon.SetActive(true); mouse_target_icon_set_alpha(1.0f); m_particles.i_update(this); _countdown_ct -= Time.deltaTime; if (_countdown_ct < 4f && _last_countdown_ct > 4f) { UiPanelGame.inst._chats.push_message("3...", 2); Main.AudioController.PlayEffect("sfx_ready"); } else if (_countdown_ct < 3f && _last_countdown_ct > 3f) { UiPanelGame.inst._chats.push_message("2...", 1); Main.AudioController.PlayEffect("sfx_ready"); } else if (_countdown_ct < 2f && _last_countdown_ct > 2f) { UiPanelGame.inst._chats.push_message("1...", 2); Main.AudioController.PlayEffect("sfx_ready"); } _last_countdown_ct = _countdown_ct; Vector3 mouse_pt = GetLastMousePointInBallBounds(); m_mouseTargetIcon.transform.position = mouse_pt; m_mouseTargetIcon.transform.localScale = Util.valv(50.0f); if (m_matchOpeningAnimIds.Count == 0) { m_currentMode = LevelControllerMode.GamePlay; //m_mouseTargetIcon.SetActive(true); // throw it in if (m_looseBalls.Count > 0) { LooseBall lb = m_looseBalls[0]; Vector3 throwDir = m_playerTeamFootballers[0].transform.position - lb.transform.position; throwDir.Normalize(); lb.sim_initialize(lb.transform.position, throwDir * 4.0f); UiPanelGame.inst.show_popup_message(0); Main.AudioController.PlayEffect("sfx_go"); } UiPanelGame.inst._chats.push_message("And the match is underway!", 1); m_enemyTeam.StartMatch(); } } m_mouseTargetIconTheta += mouse_target_anim_speed * Util.dt_scale; Util.transform_set_euler_world(m_mouseTargetIcon.transform, new Vector3(0, 0, m_mouseTargetIconTheta)); }