Exemple #1
0
    private void create()
    {
        GameObject o = null;

        o = Instantiate(PrefBackButton);
        o.transform.SetParent(transform, false);
        _backButton = o.GetComponent <Button>();

        Array array = Enum.GetValues(typeof(EZodiac));
        int   count = array.Length - 1; // except EZodiac.MAX

        for (int id = 0; id < count; ++id)
        {
            o = Instantiate(PrefCustomToggle);
            o.transform.SetParent(ToggleGroup.transform, false);

            EZodiac zodiac = (EZodiac)array.GetValue(id);

            ZodiacToggle zToggle = o.AddComponent <ZodiacToggle>();
            zToggle.Zodiac = zodiac;

            Toggle toggle = zToggle.Component;
            if (SelectedZodiac == zToggle.Zodiac)
            {
                toggle.isOn = true;
            }
            else
            {
                toggle.isOn = false;
            }

            toggle.group = ToggleGroup;
        }
    }
Exemple #2
0
    void Start()
    {
        MainCharacter mainCharacter = Manager.Instance.Object.MainCharacter;

        EConstitution constitution   = mainCharacter.Constitution;
        int           constitutionId = (int)constitution;
        Constitution  c = Manager.Instance.DT.Constitution[constitutionId];

        ConstitutionImage.sprite = c.sprite;
        ConstitutionImage.color  = c.color;
        //setConstitutionText(get(constitution));

        EZodiac zodiac = Manager.Instance.Object.NurtureMode.Character.Zodiac;

        ZodiacImage.sprite = get(zodiac);
        //setZodiacText(get(zodiac));

        int age = mainCharacter.Age;

        setAgeText(age);

        string name = mainCharacter.Name;

        setNameText(name);

        Manager.Instance.Object.NurtureMode.Character.AgeChangeEvent.Attach(onAgeChanged);
    }
        // constructor
        public Character(string name, EZodiac zodiac, int age, ECondition condition, int[] actionCount)
        {
            _name        = name;
            _zodiac      = zodiac;
            _age         = age;
            _condition   = condition;
            _actionCount = actionCount;

            _ageChangeEvent = new AgeChangeEvent();
            _statEvent      = new CharacterStatEvent();
            _conditionEvent = new CharacterConditionEvent();
        }
Exemple #4
0
    public MainCharacter(string name, EZodiac zodiac, int age, Nurture.ECondition condition, int[] actionCount,
                         EConstitution constitution, int money, Wardrobe wardrobe, int wearingCostumeId)
        : base(name, zodiac, age, condition, actionCount)
    {
        _constitution     = constitution;
        _money            = money;
        _wardrobe         = wardrobe;
        _wearingCostumeId = wearingCostumeId;

        // events
        _moneyChangeEvent = new MoneyChangeEvent();
        _buyCostumeEvent  = new BuyCostumeEvent();
        _wearCostumeEvent = new WearCostumeEvent();
    }
Exemple #5
0
    private Sprite get(EZodiac zodiac)
    {
        int zodiacId = (int)zodiac;

        if (zodiacId < 0)
        {
            return(null);
        }
        else if (zodiacId >= Manager.Instance.DT.Zodiac.Count)
        {
            return(null);
        }
        else
        {
            return(Manager.Instance.DT.Zodiac[zodiacId].image);
        }
    }
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);
    }