public void FeedPet(CarryItem food) { food.transform.parent = null; food.transform.position = FoodSlot.position; foodItem = food.gameObject; EnterState(PetState.Eating); }
public void FeedHuman(CarryItem food) { food.transform.parent = null; GameObject.Destroy(food.gameObject); Depression -= DepressionDecreaseOnFood; EnterState(HumanState.Eating); }
private void StoreItem(CarryItem item) { var slot = EmptySlots.FirstOrDefault(); if (slot == null) { return; } item.transform.position = slot.transform.position; item.transform.parent = slot.transform; }
public bool IsMet(GameObject triggerer) { bool condition_met = false; if (type == NarrativeConditionType.None) { condition_met = true; } if (type == NarrativeConditionType.CustomInt) { int i1 = NarrativeData.Get().GetCustomInt(target_id); int i2 = target_type == NarrativeConditionTargetType.Target ? NarrativeData.Get().GetCustomInt(other_target_id) : value_int; condition_met = CompareInt(i1, i2); } if (type == NarrativeConditionType.CustomFloat) { float f1 = NarrativeData.Get().GetCustomFloat(target_id); float f2 = target_type == NarrativeConditionTargetType.Target ? NarrativeData.Get().GetCustomFloat(other_target_id) : value_float; condition_met = CompareFloat(f1, f2); } if (type == NarrativeConditionType.CustomString) { string s1 = NarrativeData.Get().GetCustomString(target_id); string s2 = target_type == NarrativeConditionTargetType.Target ? NarrativeData.Get().GetCustomString(other_target_id) : value_string; condition_met = CompareString(s1, s2); } if (type == NarrativeConditionType.IsVisible) { GameObject targ = target.GetTargetObject(triggerer); condition_met = (targ != null && targ.activeSelf); if (targ != null) { condition_met = targ.activeSelf; } if (oper2 == NarrativeConditionOperator2.IsFalse) { condition_met = !condition_met; } } if (type == NarrativeConditionType.HoldItem) { GameObject targ = target.GetTargetObject(triggerer); if (targ && targ.GetComponent <CharacterHoldItem>()) { CharacterHoldItem character = targ.GetComponent <CharacterHoldItem>(); CarryItem item = character.GetHeldItem(); condition_met = (item != null && (item.item_type == value_string || value_string == "")); } if (oper2 == NarrativeConditionOperator2.IsFalse) { condition_met = !condition_met; } } if (type == NarrativeConditionType.InsideRegion) { GameObject targ = target.GetTargetObject(triggerer); if (targ && value_object) { if (value_object.GetComponent <Region>()) { condition_met = value_object.GetComponent <Region>().IsInside(targ); } } if (oper2 == NarrativeConditionOperator2.IsFalse) { condition_met = !condition_met; } } if (type == NarrativeConditionType.QuestStarted) { if (value_object && value_object.GetComponent <NarrativeQuest>()) { NarrativeQuest quest = value_object.GetComponent <NarrativeQuest>(); condition_met = NarrativeData.Get().IsQuestStarted(quest.quest_id); if (oper2 == NarrativeConditionOperator2.IsFalse) { condition_met = !condition_met; } } } if (type == NarrativeConditionType.QuestStartedActive) { if (value_object && value_object.GetComponent <NarrativeQuest>()) { NarrativeQuest quest = value_object.GetComponent <NarrativeQuest>(); condition_met = NarrativeData.Get().IsQuestActive(quest.quest_id); if (oper2 == NarrativeConditionOperator2.IsFalse) { condition_met = !condition_met; } } } if (type == NarrativeConditionType.QuestCompleted) { if (value_object && value_object.GetComponent <NarrativeQuest>()) { NarrativeQuest quest = value_object.GetComponent <NarrativeQuest>(); condition_met = NarrativeData.Get().IsQuestCompleted(quest.quest_id); if (oper2 == NarrativeConditionOperator2.IsFalse) { condition_met = !condition_met; } } } if (type == NarrativeConditionType.DialogueTriggered) { GameObject targ = target.GetTargetObject(); if (targ && targ.GetComponent <DialogueEvent>()) { DialogueEvent cinema = targ.GetComponent <DialogueEvent>(); condition_met = cinema.GetTriggerCount() >= 1; if (oper2 == NarrativeConditionOperator2.IsFalse) { condition_met = !condition_met; } } } if (type == NarrativeConditionType.CustomFunction) { if (custom_condition != null) { if (custom_condition.GetComponent <CustomContidion>() != null) { condition_met = custom_condition.GetComponent <CustomContidion>().IsMet(); } if (oper2 == NarrativeConditionOperator2.IsFalse) { condition_met = !condition_met; } } } return(condition_met); }
public void Trigger(GameObject triggerer) { if (type == NarrativeEffectType.CustomInt) { NarrativeData.Get().SetCustomInt(target_id, value_int); } if (type == NarrativeEffectType.CustomFloat) { NarrativeData.Get().SetCustomFloat(target_id, value_float); } if (type == NarrativeEffectType.CustomString) { NarrativeData.Get().SetCustomString(target_id, value_string); } if (type == NarrativeEffectType.Move) { GameObject targ = target.GetTargetObject(); GameObject targ_pos = value_object; if (targ != null && targ_pos != null) { targ.transform.position = targ_pos.transform.position; } } if (type == NarrativeEffectType.Show) { GameObject targ = target.GetTargetObject(); if (targ) { targ.SetActive(true); } } if (type == NarrativeEffectType.Hide) { GameObject targ = target.GetTargetObject(); if (targ) { targ.SetActive(false); } } if (type == NarrativeEffectType.Spawn) { GameObject targ = target.GetTargetObject(); if (targ != null) { GameObject.Instantiate(targ, triggerer.transform.position, Quaternion.identity); } } if (type == NarrativeEffectType.Destroy) { GameObject targ = target.GetTargetObject(triggerer); Destroy(targ); } if (type == NarrativeEffectType.DestroyHeld) { GameObject targ = target.GetTargetObject(triggerer); if (targ && targ.GetComponent <CharacterHoldItem>()) { CarryItem item = targ.GetComponent <CharacterHoldItem>().GetHeldItem(); if (item) { Destroy(item.gameObject); } } } if (type == NarrativeEffectType.StartDialogue) { GameObject targ = target.GetTargetObject(triggerer); if (targ && targ.GetComponent <DialogueEvent>()) { if (targ.GetComponent <DialogueEvent>().AreConditionsMet()) { NarrativeManager.Get().StartEvent(targ.GetComponent <DialogueEvent>()); } } if (targ && targ.GetComponent <DialogueChoice>()) { if (targ.GetComponent <DialogueChoice>().AreConditionsMet()) { targ.GetComponent <DialogueChoice>().Trigger(triggerer); } } } if (type == NarrativeEffectType.LockCamera) { FollowCamera pcam = FollowCamera.Get(); if (pcam != null) { pcam.LockCameraOn(value_object); } } if (type == NarrativeEffectType.UnlockCamera) { FollowCamera pcam = FollowCamera.Get(); if (pcam != null) { pcam.UnlockCamera(); } } if (type == NarrativeEffectType.LockGameplay) { foreach (PlayerControls controls in PlayerControls.GetAll()) { controls.disable_controls = true; } } if (type == NarrativeEffectType.UnlockGameplay) { foreach (PlayerControls controls in PlayerControls.GetAll()) { controls.disable_controls = false; } } if (type == NarrativeEffectType.StartQuest) { NarrativeQuest quest = value_object.GetComponent <NarrativeQuest>(); NarrativeData.Get().StartQuest(quest.quest_id); if (QuestBox.Get()) { QuestBox.Get().ShowBox(quest, "New Quest"); } } if (type == NarrativeEffectType.CancelQuest) { NarrativeQuest quest = value_object.GetComponent <NarrativeQuest>(); NarrativeData.Get().CancelQuest(quest.quest_id); if (QuestBox.Get()) { QuestBox.Get().ShowBox(quest, "Quest Failed"); } } if (type == NarrativeEffectType.CompleteQuest) { NarrativeQuest quest = value_object.GetComponent <NarrativeQuest>(); NarrativeData.Get().CompleteQuest(quest.quest_id); if (QuestBox.Get()) { QuestBox.Get().ShowBox(quest, "Quest Completed"); } } if (type == NarrativeEffectType.RunEvent) { GameObject targ = target.GetTargetObject(triggerer); if (targ && targ.GetComponent <NarrativeEvent>()) { targ.GetComponent <NarrativeEvent>().Run(triggerer); } } if (type == NarrativeEffectType.RunEventIfMet) { GameObject targ = target.GetTargetObject(triggerer); if (targ && targ.GetComponent <NarrativeEvent>()) { targ.GetComponent <NarrativeEvent>().RunIfConditionsMet(triggerer); } } if (type == NarrativeEffectType.CallFunction) { if (callfunc_evt != null) { callfunc_evt.Invoke(); } } }