Ejemplo n.º 1
0
 public void Start()
 {
     child.SetActive(false);
     BtnOk.onClick.AddListener(delegate
     {
         CharacterDTO characterDto = PlayerSingleton.Singleton.GetNowCharacterTDO(_character.id);
         if (characterDto.Cost > 0 && PlayerSingleton.Singleton.Player.Money >= characterDto.Cost)
         {
             PlayerSingleton.Singleton.Player.Money -= characterDto.Cost;
         }
         UpdateTDO update = PlayerSingleton.Singleton.Player.Updates.FirstOrDefault(p => p.id == _character.id);
         if (update == null)
         {
             update = new UpdateTDO()
             {
                 id = _character.id
             };
             PlayerSingleton.Singleton.Player.Updates.Add(update);
         }
         update.Level++;
         update.StartUpdate = DateTime.Now;
         update.UpdateTime  = characterDto.UpdateTime;
         PlayerSingleton.Singleton.SavePlayer();
         child.SetActive(false);
     });
     BtnCansel.onClick.AddListener(delegate
     {
         child.SetActive(false);
     });
 }
Ejemplo n.º 2
0
        public int GetCharacterLevel(int id)
        {
            int       level = 0;
            UpdateTDO tDto  = player.Updates.FirstOrDefault(p => p.id == id);

            if (tDto != null)
            {
                level = tDto.Level;
            }
            return(level);
        }
Ejemplo n.º 3
0
        public bool NowIsUpdate(int id)
        {
            UpdateTDO update = GetUpdate(id);

            if (update != null)
            {
                DateTime dt = new DateTime(update.StartUpdate.Ticks);
                return(dt.AddSeconds(update.UpdateTime) > DateTime.Now);
            }
            return(false);
        }
Ejemplo n.º 4
0
    public void Update()
    {
        timeUpdate += Time.fixedDeltaTime;
        if (timeUpdate < 1)
        {
            return;
        }
        timeUpdate = 0;
        if (_propertyesInfo != null)
        {
            if (!PlayerSingleton.Singleton.NowIsUpdate(_propertyesInfo.id))
            {
                if (canUpdate)
                {
                    Init();
                }
                canUpdate = false;
                return;
            }
            update = PlayerSingleton.Singleton.GetUpdate(_propertyesInfo.id);

            if (update != null)
            {
                if (!canUpdate)
                {
                    endTimeTask         = new DateTime(update.StartUpdate.Ticks).AddSeconds(update.UpdateTime);
                    CharacterUpdateTime = update.UpdateTime;
                }
                canUpdate           = true;
                time                = (endTimeTask - DateTime.Now).TotalSeconds;
                procentage          = 1 - ((CharacterUpdateTime / 100) * (100d / CharacterUpdateTime * time)) / CharacterUpdateTime;
                BarImage.fillAmount = (float)procentage;


                BarText.text = TimeSpan.FromSeconds(time).GetTimeString();
            }
            else
            {
                if (canUpdate)
                {
                    Init();
                }
                canUpdate = false;
            }
        }
    }
Ejemplo n.º 5
0
    private void Init()
    {
        characterDto   = PlayerSingleton.Singleton.GetNowCharacterTDO(_propertyesInfo.id);
        level          = PlayerSingleton.Singleton.GetCharacterLevel(_propertyesInfo.id);
        LevelText.text = level.ToString();
        NameText.text  = _propertyesInfo.Name;
        PowerText.text = characterDto.Power.ToString();
        TimeText.text  = TimeSpan.FromSeconds(characterDto.UpdateTime).GetTimeString();
        if (_propertyesInfo.Characters.Count > 0 && !PlayerSingleton.Singleton.NowIsUpdate(_propertyesInfo.id))
        {
            BarText.text = String.Format("{0} / {1}", level, _propertyesInfo.Characters.Count - 1);
            if (_propertyesInfo.Characters.Count > 0)
            {
                BarImage.fillAmount = level / _propertyesInfo.Characters.Count;
            }
        }
        else
        {
            update = PlayerSingleton.Singleton.GetUpdate(_propertyesInfo.id);
        }
        CosText.text = characterDto.Cost.ToString();
        PlayerSingleton.Singleton.SetImageToCharacter(Image, _propertyesInfo.id);

        GetComponent <Button>().onClick.AddListener(delegate
        {
            if (PlayerSingleton.Singleton.NowIsUpdate(_propertyesInfo.id))
            {
                return;
            }
            if (level + 1 >= _propertyesInfo.Characters.Count)
            {
                return;
            }
            if (ConfirmUI == null)
            {
                ConfirmUI = GameObject.Find("ConfirmUI");
            }
            ConfirmUI.SetActive(true);
            ConfirmUI.GetComponent <ComfirmManager>()._propertyesInfo = _propertyesInfo;
        });
    }