예제 #1
0
        public void RemoveBuff(AtavismEffect effect, int pos)
        {
            Dictionary <string, object> props = new Dictionary <string, object>();

            props.Add("effectID", effect.id);
            props.Add("pos", pos);
            NetworkAPI.SendExtensionMessage(ClientAPI.GetPlayerOid(), false, "ao.REMOVE_BUFF", props);
        }
예제 #2
0
        public AtavismEffect Clone(GameObject go)
        {
            AtavismEffect clone = go.AddComponent <AtavismEffect>();

            clone.id      = id;
            clone.name    = name;
            clone.icon    = icon;
            clone.tooltip = tooltip;
            clone.Length  = Length;
            return(clone);
        }
예제 #3
0
        public void EffectsPropertyHandler(object sender, ObjectPropertyChangeEventArgs args)
        {
            if (args.Oid != ClientAPI.GetPlayerOid())
            {
                return;
            }
            //ClientAPI.Write("Got effect update at time: " + Time.realtimeSinceStartup);
            LinkedList <object> effects_prop = (LinkedList <object>)ClientAPI.GetPlayerObject().GetProperty("effects");

            AtavismLogger.LogDebugMessage("Got player effects property change: " + effects_prop);
            playerEffects.Clear();
            //	int pos = 0;
            foreach (string effectsProp in effects_prop)
            {
                AtavismLogger.LogWarning("Effect: " + effectsProp);
                string[] effectData = effectsProp.Split(',');
                int      effectID   = int.Parse(effectData[0]);
                //long endTime = long.Parse(effectData[3]);
                // long serverTime = ClientAPI.ScriptObject.GetComponent<TimeManager>().ServerTime;
                //long timeTillEnd = endTime - serverTime;
                long timeUntilEnd = long.Parse(effectData[4]);
                bool active       = bool.Parse(effectData[5]);
                long duration     = long.Parse(effectData[6]);
                AtavismLogger.LogInfoMessage("Got effect " + effectID + " active? " + active);
                //if (timeTillEnd < duration)
                //	duration = timeTillEnd;

                float secondsLeft = (float)timeUntilEnd / 1000f;

                if (!effects.ContainsKey(effectID))
                {
                    AtavismLogger.LogWarning("Effect " + effectID + " does not exist");
                    continue;
                }
                AtavismEffect effect = effects[effectID].Clone(tempCombatDataStorage);
                effect.StackSize  = int.Parse(effectData[1]);
                effect.isBuff     = bool.Parse(effectData[2]);
                effect.Active     = active;
                effect.Expiration = Time.time + secondsLeft;
                effect.Length     = (float)duration / 1000f;
                playerEffects.Add(effect);
            }
            // dispatch a ui event to tell the rest of the system
            string[] event_args = new string[1];
            AtavismEventSystem.DispatchEvent("EFFECT_UPDATE", event_args);
        }
예제 #4
0
        void Start()
        {
            if (instance != null)
            {
                return;
            }
            instance = this;

            tempCombatDataStorage = new GameObject("TemporaryCombatData");
            DontDestroyOnLoad(tempCombatDataStorage);

            playerAbilities = new List <AtavismAbility>();
            //   abilitiesList = new List<AtavismAbility>();

            abilities = new Dictionary <int, AtavismAbility>();
            Object[] abilityPrefabs = Resources.LoadAll("Content/Abilities");
            foreach (Object abilityPrefab in abilityPrefabs)
            {
                GameObject     go          = (GameObject)abilityPrefab;
                AtavismAbility abilityData = go.GetComponent <AtavismAbility>();
                if (!abilities.ContainsKey(abilityData.id))
                {
                    abilities.Add(abilityData.id, abilityData);
                }
            }

            playerEffects = new List <AtavismEffect>();
            effects       = new Dictionary <int, AtavismEffect>();
            Object[] effectPrefabs = Resources.LoadAll("Content/Effects");
            foreach (Object effectPrefab in effectPrefabs)
            {
                GameObject    go         = (GameObject)effectPrefab;
                AtavismEffect effectData = go.GetComponent <AtavismEffect>();
                if (!effects.ContainsKey(effectData.id))
                {
                    effects.Add(effectData.id, effectData);
                }
            }
        }
예제 #5
0
        public List <AtavismEffect> GetTargetEffects()
        {
            List <AtavismEffect> targetEffects = new List <AtavismEffect>();
            LinkedList <object>  effects_prop  = (LinkedList <object>)ClientAPI.GetTargetObject().GetProperty("effects");

            AtavismLogger.LogDebugMessage("Got target effects property change: " + effects_prop);
            //	int pos = 0;
            foreach (string effectsProp in effects_prop)
            {
                string[] effectData = effectsProp.Split(',');
                int      effectID   = int.Parse(effectData[0]);
                //long endTime = long.Parse(effectData[2]);
                //long serverTime = ClientAPI.ScriptObject.GetComponent<TimeManager>().ServerTime;
                //long timeTillEnd = endTime - serverTime;
                long timeUntilEnd = long.Parse(effectData[3]);
                bool active       = bool.Parse(effectData[4]);
                long duration     = long.Parse(effectData[5]);
                AtavismLogger.LogInfoMessage("Got effect " + effectID + " active? " + active);
                //if (timeTillEnd < duration)
                //	duration = timeTillEnd;

                float secondsLeft = (float)timeUntilEnd / 1000f;

                if (!effects.ContainsKey(effectID))
                {
                    AtavismLogger.LogWarning("Effect " + effectID + " does not exist");
                    continue;
                }
                AtavismEffect effect = effects[effectID].Clone(tempCombatDataStorage);
                effect.Active     = active;
                effect.Expiration = Time.time + secondsLeft;
                effect.Length     = duration / 1000f;
                targetEffects.Add(effect);
            }
            return(targetEffects);
        }
예제 #6
0
        public void HandleCombatEvent(Dictionary <string, object> props)
        {
            string eventType = (string)props["event"];
            OID    caster    = (OID)props["caster"];
            OID    target    = (OID)props["target"];
            int    abilityID = (int)props["abilityID"];
            int    effectID  = (int)props["effectID"];
            string value1    = "" + (int)props["value1"];
            string value2    = "" + (int)props["value2"];
            string value3    = (string)props["value3"];
            string value4    = (string)props["value4"];

            // Debug.LogWarning("Got Combat Event " + eventType);
//             Debug.LogError("HandleCombatEvent " + caster + " | " + target + " | " + abilityID + " | " + effectID + " | " + value1 + " | " + value2+" | "+ eventType);
            //Automatical select attacer
            try
            {
                if (target.ToLong() == ClientAPI.GetPlayerOid() && target != caster &&
                    (ClientAPI.GetTargetObject() == null || (ClientAPI.GetTargetObject() != null && ClientAPI.GetTargetObject().PropertyExists("health") && (int)ClientAPI.GetTargetObject().GetProperty("health") == 0)))
                {
                    ClientAPI.SetTarget(caster.ToLong());
                }
            }
            catch (System.Exception e)
            {
                Debug.LogError("Exception e=" + e);
            }
            // ClientAPI.Write("Got Combat Event: " + eventType);
            //   int messageType = 2;

            if (eventType == "CombatPhysicalDamage")
            {
                //		messageType = 1;
            }
            else if (eventType == "CombatMagicalDamage")
            {
            }
            else if (eventType == "CombatPhysicalCritical")
            {
                ClientAPI.GetObjectNode(target.ToLong()).MobController.PlayAnimationTrigger("Critic");

                //		messageType = 1;
            }
            else if (eventType == "CombatMagicalCritical")
            {
                ClientAPI.GetObjectNode(target.ToLong()).MobController.PlayAnimationTrigger("Critic");
                //		messageType = 1;
            }
            else if (eventType == "CombatMissed")
            {
                ClientAPI.GetObjectNode(target.ToLong()).MobController.PlayAnimationTrigger("Evaded");

#if AT_I2LOC_PRESET
                if (target.ToLong() == ClientAPI.GetPlayerOid())
                {
                    value1 = I2.Loc.LocalizationManager.GetTranslation("MissedSelf");
                }
                else
                {
                    value1 = I2.Loc.LocalizationManager.GetTranslation("Missed");
                }
#else
                value1 = "Missed";
#endif
            }
            else if (eventType == "CombatDodged")
            {
                ClientAPI.GetObjectNode(target.ToLong()).MobController.PlayAnimationTrigger("Dodged");

#if AT_I2LOC_PRESET
                if (target.ToLong() == ClientAPI.GetPlayerOid())
                {
                    value1 = I2.Loc.LocalizationManager.GetTranslation("DodgedSelf");
                }
                else
                {
                    value1 = I2.Loc.LocalizationManager.GetTranslation("Dodged");
                }
#else
                value1 = "Dodged";
#endif
            }
            else if (eventType == "CombatBlocked")
            {
                ClientAPI.GetObjectNode(target.ToLong()).MobController.PlayAnimationTrigger("Blocked");
#if AT_I2LOC_PRESET
                if (target.ToLong() == ClientAPI.GetPlayerOid())
                {
                    value1 = I2.Loc.LocalizationManager.GetTranslation("BlockedSelf");
                }
                else
                {
                    value1 = I2.Loc.LocalizationManager.GetTranslation("Blocked");
                }
#else
                value1 = "Blocked";
#endif
            }
            else if (eventType == "CombatParried")
            {
                ClientAPI.GetObjectNode(target.ToLong()).MobController.PlayAnimationTrigger("Parried");
                #if AT_I2LOC_PRESET
                if (target.ToLong() == ClientAPI.GetPlayerOid())
                {
                    value1 = I2.Loc.LocalizationManager.GetTranslation("ParriedSelf");
                }
                else
                {
                    value1 = I2.Loc.LocalizationManager.GetTranslation("Parried");
                }
#else
                value1 = "Parried";
#endif
            }
            else if (eventType == "CombatEvaded")
            {
                ClientAPI.GetObjectNode(target.ToLong()).MobController.PlayAnimationTrigger("Evaded");

#if AT_I2LOC_PRESET
                if (target.ToLong() == ClientAPI.GetPlayerOid())
                {
                    value1 = I2.Loc.LocalizationManager.GetTranslation("EvadedSelf");
                }
                else
                {
                    value1 = I2.Loc.LocalizationManager.GetTranslation("Evaded");
                }
#else
                value1 = "Evaded";
#endif
            }
            else if (eventType == "CombatImmune")
            {
#if AT_I2LOC_PRESET
                if (target.ToLong() == ClientAPI.GetPlayerOid())
                {
                    value1 = I2.Loc.LocalizationManager.GetTranslation("ImmuneSelf");
                }
                else
                {
                    value1 = I2.Loc.LocalizationManager.GetTranslation("Immune");
                }
#else
                value1 = "Immune";
#endif
            }
            else if (eventType == "CombatBuffGained" || eventType == "CombatDebuffGained")
            {
                AtavismEffect e = Abilities.Instance.GetEffect(effectID);
                if (e != null)
                {
#if AT_I2LOC_PRESET
                    value1 = I2.Loc.LocalizationManager.GetTranslation("Ability/" + e.name);
#else
                    value1 = e.name;
#endif
                }
                else
                {
                    value1 = "";
                }
            }
            else if (eventType == "CombatBuffLost" || eventType == "CombatDebuffLost")
            {
                AtavismEffect e = Abilities.Instance.GetEffect(effectID);
                if (e != null)
                {
#if AT_I2LOC_PRESET
                    value1 = I2.Loc.LocalizationManager.GetTranslation("Effects/" + e.name);
#else
                    value1 = e.name;
#endif
                }
                else
                {
                    value1 = "";
                }
            }
            else if (eventType == "CastingStarted")
            {
                if (int.Parse(value1) > 0)
                {
                    string[] csArgs = new string[2];
                    csArgs[0] = value1;
                    csArgs[1] = caster.ToString();
                    AtavismEventSystem.DispatchEvent("CASTING_STARTED", csArgs);
                }
                return;
            }
            else if (eventType == "CastingCancelled")
            {
                //    Debug.LogError("CastingCancelled 1");
                string[] ccArgs = new string[2];
                ccArgs[0] = abilityID.ToString();
                ccArgs[1] = caster.ToString();
                AtavismEventSystem.DispatchEvent("CASTING_CANCELLED", ccArgs);
                //   Debug.LogError("CastingCancelled 2");
                return;
            }
            // dispatch a ui event to tell the rest of the system
            try
            {
                string[] args = new string[9];
                args[0] = eventType;
                args[1] = caster.ToString();
                args[2] = target.ToString();
                args[3] = value1;
                args[4] = value2;
                args[5] = abilityID.ToString();
                args[6] = effectID.ToString();
                args[7] = value3;
                args[8] = value4;
                AtavismEventSystem.DispatchEvent("COMBAT_EVENT", args);
            }
            catch (System.Exception e)
            {
                Debug.LogError("COMBAT_EVENT Exception:" + e);
            }



            //ClientAPI.GetObjectNode(target.ToLong()).GameObject.GetComponent<MobController3D>().GotDamageMessage(messageType, value1);
        }