Exemplo n.º 1
0
    private void Update()
    {
        if (Input.GetKey(KeyCode.F))
        {
            PARTICLE p   = new PARTICLE();
            Ray      ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            p.pos = ray.GetPoint(2);
            p.vel = ray.direction * 200;
            p.acc = Vector3.zero;
            AddParticle(p);
        }
        if (Input.GetKey(KeyCode.Space))
        {
            if (particleCount > 0)
            {
                comps.SetBuffer(comps.FindKernel("UpdatePoss"), "_Buffer", pBuffer);
                comps.SetBuffer(comps.FindKernel("UpdateVel"), "_Buffer", pBuffer);
                comps.SetBuffer(comps.FindKernel("ClearAcc"), "_Buffer", pBuffer);
                comps.SetBuffer(comps.FindKernel("AddGravity"), "_Buffer", pBuffer);

                comps.Dispatch(comps.FindKernel("UpdatePoss"), (particleCount + 31) / 32, 1, 1);
                comps.Dispatch(comps.FindKernel("UpdateVel"), (particleCount + 31) / 32, 1, 1);
                comps.Dispatch(comps.FindKernel("ClearAcc"), (particleCount + 31) / 32, 1, 1);
                comps.Dispatch(comps.FindKernel("AddGravity"), (particleCount + 31) / 32, 1, 1);
            }
        }
    }
Exemplo n.º 2
0
 void AddParticle(PARTICLE p)
 {
     if (particleCount == MAX_PARTICLE)
     {
         return;
     }
     pBuffer.GetData(particles, 0, 0, particleCount);
     particles[particleCount++] = p;
     pBuffer.SetData(particles);
 }
Exemplo n.º 3
0
    public Particles MakePuff(PARTICLE puff, Vector3 pos, Node puffOwner)
    {
        Particles puffPart = null;

        switch (puff)
        {
        case PARTICLE.BLOOD:
            puffPart = (Particles)_bloodScene.Instance();
            break;

        case PARTICLE.PUFF:
            puffPart = (Particles)_puffScene.Instance();
            break;
        }

        if (puffOwner != null)
        {
            puffOwner.AddChild(puffPart);
        }
        else
        {
            this.AddChild(puffPart);
        }

        Transform t = puffPart.GlobalTransform;

        t.origin = pos;
        puffPart.GlobalTransform = t;

        puffPart.Emitting = true;

        // FIXME - is this necessary? Clients could emulate based off of initial shoot cmds, moving to no origin sent each frame for projectiles etc
        if (IsNetworkMaster())
        {
            foreach (Peer p in _game.Network.PeerList)
            {
                if (p.ID != 1)
                {
                    _game.Network.SendParticle(p.ID, puff, pos, puffOwner);
                }
            }
        }

        return(puffPart);
    }
Exemplo n.º 4
0
    public Particles SpawnParticle(PARTICLE partType, Transform trans, Player owner)
    {
        Flame   p      = null;
        Vector3 adjust = new Vector3(0, 0, 0);

        switch (partType)
        {
        case PARTICLE.FLAMETHROWER:
            p             = (Flame)_flamethrowerScene.Instance();
            p.PlayerOwner = owner;
            p.WeaponType  = WEAPONTYPE.FLAMETHROWER;
            adjust        = new Vector3(0, 0, -1.5f);
            break;
        }

        _game.World.ParticleManager.AddChild(p);
        p.Transform = trans;
        p.Translate(adjust);


        return(p);
    }
Exemplo n.º 5
0
 public void SendParticle(int playerID, PARTICLE puffType, Vector3 pos, Node puffOwner)
 {
     RpcId(playerID, nameof(ReceiveParticle), (int)puffType, pos.x, pos.y, pos.z, puffOwner == null ? "" : puffOwner.Name);
 }