コード例 #1
0
ファイル: TimelineView.cs プロジェクト: yuto1492/mon_rogelike
        private GameObject CreateCard(TimelineSerializableData item)
        {
            GameObject turnCard;

            if (BattleDictionary.IsActor(item.uniqId))
            {
                turnCard = Object.Instantiate((GameObject)Resources.Load("Prefabs/Battle/TurnCard"),
                                              Vector3.zero, Quaternion.identity, GameObject.Find("Timeline/TurnCards").transform);
            }
            else
            {
                turnCard = Object.Instantiate((GameObject)Resources.Load("Prefabs/Battle/EnemyTurnCard"),
                                              Vector3.zero, Quaternion.identity, GameObject.Find("Timeline/TurnCards").transform);
            }
            GameObject          battlerImage = turnCard.transform.Find("Mask/BattlerImage").gameObject;
            string              monsterId    = BattlerDictionary.GetBattlerByUniqId(item.uniqId).monsterId;
            MonsterSerializable monster      = MonsterDicionary.GetMonsterData(monsterId);
            var sprite = Resources.Load <Sprite>(monster.imageData.spritePath);
            //Sprite sprite = AssetDatabase.LoadAssetAtPath<Sprite>(monster.imageData.spritePath);
            var image = battlerImage.GetComponent <Image>();

            image.sprite = sprite;
            battlerImage.GetComponent <RectTransform>().sizeDelta =
                new Vector3(sprite.rect.width, sprite.rect.height);
            battlerImage.GetComponent <RectTransform>().localPosition = new Vector3(monster.imageData.timelineCard.x,
                                                                                    monster.imageData.timelineCard.y, 0);
            battlerImage.GetComponent <RectTransform>().localScale =
                new Vector3(monster.imageData.timelineCard.scaleX, monster.imageData.timelineCard.scaleY, 0);
            _turnCards.Add(new TimelineViewStruct()
            {
                Card = turnCard,
                Id   = item.id
            });
            return(turnCard);
        }
コード例 #2
0
        /// <summary>
        /// モンスターからドロップを抽選する
        /// </summary>
        /// <param name="monsterId"></param>
        /// <returns></returns>
        public static List <LootItemStruct> MonsterLootChoice(string monsterId)
        {
            var monsterData = MonsterDicionary.GetMonsterData(monsterId);
            //ドロップアイテムを抽選する
            var drops = DropLottery(monsterData.drops);

            return(drops);
        }
コード例 #3
0
        private SpriteRenderer CreateSprite(GameObject targetObject, string monsterId)
        {
            var monsterData    = MonsterDicionary.GetMonsterData(monsterId);
            var spriteRenderer = targetObject.AddComponent <SpriteRenderer>();

            spriteRenderer.sprite       = MonsterDicionary.GetSprite(monsterId);
            spriteRenderer.material     = Resources.Load("Material/AllinDefaultMaterials", typeof(Material)) as Material;
            spriteRenderer.sortingOrder = 2;
            return(spriteRenderer);
        }
コード例 #4
0
        private void CreateMemberSprite()
        {
            var actorsTransformParent = GameObject.Find("Actors");
            var members    = MemberDataModel.Instance.GetActorData();
            var memberSize = members.Count;

            foreach (var(battler, index) in members.Select((battler, index) => (battler, index)))
            {
                var        monsterData    = MonsterDicionary.GetMonsterData(battler.monsterId);
                GameObject memberObject   = new GameObject();
                var        spriteRenderer = CreateSprite(memberObject, battler.monsterId);
                var        padding        = 16 / memberSize;
                var        posX           = (padding * index) - (padding * (memberSize - 1) / 2) - (0.5f * memberSize);
                memberObject.transform.position = new Vector3(posX, -1.9f, 0);
                if (monsterData.imageData.actorScale != 0)
                {
                    memberObject.transform.localScale = new Vector3(monsterData.imageData.actorScale,
                                                                    monsterData.imageData.actorScale, 1);
                }

                memberObject.transform.SetParent(actorsTransformParent.transform, false);
                memberObject.AddComponent <BoxCollider2D>();
                var ui = Object.Instantiate(
                    (GameObject)Resources.Load("Prefabs/Battle/MemberInfo"), memberObject.transform.position, Quaternion.identity,
                    GameObject.Find("FrontCanvas/EnemiesInfo").transform
                    );
                var uiStruct = new UiStruct
                {
                    UiParent = ui.transform,
                    HpBar    = ui.transform.Find("HPBar"),
                    HpText   = ui.transform.Find("HPBar/ValueText"),
                    MpBar    = ui.transform.Find("MPBar"),
                    MpText   = ui.transform.Find("MPBar/ValueText")
                };
                uiStruct.HpText.GetComponent <TextMeshProUGUI>().SetText(battler.parameter.hp.ToString());
                uiStruct.MpText.GetComponent <TextMeshProUGUI>().SetText(battler.parameter.mp.ToString());
                float rate = (float)battler.parameter.hp / battler.parameter.maxHp;
                uiStruct.HpBar.GetComponent <Slider>().value = rate;
                rate = (float)battler.parameter.mp / battler.parameter.maxMp;
                uiStruct.MpBar.GetComponent <Slider>().value = rate;
                _sprites.Add(new BattlerSpriteStruct()
                {
                    UniqId                = battler.uniqId,
                    SpriteObject          = memberObject.transform,
                    SpriteRenderer        = spriteRenderer,
                    MaterialPropertyBlock = new MaterialPropertyBlock(),
                    Ui = uiStruct,
                    StatusTransform = ui.transform.Find("Status"),
                    Statuses        = new List <StateStruct>()
                });
            }
        }
コード例 #5
0
        /// <summary>
        /// スキルの習得
        /// </summary>
        /// <param name="battler"></param>
        /// <returns></returns>
        public static List <string> SkillLearning(BattlerSerializable battler)
        {
            var monster = MonsterDicionary.GetMonsterData(battler.monsterId);
            int level   = battler.level;

            if (battler.learning.Contains(SkillIds.ATTACK) == false)
            {
                battler.learning.Add(SkillIds.ATTACK);
            }
            monster.learning.ForEach(x =>
            {
                if (level >= x.learnLevel)
                {
                    if (battler.learning.Contains(x.skillId) == false)
                    {
                        battler.learning.Add(x.skillId);
                    }
                }
            });
            return(battler.learning);
        }
コード例 #6
0
        /// <summary>
        /// バトラーを作成する
        /// </summary>
        /// <param name="monsterId"></param>
        /// <param name="level"></param>
        public static BattlerSerializable Create(string monsterId, int level = 1)
        {
            MonsterSerializable monster = MonsterDicionary.GetMonsterData(monsterId);
            BattlerSerializable battler = new BattlerSerializable();

            battler.level     = level;
            battler.monsterId = monsterId;
            battler.name      = monster.data.name;
            battler.potential = monster.potential;
            battler.parameter = CalcParameter(monster, level);
            LevelUp(level, battler);
            battler.learning   = new List <string>();
            battler.learning   = SkillLearning(battler);
            battler.skills     = new List <string>();
            battler.skills     = AllSkillEquipment(battler);
            battler.resistRate = new BattlerSerializableResistRate();
            battler.status     = new List <BattlerSerializableStatus>();
            battler.ai         = monster.ai;
            battler.uniqId     = CreateUniqId();

            return(battler);
        }
コード例 #7
0
ファイル: ActorLogic.cs プロジェクト: yuto1492/mon_rogelike
 public static int CalcNeedExp(string monsterId, int level)
 {
     return((int)Math.Pow(MonsterDicionary.GetMonsterData(monsterId).data.needExp *level, (float)level / 10));
 }
コード例 #8
0
ファイル: ActorLogic.cs プロジェクト: yuto1492/mon_rogelike
        public static BattlerSerializable Create(string monsterId, int level = 1)
        {
            string name = MonsterDicionary.GetMonsterData(monsterId).data.name;

            return(Create(monsterId, name, level));
        }