Esempio n. 1
0
    public override void CmdfireInit(Vector3 position, Vector3 forwardRotation, GameObject owner)
    {
        centerObj           = GameObject.Find("planet").transform;
        transform.position += transform.forward * fireOffset;
        for (int i = 0; i < cell_amount; i++)
        {
            float offset = ((i - (cell_amount / 2f)) / cell_amount) * angle;
            //Debug.Log(i + " :  " + offset.ToString());
            if (i == 19)
            {
                ;
            }
            GameObject obj = GameObject.Instantiate(cellBulletPrefab);
            bullet     bul = obj.GetComponent <bullet>();
            NetworkServer.Spawn(obj);
            bul.CmdfireInit(position, forwardRotation);


            // still buggy...
            //bul.transform.RotateAround( centerObj.position- bul.transform.position, offset );
            bul.transform.Rotate(new Vector3(0, offset, 0));
            Debug.Log(bul.transform.forward);
            //bul.transform.Rotate(0, offset, 0);
            bul.setOwner(owner);
        }
    }
Esempio n. 2
0
    void CmdFire(string bulletStr)
    {
        GameObject obj = null;

        obj = GameObject.Instantiate(m_bulletCenter.getBulletType(bulletStr).prefab);


        // handle fire procedure
        if (obj != null)
        {
            bullet bul = obj.GetComponent <bullet>();

            bul.CmdfireInit(bodyTrans.transform.position + bodyTrans.transform.up * 0.1f + bodyTrans.transform.forward * 0.3f, bodyTrans.transform.forward, gameObject);
            //bul.setOwner(this.gameObject);
            NetworkServer.Spawn(obj);
        }
        else // something wrong!!
        {
            Debug.Log("no bullet to shot!!");
        }
    }