public virtual void Use(Entity user, JoyObject target) { if (user.ManaRemaining < m_ManaCost) { return; } }
public static PhysicsResult IsCollision(Vector2Int from, Vector2Int to, WorldInstance worldRef) { Entity tempEntity = worldRef.GetEntity(to); if (tempEntity != null && from != to) { if (tempEntity.WorldPosition != from) { return(PhysicsResult.EntityCollision); } } if (worldRef.Walls.ContainsKey(to)) { return(PhysicsResult.WallCollision); } JoyObject obj = worldRef.GetObject(to); if (obj != null) { return(PhysicsResult.ObjectCollision); } else { return(PhysicsResult.None); } }
public void AttachJoyObject(JoyObject joyObject) { m_JoyObject = joyObject; m_SpriteRenderer = this.GetComponent <SpriteRenderer>(); if (m_JoyObject.JoyName.StartsWith("Downstairs") || m_JoyObject.JoyName.StartsWith("Upstairs")) { m_SpriteRenderer.sortingLayerName = "Walls"; } else if (m_JoyObject.GetType() == typeof(JoyObject)) { if (m_JoyObject.IsWall) { m_SpriteRenderer.sortingLayerName = "Walls"; } else { m_SpriteRenderer.sortingLayerName = "Terrain"; } } else { if (m_JoyObject.GetType() == typeof(ItemInstance)) { m_SpriteRenderer.sortingLayerName = "Objects"; } else { m_SpriteRenderer.sortingLayerName = "Entities"; } } this.name = m_JoyObject.JoyName + ":" + m_JoyObject.GUID; this.transform.position = new Vector3(m_JoyObject.WorldPosition.x, m_JoyObject.WorldPosition.y, 0.0f); }
/* * public static void PerformCombat(Entity attackerRef, Entity defenderRef) * { * ItemInstance attackerMainWeapon = attackerRef.GetEquipment("Hand1"); * ItemInstance attackerOffWeapon = attackerRef.GetEquipment("Hand2"); * * if (attackerMainWeapon != null) * { * int totalDamage = SwingWeapon(attackerRef, defenderRef, attackerMainWeapon); * * if (totalDamage > 0) * { * defenderRef.DamageMe(totalDamage); * } * } * * if (attackerOffWeapon == null || attackerOffWeapon.GUID == attackerMainWeapon.GUID) * return; * * int offHandDamage = SwingWeapon(attackerRef, defenderRef, attackerOffWeapon); * * if (offHandDamage > 0) * { * defenderRef.DamageMe(offHandDamage); * } * * if(!defenderRef.Alive) * { * attackerRef.FulfillNeed(NeedIndex.Morality, defenderRef.Sentient ? -5 : -1, 0); * attackerRef.AddExperience(defenderRef.Level); * QuestTracker.PerformEntityDestruction(attackerRef, defenderRef); * } * else if(!attackerRef.Alive) * { * defenderRef.AddExperience(attackerRef.Level); * QuestTracker.PerformEntityDestruction(defenderRef, attackerRef ); * } * } */ //PUT IN EVENT PROCESSING TRIGGERS AND STUFF public static int SwingWeapon(Entity attackerRef, JoyObject defenderRef, bool log = true) { ItemInstance mainHand = attackerRef.GetEquipment("Hand1"); ItemInstance offHand = attackerRef.GetEquipment("Hand2"); if (mainHand == null) { return(0); } int attackerToHit = RNG.RollSuccesses(attackerRef.Statistics[StatisticIndex.Agility].Value, attackerRef.Statistics[StatisticIndex.Agility].SuccessThreshold); int attackerSkillBonus = 0; if (mainHand.ItemType.GoverningSkill != "None") { if (attackerRef.Skills[mainHand.ItemType.GoverningSkill].value > 0) { attackerSkillBonus = RNG.RollSuccesses(attackerRef.Skills[mainHand.ItemType.GoverningSkill].value, attackerRef.Skills[mainHand.ItemType.GoverningSkill].SuccessThreshold); } } else { attackerSkillBonus = RNG.RollSuccesses(attackerRef.Skills["Throwing"].value, attackerRef.Skills["Throwing"].SuccessThreshold); } attackerToHit += attackerSkillBonus; if (defenderRef.GetType().Equals(typeof(Entity))) { Entity defender = (Entity)defenderRef; int defenderDodge = RNG.RollSuccesses(attackerRef.Statistics[StatisticIndex.Agility].Value, attackerRef.Statistics[StatisticIndex.Agility].SuccessThreshold); int defenderEvasion = 0; if (defender.Skills["Evasion"].value > 0) { defenderEvasion = RNG.RollSuccesses(defender.Skills["Evasion"].value, defender.Skills["Evasion"].SuccessThreshold); } defenderDodge += defenderEvasion; if (attackerToHit < defenderDodge) { if (log) { ActionLog.AddText(attackerRef.JoyName + " misses " + defenderRef.JoyName, LogType.Information); } return(0); } } int totalDamage = attackerToHit + attackerSkillBonus + RNG.RollSuccesses(attackerRef.Statistics[StatisticIndex.Strength].Value, attackerRef.Statistics[StatisticIndex.Strength].SuccessThreshold); if (log) { ActionLog.AddText(attackerRef.JoyName + " " + mainHand.ItemType.ActionString + " " + defenderRef.JoyName + " for " + totalDamage, LogType.Information); } return(totalDamage); }
public void AddObject(JoyObject objectRef) { if (objectRef.IsWall) { m_Walls.Add(objectRef.WorldPosition, objectRef); } else { m_Objects.Add(objectRef); } IsDirty = true; }
public static QuestStep MakeDestroyQuest(Entity provider, WorldInstance overworldRef) { QuestAction action = QuestAction.Destroy; int result = RNG.Roll(0, 1); JoyObject target = null; if (result == 0) { int breakout = 0; //Destroy an item while (breakout < 100) { Entity holder = overworldRef.GetRandomSentientWorldWide(); if (holder.Backpack.Count > 0) { result = RNG.Roll(0, holder.Backpack.Count - 1); target = holder.Backpack[result]; break; } breakout += 1; } if (breakout == 100) { target = overworldRef.GetRandomSentientWorldWide(); } } else { //Destroy a creature target = overworldRef.GetRandomSentientWorldWide(); } QuestStep step = new QuestStep(action, new List <ItemInstance>(), new List <JoyObject>() { target }, new List <World.WorldInstance>()); return(step); }
public MoonObject(JoyObject obj) { m_AssociatedObject = obj; }