示例#1
0
    public void UpdateModel()
    {
        if (model == null)
        {
            return;
        }
        intro_text.text = model._config.skill_des.Replace("t", "<color=#FF9A00>" + (int)model.GetHurtValue() + "</color>");
        double needMoney = 0;

        if (!model.IsLearn())
        {
            needMoney = model.GetLearnMoney();
            level_up_button.GetComponentInChildren <Text>().text = "学习";
            level_up_info_text.text = "学习需要金钱:" + ((ActorModel.Model.GetMoney() >= needMoney) ? "<color=green>" : "<color=red>") + needMoney + "</color>";
        }
        else
        {
            needMoney = model.GetLevelUpMoney();
            level_up_button.GetComponentInChildren <Text>().text = "升级";
            level_up_info_text.text = DreamerUtil.GetColorRichText("\t\t等级:" + model.GetSkillLevel(), Color.white) + "\n升级所需金钱: " + ((ActorModel.Model.GetMoney() >= needMoney) ? "<color=green>" : "<color=red>") + needMoney + " </color>";
        }

        level_up_button.interactable = ActorModel.Model.GetMoney() >= needMoney;
        level_up_button.GetComponentInChildren <Text>().color = ActorModel.Model.GetMoney() >= needMoney ? Color.yellow : Color.gray;
    }
示例#2
0
    private void Awake()
    {
        if (!GetComponent <AudioSource>())
        {
            _audio = gameObject.AddComponent <AudioSource>();
        }

        _clips = DreamerUtil.GetScriptableObject <AudioClips>();
    }
示例#3
0
    public void SignIn()
    {
        ActorModel.Model.SignInDate.Add(TimeModel.Instance.Now);
        View.CurrentScene.GetView <SignInView>().UpdateCell();
        View.CurrentScene.GetView <SignInView>().isTiming = true;
        var money = double.Parse(ItemValueText.text.Trim('x'));

        ActorModel.Model.SetMoney(money);
        View.CurrentScene.OpenView <TipView>().SetContent("签到成功! \n获得奖励" + DreamerUtil.GetColorRichText("    金币: x" + money, Color.yellow));
    }
示例#4
0
 public void UpdateReadyState(bool ready)
 {
     if (isLocal)
     {
         return;
     }
     this.isReady = ready;
     DreamerTool.UI.View.CurrentScene.GetView <RoomView>().CheckReady();
     ready_text.text = ready ? DreamerUtil.GetColorRichText("已准备", Color.green) : DreamerUtil.GetColorRichText("未准备", Color.red);
 }
示例#5
0
    public void Init()
    {
        player_name_text.text = ActorModel.Model.actor_name + " (" + ActorModel.Model.knightLevel + ")";
        var attrubutes = Enum.GetNames(typeof(PlayerAttribute));

        for (int i = 0; i < attrubutes.Length; i++)
        {
            player_attribute_text[i].transform.GetChild(0).gameObject.SetActive(false);
            player_attribute_text[i].text = attrubutes[i] + ": " + DreamerUtil.GetColorRichText(ActorModel.Model.GetPlayerAttribute((PlayerAttribute)Enum.Parse(typeof(PlayerAttribute), attrubutes[i])).ToString(), Color.yellow);
        }
    }
        public static void InitByScriptableObject()
        {
            var prefabs = DreamerUtil.GetScriptableObject <GameObjectPoolPrefabs>();

            foreach (var item in prefabs.Prefabs)
            {
                var prefabType = item.prefabType.String2Enum <GameObjectPoolPrefabType>();
                if (!pools.ContainsKey(prefabType))
                {
                    pools.Add(prefabType, new GameObjectPool(item.prefab));
                }
            }
        }
        public static void AddGameObjectPoolPrefabType(List <GameObject> gameObjectLst)
        {
            var path = AssetDataBaseManager.GetScriptPath(DreamerToolConfig.GameObjectPrefabTypeName);

            if (path == "")
            {
                return;
            }

            using (StreamWriter sw = new StreamWriter(new FileStream(path, FileMode.Truncate)))
            {
                StringBuilder result = new StringBuilder();
                var           header = "public enum GameObjectPoolPrefabType\n{";
                result.Append(header);
                foreach (int v in Enum.GetValues(typeof(GameObjectPoolPrefabType)))
                {
                    result.Append("\n\t");
                    string strName = Enum.GetName(typeof(GameObjectPoolPrefabType), v);
                    var    gameObj = gameObjectLst.Find(gameObject => { return(gameObject.name == strName); });
                    if (gameObj != null)
                    {
                        gameObjectLst.Remove(gameObj);
                    }

                    result.Append(strName);
                    result.Append(",");
                }



                foreach (var gameObject in gameObjectLst)
                {
                    result.Append("\n\t");
                    result.Append(gameObject.name);
                    result.Append(",");
                }


                result.Append("\n}");
                sw.Write(result.ToString());
            }

            var prefabs = DreamerUtil.GetScriptableObject <GameObjectPoolPrefabs>();

            foreach (var gameObject in gameObjectLst)
            {
                prefabs.AddGameObject(new GameObjectPoolPrefab(gameObject.name, gameObject));
            }
        }
示例#8
0
    public void LevelUp()
    {
        if (!model.IsLearn())
        {
            View.CurrentScene.OpenView <TipView>().SetContent(DreamerUtil.GetColorRichText(model._config.skill_name, Color.yellow) + "\t学习成功!");
            model.Learn();
        }
        else
        {
            View.CurrentScene.OpenView <TipView>().SetContent(DreamerUtil.GetColorRichText(model._config.skill_name, Color.yellow) + "\t升级成功!");
        }
        model.SetSkillLevel(1);

        ActorModel.Model.SetMoney(-model.GetLevelUpMoney());
        EventManager.OnSkillLevelUp(model);
    }
示例#9
0
    IEnumerator TextAnim(Text t, double value, double end, string c)
    {
        while (value != end)
        {
            if (value > end)
            {
                value--;
            }
            else
            {
                value++;
            }

            t.text = c + DreamerUtil.GetColorRichText(value.ToString(), Color.yellow);

            yield return(null);
        }
    }
示例#10
0
 public void OnChallengeBtnClick()
 {
     if (ActorModel.Model.GetMoney() >= 1000)
     {
         CurrentScene.OpenView <BoxView>().SetText("你确定要进行挑战吗?\n需要支付" + DreamerUtil.GetColorRichText("1000金币", Color.yellow) + "门票费用哦", (v) => {
             if (v)
             {
                 EndlessScene.level = levelIndex;
                 ActorModel.Model.SetMoney(-1000);
                 LoadingScene.LoadScene(GameConstData.ENDLESSS_SCENE_NAME);
             }
         });
     }
     else
     {
         CurrentScene.OpenView <TipView>().SetContent("没钱来干什么,挑战一次需要1000金币!");
     }
 }
    private static void AddToGameObjectPool()
    {
        var config        = DreamerUtil.GetScriptableObject <GameObjectPoolPrefabs>();
        var selectObjects = Selection.objects;
        List <GameObject> gameObjectList = new List <GameObject>();

        foreach (var selectedobject in selectObjects)
        {
            if (selectedobject is GameObject)
            {
                gameObjectList.Add(selectedobject as GameObject);
            }
            else
            {
                Debug.Log(selectedobject.name + "不是预制体");
            }
        }

        GameObjectPoolManager.AddGameObjectPoolPrefabType(gameObjectList);
    }
示例#12
0
 public IEnumerator GetTime()
 {
     yield return(StartCoroutine(DreamerUtil.GetDateTimeFromURL((time) => {
         Now = time;
     })));
 }
示例#13
0
    public void GetHurt(AttackData attackData)
    {
        if (enemy_data.isdie)
        {
            return;
        }
        if (!isSuperArmor)
        {
            transform.rotation = attackData.attack_pos.x > transform.position.x ? Quaternion.Euler(0, 180, 0) : Quaternion.identity;
        }
        var hurt = DreamerUtil.GetHurtValue(attackData.hurt_value, model.GetDefend());

        enemy_data.SetHealth(-hurt);

        var pop_text = GameObjectPoolManager.GetPool("pop_text").Get(transform.position + popTextOffset, Quaternion.identity, 0.5f);

        pop_text.GetComponent <PopText>().SetText(Mathf.RoundToInt((float)hurt).ToString(), attackData.isCrit?Color.red:Color.white);

        View.CurrentScene.GetView <GameInfoView>().enemy_health.SetData(enemy_data);

        AudioManager.Instance.PlayOneShot("hit");
        GameObjectPoolManager.GetPool("hit_effect").Get(transform.position + new Vector3(0, 2, 0), Quaternion.identity, 0.5f);


        if (isSuperArmor)
        {
            attackData.attack_type = HitType.普通;
        }


        GameStaticMethod.ChangeChildrenSpriteRendererColor(gameObject, Color.red);

        switch (attackData.attack_type)
        {
        case HitType.普通:
            if (!isGround)
            {
                _rigi.ClearGravity();
            }
            _rigi.ResetVelocity();
            _anim.SetTrigger("hit");
            break;

        case HitType.击退:

            if (!isGround)
            {
                _rigi.ResetVelocity();
                _rigi.ClearGravity();
            }
            else
            {
                _rigi.ResetVelocity();
                _rigi.AddForce(transform.right * hit_back_distance, ForceMode2D.Impulse);
            }
            _anim.SetTrigger("hit");
            break;

        case HitType.击飞:
            _anim.SetTrigger("hitfly");
            _rigi.ResetVelocity();
            if (isGround)
            {
                _rigi.AddForce(new Vector2(transform.right.x * 0.5f, 0.5f).normalized *hit_fly_distance, ForceMode2D.Impulse);
            }
            else
            {
                _rigi.AddForce(new Vector2(transform.right.x * 0.5f, 0).normalized *hit_fly_distance, ForceMode2D.Impulse);
            }
            break;

        case HitType.挑:
            _rigi.ResetVelocity();
            _rigi.AddForce(Vector2.up * 95, ForceMode2D.Impulse);
            break;

        default:
            break;
        }
    }
示例#14
0
    public void UpdatePlayAttributeText(PlayerAttribute attribute, double value)
    {
        //   StopAllCoroutines();

        var start = ActorModel.Model.GetPlayerAttribute(attribute) - value;

        var coroutine = StartCoroutine(TextAnim(player_attribute_text[(int)attribute], start, ActorModel.Model.GetPlayerAttribute(attribute), attribute + ": "));

        if (coroutines.ContainsKey(attribute))
        {
            if (coroutines[attribute] != null)
            {
                StopCoroutine(coroutines[attribute]);
            }
            coroutines.Remove(attribute);
        }
        coroutines.Add(attribute, coroutine);

        player_attribute_text[(int)attribute].transform.GetChild(0).gameObject.SetActive(false);
        player_attribute_text[(int)attribute].transform.GetChild(0).gameObject.SetActive(true);

        player_attribute_text[(int)attribute].transform.GetChild(0).GetComponent <Text>().text = DreamerUtil.GetColorRichText("(" + (value > 0?"+":"") + value + ")", (value > 0?Color.green:Color.red));
    }