Esempio n. 1
0
        public void Reset(Action onComplete)
        {
            AnalyticsHelper.FireEvent("Reset");

            StopAllProcessors(() =>
            {
                if (ScriptsReset != null)
                {
                    ScriptsReset(this, EventArgs.Empty);
                }

                try
                {
                    ScriptEngine.Instance.Reset();
                }
                catch (Exception x)
                {
                    m_logger.Warning("Unhandled exception {0} resetting script engine. Continuing anyway.", x.ToString());
                }

                StorageManager.DeleteGameFolder();

                if (onComplete != null)
                {
                    onComplete();
                }
            });
        }
Esempio n. 2
0
        void RegisterAndroid()
        {
            m_logger.Debug("RegisterAndroid");

            if (string.IsNullOrEmpty(GoogleConsoleProjectId))
            {
                m_logger.Warning("Google project ID not configured.");

                return;
            }

            AndroidRemoteNotificationManager.Register(GoogleConsoleProjectId, (regId) =>
            {
                if (string.IsNullOrEmpty(regId))
                {
                    m_logger.Error("Failed to get registration ID");

                    //ResultText.text = string.Format("Failed to get the registration id");
                    return;
                }

                //ResultText.text = string.Format(@"Your registration Id is = {0}", regId);
                m_logger.Debug("in Register method");

                WebServices.Instance.UserManager.RegisterPushNotifications(GoogleCloud, regId, (success) =>
                {
                    m_logger.Debug("Register Android push notifications complete: success={0}", success);
                });

                WaitForUpdates();
            });
        }
        public void Initialize()
        {
            if (IsInitialized)
            {
                return;
            }

            m_Logger = new Logger(this);

            PurchasableItems = new Dictionary <string, ScriptDirectoryItem>();

            var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

            var items = ScriptRunnerManager.Instance.GetScriptRunners().Where(item => !string.IsNullOrEmpty(item.ProductIdentifier));

            foreach (var item in items)
            {
                if (PurchasableItems.ContainsKey(item.ProductIdentifier))
                {
                    m_Logger.Warning(string.Format("PurchaseManager Purchasable item ({0}) already registered.", item.ProductIdentifier));
                    continue;
                }

                m_Logger.Verbose(string.Format("PurchaseManager Purchasable item ({0}) registered.", item.ProductIdentifier));

                PurchasableItems.Add(item.ProductIdentifier, item);
                builder.AddProduct(item.ProductIdentifier, ProductType.NonConsumable);
            }

            UnityPurchasing.Initialize(this, builder);
            m_Logger.Verbose(string.Format("PurchaseManager {0} initialized.", this.GetType()));
        }
Esempio n. 4
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);
                    }
                }
            }
        }
        public override void Play(ResourceActivationContext activationContext, PlayableContent playable, Action onClose = null)
        {
            if (playable.Content is LocalizedAudioContent)
            {
                QueueAudioContent(activationContext, playable, playable.Content as LocalizedAudioContent, onClose);
            }
            else if (playable.Content is LocativeAudioContent)
            {
                m_locativeAudioProcessor.ActivateResource(activationContext, playable.Content as LocativeAudioContent);
            }
            else if (IsScreenContent(playable))
            {
                QueueScreenContent(activationContext, playable, onClose);
            }
            else
            {
                m_logger.Warning("Unhandled content type {0} (playable.Id={1})",
                                 playable.Content != null ? playable.Content.Type : null,
                                 playable.Id);

                if (onClose != null)
                {
                    onClose();
                }
            }
        }
Esempio n. 6
0
        public override void ApplyEffect(AppliedEffect appliedEffect)
        {
            //Retrieve the container holding the object and add animation component to it
            var sceneObject = appliedEffect.WorldObject.GetAnimationTarget().transform.parent.gameObject;
            var sAnimations = appliedEffect.Effect as ScriptedAnimation;

            if (sceneObject && sAnimations != null)
            {
                if (sceneObject.GetComponent <Animation>() == null)
                {
                    sceneObject.AddComponent <Animation>();
                }

                Transform transform = sceneObject.transform;

                //Build a new animation clip, storing the keyframes in a 2D array
                AnimationClip clip = new AnimationClip
                {
                    legacy = true
                };

                float time = 0.0f;

                ListDictionary <string, PropertyKeyframe> propertyKeyframes = new ListDictionary <string, PropertyKeyframe>();

                Action <string, float, string, double?> addKeyframe = (prop, _time, easing, val) =>
                {
                    if (val.HasValue)
                    {
                        propertyKeyframes.Add(prop,
                                              new PropertyKeyframe
                        {
                            Easing   = easing,
                            Keyframe = new Keyframe(_time, (float)val.Value)
                        });
                    }
                };

                Action <string, float, string, NullableVector> addKeyframeVector = (prop, _time, easing, vec) =>
                {
                    if (vec != null)
                    {
                        addKeyframe(prop + ".x", _time, easing, vec.X);
                        addKeyframe(prop + ".y", _time, easing, vec.Y);
                        addKeyframe(prop + ".z", _time, easing, vec.Z);
                    }
                };

                // Let's add initial settings for the animation
                //addKeyframeVector("localPosition", 0,

                foreach (var kFrame in sAnimations.Keyframes)
                {
                    time += (float)kFrame.Duration.TotalSeconds;

                    if (kFrame.Properties != null)
                    {
                        foreach (var property in kFrame.Properties)
                        {
                            if (property is MotiveTransform)
                            {
                                var xform = property as MotiveTransform;

                                addKeyframeVector("localPosition", time, kFrame.Easing, xform.Position);
                                addKeyframeVector("localScale", time, kFrame.Easing, xform.Scale);

                                if (xform.Rotation != null)
                                {
                                    var rot = Quaternion.Euler(
                                        (float)xform.Rotation.X.GetValueOrDefault(),
                                        (float)xform.Rotation.Y.GetValueOrDefault(),
                                        (float)xform.Rotation.Z.GetValueOrDefault());

                                    addKeyframe("localRotation.x", time, kFrame.Easing, rot.x);
                                    addKeyframe("localRotation.y", time, kFrame.Easing, rot.y);
                                    addKeyframe("localRotation.z", time, kFrame.Easing, rot.z);
                                    addKeyframe("localRotation.w", time, kFrame.Easing, rot.w);
                                }
                            }
                            else
                            {
                                m_logger.Warning("Unknown property type in keyframe: {0}", property.Type);
                            }
                        }
                    }
                }

                //Set Easing Properties
                //SetEasing(sAnimations);

                //Setting the animation curves to the animation clip
                foreach (var kv in propertyKeyframes)
                {
                    SetEasing(kv.Value);
                    // NOTE: For now we know that all properties are transforms. We can extend
                    // the model to handle different property types in the future.
                    clip.SetCurve("", typeof(Transform), kv.Key, new AnimationCurve(kv.Value.Select(v => v.Keyframe).ToArray()));
                    //clip.SetCurve("", typeof(Transform), kv.Key, AnimationCurve.Linear(0, 0, 1, 1));
                }

                //Loop Check
                if (sAnimations.Loop)
                {
                    clip.wrapMode = WrapMode.Loop;
                }

                var anim = sceneObject.GetComponent <Animation>();

                if (anim)
                {
                    anim.AddClip(clip, sAnimations.Id);
                }

                // Uncomment this in the editor to stash a version of the created animation
                //UnityEditor.AssetDatabase.CreateAsset(clip, "Assets/" + sAnimations.Id + ".anim");

                base.ApplyEffect(appliedEffect);
            }
        }