private void player_goal_score(Vector3 tar) { _enemy_team_score++; m_currentMode = LevelControllerMode.GoalZoomOut; Main._current_repeat_reason = RepeatReason.ScoredOn; UiPanelGame.inst.show_popup_message(1); _goalzoomoutfocuspos = tar; }
private void DoMatchOpeningSequence() { m_currentMode = LevelControllerMode.Opening; _countdown_ct = 0; // hide cursor //m_mouseTargetIcon.SetActive(false); List <BotBase> allBots = new List <BotBase>( m_playerTeam.TeamMembers.Count + m_enemyTeam.TeamMembers.Count); allBots.AddRange(m_playerTeam.TeamMembers); allBots.AddRange(m_enemyTeam.TeamMembers); for (int i = 0; i < allBots.Count; i++) { BotBase bot = allBots[i]; GenericFootballer footballer = bot.GetComponent <GenericFootballer>(); footballer.force_play_animation(FootballerAnimResource.ANIM_RUN); footballer.force_facing_direction(bot.HomePosition.x >= bot.transform.position.x ? true : false); float d = Vector3.Distance(bot.transform.position, bot.HomePosition); float r = Util.rand_range(200.0f, 220.0f); float t = d / r; _countdown_ct = Math.Max(_countdown_ct, t); _last_countdown_ct = _countdown_ct; LTDescr animDesc = LeanTween.move( bot.gameObject, bot.HomePosition, t) .setEase(LeanTweenType.linear); int animId = animDesc.id; animDesc.setOnComplete(() => { footballer.force_play_animation(FootballerAnimResource.ANIM_IDLE); footballer.force_facing_direction(bot.Team == Team.PlayerTeam ? true : false); m_matchOpeningAnimIds.Remove(animId); }); m_matchOpeningAnimIds.Add(animId); } { m_topReferee.transform.position = Main.FieldController.GetFieldCenter(); CreateLooseBall(m_topReferee.transform.position, Vector3.zero); } }
private void enemy_goal_score(Vector3 tar) { if (Main._current_level == GameLevel.Level1) { Main._current_level = GameLevel.Level2; } else if (Main._current_level == GameLevel.Level2) { Main._current_level = GameLevel.Level3; } else { Main._current_level = GameLevel.End; } _player_team_score++; m_currentMode = LevelControllerMode.GoalZoomOut; Main._current_repeat_reason = RepeatReason.None; UiPanelGame.inst.show_popup_message(1); _goalzoomoutfocuspos = tar; }
private void DoMatchOpeningImmediate() { m_currentMode = LevelControllerMode.GamePlay; List <BotBase> allBots = new List <BotBase>( m_playerTeam.TeamMembers.Count + m_enemyTeam.TeamMembers.Count); allBots.AddRange(m_playerTeam.TeamMembers); allBots.AddRange(m_enemyTeam.TeamMembers); for (int i = 0; i < allBots.Count; i++) { allBots[i].transform.position = allBots[i].HomePosition; } { Vector3 pos = Main.FieldController.GetFieldCenter(); CreateLooseBall(pos, Vector3.zero); } m_enemyTeam.StartMatch(); }
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)); }