public void SetType (FarmerActionType type) { if (actionSprites.ContainsKey(type)) { rend.sprite = actionSprites[type]; } else { rend.sprite = moveMarker; } }
public bool CanAffordAction(FarmerActionType action, ICollection<Farmer.FarmerAction> includedPendingActions = null, Farmer.FarmerAction includedCurrentAction = null) { if (!actionCostDict.ContainsKey(action)) { return true; } int pendingCost = 0; if (includedPendingActions != null) { foreach (Farmer.FarmerAction actionPair in includedPendingActions) { if (actionCostDict.ContainsKey(actionPair.type)) { pendingCost += actionCostDict[actionPair.type]; } } } if (includedCurrentAction != null && actionCostDict.ContainsKey(includedCurrentAction.type)) { pendingCost += actionCostDict[includedCurrentAction.type]; } Counter pt = FindObjectOfType<Toolbar>().poopCounter; return pt.amount >= actionCostDict[action] + pendingCost; }
public bool CreatePrefabForAction (FarmerActionType action, Vector3 pos) { if (!prefabDict.ContainsKey(action)) { return false; } if (actionCostDict.ContainsKey(action)) { Counter pt = FindObjectOfType<Toolbar>().poopCounter; if (pt.amount < actionCostDict[action]) { FindObjectOfType<Farmer>().ClearActions(); return false; } else { pt.ChangeCount(-actionCostDict[action]); } } GameObject prefab = prefabDict[action]; // Check that cannot spawn past the grass limit. if (prefab.tag != "Grass" || GameObject.FindGameObjectsWithTag("Grass").Length < grassLimit) { GameObject instance = Instantiate<GameObject>(prefab); instance.transform.position = pos; return true; } else { return false; } }
public void EnqueueAction (FarmerActionType actionType, Vector2 target) { // don't judge me for not having a constructor FarmerAction newAction = new FarmerAction { type = actionType, target = target }; actions.AddLast(newAction); SetMarkers(); }