Inheritance: MonoBehaviour
コード例 #1
0
    void OnCollisionEnter(Collision col)
    {
        Dodgeball ball = col.gameObject.GetComponent <Dodgeball>();

        Debug.Log(ball.isLive);
        if (ball && ball.isLive)
        {
            StartCoroutine(dieCycle());
        }
    }
コード例 #2
0
    void OnCollisionEnter(Collision col)
    {
        Dodgeball ball = col.gameObject.GetComponent <Dodgeball>();

        if (ball && ball.isLive)
        {
            GameController.onDeath();
            //Destroy(gameObject);
        }
    }
コード例 #3
0
    Dodgeball ThrowNewBall(Vector3 position, Vector3 direction)
    {
        Dodgeball newBall = GameObject.Instantiate(dodgeballPrefab, position, Quaternion.identity).GetComponent <Dodgeball>();

        newBall.transform.parent = this.transform;
        newBall.ID     = DodgeBalls.Count;
        newBall.isLive = true;
        DodgeBalls.Add(newBall);
        newBall.ThrowBall(direction);
        return(newBall);
    }
コード例 #4
0
    private void ThrowDodgeball(Vector2 throwAtPoint)
    {
        Vector2 throwFromPoint = CalculateThrowFromPoint(throwAtPoint);
        Vector2 throwVelocity  = CalculateThrowVelocity(throwFromPoint, throwAtPoint);
        // Spawn position is important for Dodgeball; set it at the Player and then offset it.
        Dodgeball dodgeball = Instantiate(dodgeballPrefab, transform.position, Quaternion.identity);

        dodgeball.SetPosition(throwFromPoint);
        dodgeball.SetVelocity(throwVelocity);
        dodgeball.SetTeam(player.Team);
        NetworkServer.Spawn(dodgeball.gameObject);
    }
コード例 #5
0
ファイル: GrabHitbox.cs プロジェクト: N8-Des/Dont-Get-Hit
    void OnTriggerEnter(Collider coll)
    {
        Dodgeball d = coll.GetComponent <Dodgeball>();

        if (d != null)
        {
            if (d.teamOn != teamOn && d.isActive)
            {
                player.CatchBall(d.playerID, d.GetComponent <PhotonView>().viewID);
            }
        }
    }
コード例 #6
0
ファイル: BuntBat.cs プロジェクト: N8-Des/Dont-Get-Hit
    public void OnTriggerEnter(Collider coll)
    {
        Dodgeball d = coll.GetComponent <Dodgeball>();

        if (d != null)
        {
            coll.GetComponent <PhotonView>().RPC("RPC_SetTeam", PhotonTargets.All, team, player.viewID);
            coll.GetComponent <PhotonView>().RPC("RPC_SetVelocity", PhotonTargets.All, (player.transform.forward.normalized * 25 + up) * 1.3f);
            coll.GetComponent <PhotonView>().RPC("RPC_Bunt", PhotonTargets.All);
            hasHit = true;
            sounds.clips[1].Play();
        }
    }
コード例 #7
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        GameObject    hitObject = collision.gameObject;
        EnemyDeath    enemy     = hitObject.GetComponent <EnemyDeath>();
        Dodgeball     dodgeball = hitObject.GetComponent <Dodgeball>();
        ShieldPowerUp shield    = hitObject.GetComponent <ShieldPowerUp>();

        if (hitObject == GameObject.Find("Player"))
        {
            PlayerCharacter p = hitObject.GetComponent <PlayerCharacter>();
            p.Hurt();
            Destroy(this.gameObject);
        }
        //I don't know if we want the enemy to be destroyed by its own dodgeballs
        else if (enemy != null)
        {
            //enemy.Die();
            Destroy(this.gameObject);
        }
        else if (shield != null)
        {
            Destroy(this.gameObject);
        }

        /* else if (dodgeball != null)
         * {
         *  var speed = lastVelocity.magnitude; //We can reduce this if we want
         *  var direction = Vector3.Reflect(lastVelocity.normalized, collision.contacts[0].normal);
         *
         *  rb.velocity = direction * speed;
         * } *///cool idea but causes ball interaction glitches
        else
        {
            Destroy(this.gameObject);
        }
    }
コード例 #8
0
 void OnEnable()
 {
     _evCtrl = (Dodgeball)target;
 }
コード例 #9
0
 private void HandleServerDodgeballDespawned(Dodgeball dodgeball)
 {
 }
コード例 #10
0
 private void HandleDodgeballDespawned(Dodgeball dodgeball)
 {
     dodgeballs.Remove(dodgeball);
 }
コード例 #11
0
 private void HandleDodgeballSpawned(Dodgeball dodgeball)
 {
     dodgeballs.Add(dodgeball);
 }
コード例 #12
0
ファイル: PlayerShoot.cs プロジェクト: TenBitious/Project-BB
 // Use this for initialization
 void Start()
 {
     ball_Current        = Ball;
     ball_Start_Location = GetComponentInChildren <ShootLocation>().transform.position;
     m_Player_Info       = GetComponent <PlayerInfo>();
 }
コード例 #13
0
 public void onNetworkThrowBall(Vector3 position, Vector3 direction)
 {
     Dodgeball newBall = ThrowNewBall(position, direction);
 }
コード例 #14
0
    public void ThrowBall(Vector3 position, Vector3 direction)
    {
        Dodgeball newBall = ThrowNewBall(position, direction);

        network.ThrowBall(newBall.ID, position, direction);
    }