コード例 #1
0
    /// <summary>
    /// 帧事件绑定的方法
    /// </summary>
    public void Fire()
    {
        bullet = ObjectPool.Instance.GetObj(DBA.Instance.GetBulletNameByWeaponName(GetComponent <PlayerAttack>().currentWeaponName));
        Debug.Log("我是" + gameObject.name + ",我进行了攻击");


        BulletClassType bulletType = bullet.GetComponent <BulletClassType>();

        if (bulletType != null)
        {
            bulletType.ViewID = phv.ViewID;
        }
        Debug.Log(bullet);
        BulletCSharp bulletCsharp = bullet.GetComponent <BulletCSharp>();

        if (bulletCsharp != null)
        {
            bullet.transform.position = gameObject.transform.position;
            Destroy(bulletCsharp);
        }

        BulletCSharp bulletCSharp = bullet.AddComponent <BulletCSharp>();

        bulletCSharp.BAwake(gameObject.transform);
    }
コード例 #2
0
    private void OnTriggerEnter(Collider other)
    {
        if (!phv.IsMine)
        {
            return;
        }
        BulletClassType bulletClassType = other.GetComponent <BulletClassType>();

        if (bulletClassType != null && bulletClassType.ViewID != phv.ViewID)
        {
            //pb = GetComponent<PlayerBlood>();
            //pb.bloodValue -= 1;
            //发送扣血

            phv.RPC("reduceBlood", RpcTarget.AllBufferedViaServer, 1, phv.ViewID, bulletClassType.ViewID);
        }
    }
コード例 #3
0
    /// <summary>
    /// 外部调用的开始方法
    /// </summary>
    /// <param name="t">传入玩家</param>
    public void BAwake(Transform t)
    {
        player            = t;
        dir               = new Vector3(player.forward.x, 0, player.forward.z).normalized;
        transform.forward = dir;
        if (GetComponent <Rigidbody>() == null)
        {
            gameObject.AddComponent <Rigidbody>();
        }
        rig                = GetComponent <Rigidbody>();
        rig.useGravity     = false;
        transform.position = new Vector3(player.position.x, player.position.y + 0.5f, player.position.z + 0.5f);

        IsFire();
        StartCoroutine(Rec());

        bulletClassType = GetComponent <BulletClassType>();
    }