コード例 #1
0
ファイル: Block.cs プロジェクト: mdlandis/voidheart
        protected override void OnBeforeEvent(VEntity entity)
        {
            LowLevelDealDamageEvent dealDamage = entity.GetVComponent <LowLevelDealDamageEvent>();
            VEntity blockingEntity             = ecsManager.GetVEntityById(dealDamage.receiverId);

            BlockBuffComponent block = blockingEntity.GetVComponent <BlockBuffComponent>();

            if (block != null)
            {
                int blockDeduct = Math.Min(block.blockAmount, dealDamage.damageAmount);

                block.blockAmount       -= blockDeduct;
                dealDamage.damageAmount -= blockDeduct;

                if (blockingEntity.HasVComponent <BlockDisplayComponent>())
                {
                    int newBlockAmount = block.blockAmount;
                    NumberedIconDisplay blockDisplay = blockingEntity.GetVComponent <BlockDisplayComponent>().blockDisplay;
                    ecsManager.QueueAnimationEvent("blockRemoveEvent", component: new GenericBlockingAnimationEvent {
                        a = (passedEcsManager) => {
                            blockDisplay.transform.DOShakePosition(.5f, .1f);
                            blockDisplay.SetValue(newBlockAmount);
                        },
                        duration = 0.5f
                    });
                }
            }
        }
コード例 #2
0
ファイル: Block.cs プロジェクト: mdlandis/voidheart
        protected override void OnExecuteEvent(VEntity eventEntity)
        {
            BlockApplyEffectEvent blockEvent = eventEntity.GetVComponent <BlockApplyEffectEvent>();
            VEntity blockingEntity           = ecsManager.GetVEntityById(blockEvent.sourceId);

            if (!blockingEntity.HasVComponent <BlockBuffComponent>())
            {
                ecsManager.AddComponent(blockingEntity, new BlockBuffComponent {
                });
                ecsManager.AddComponent(blockingEntity, new BlockDisplayComponent {
                    blockDisplay = NumberedIconDisplay.Instantiate(iconDisplayPrefab)
                });

                NumberedIconDisplay blockDisplayForAppear = blockingEntity.GetVComponent <BlockDisplayComponent>().blockDisplay;
                blockDisplayForAppear.gameObject.transform.SetParent(blockingEntity.GetVComponent <PositionDisplayComponent>().mainTransform);
                blockDisplayForAppear.gameObject.transform.localPosition = new Vector3(.1f, .1f, 0.0f);

                ecsManager.QueueAnimationEvent("blockAppearAnim", component: new GenericImmediateAnimationEvent {
                    a = (passedEcsManager) => {
                        blockDisplayForAppear.Appear();
                    }
                });
            }

            BlockBuffComponent blockComponent = blockingEntity.GetVComponent <BlockBuffComponent>();

            blockComponent.blockAmount += (blockEvent.blockAmount);

            string blockAmountString         = blockComponent.blockAmount.ToString();
            NumberedIconDisplay blockDisplay = blockingEntity.GetVComponent <BlockDisplayComponent>().blockDisplay;

            ecsManager.QueueAnimationEvent("blockIncrement", component: new GenericImmediateAnimationEvent {
                a = (passedEcsManager) => {
                    blockDisplay.SetValue(blockAmountString);
                }
            });
        }