private static HarvestAction ParseHarvestAction(Entity entity, MapController mapController, Dictionary <string, string> fields) { HarvestAction harvestAction = ParseAction <HarvestAction>(mapController, fields); harvestAction.resource = (Resource)Enum.Parse(typeof(Resource), fields[nameof(HarvestAction) + "." + nameof(HarvestAction.resource)], true); harvestAction.harvestAmount = ParseCost(fields, nameof(HarvestAction) + "."); AssetDatabase.CreateAsset(harvestAction.harvestAmount, "Assets/ScriptableObjects/Costs/Harvests/" + entity.name + "HarvestCost.asset"); return(harvestAction); }
private void IncrementResources() { foreach (Entity entity in entities.Values) { Actions.Action action = entity.GetAction(ActionType.HARVEST); if (action != null) { HarvestAction harvestAction = (HarvestAction)action; resources.Increment(harvestAction.GetHarvestAmount()); } } }
public static Entity ParseEntity(Dictionary <string, string> fields) { EntityParser entity = ScriptableObject.CreateInstance <EntityParser>(); entity.name = fields[nameof(name)]; entity.m_Type = GetOrCreateEntityType(fields[nameof(name)], fields[nameof(entity.Type.EntityClass)]); entity.m_MaxActionPoints = Int32.Parse(fields[nameof(ActionPoints)]); entity.m_MaxHp = Int32.Parse(fields[nameof(Hp)]); entity.m_Hp = entity.m_MaxHp; entity.m_Defense = Int32.Parse(fields[nameof(Defense)]); entity.m_Cost = ParseCost(fields); AssetDatabase.CreateAsset(entity.Cost, "Assets/ScriptableObjects/Costs/Entities/" + entity.name + "Cost.asset"); MapController mapController = AssetDatabase.LoadAssetAtPath <MapController>("Assets/ScriptableObjects/MapController.asset"); if (fields.Keys.Any(field => field.Contains(nameof(MoveAction)))) { MoveAction moveAction = ParseMoveAction(mapController, fields); AssetDatabase.CreateAsset(moveAction, "Assets/ScriptableObjects/Actions/MoveActions/" + entity.name + "MoveAction.asset"); entity.AddAction(moveAction); } if (fields.Keys.Any(field => field.Contains(nameof(AttackAction)))) { AttackAction attackAction = ParseAttackAction(mapController, fields); AssetDatabase.CreateAsset(attackAction, "Assets/ScriptableObjects/Actions/AttackActions/" + entity.name + "AttackAction.asset"); entity.AddAction(attackAction); } if (fields.Keys.Any(field => field.Contains(nameof(BuildAction)))) { BuildAction buildAction = ParseBuildAction(mapController, fields); AssetDatabase.CreateAsset(buildAction, "Assets/ScriptableObjects/Actions/BuildActions/" + entity.name + "BuildAction.asset"); entity.AddAction(buildAction); } if (fields.Keys.Any(field => field.Contains(nameof(HarvestAction)))) { HarvestAction harvestAction = ParseHarvestAction(entity, mapController, fields); AssetDatabase.CreateAsset(harvestAction, "Assets/ScriptableObjects/Actions/HarvestActions/" + entity.name + "HarvestAction.asset"); entity.AddAction(harvestAction); } if (fields.Keys.Any(field => field.Contains(nameof(HealAction)))) { HealAction healAction = ParseHealAction(mapController, fields); AssetDatabase.CreateAsset(healAction, "Assets/ScriptableObjects/Actions/HealActions/" + entity.name + "HealAction.asset"); entity.AddAction(healAction); } return((Entity)entity); }
private void HandleHarvestAction(HarvestAction ha) { DateTime now = DateTime.Now; ChatManager.ServerMessageToAllLoc(EcoAnalyzerProtocol1.HarvestMessage(now, ha), false, category: ChatCategory.Info); }
public Mine() : base("Mine", new Cost(), 3) { HarvestAction harvestAction = new HarvestAction(Harvest); this.AddAction(harvestAction); }
internal static string HarvestMessage(DateTime timestamp, HarvestAction a) { return($"Harvest(timestamp={timestamp:u}, worldtime={a.TimeSeconds}, item={a.SpeciesName}, user={a.Username})\n"); }
public HarvestResourceAction(IslandElement resource, HarvestAction action) { harvestTime = 0f; this.resource = resource; this.action = action; }