private void SaveActionButtons(SaveData data) { for (var i = 0; i < actionButtons.Length; i++) { if (actionButtons[i].MyUsable != null) { var a = new ActionButtonData((actionButtons[i].MyUsable as Projectile).MyName, i); data.MyActionButtonData.Add(a); } } }
private void doGoodAction(ActionButtonData button) { GameData.food += button.affected_food; if (GameData.food < 0) { GameData.food = 0; } GameData.resources += button.affected_resources; if (GameData.resources < 0) { GameData.resources = 0; } GameData.population_size += button.affected_people; GameData.population_abilities.addChromozome(button.affected_chromozome); }
/// <summary> /// Enregistrement des données des boutons d'actions /// </summary> /// <param name="data">Données de sauvegarde</param> private void SaveActionButtons(SaveData data) { for (int i = 0; i < actionButtons.Length; i++) { if (actionButtons[i].MyUseable != null) { ActionButtonData actionButtonData; if (actionButtons[i].MyUseable is Spell) { actionButtonData = new ActionButtonData((actionButtons[i].MyUseable as Spell).MyTitle, false, i); } else { actionButtonData = new ActionButtonData((actionButtons[i].MyUseable as Item).MyKey, true, i); } data.MyActionButtonData.Add(actionButtonData); } } }
private void onClick(ActionButtonData button, GameObject go) { string validated = validator.validate(button); // verifica daca exista destule resurse pentru a efectua actiunea if (String.IsNullOrEmpty(validated)) // string gol => nu a fost nici o eroare, se poate executa { EnergyBarManager.Instance.consumeEnergy(); double requested_ability_percentage = GameData.population_abilities.abilities[button.requested_ability]; if (requested_ability_percentage >= button.requested_ability_percentage) { doGoodAction(button); } else { doBadAction(button); StartCoroutine(showErrorPanel(button.bad_message)); } } else { StartCoroutine(showErrorPanel(validated)); } }