Example #1
0
    public void Destory()
    {
        if (m_effectInstance != null)
        {
            GameObject.Destroy(m_effectInstance.gameObject);
        }

        m_effectInstance = null;
    }
Example #2
0
    public GameEffect()
    {
        m_effectDic = new Dictionary <byte, EffectBase>
        {
            { (byte)EEffectType.Shield, new EffectShield(5f) },
            { (byte)EEffectType.BananaBall, new EffectBananaBall(10f) },
            { (byte)EEffectType.InkEffect, new EffectInk(6f) }
        };

        m_effectData = new GameEffectData();

        GameResModuel resModuel = GameStart.GetInstance().ResModuel;
        GameObject    prefab    = resModuel.LoadResources <GameObject>(EResourceType.Effect, "Warning");

        prefab           = CommonFunc.Instantiate(prefab);
        m_effectInstance = prefab.AddComponent <GameEffectInstance>();
        m_effectInstance.gameObject.SetActive(false);

        m_effecting      = false;
        m_createNextTime = Time.time + m_effectData.GetRandomTime();

        m_preEffectType = EEffectType.MaxType;
    }
Example #3
0
        public static Action <object> ParseMessageToAction(Message message)
        {
            if (message.Type == MsgType.Reply)
            {
                throw new InvalidOperationException("Server received MsgType.Reply... those are meant to only flow the other way.");
            }
            if (message.Type == MsgType.Notify)
            {
                return(null);                                // Notify messages ONLY raise the OnReceiveMessage event and nothing else.
            }
            if (message.Type == MsgType.LaunchActivity)
            {
                var substrings           = message.Content.Split(onNEXT);
                var type                 = Type.GetType(substrings[0]);
                var tdata                = Type.GetType(substrings[1]);
                var serializedPassedInfo = substrings[2]; // Currently nothing is done with this, since it'll be a right pain in the arse to do.

                return((o) =>
                {
                    // Todo - embed the PassedInfo into somewhere (Res? try again for Bundle syntax?) before this.
                    Application.Context.StartActivity(type);
                });
            }
            if (message.Type == MsgType.PushSFX)
            {
                IEffect FX;
                if (!Res.SFX.Effects.TryGetValue($"RequestedFX{NEXT}{message.Content}", out FX))
                {
                    if (!int.TryParse(message.Content, out int ResourceID))
                    {
                        ResourceID = typeof(Resource.Id).GetStaticProperty <int>(message.Content);
                    }
                    FX = Res.SFX.Register($"RequestedFX{NEXT}{message.Content}", ResourceID);
                }
                if (FX == null)
                {
                    return(null);
                }

                return((o) =>
                {
                    FX.Activate();
                    FX.Play();
                });
            }
            if (message.Type == MsgType.PushSpeech)
            {
                return((o) =>
                {
                    Speech.Say(message.Content);
                });
            }
            if (message.Type == MsgType.PushEffect)
            {
                var substrings   = message.Content.Split(onNEXT, 2);
                var effectName   = substrings[0];
                var effectParams = substrings[1];
                //if (!MasterSpellLibrary.CastingResults.ContainsKey(effectName))
                //{
                //    Log.Warn(_tag, $"Unable to locate game effect '{effectName}'.");
                //    return null;
                //}
                if (!GameEffect.Definition.ContainsKey(effectName))
                {
                    Log.Warn(_tag, $"Unable to locate effect '{effectName}'.");
                    return(null);
                }

                //var doFunc = MasterSpellLibrary.CastingResults[effectName];
                return((o) =>
                {
                    GameEffect
                    .Definition[effectName]?
                    .OnReceiving(TemporaryAddressBook_SingleEntry ?? new CommsContact(), effectParams);
                });
            }
            if (message.Type == MsgType.PushEffect2)
            {
                var effectInstance = GameEffectInstance.FromStringForm(message.Content);

                //var doFunc = MasterSpellLibrary.CastingResults[effectName];
                return((o) =>
                {
                    effectInstance?
                    .SourceEffect?
                    .OnReceiving2(effectInstance);
                });
            }
            if (message.Type == MsgType.Query)
            {
                return((o) =>
                {
                    var target = AddressBook.Resolve(message.From);
                    target.SendMessage(DataLibrarian.FetchRequestedData(message, o));
                });
            }
            if (message.Type == MsgType.SetScenarioVariable)
            {
                var substrings = message.Content.Split(onNEXT);
                Encounters.Scenario.Current.SetVariable(substrings[0],
                                                        (Encounters.Scenario.State)Enum.Parse(typeof(Encounters.Scenario.State), substrings[1]), false); // False meaning don't rebroadcast it.
            }
            throw new NotImplementedException();
        }