Esempio n. 1
0
    private PreviewEffect PlayEffect(string name, Vector3 pos, Vector3 euler)
    {
        if (string.IsNullOrEmpty(name))
        {
            return(null);
        }
        var eft = EffectUtil.FindEffect(name);

        if (eft != null)
        {
            eft.position = pos;
            eft.euler    = euler;
            eft.Play();
            return(eft);
        }
        //创建新的特效
        string     efxPath = "Assets/AssetBases/PrefabAssets/efx/";
        GameObject prefab  = AssetDatabase.LoadAssetAtPath <GameObject>(efxPath + name + ".prefab");

        if (prefab != null)
        {
            GameObject efxgo = UnityEngine.Object.Instantiate(prefab);
            efxgo.name = name;
            this.AddGameObject(efxgo, false);
            eft          = EffectUtil.Play(efxgo);
            eft.position = pos;
            eft.euler    = euler;
        }
        return(eft);
    }
Esempio n. 2
0
 void DoPlay(GameObject fxObj, Transform attach_node, Vector3 pos, Vector3 scale)
 {
     fxObj.transform.parent = attach_node;
     EffectUtil.AttachNode(attach_node, fxObj.transform);
     fxObj.transform.localPosition = pos;
     fxObj.transform.localScale    = scale;
 }
Esempio n. 3
0
    public override void Reset()
    {
        m_AnimateTriggerTick = 0;
        m_AnimateProgress    = 0;
        isPlaying            = false;
        m_DragAnima          = false;

        AudioUtil.Cleanup();
        EffectUtil.Cleanup();

        base.Reset();
    }
Esempio n. 4
0
    public static void CreatProjectile(ISkill skill, CommonParam param, SkillActionData effectData)
    {
        string effectName = effectData.Para1;

        TryParseWithDebug(effectData.Para2, out int speed, "投射物速度");
        string startPoint = effectData.Para3;

        int index = UnityEngine.Random.Range(0, effects.Length);

        effectName = effects[index]; //todo FakeData

        Transform spawnTransform = null;

        if (param.IsBounce && param.BounceParam.BounceTime > 1) //技能发出点是上一个Target
        {
            spawnTransform = param.BounceParam.LastBouncedActor.GetTransform();
        }
        else //技能发出点是默认的技能释放者
        {
            spawnTransform = skill.GetContext().GetSelfActor().GetTransform();
        }

        var newTarget = param.Targets[0];

        if (param.IsBounce)
        {
            param.BounceParam.AddLastBouncedTarget(newTarget);
        }

        Transform spawnPoint    = spawnTransform.Find(startPoint);
        Vector3   spawnPosition = spawnPoint ? spawnPoint.position : spawnTransform.position;

        GameObject projectile = EffectUtil.InstantiateEffect(effectName, spawnPosition, Quaternion.identity);
        var        script     = projectile.AddComponent <SkillProjectile>();

        script.BeginProjectile(skill, param, effectData, newTarget, speed);
    }
        public RenderingStrategy(SlimDX.Direct3D11.Device device, DeviceContext deviceContext, Segmenter segmenter)
        {
            mSegmenter = segmenter;

            mStopwatch.Start();

            mEffect = EffectUtil.CompileEffect(device, @"Shaders\Segmenter2D.fx");

            // create position vertex data, making sure to rewind the stream afterward
            var positionVertexDataStream = new DataStream(NUM_VERTICES * POSITION_NUM_COMPONENTS_PER_VERTEX * POSITION_NUM_BYTES_PER_COMPONENT, true, true);

            positionVertexDataStream.Write(POSITION_TOP_LEFT);
            positionVertexDataStream.Write(POSITION_BOTTOM_LEFT);
            positionVertexDataStream.Write(POSITION_TOP_RIGHT);
            positionVertexDataStream.Write(POSITION_BOTTOM_RIGHT);
            positionVertexDataStream.Position = 0;

            // create texcoord vertex data, making sure to rewind the stream afterward
            var texCoordVertexDataStream = new DataStream(NUM_VERTICES * TEXCOORD_NUM_COMPONENTS_PER_VERTEX * TEXCOORD_NUM_BYTES_PER_COMPONENT, true, true);

            texCoordVertexDataStream.Write(TEXCOORD_TOP_LEFT);
            texCoordVertexDataStream.Write(TEXCOORD_BOTTOM_LEFT);
            texCoordVertexDataStream.Write(TEXCOORD_TOP_RIGHT);
            texCoordVertexDataStream.Write(TEXCOORD_BOTTOM_RIGHT);
            texCoordVertexDataStream.Position = 0;

            // create the input layout
            var inputElements = new[]
            {
                new InputElement("POSITION", 0, POSITION_FORMAT, POSITION_SLOT),
                new InputElement("TEXCOORD", 0, TEXCOORD_FORMAT, TEXCOORD_SLOT)
            };

            var technique = mEffect.GetTechniqueByName("Segmenter2D");

            mPass = technique.GetPassByName("Segmenter2D");

            mInputLayout = new InputLayout(device, mPass.Description.Signature, inputElements);

            // create the vertex buffers
            mPositionVertexBuffer = new Buffer(device,
                                               positionVertexDataStream,
                                               NUM_VERTICES * POSITION_NUM_COMPONENTS_PER_VERTEX * POSITION_NUM_BYTES_PER_COMPONENT,
                                               ResourceUsage.Default,
                                               BindFlags.VertexBuffer,
                                               CpuAccessFlags.None,
                                               ResourceOptionFlags.None,
                                               0);

            mTexCoordVertexBuffer = new Buffer(device,
                                               texCoordVertexDataStream,
                                               NUM_VERTICES * TEXCOORD_NUM_COMPONENTS_PER_VERTEX * TEXCOORD_NUM_BYTES_PER_COMPONENT,
                                               ResourceUsage.Default,
                                               BindFlags.VertexBuffer,
                                               CpuAccessFlags.None,
                                               ResourceOptionFlags.None,
                                               0);

            System.Threading.Thread.Sleep(1000);
            Trace.WriteLine("\nMojo initializing TinyText.Context (NOTE: TinyText.Context generates D3D11 warnings)...\n");

            bool result;

            mTinyTextContext = new Context(device, deviceContext, MAX_NUM_TEXT_CHARACTERS, out result);
            Release.Assert(result);

            Trace.WriteLine("\nMojo finished Initializing TinyText.Context...\n");
        }
Esempio n. 6
0
 private void UpdatePreviewEffect()
 {
     EffectUtil.Update();
 }