Exemple #1
0
    //
    void Awake()
    {
        // load
        Nurture.Calendar calendar = loadCalendar();

        _mainCharacter = loadMainCharacter(calendar);
        loadAllStat(_mainCharacter);

        Story.TargetCharacter targetCharacter = loadTargetCharacter();

        // story
        _storyMode = new Story.Mode(targetCharacter);

        // nurture
        _nurtureMode = new Nurture.Mode(calendar, _mainCharacter);

        // board game
        _boardGameMode = new BoardGame.BoardGameMode();

        // combat
        _combatMode = new Combat.CombatMode();

        // events
        _endNurtureEvent = new EndNurtureEvent();

        // attach handler
        NurtureMode.Schedule.EndEvent.Attach(onScheduleEnd);
    }
Exemple #2
0
    //
    private void autoSaveNurture()
    {
        Nurture.Calendar calendar = NurtureMode.Calendar;
        CustomPlayerPrefs.SetInt(PlayerPrefsKey.YEAR, calendar.Year);
        CustomPlayerPrefs.SetInt(PlayerPrefsKey.MONTH, calendar.Month);

        Nurture.Character nurtureCharacter = NurtureMode.Character;
        int condition = (int)nurtureCharacter.Condition;

        CustomPlayerPrefs.SetInt(PlayerPrefsKey.CONDITION, condition);

        int actionCount = Manager.Instance.DT.Action.Count;

        for (int id = 0; id < actionCount; ++id)
        {
            string key = PlayerPrefsKey.GetKey(PlayerPrefsKey.ACTION_COUNT, id);
            CustomPlayerPrefs.SetInt(key, nurtureCharacter.GetActionCount(id));
        }

        CustomPlayerPrefs.SetInt(PlayerPrefsKey.MONEY, nurtureCharacter.Money);

        CustomPlayerPrefs.SetInt(PlayerPrefsKey.STRESS, nurtureCharacter.Stress);
        CustomPlayerPrefs.SetInt(PlayerPrefsKey.STAMINA, nurtureCharacter.Stamina);
        CustomPlayerPrefs.SetInt(PlayerPrefsKey.INTELLECT, nurtureCharacter.Intellect);
        CustomPlayerPrefs.SetInt(PlayerPrefsKey.GRACE, nurtureCharacter.Grace);
        CustomPlayerPrefs.SetInt(PlayerPrefsKey.CHARM, nurtureCharacter.Charm);
        CustomPlayerPrefs.SetInt(PlayerPrefsKey.ATTACK, nurtureCharacter.Attack);
        CustomPlayerPrefs.SetInt(PlayerPrefsKey.DEFENSE, nurtureCharacter.Defense);
        CustomPlayerPrefs.SetInt(PlayerPrefsKey.LEADERSHIP, nurtureCharacter.Leadership);
        CustomPlayerPrefs.SetInt(PlayerPrefsKey.TACTIC, nurtureCharacter.Tactic);
        CustomPlayerPrefs.SetInt(PlayerPrefsKey.MORALITY, nurtureCharacter.Morality);
        CustomPlayerPrefs.SetInt(PlayerPrefsKey.GOODNESS, nurtureCharacter.Goodness);
        CustomPlayerPrefs.SetInt(PlayerPrefsKey.SENSIBILITY, nurtureCharacter.Sensibility);
        CustomPlayerPrefs.SetInt(PlayerPrefsKey.ARTS, nurtureCharacter.Arts);
    }
Exemple #3
0
    // Use this for initialization
    void OnEnable()
    {
        Nurture.Calendar calendar = Manager.Instance.Object.NurtureMode.Calendar;

        string s = string.Format("{0} {1}  {2} {3}",
                                 calendar.Year, Def.YEAR_UNIT,
                                 calendar.Month, Def.MONTH_UNIT);

        _text.text = s;
    }
Exemple #4
0
    /********** Load **********/
    private Nurture.Calendar loadCalendar()
    {
        int year = CustomPlayerPrefs.GetInt(PlayerPrefsKey.YEAR, -1);

        if (year < 0)
        {
            Log.Error(string.Format("not found '{0}'", PlayerPrefsKey.YEAR));
            return(null);
        }

        int month = CustomPlayerPrefs.GetInt(PlayerPrefsKey.MONTH, -1);

        if (month < 0)
        {
            Log.Error(string.Format("not found '{0}'", PlayerPrefsKey.MONTH));
            return(null);
        }

        Nurture.Calendar calendar = new Nurture.Calendar(year, month, Def.INIT_DAY);
        return(calendar);
    }
Exemple #5
0
    // Use this for initialization
    void Start()
    {
        Nurture.Calendar _calendar = Manager.Instance.Object.NurtureMode.Calendar;
        if (null != _calendar)
        {
            setYearText(_calendar.Year.ToString());
            setMonthText(_calendar.Month.ToString());
            setDayText(_calendar.Day.ToString());
        }
        else
        {
            Log.Error("not found calendar");
        }

        setYearUnitText(Def.YEAR_UNIT);
        setMonthUnitText(Def.MONTH_UNIT);
        setDayUnitText(Def.DAY_UNIT);

        _calendar.YearChangeEvent.Attach(onYearChanged);
        _calendar.MonthChangeEvent.Attach(onMonthChanged);
        _calendar.DayChangeEvent.Attach(onDayChanged);
    }
Exemple #6
0
    private MainCharacter loadMainCharacter(Nurture.Calendar calendar)
    {
        if (null == calendar)
        {
            Log.Error("not found calendar");
            return(null);
        }

        string name = CustomPlayerPrefs.GetString(PlayerPrefsKey.NAME, null);

        if (null == name)
        {
            Log.Error(string.Format("not found Player's '{0}'", PlayerPrefsKey.NAME));
            return(null);
        }

        int zodiac = CustomPlayerPrefs.GetInt(PlayerPrefsKey.ZODIAC, -1);

        if (false == Enum.IsDefined(typeof(EZodiac), zodiac))
        {
            Log.Error(string.Format("not found '{0}'", PlayerPrefsKey.ZODIAC));
            return(null);
        }

        int age = Def.INIT_AGE + (calendar.Year - Def.INIT_YEAR);

        int condition = CustomPlayerPrefs.GetInt(PlayerPrefsKey.CONDITION, -1);

        if (false == Enum.IsDefined(typeof(Nurture.ECondition), condition))
        {
            Log.Error(string.Format("not found '{0}'", PlayerPrefsKey.CONDITION));
            return(null);
        }

        int[] actionCount = new int[Manager.Instance.DT.Action.Count];
        int   numAction   = actionCount.Length;

        for (int id = 0; id < numAction; ++id)
        {
            string key   = PlayerPrefsKey.GetKey(PlayerPrefsKey.ACTION_COUNT, id);
            int    value = CustomPlayerPrefs.GetInt(key, -1);
            if (value < 0)
            {
                Log.Error(string.Format("not found '{0}'", key));
                return(null);
            }

            actionCount[id] = value;
        }

        int constitution = CustomPlayerPrefs.GetInt(PlayerPrefsKey.CONSTITUTION, -1);

        if (false == Enum.IsDefined(typeof(EConstitution), constitution))
        {
            Log.Error(string.Format("not found '{0}'", PlayerPrefsKey.CONSTITUTION));
            return(null);
        }

        int money = CustomPlayerPrefs.GetInt(PlayerPrefsKey.MONEY, -1);

        if (money < Def.MIN_MONEY)
        {
            Log.Error(string.Format("not found '{0}'", PlayerPrefsKey.MONEY));
            return(null);
        }

        int wearingCostumeId = CustomPlayerPrefs.GetInt(PlayerPrefsKey.WEARING_COSTUME, -1);

        if (false == ExtMainCharacterCostume.IsValid(wearingCostumeId))
        {
            Log.Error(string.Format("not found '{0}'", PlayerPrefsKey.WEARING_COSTUME));
            return(null);
        }

        Wardrobe wardrobe     = new Wardrobe();
        int      costumeCount = Manager.Instance.DT.MainCharacterCostume.Count;

        for (int id = 0; id < costumeCount; ++id)
        {
            string key   = PlayerPrefsKey.GetKey(PlayerPrefsKey.ISBUY_COSTUME, id);
            int    value = CustomPlayerPrefs.GetInt(key, -1);
            if (-1 == value)
            {
                Log.Error(string.Format("not found '{0}'", key));
                return(null);
            }

            bool isBuy = PlayerPrefsKey.GetIntToBool(value);
            CostumeController costume = new CostumeController(id, isBuy);
            wardrobe.CostumeList.Add(costume);
        }

        EZodiac z = (EZodiac)zodiac;

        Nurture.ECondition c  = (Nurture.ECondition)condition;
        EConstitution      cs = (EConstitution)constitution;

        MainCharacter mc = new MainCharacter(name, z, age, c, actionCount, cs, money, wardrobe, wearingCostumeId);

        return(mc);
    }