コード例 #1
0
        public void SpawnNPCInLevel(string pNPCID, Vector2 pPosition, string pFacing, bool UpdateDataLocation = false)
        {
            NPCData NPC = GetNPC(pNPCID);

            foreach (NPCData npc in SpawnedNPCs)
            {
                if (npc.NPCID == NPC.NPCID)
                {
                    return;
                }
            }
            NPCData newNPC = Instantiate <NPCData>(NPC, pPosition, transform.rotation);

            CharacterDirection facing = (CharacterDirection)System.Enum.Parse(typeof(CharacterDirection), pFacing);

            newNPC.GetComponent <AnimationController>().ChangeFacing(facing);
            SpawnedNPCs.Add(newNPC);
            //            print("Spawning: " + newNPC.NPCID);

            if (UpdateDataLocation)
            {
                ChangeNPCDataLocation(pNPCID, SceneManager.GetActiveScene().name, pPosition);
            }
        }
コード例 #2
0
 void Start()
 {
     Data = GetComponent <NPCData>();
 }
コード例 #3
0
        bool CheckDailyFilter(Conversation pConversation, NPCData pNPC)
        {
            List <string> months = new List <string>();

            if (ShowDebug)
            {
                Debug.Log("Months: " + months);
            }
            string monthString = pConversation.LookupValue("Seasons");

            months = monthString.Split(',').ToList <string>();
            if (monthString != string.Empty && !months.Contains(TimeManager.Instance.CurrentMonth.Name.ToString()))
            {
                if (ShowDebug)
                {
                    Debug.Log("Months not compatible");
                }
                return(false);
            }

            string dayspanString = pConversation.LookupValue("DaySpans");

            if (ShowDebug)
            {
                Debug.Log("Day Spans: " + dayspanString);
            }
            if (dayspanString != string.Empty)
            {
                List <string> daySpans = dayspanString.Split('/').ToList <string>();
                foreach (string span in daySpans)
                {
                    if (ShowDebug)
                    {
                        Debug.Log("Span: " + span);
                    }
                    List <string> spantimes = span.Split(',').ToList <string>();
                    if (spantimes.Count < 2)
                    {
                        Debug.Log("Span format error");
                        continue;
                    }
                    int firstDay = int.Parse(spantimes[0]);
                    int lastDay  = int.Parse(spantimes[1]);
                    if (ShowDebug)
                    {
                        Debug.Log("Min: " + firstDay.ToString() + " Max: " + lastDay.ToString());
                    }
                    if (TimeManager.Instance.CheckWithinDaySpan(firstDay, lastDay) == false)
                    {
                        if (ShowDebug)
                        {
                            Debug.Log("Days not compatible. Not adding.");
                        }
                        return(false);
                    }
                }
            }

            int minYear     = pConversation.LookupInt("MinYear");
            int maxYear     = pConversation.LookupInt("MaxYear");
            int currentYear = TimeManager.Instance.CurrentYear;

            if (minYear > 0 && currentYear < minYear)
            {
                if (ShowDebug)
                {
                    Debug.Log("Year too low. Not adding.");
                }
                return(false);
            }
            if (maxYear > 0 && currentYear > maxYear)
            {
                if (ShowDebug)
                {
                    Debug.Log("Years too high. Not adding.");
                }
                return(false);
            }

            string        weatherSting = pConversation.LookupValue("Weathers");
            List <string> weathers     = weatherSting.Split(',').ToList <string>();

            if (ShowDebug)
            {
                Debug.Log("Weathers: " + weathers.ToString());
            }
            if (weatherSting != string.Empty && !weathers.Contains(WeatherManager.Instance.CurrentWeather.Name.ToString()))
            {
                if (ShowDebug)
                {
                    Debug.Log("Weathers not compatible. Not adding");
                }
                return(false);
            }

            float minAffection = pConversation.LookupFloat("MinAffection");
            float maxAffection = pConversation.LookupFloat("MaxAffection");

            if (pNPC.CurrentAffection < minAffection)
            {
                if (ShowDebug)
                {
                    Debug.Log("Affection too low. Not adding");
                }
                return(false);
            }
            if (maxAffection > 0 && pNPC.CurrentAffection > maxAffection)
            {
                if (ShowDebug)
                {
                    Debug.Log("Affection too high. Not adding");
                }
                return(false);
            }

            float minAcquaintance = pConversation.LookupFloat("MinAcquaintance");
            float maxAcquaintance = pConversation.LookupFloat("MaxAcquaintance");

            if (pNPC.CurrentAcquaintance < minAcquaintance)
            {
                if (ShowDebug)
                {
                    Debug.Log("Acquaintance too low. Not adding");
                }
                return(false);
            }
            if (maxAcquaintance > 0 && pNPC.CurrentAcquaintance > maxAcquaintance)
            {
                if (ShowDebug)
                {
                    Debug.Log("Acquaintance too high. Not adding");
                }
                return(false);
            }


            return(true);
        }