コード例 #1
0
        void ApplyEffects(WorldObjectBehaviour worldObj, ResourceActivationContext effectContext, WorldObjectEffectPlayer resource)
        {
            if (resource.Effects != null)
            {
                foreach (var eref in resource.Effects)
                {
                    switch (eref.Type)
                    {
                    case "motive.unity.animation":

                        var anim = eref as UnityAnimation;

                        if (anim != null)
                        {
                            var asset = anim.Asset;

                            if (asset != null)
                            {
                                var animTgt = worldObj.GetAnimationTarget();

                                if (animTgt)
                                {
                                    // Target may have been destroyed somewhere
                                    var objAnim = worldObj.GetAnimationTarget().AddComponent <WorldObjectAnimation>();
                                    objAnim.AnimationAsset = asset;

                                    m_effects.Add(effectContext.InstanceId, objAnim);
                                }
                            }
                        }
                        break;
                    }
                }
            }
        }
コード例 #2
0
        void ApplyEffects(WorldObjectBehaviour worldObj, ResourceActivationContext effectContext, WorldObjectEffectPlayer resource)
        {
            if (resource.Effects != null)
            {
                foreach (var eref in resource.Effects)
                {
                    IWorldObjectEffectHandler handler;

                    if (m_effectHandlers.TryGetValue(eref.Type, out handler))
                    {
                        var appliedEffect = new AppliedEffect(handler, worldObj, effectContext, resource, eref);

                        handler.ApplyEffect(appliedEffect);

                        m_appliedEffects.Add(effectContext.InstanceId, appliedEffect);
                    }
                    else
                    {
                        var errStr = string.Format("Could not find handler for effect type {0}", eref.Type);

                        SystemErrorHandler.Instance.ReportError(errStr);

                        m_logger.Warning(errStr);
                    }
                }
            }
        }
コード例 #3
0
 public AppliedEffect(IWorldObjectEffectHandler handler, WorldObjectBehaviour worldObject, ResourceActivationContext activationContext, WorldObjectEffectPlayer effectPlayer, IScriptObject effect)
 {
     Handler           = handler;
     WorldObject       = worldObject;
     ActivationContext = activationContext;
     EffectPlayer      = effectPlayer;
     Effect            = effect;
 }