Beispiel #1
0
    public void ActualUpdate()
    {
        if (!enabled)
        {
            return;
        }

        m_force_data.info.shape_type     = m_shape_type;
        m_force_data.info.dir_type       = m_direction_type;
        m_force_data.info.strength       = m_strength_near;
        m_force_data.info.random_diffuse = m_random_diffuse;
        m_force_data.info.random_seed    = m_random_seed;
        m_force_data.info.direction      = m_direction;
        m_force_data.info.center         = transform.position;
        m_force_data.info.rcp_cellsize   = new Vector3(1.0f / m_vectorfield_cellsize.x, 1.0f / m_vectorfield_cellsize.y, 1.0f / m_vectorfield_cellsize.z);
        if (m_shape_type == CSForceShape.Sphere)
        {
            m_force_data.sphere.center = transform.position;
            m_force_data.sphere.radius = transform.localScale.x;
        }
        else if (m_shape_type == CSForceShape.Box)
        {
            Vector3   zero = Vector3.zero;
            Vector3   one  = Vector3.one;
            Matrix4x4 m    = transform.localToWorldMatrix;
            MPGPImpl.BuildBox(ref m_force_data.box, ref m, ref zero, ref one);
        }
        EachTargets((t) => { t.AddForce(ref m_force_data); });
    }
Beispiel #2
0
    void Update()
    {
        Vector3   zero = Vector3.zero;
        Vector3   one  = Vector3.one;
        Vector3   s    = transform.localScale;
        Matrix4x4 bt   = Matrix4x4.identity;

        bt.SetColumn(3, new Vector4(0.0f, 0.0f, 0.5f, 1.0f));
        bt          = Matrix4x4.Scale(new Vector3(s.x, s.y, s.z * range)) * bt;
        forceMatrix = transform.localToWorldMatrix * bt;

        CSForce force = new CSForce();

        force.info.shape_type = CSForceShape.Box;
        force.info.dir_type   = CSForceDirection.Directional;
        force.info.strength   = strength;
        force.info.direction  = transform.forward;
        MPGPImpl.BuildBox(ref force.box, ref forceMatrix, ref zero, ref one);
        MPGPWorld.GetInstances().ForEach((t) => { t.AddForce(ref force); });

        foreach (Transform child in transform)
        {
            child.Rotate(new Vector3(0.0f, 0.0f, 1.0f), strength * 0.33f);
        }
    }
Beispiel #3
0
    void Blow()
    {
        TestShooter ts = TestShooter.instance;

        if (ts.gameMode == TestShooter.GameMode.Exception)
        {
            Vector3 zero     = Vector3.zero;
            Vector3 one      = Vector3.one;
            Vector3 pos      = trans.position;
            float   strength = 2000.0f;

            CSForce force = new CSForce();
            force.info.shape_type = CSForceShape.Box;
            force.info.dir_type   = CSForceDirection.Radial;
            force.info.strength   = strength;
            force.info.center     = pos - (trans.forward * 6.0f);
            MPGPImpl.BuildBox(ref force.box, ref blowMatrix, ref zero, ref one);
            MPGPWorld.GetInstances().ForEach((t) => { t.AddForce(ref force); });
        }
    }