public static DetectiveManager GetInstantiate()
 {
     if (instance == null)
     {
         instance = FindObjectOfType <DetectiveManager>();
     }
     if (instance == null)
     {
         Game game = Game.GetInstantiate();
         instance = Instantiate(game.detectiveManager, game.transform);
     }
     return(instance);
 }
Beispiel #2
0
        private void Awake()
        {
            GetInstantiate();

            DontDestroyOnLoad(instance);
            ControlManager.GetInstantiate();
            DetectiveManager.GetInstantiate();
            TraitManager.GetInstantiate();
            ItemManager.GetInstantiate();
            QuestManager.GetInstantiate();
            MapManager.GetInstantiate();
            DialogManager.GetInstantiate();
            Agency.GetInstantiate();
        }
Beispiel #3
0
        public void ReturnToHome()
        {
            Agency agency = Agency.GetInstantiate();

            foreach (Team team in agency.teams)
            {
                team.RemoveDetective(this);
            }
            DetectiveManager detectiveManager = DetectiveManager.GetInstantiate();

            detectiveManager.TeamOnTarget(new List <Detective> {
                this
            }, home, null, activityPlace);
        }
Beispiel #4
0
        public void Realize(iEffectsContainer effectsContainer, Team team)
        {
            this.effectsContainer = effectsContainer;
            Game             game             = Game.GetInstantiate();
            Agency           agency           = Agency.GetInstantiate();
            QuestManager     questManager     = QuestManager.GetInstantiate();
            DetectiveManager detectiveManager = DetectiveManager.GetInstantiate();

            UI.InterfaceManager interfaceManager = UI.InterfaceManager.GetInstantiate();
            if (type == EffectType.INSTANTIATE_QUEST)
            {
                GameObject goFolder = null;
                if (agency.transform.Find("Quests"))
                {
                    goFolder = agency.transform.Find("Quests").gameObject;
                }
                else
                {
                    goFolder = new GameObject("Quests");
                    goFolder.transform.parent = agency.transform;
                }
                Quest questInstance = Instantiate(quest, goFolder.transform);
                agency.quests.Add(questInstance);
                questInstance.Realize();
            }
            else if (type == EffectType.CHANGE_QUEST)
            {
                GetQuest().ChangeMainState(mainState);
            }
            else if (type == EffectType.CHANGE_TASK)
            {
                if (effectsContainer is QuestTask)
                {
                    team.reportEvent.Add(questEvent);
                    team.reportChangeTask.Add(task);
                    team.reportTaskState.Add(mainState);
                    if (mainState == MainState.Started && task.mainState == MainState.NotStarted)
                    {
                        team.reportQuest.Add(GetQuest());
                        List <string> keys = new List <string>()
                        {
                            questEvent.eventName, task.taskName
                        };
                        FileNoteContainer noteContainer = FileNoteContainer.Create(Dialog.DialogManager.GetInstantiate().newTaskNote, team.transform, keys);
                        team.reportNotes.Add(noteContainer);
                    }
                }
                else
                {
                    questEvent.ChangeTask(task, mainState);
                }
            }
            else if (type == EffectType.CHANGE_OBJECTIVE)
            {
                if (effectsContainer is QuestTask)
                {
                    team.reportChangeObjective.Add(objective);
                    team.reportObjectiveState.Add(mainState);
                }
                else
                {
                    objective.state = mainState;
                }
            }
            else if (type == EffectType.CHANGE_QUEST_STATE || type == EffectType.CHANGE_DIALOG_STATE || type == EffectType.CHANGE_GLOBAL_STATE)
            {
                if (questState.type == QuestStateType.BOOL)
                {
                    questState.boolValue = boolValue;
                }
                else if (questState.type == QuestStateType.INT)
                {
                    questState.intValue = intValue;
                }
                else if (questState.type == QuestStateType.SPECIAL)
                {
                    questState.specialValue = stringValue;
                }
            }
            else if (type == EffectType.ADD_FILE_NOTE)
            {
                foreach (FileNote fileNote in fileNotes)
                {
                    if (fileNote != null)
                    {
                        if (effectsContainer is QuestTask)
                        {
                            team.reportQuest.Add(GetQuest());
                            team.reportNotes.Add(FileNoteContainer.Create(fileNote, team.transform));
                        }
                        else
                        {
                            GetQuest().notes.Add(FileNoteContainer.Create(fileNote, GetQuest().transform));
                        }
                    }
                }
            }
            else if (type == EffectType.ADD_ITEM)
            {
                if (team != null)
                {
                    Item newItem = Instantiate(item);
                    team.AddItem(newItem);
                    team.reportQuest.Add(GetQuest());
                    FileNoteContainer noteContainer = FileNoteContainer.Create(Dialog.DialogManager.GetInstantiate().addItemNote, team.transform, newItem.itemName);
                    team.reportNotes.Add(noteContainer);
                }
                else
                {
                    Item newItem = Instantiate(item, agency.transform);
                    agency.items.Add(newItem);
                }
            }
            else if (type == EffectType.CHANGE_MONEY)
            {
                agency.ChangeMoney(money);
            }
            else if (type == EffectType.REALIZE_TASK)
            {
                Team owner = effectsContainer.GetTeam();
                if (owner != null)
                {
                    if (!owner.targetTasks.Contains(task))
                    {
                        owner.targetTasks.Insert(0, task);
                    }
                }
            }
            else if (type == EffectType.REALIZE_LOGIC_MAP)
            {
                if (logicMapOwner == LogicMap.LogicMapOwnerType.QUEST)
                {
                    logicMap.RealizeLogicMap(GetQuest(), team);
                }
                else if (logicMapOwner == LogicMap.LogicMapOwnerType.QUEST_TASK)
                {
                    logicMap.RealizeLogicMap(task, team);
                }
            }
            else if (type == EffectType.START_DIALOG)
            {
                Dialog.DialogManager.GetInstantiate().StartDialog(dialog, team, GetQuest());
            }
            else if (type == EffectType.FINALIZE_TASK)
            {
                task.FinalizeTask();
            }
            else if (type == EffectType.TEAM_GOTO_OFFICE)
            {
                if (team != null)
                {
                    team.GoTo(agency.GetOffice(), team.GetPriorityWay(), true);
                }
            }
            else if (type == EffectType.TEAM_GOTO_HOMES)
            {
                if (team != null)
                {
                    for (int i = 0; i < team.detectives.Count; i++)
                    {
                        team.detectives[i].ReturnToHome();
                        i--;
                    }
                }
            }
            else if (type == EffectType.TEAM_GOTO_EVENT)
            {
                if (team != null)
                {
                    game.ChangeGameState(GameState.WAIT_ACTIVITY_CHOICE);
                    detectiveManager.teamOnWait = team;
                    interfaceManager.detectiveRow.ResetRow();
                }
            }
            else if (type == EffectType.TELEPORT_TO_EVENT)
            {
                if (team.curTarget is QuestEvent)
                {
                    ((QuestEvent)team.startPlace).RemoveTeam(team);
                    team.startPlace = questEvent;
                    questEvent.AddTeam(team);
                }
            }
            else if (type == EffectType.TIMELINE_ACTION_CHANGE_QUEST_STATE)
            {
                Timeline   timeline = Timeline.GetInstantiate();
                GameObject goAction = new GameObject(string.Format("TimelineAction_ChangeQuestState"));
                goAction.transform.parent = timeline.transform;
                TimelineAction action = goAction.AddComponent <TimelineAction>();
                action.actionType   = TimelineActionType.CHANGE_QUEST_STATE;
                action.questState   = questState;
                action.flag         = boolValue;
                action.value        = intValue;
                action.specialValue = stringValue;
                if (waitType == LogicMap.WaitType.ABSOLUTE)
                {
                    action.timer = GameTime.ConvertToFloat(waitTime);
                }
                else if (waitType == LogicMap.WaitType.RELATION)
                {
                    action.timer = timeline.GetTime() + GameTime.ConvertToFloat(waitTime);
                }
                timeline.RegistrateAction(action);
            }
            else if (type == EffectType.CHECK_QUEST)
            {
            }
        }
        public override void OnInspectorGUI()
        {
            Detective detective = (Detective)target;
            GUIStyle  boldStyle = new GUIStyle();

            boldStyle.fontStyle = FontStyle.Bold;
            DetectiveManager detectiveManager = DetectiveManager.GetInstantiate();

            if (!detectiveManager.GetDetectives().Contains(detective))
            {
                if (PrefabUtility.GetPrefabType(detective) == PrefabType.Prefab)
                {
                    if (GUILayout.Button("!!! Registrate !!!"))
                    {
                        detectiveManager.Registrate(detective);
                    }
                }
                else
                {
                    EditorGUILayout.LabelField("---Обратитесь к префабу для регистрации в Game!---");
                }
                GUILayout.Space(10);
            }
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(detective.activity.ToString());
            if (detective.activityPlace != null)
            {
                EditorGUILayout.LabelField(detective.activityPlace.GetPlaceName());
            }
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(10);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("characterName"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("characterAvatar"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("sex"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("age"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("characterStory"));
            GUILayout.Space(10);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("temper"));
            GUILayout.Space(10);
            GUILayout.Space(10);
            EditorGUILayout.LabelField("Parameters", boldStyle);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("curHealth"), new GUIContent("Health"));
            EditorGUILayout.LabelField(string.Format("{0}/{1}", detective.minHealth, detective.maxHealth));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("curStress"), new GUIContent("Stress"));
            EditorGUILayout.LabelField(string.Format("{0}/{1}", detective.minStress, detective.maxStress));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("curLoyalty"), new GUIContent("Loyalty"));
            EditorGUILayout.LabelField(string.Format("{0}/{1}", detective.minLoyalty, detective.maxLoyalty));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("curConfidence"), new GUIContent("Confidence"));
            EditorGUILayout.LabelField(string.Format("{0}/{1}", detective.minConfidence, detective.maxConfidence));
            EditorGUILayout.EndHorizontal();
            GUILayout.Space(10);
            EditorGUILayout.LabelField("Methods", boldStyle);
            for (int i = 0; i < detective.methods.Count; i++)
            {
                Method method = detective.methods[i];
                GUILayout.BeginHorizontal();
                detective.methodsValues[i] = EditorGUILayout.IntField(method.ToString(), detective.methodsValues[i]);
                EditorGUILayout.LabelField(string.Format("/ {0}", detective.maxMethodsValues[i]));
                GUILayout.EndHorizontal();
            }
            GUILayout.Space(10);
            eUtils.DrawTraitContainerList(detective.traits, detective.transform, ref showTrait);
            GUILayout.Space(10);
            EditorGUILayout.LabelField("Salary", boldStyle);
            Money salary = detective.salary;

            eUtils.DrawMoneyInspecor(ref salary);
            detective.salary = salary;
            GUILayout.Space(10);
            if (detective.GetMaxItemSlot() - detective.blockedSlots - detective.GetEquipment().Count < 0)
            {
                GUI.color = Color.red;
            }
            if (GUILayout.Button(string.Format("Equipment {0}/{1}", detective.GetEquipment().Count, detective.GetMaxItemSlot() - detective.blockedSlots)))
            {
                showEquipment = !showEquipment;
            }
            GUI.color = new Color(1, 1, 1);
            if (showEquipment)
            {
                ItemManager itemManager = ItemManager.GetInstantiate();
                for (int i = 0; i < detective.GetEquipment().Count; i++)
                {
                    EditorGUILayout.BeginHorizontal("box");
                    int lastIndex = itemManager.GetEquipment().IndexOf(detective.GetEquipment()[i].equipment);
                    int index     = EditorGUILayout.Popup(lastIndex, itemManager.GetEquipmentNames().ToArray());
                    if (index != -1 && index != lastIndex)
                    {
                        detective.GetEquipment()[i].equipment       = itemManager.GetEquipment()[index];
                        detective.GetEquipment()[i].gameObject.name = detective.GetEquipment()[i].equipment.name;
                    }
                    if (GUILayout.Button("Delete", new GUILayoutOption[] { GUILayout.Width(60) }))
                    {
                        DestroyImmediate(detective.GetEquipment()[i].gameObject);
                        detective.GetEquipment().RemoveAt(i);
                        break;
                    }
                    EditorGUILayout.EndHorizontal();
                }
                if (GUILayout.Button("Add equipmet"))
                {
                    detective.AddEquipment(null);
                }
            }
            GUILayout.Space(10);

            EditorGUILayout.PropertyField(serializedObject.FindProperty("home"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("priorityWay"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("wayColor"));
            serializedObject.ApplyModifiedProperties();
        }