private void stop_lerping(GameObject other)
    {
        // if (other == lerp_owner || other.layer == 11) return;
        if (other == lerp_owner)
        {
            return;
        }
        // check if the ball was intercepted by the other team
        if (other.tag == "Player")
        {
            // COMMENTARY CHECK
            if (other.GetComponent <Movement2D_Base>().team_id != lerp_owner.GetComponent <Movement2D_Base>().team_id)
            {
                commentator.Comment(Commentator.Trigger.Intercept, true);
                Debug.Log("BALL WAS INTERCEPTED BY THE OTHER TEAM");
            }
            else
            {
                //commentator.Comment(Commentator.Trigger.Intercept, true);
                //Debug.Log("BALL WAS SUCCESSFULLY CAUGHT!");
            }
        }

        if (other.GetComponent <Movement2D_QuickPass>() != null)
        {
            // insert code for pass and interception comments
        }
        lerping = false;
        ReactivateRigid();
    }
    IEnumerator Countdown(int playerID)
    {
        while (currentCount > 0.0f)
        {
            yield return(new WaitForSecondsRealtime(1.0f));

            currentCount -= 1.0f;
            // Update text
            respawnCountdown.text = currentCount.ToString();
        }
        Commentator c = _AudioMaster.inst.gameObject.transform.GetChild(1).GetComponent <Commentator>();

        c.Comment(Commentator.Trigger.Spawn, true);
        _PlayerManager.Instance.players[playerID].SetActive(true);
        Destroy(gameObject);
    }
Exemple #3
0
    public virtual void lose_ball(Vector2 vel, bool sameTeam)
    {
        if (sameTeam)
        {
            return;
        }

        stacker.PlaySound(tackleSound, 1);
        // get camera zoom
        GameObject cameraZoomGO = GameObject.FindGameObjectWithTag("MainCamera");

        if (cameraZoomGO != null)
        {
            cameraZoom = cameraZoomGO.GetComponent <CameraZoom>();
            cameraZoom.ZoomIn(gameObject, lose_ball_zoom_time, slow_down_rate);
        }
        else
        {
            //Debug.Log("Tutorial_Cam: " + tutorial_cam.name);
            cameraZoom = tutorial_cam.GetComponent <CameraZoom>();
            //cameraZoom.ZoomIn(gameObject, lose_ball_zoom_time, slow_down_rate);
        }

        has_ball = false;
        charging = false;
        ball.transform.parent = null;
        ball.GetComponent <Ball_Behavior>().dropped();
        ball.GetComponent <Rigidbody2D>().velocity = vel;
        StartCoroutine(ball.GetComponent <Ball_Behavior>().BallNoGrab(1f));
        // Debug.Log("Ball velocity: " + ball.GetComponent<Rigidbody2D>().velocity);
        ball = null;
        GetStunned();
        Commentator c = _AudioMaster.inst.gameObject.transform.GetChild(1).GetComponent <Commentator>();

        c.Comment(Commentator.Trigger.Tackle, true);
        // Debug.Log(gameObject.name + ": DISPOSSESSED!!!");
    }
Exemple #4
0
    private void trigger_hit(GameObject other)
    {
        if (already_scored)
        {
            return;
        }
        if (other.CompareTag("Ball"))
        {
            already_scored = true;
            Debug.Log("Goal Hit Ball!!!");


            Transform zoomCollider = other.transform.Find("Zoom Collider");
            if (zoomCollider != null)
            {
                if (zoomCollider.GetComponent <GoalZoom>() != null)
                {
                    StartCoroutine(WaitForZoomOut(zoomCollider.GetComponent <GoalZoom>()));
                }
            }
            else
            {
                Debug.Log("Goal can't find the zoomcollider");
            }


            _AudioMaster.inst.ScoreSound();
            // if (in_tutorial) return;

            // COMMENTARY CHECK
            if (!in_tutorial)
            {
                if (other.GetComponent <Ball_Behavior>().last_team_id == team)
                {
                    float long_throw_threshold = 20.0f;
                    float shot_distance        = Vector3.Distance(other.GetComponent <Ball_Behavior>().last_held_pos, transform.position);
                    if (shot_distance > long_throw_threshold)
                    {
                        commentator.Comment(Commentator.Trigger.LongGoal, true);
                        //Debug.Log("PLAYER SCORED A LONGSHOT!");
                    }
                    else
                    {
                        commentator.Comment(Commentator.Trigger.Goal, true);
                    }
                    //Debug.Log("THE PLAYER SCORED ON THEMSELVES!");
                }
                else
                {
                    commentator.Comment(Commentator.Trigger.OwnGoal, true);
                }
            }

            if (!in_tutorial)
            {
                _GameManager.score[team]++;
                if (!_GameManager.Instance.GamePoint() || true)
                {
                    StartCoroutine(PlayTransition(other));
                }
            }
            else
            {
                // reset ball
                other.GetComponent <Ball_Behavior>().reset_ball();
            }


            if (!in_tutorial /*&& _GameManager.Instance.GamePoint()*/)
            {
                StartCoroutine(RestPlayer());
            }

            // GetComponent<GoalAnimator>().PlayGoalAnimation();
        }
    }