public void Dead(int uniqId)
        {
            var sprite = GetSprite(uniqId);

            if (BattleDictionary.IsActor(uniqId))
            {
                sprite.SpriteRenderer.material.EnableKeyword(ShaderProperties.GREYSCALE_ON);
            }
            else
            {
                sprite.SpriteRenderer.material.DisableKeyword(ShaderProperties.SHADOW_ON);
                sprite.SpriteRenderer.material.EnableKeyword(ShaderProperties.FADE_ON);
                sprite.Ui.HpBar.gameObject.SetActive(false);
                float fade = 0f;
                DOTween.To(() => fade,
                           (x) => fade = x, 1f, 0.8f).Play().OnUpdate(() =>
                {
                    sprite.SpriteRenderer.GetPropertyBlock(sprite.MaterialPropertyBlock);
                    sprite.MaterialPropertyBlock.SetFloat(ShaderProperties.FadeAmount, fade);
                    sprite.SpriteRenderer.SetPropertyBlock(sprite.MaterialPropertyBlock);
                }).OnComplete(
                    () =>
                {
                    sprite.SpriteRenderer.enabled = false;
                });
            }
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        private void BattlerSpriteSubscribe()
        {
            List <int> uniqIds = EnemyDataModel.Instance.UniqIds();

            uniqIds.AddRange(MemberDataModel.Instance.UniqIds());
            uniqIds.ForEach(uniqId =>
            {
                //アクティブ時
                _container.Add(_battlerSpriteModel.GetData(uniqId).Active.Subscribe(isActive =>
                {
                    if (isActive)
                    {
                        AnnounceTextView.Instance.TurnStartText(uniqId);
                        _battlerSpriteView.DeActiveOutline();
                        _battlerSpriteView.OnActiveOutline(uniqId);
                        //メンバーの場合
                        if (BattleDictionary.IsActor(uniqId))
                        {
                            _battleModel.ActiveUniqId = uniqId;
                            _skillsView.SkillView(uniqId);
                        }
                        //敵の場合
                        else
                        {
                            _skillsView.SkillHide();
                            _battleManager.AiAction(uniqId);
                        }
                    }
                    else
                    {
                        _battlerSpriteView.DeActiveOutline();
                        _skillsView.SkillHide();
                    }
                }));
                //HPに変動があった時
                _container.Add(_battlerSpriteModel.GetData(uniqId).Hp.Subscribe(value =>
                {
                    _battlerSpriteView.HpBarRefresh(uniqId);
                }));
                //死んだ時
                _container.Add(_battlerSpriteModel.GetData(uniqId).Dead.Subscribe(isDead =>
                {
                    if (isDead)
                    {
                        _battlerSpriteView.Dead(uniqId);
                        BattleLogic.Dead(BattlerDictionary.GetBattlerByUniqId(uniqId));
                        //PlaySe.GetInstance().Play("SE/Miscs/MonsterDie");
                    }
                }));
                //状態異常にかかった時
                _container.Add(_battlerSpriteModel.GetData(uniqId).Status.Subscribe(_ =>
                {
                    _battlerSpriteView.StatusIconRefresh(uniqId);
                }));
            });
        }
        public void OnActiveOutline(int uniqId)
        {
            var sprite                = GetSprite(uniqId);
            var spriteRenderer        = sprite.SpriteRenderer;
            var materialPropertyBlock = sprite.MaterialPropertyBlock;

            spriteRenderer.material.EnableKeyword(ShaderProperties.OUTBASE_ON);
            spriteRenderer.GetPropertyBlock(materialPropertyBlock);
            if (BattleDictionary.IsActor(sprite.UniqId))
            {
                materialPropertyBlock.SetColor(ShaderProperties.OutlineColor, Color.yellow);
            }
            else
            {
                materialPropertyBlock.SetColor(ShaderProperties.OutlineColor, new Color(1f, 0.2758853f, 0.2f, 1f));
            }
            spriteRenderer.SetPropertyBlock(materialPropertyBlock);
        }