public void AbilitiesPropertyHandler(object sender, ObjectPropertyChangeEventArgs args) { if (args.Oid != ClientAPI.GetPlayerOid()) { return; } List <object> abilities_prop = (List <object>)ClientAPI.GetPlayerObject().GetProperty("abilities"); AtavismLogger.LogDebugMessage("Got player abilities property change: " + abilities_prop); playerAbilities.Clear(); //int pos = 0; foreach (int abilityNum in abilities_prop) { if (!abilities.ContainsKey(abilityNum)) { AtavismLogger.LogWarning("Ability " + abilityNum + " does not exist"); continue; } AtavismAbility ability = abilities[abilityNum].Clone(tempCombatDataStorage); playerAbilities.Add(ability); } // dispatch a ui event to tell the rest of the system string[] event_args = new string[1]; AtavismEventSystem.DispatchEvent("ABILITY_UPDATE", event_args); }
public void LootParticlesHandler(object sender, ObjectPropertyChangeEventArgs args) { AtavismObjectNode worldObj = ClientAPI.WorldManager.GetObjectNode(args.Oid); if (worldObj == null) { AtavismLogger.LogWarning("Loot Particles: found no object"); return; } if (worldObj.CheckBooleanProperty("lootable")) { GameObject newLootParticle = (GameObject)GameObject.Instantiate(lootParticle, worldObj.GameObject.transform.position, Quaternion.identity); newLootParticle.transform.parent = worldObj.GameObject.transform; if (attachedLootParticles.ContainsKey(args.Oid)) { if (attachedLootParticles[args.Oid] != null) { Destroy(attachedLootParticles[args.Oid]); } attachedLootParticles.Remove(args.Oid); } attachedLootParticles.Add(args.Oid, newLootParticle); } else if (attachedLootParticles.ContainsKey(args.Oid)) { Destroy(attachedLootParticles[args.Oid]); attachedLootParticles.Remove(args.Oid); } }
public void RecipesPropertyHandler(object sender, ObjectPropertyChangeEventArgs args) { if (args.Oid != ClientAPI.GetPlayerOid()) { return; } LinkedList <object> recipes_prop = (LinkedList <object>)ClientAPI.GetPlayerObject().GetProperty("recipes"); Debug.Log("Got player recipes property change: " + recipes_prop); //LinkedList<string> recipeIDs = new LinkedList<string>(); int numRecipes = 0; Dictionary <string, object> props = new Dictionary <string, object>(); foreach (string recipeString in recipes_prop) { // Get items bool haveBlueprint = false; int recipeID = int.Parse(recipeString); foreach (Blueprint bp in blueprints) { if (bp.recipeID == recipeID) { haveBlueprint = true; } } if (!haveBlueprint) { props.Add("recipe" + numRecipes, recipeID); numRecipes++; } } props.Add("numRecipes", numRecipes); NetworkAPI.SendExtensionMessage(ClientAPI.GetPlayerOid(), false, "crafting.GET_BLUEPRINTS", props); }
public void LootParticlesHandler(object sender, ObjectPropertyChangeEventArgs args) { AtavismObjectNode worldObj = ClientAPI.WorldManager.GetObjectNode(args.Oid); if (worldObj == null) { AtavismLogger.LogWarning("Loot Particles: found no object"); return; } if (worldObj.CheckBooleanProperty("lootable")) { GameObject newLootParticle = (GameObject)GameObject.Instantiate(lootParticle, worldObj.GameObject.transform.position, Quaternion.identity); newLootParticle.transform.parent = worldObj.GameObject.transform; attachedLootParticles.Add(args.Oid, newLootParticle); } else if (attachedLootParticles.ContainsKey(args.Oid)){ Destroy(attachedLootParticles[args.Oid]); attachedLootParticles.Remove(args.Oid); } }
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); }
public void HandleState(object sender, ObjectPropertyChangeEventArgs args) { if (args.Oid == ClientAPI.GetPlayerOid()) { return; } string state = (string)ClientAPI.GetObjectProperty(args.Oid, args.PropName); if (state == "spirit") { ClientAPI.GetObjectNode(args.Oid).GameObject.SetActive(false); } else { ClientAPI.GetObjectNode(args.Oid).GameObject.SetActive(true); } }
public void AbilitiesPropertyHandler(object sender, ObjectPropertyChangeEventArgs args) { if (args.Oid != ClientAPI.GetPlayerOid()) return; LinkedList<object> abilities_prop = (LinkedList<object>)ClientAPI.GetPlayerObject().GetProperty("abilities"); AtavismLogger.LogDebugMessage("Got player abilities property change: " + abilities_prop); playerAbilities.Clear(); int pos = 0; foreach (int abilityNum in abilities_prop) { if (!abilities.ContainsKey(abilityNum)) { UnityEngine.Debug.LogWarning("Ability " + abilityNum + " does not exist"); continue; } Ability ability = abilities[abilityNum].Clone(gameObject); playerAbilities.Add(ability); } // dispatch a ui event to tell the rest of the system string[] event_args = new string[1]; AtavismEventSystem.DispatchEvent("ABILITY_UPDATE", event_args); }
public void ActionsPropertyHandler(object sender, ObjectPropertyChangeEventArgs args) { if (args.Oid != ClientAPI.GetPlayerOid()) return; UpdateActions(); }
public void RecipesPropertyHandler(object sender, ObjectPropertyChangeEventArgs args) { if (args.Oid != ClientAPI.GetPlayerOid()) return; LinkedList<object> recipes_prop = (LinkedList<object>)ClientAPI.GetPlayerObject().GetProperty("recipes"); Debug.Log("Got player recipes property change: " + recipes_prop); LinkedList<string> recipeIDs = new LinkedList<string>(); int numRecipes = 0; Dictionary<string, object> props = new Dictionary<string, object> (); foreach (string recipeString in recipes_prop) { // Get items bool haveBlueprint = false; int recipeID = int.Parse(recipeString); foreach(Blueprint bp in blueprints) { if (bp.recipeID == recipeID) haveBlueprint = true; } if (!haveBlueprint) { props.Add ("recipe"+ numRecipes, recipeID); numRecipes++; } } props.Add ("numRecipes", numRecipes); NetworkAPI.SendExtensionMessage (ClientAPI.GetPlayerOid(), false, "crafting.GET_BLUEPRINTS", props); }