/// <summary>
    /// 造成伤害
    /// </summary>
    /// <param name="attackHurtStruct"></param>
    public override CalculateHurt.Result GiveAttackHurtStruct(AttackHurtStruct attackHurtStruct)
    {
        IPlayerState        iPlayerState        = GameState.Instance.GetEntity <IPlayerState>();
        IAttributeState     playerAttribute     = iPlayerState.GetResultAttribute();
        PhysicDefenseFactor physicDefenseFactor = new PhysicDefenseFactor()//物理防御系数
        {
            CoefficientRatioReducingDamageFactor = iPlayerState.SelfRoleOfRaceInfoStruct.physicDefenseToHurtRateRatio,
            ImmunityInjury = iPlayerState.SelfRoleOfRaceInfoStruct.physicQuickToHurtExemptRatio
        };
        MagicDefenseFactor magicDefenseFactor = new MagicDefenseFactor() //魔法防御系数
        {
            CoefficientRatioReducingDamageFactor = iPlayerState.SelfRoleOfRaceInfoStruct.magicDefenseToHurtRateRatio
        };

        CalculateHurt.Result calculateHurtResult = CalculateHurt.Calculate(attackHurtStruct, playerAttribute, physicDefenseFactor, magicDefenseFactor);
        if (calculateHurtResult.hurt >= 0)
        {
            if (calculateHurtResult.hurt != 0)
            {
                //减血(因为这里是整合的属性,必须在外部将自身血量减去)
                iPlayerState.HP -= calculateHurtResult.hurt;
                //终端咏唱
                ISkillState iSkillState = GameState.Instance.GetEntity <ISkillState>();
                iSkillState.GetHitToSkillState();
                //手柄震动
                iPlayerState.SetVibration(0.1f, 0.7f, 0.7f);
            }
            //显示伤害
            base.ShowHurt(calculateHurtResult, iPlayerState.PlayerObj);
        }
        return(calculateHurtResult);
    }
예제 #2
0
    private void ClickOK(BaseEventData data)
    {
        if (addPoint > 0)
        {
            playerState.PropertyPoint -= addPoint;
            IAttributeState baseAttribute = iPlayerAttributeState.GetAttribute(0);//基础属性
            switch (BaseAttributeType)
            {
            case EnumBaseAttributeType.Power:
                playerState.Strength += addPoint;
                baseAttribute.Power  += addPoint;
                break;

            case EnumBaseAttributeType.Mental:
                playerState.Spirit   += addPoint;
                baseAttribute.Mental += addPoint;
                break;

            case EnumBaseAttributeType.Quick:
                playerState.Agility += addPoint;
                baseAttribute.Quick += addPoint;
                break;
            }
            addPoint = 0;
            UpdateShow();
        }
    }
예제 #3
0
 /// <summary>
 /// 玩家属性发生更改
 /// </summary>
 /// <param name="iAttribute"></param>
 /// <param name="fieldName"></param>
 private void IAttributeStateChanged(IAttributeState iAttribute, string fieldName)
 {
     if (string.Equals(fieldName, GameState.Instance.GetFieldName <IAttributeState, float>(temp => temp.ExemptionChantingTime)))//咏唱时间改变
     {
         ChangeHoldingImage();
     }
 }
예제 #4
0
 /// <summary>
 /// 监听属性发生变化,主要是监听速度
 /// </summary>
 /// <param name="iAttribute"></param>
 /// <param name="fieldName"></param>
 private void IAttributeStateChanged(IAttributeState iAttribute, string fieldName)
 {
     if (string.Equals(fieldName, GameState.GetFieldNameStatic <IAttributeState, float>(temp => temp.AttackSpeed)))
     {
         attackSpeed = iAttributeState.AttackSpeed;
     }
 }
            public void Parse(IMpeg2VideoReader reader, IAttributeState resultState)
            {
                resultState.Name = Attribute.UserDataBytes;

                // User data size limit (4 KB)
                uint maxUserDataLength = reader.State.Configuration.UserDataMaxLength;

                // Verify and copy user data bytes
                var sb = new StringBuilder();

                while ((reader.ShowBits(24) != 1) && reader.HasBytes(1))
                {
                    // Verify that there are no 23 or more consecutive zero bits
                    if ((reader.ShowBits(23) == 0) && reader.HasBytes(3))
                    {
                        if (!IsValidUserDataThatEndsWithOneOrTwoZeroBytes(reader))
                        {
                            resultState.Invalidate();
                        }
                        break;
                    }

                    // Read next byte
                    sb.Append((char)reader.GetBits(8));

                    if (sb.Length > maxUserDataLength)
                    {
                        resultState.Invalidate();
                        break;
                    }
                }

                // TODO: the formatter should perform the hexdump (to reduce memory footprint)
                resultState.Value = sb.ToString();
            }
예제 #6
0
        public void Parse(IMpeg2SystemReader reader, IAttributeState resultState)
        {
            resultState.Name = _attributeName;

            ulong bits32To30 = reader.GetBits(3, "Bits [32..30]");

            reader.GetMarker();
            ulong bits29To15 = reader.GetBits(15, "Bits [29..15]");

            reader.GetMarker();
            ulong bits14To0 = reader.GetBits(15, "Bits [14..0]");

            reader.GetMarker();

            ulong value = (bits32To30 << 30) | (bits29To15 << 15) | bits14To0;

            if (_hasExtension && reader.State.IsMpeg2())
            {
                ulong extension = reader.GetBits(9, "Extension");

                // TODO: what if extension >= 300 ?

                value = (300 * value) + extension;
            }

            resultState.Value = value;

            reader.State.LastTimestamp = value;
        }
예제 #7
0
 private void Start()
 {
     GameState.Instance.Registor <ISkillState>(ISkillStateChanged);
     GameState.Instance.Registor <IAttributeState>(IAttributeStateChanged);
     skillStructData = DataCenter.Instance.GetMetaData <SkillStructData>();
     iSkillState     = GameState.Instance.GetEntity <ISkillState>();
     iAttributeState = GameState.Instance.GetEntity <IAttributeState>();
 }
    /// <summary>
    /// 攻击造成的延迟处理携程
    /// </summary>
    /// <returns></returns>
    IEnumerator PhysicAttackDelay()
    {
        PlayerAnimSpeed.speedRate = 0;
        yield return(new WaitForSeconds(0.15f));

        IAttributeState iAttribute = GameState.Instance.GetEntity <IAttributeState>();

        PlayerAnimSpeed.speedRate  = iAttribute.AttackSpeed;
        physicAttackDelayCoroutine = null;
    }
예제 #9
0
        public IAttributeState Get(string id)
        {
            IAttributeState state = CurrentSession.Get <AttributeState>(id);

            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IAttributeState>(state, new Type[] { typeof(ISaveable) }, _readOnlyPropertyNames));
            }
            return(state);
        }
        public static TDeleteAttribute ToDeleteAttribute <TDeleteAttribute>(this IAttributeState state)
            where TDeleteAttribute : IDeleteAttribute, new()
        {
            var cmd = new TDeleteAttribute();

            cmd.AttributeId = state.AttributeId;
            cmd.Version     = ((IAttributeStateProperties)state).Version;

            return(cmd);
        }
        public IAttributeState Get(string id)
        {
            IAttributeState state = CurrentSession.Get <AttributeState> (id);

            if (state == null)
            {
                state = new AttributeState();
                (state as AttributeState).AttributeId = id;
            }
            return(state);
        }
        public void Save(IAttributeState state)
        {
            CurrentSession.SaveOrUpdate(state);

            var saveable = state as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
        }
예제 #13
0
 public DtoAttributeAliasStates(IAttributeState outerState, IEnumerable <IAttributeAliasState> innerStates)
 {
     this._outerState = outerState;
     if (innerStates == null)
     {
         this._innerStates = new IAttributeAliasState[] { };
     }
     else
     {
         this._innerStates = innerStates;
     }
 }
예제 #14
0
 private void Start()
 {
     parentObj = gameObject.transform.parent.gameObject;
     if (iAttributeState == null)
     {
         iAttributeState = GameState.Instance.GetEntity <IAttributeState>();
     }
     if (iAttributeState != null)
     {
         attackSpeed = iAttributeState.AttackSpeed;
         iAttributeState.Registor <IAttributeState>(IAttributeStateChanged);
     }
 }
예제 #15
0
            public void Parse(IMpeg2SystemReader reader, IAttributeState resultState)
            {
                resultState.Name = SystemHeader.Attribute.StreamInfo;

                // TODO: use formatter "{0:X2}"
                uint streamId = reader.GetBits(8, Attribute.StreamId, id => id == 0xb8 || id == 0xb9 || id >= 0xbc);

                resultState.Value     = streamId;
                resultState.Formatter = _streamInfoResultFormatter;

                reader.GetBits(2, 0x3);
                reader.GetBits(1, Attribute.PStdBufferBoundScale, n => (!IsAudioStream(streamId) || n == 0) && (!IsVideoStream(streamId) || n == 1));
                reader.GetBits(13, Attribute.PStdBufferSizeBound);
            }
            public void Parse(IMpeg2VideoReader reader, IAttributeState resultState)
            {
                resultState.Name = GroupOfPicturesHeader.Attribute.TimeCode;
                reader.GetBits(1, Attribute.DropFrameFlag);
                uint hours   = reader.GetBits(5, Attribute.TimeCodeHours, h => h <= 23);
                uint minutes = reader.GetBits(6, Attribute.TimeCodeMinutes, m => m <= 59);

                reader.GetMarker();
                uint seconds  = reader.GetBits(6, Attribute.TimeCodeSeconds, s => s <= 59);
                uint pictures = reader.GetBits(6, Attribute.TimeCodePictures);

                resultState.Value     = 64 * (3600 * hours + 60 * minutes + seconds) + pictures;
                resultState.Formatter = _timeCodeResultFormatter;
            }
예제 #17
0
 /// <summary>
 /// 监听属性变化
 /// </summary>
 /// <param name="iAttribute"></param>
 /// <param name="fieldName"></param>
 private void IAttribute_Changed(IAttributeState iAttribute, string fieldName)
 {
     if (string.Equals(fieldName, GameState.GetFieldNameStatic <IAttributeState, float>(temp => temp.HP)))
     {
         if (blackboard != null)
         {
             blackboard.SetValue("HP", iAttribute.HP);
         }
         if (iAttribute.HP <= 0 && destroyCoroutine == null)
         {
             destroyCoroutine = StartCoroutine(DestoryThis());
         }
     }
 }
        public IAttributeState Get(string id, bool nullAllowed)
        {
            IAttributeState state = CurrentSession.Get <AttributeState> (id);

            if (!nullAllowed && state == null)
            {
                state = new AttributeState();
                (state as AttributeState).AttributeId = id;
            }
            if (ReadOnlyProxyGenerator != null && state != null)
            {
                return(ReadOnlyProxyGenerator.CreateProxy <IAttributeState>(state, new Type[] { typeof(ISaveable) }, _readOnlyPropertyNames));
            }
            return(state);
        }
예제 #19
0
            public void Parse(IMpeg2VideoReader reader, IAttributeState resultState)
            {
                resultState.Name = Attribute.CopyrightNumber;

                ulong copyrightNumber1 = reader.GetBits(20, "Bits [63..44]");

                reader.GetMarker();
                ulong copyrightNumber2 = reader.GetBits(22, "Bits [43..22]");

                reader.GetMarker();
                ulong copyrightNumber3 = reader.GetBits(22, "Bits [21..0]");

                resultState.Value     = (copyrightNumber1 << 44) | (copyrightNumber2 << 22) | copyrightNumber3;
                resultState.Formatter = _copyrightNumberResultFormatter;
            }
            public void Parse(IMpeg2SystemReader reader, IAttributeState resultState)
            {
                _timeStampAttribute.Parse(reader, resultState);

                if (_useSystemClockReferenceValidation)
                {
                    ulong systemClockReference = reader.State.LastTimestamp + 1;
                    if (!IsContinuousStream(reader.State, systemClockReference))
                    {
                        resultState.Invalidate();
                        return;
                    }

                    reader.State.LastSystemClockReference = systemClockReference;
                }
            }
예제 #21
0
        public async Task <IAttributeState> GetAsync(string attributeId)
        {
            IAttributeState state         = null;
            var             idObj         = attributeId;
            var             uriParameters = new AttributeUriParameters();

            uriParameters.Id = idObj;

            var req = new AttributeGetRequest(uriParameters);

            var resp = await _ramlClient.Attribute.Get(req);

            AttributeProxyUtils.ThrowOnHttpResponseError(resp);
            state = resp.Content;
            return(state);
        }
        public void Save(IAttributeState state)
        {
            IAttributeState s = state;

            if (ReadOnlyProxyGenerator != null)
            {
                s = ReadOnlyProxyGenerator.GetTarget <IAttributeState>(state);
            }
            CurrentSession.SaveOrUpdate(s);

            var saveable = s as ISaveable;

            if (saveable != null)
            {
                saveable.Save();
            }
        }
예제 #23
0
    /// <summary>
    /// 检测到攻击触发到对象(注意通过该函数实现的都是物理攻击,魔法攻击请在各自的子类中独立实现)
    /// </summary>
    /// <param name="iOjbInteractive"></param>
    protected virtual void CheckTargetResult(IObjInteractive iOjbInteractive)
    {
        if (NowCheckFrame == null)
        {
            return;
        }
        if (attackAnimationTime > NowCheckFrame.endTime || attackAnimationTime < NowCheckFrame.startTime)
        {
            return;
        }
        if (tempCheckedTargetList.Contains(iOjbInteractive))
        {
            return;
        }
        tempCheckedTargetList.Add(iOjbInteractive);
        //计算伤害
        MonsterControl monsterControl = GetComponent <MonsterControl>();

        if (monsterControl == null)
        {
            return;
        }
        IAttributeState iAttributeState = monsterControl.GetMonsterAttributeState();

        if (iAttributeState == null)
        {
            return;
        }
        iAttributeState.PhysicsAttacking *= NowCheckFrame.magnification;
        AttackHurtStruct attackHurtStruct = new AttackHurtStruct()
        {
            attributeState       = iAttributeState,
            hurtFromObj          = gameObject,
            hurtType             = EnumHurtType.NormalAction,                 //怪物的伤害都依照普通攻击来计算(普通攻击和技能的区别暂时不知道)
            statusLevelDataInfos = new StatusDataInfo.StatusLevelDataInfo[0], //暂时没有附加状态
            hurtTransferNum      = 0,
            thisUsedMana         = 0                                          //物理技能没有耗魔
        };

        iOjbInteractive.GiveAttackHurtStruct(attackHurtStruct);
    }
        public void Parse <TReader>(IAttributeParser <TReader> parser, TReader reader) where TReader : IReader
        {
            IResultAttributeBuilder attributeBuilder = _createAttributeBuilder();
            IAttributeState         attributeState   = _createAttributeState(this, attributeBuilder);
            IState previousState = _activeState.ChangeState(attributeState);

            try
            {
                parser.Parse(reader, attributeState);
            }
            finally
            {
                _activeState.ChangeState(previousState);
            }

            // TODO: 'Name' must be set on 'attributeBuilder' !!

            if (!attributeState.Valid)
            {
                attributeBuilder.Invalidate();
            }

            _resultBuilder.AddAttribute(attributeBuilder.Build());
        }
        public static TMergePatchAttribute ToMergePatchAttribute <TMergePatchAttribute, TCreateAttributeValue, TMergePatchAttributeValue>(this IAttributeState state)
            where TMergePatchAttribute : IMergePatchAttribute, new()
            where TCreateAttributeValue : ICreateAttributeValue, new()
            where TMergePatchAttributeValue : IMergePatchAttributeValue, new()
        {
            var cmd = new TMergePatchAttribute();

            cmd.Version = ((IAttributeStateProperties)state).Version;

            cmd.AttributeId          = state.AttributeId;
            cmd.Name                 = state.Name;
            cmd.OrganizationId       = state.OrganizationId;
            cmd.Description          = state.Description;
            cmd.IsMandatory          = state.IsMandatory;
            cmd.IsInstanceAttribute  = state.IsInstanceAttribute;
            cmd.AttributeValueType   = state.AttributeValueType;
            cmd.AttributeValueLength = state.AttributeValueLength;
            cmd.IsList               = state.IsList;
            cmd.FieldName            = state.FieldName;
            cmd.ReferenceId          = state.ReferenceId;
            cmd.Active               = ((IAttributeStateProperties)state).Active;

            if (state.Name == null)
            {
                cmd.IsPropertyNameRemoved = true;
            }
            if (state.OrganizationId == null)
            {
                cmd.IsPropertyOrganizationIdRemoved = true;
            }
            if (state.Description == null)
            {
                cmd.IsPropertyDescriptionRemoved = true;
            }
            if (state.AttributeValueType == null)
            {
                cmd.IsPropertyAttributeValueTypeRemoved = true;
            }
            if (state.AttributeValueLength == null)
            {
                cmd.IsPropertyAttributeValueLengthRemoved = true;
            }
            if (state.FieldName == null)
            {
                cmd.IsPropertyFieldNameRemoved = true;
            }
            if (state.ReferenceId == null)
            {
                cmd.IsPropertyReferenceIdRemoved = true;
            }
            foreach (var d in state.AttributeValues)
            {
                var c = d.ToCreateOrMergePatchAttributeValue <TCreateAttributeValue, TMergePatchAttributeValue>();
                cmd.AttributeValueCommands.Add(c);
            }
            return(cmd);
        }
        public static IAttributeCommand ToCreateOrMergePatchAttribute <TCreateAttribute, TMergePatchAttribute, TCreateAttributeValue, TMergePatchAttributeValue>(this IAttributeState state)
            where TCreateAttribute : ICreateAttribute, new()
            where TMergePatchAttribute : IMergePatchAttribute, new()
            where TCreateAttributeValue : ICreateAttributeValue, new()
            where TMergePatchAttributeValue : IMergePatchAttributeValue, new()
        {
            bool bUnsaved = ((IAttributeState)state).IsUnsaved;

            if (bUnsaved)
            {
                return(state.ToCreateAttribute <TCreateAttribute, TCreateAttributeValue>());
            }
            else
            {
                return(state.ToMergePatchAttribute <TMergePatchAttribute, TCreateAttributeValue, TMergePatchAttributeValue>());
            }
        }
        public static TCreateAttribute ToCreateAttribute <TCreateAttribute, TCreateAttributeValue>(this IAttributeState state)
            where TCreateAttribute : ICreateAttribute, new()
            where TCreateAttributeValue : ICreateAttributeValue, new()
        {
            var cmd = new TCreateAttribute();

            cmd.Version = ((IAttributeStateProperties)state).Version;

            cmd.AttributeId          = state.AttributeId;
            cmd.Name                 = state.Name;
            cmd.OrganizationId       = state.OrganizationId;
            cmd.Description          = state.Description;
            cmd.IsMandatory          = state.IsMandatory;
            cmd.IsInstanceAttribute  = state.IsInstanceAttribute;
            cmd.AttributeValueType   = state.AttributeValueType;
            cmd.AttributeValueLength = state.AttributeValueLength;
            cmd.IsList               = state.IsList;
            cmd.FieldName            = state.FieldName;
            cmd.ReferenceId          = state.ReferenceId;
            cmd.Active               = ((IAttributeStateProperties)state).Active;
            foreach (var d in state.AttributeValues)
            {
                var c = d.ToCreateAttributeValue <TCreateAttributeValue>();
                cmd.AttributeValues.Add(c);
            }
            return(cmd);
        }
예제 #28
0
        protected bool IsRepeatedCommand(IAttributeCommand command, IEventStoreAggregateId eventStoreAggregateId, IAttributeState state)
        {
            bool repeated = false;

            if (((IAttributeStateProperties)state).Version > command.AggregateVersion)
            {
                var lastEvent = EventStore.GetEvent(typeof(IAttributeEvent), eventStoreAggregateId, command.AggregateVersion);
                if (lastEvent != null && lastEvent.CommandId == command.CommandId)
                {
                    repeated = true;
                }
            }
            return(repeated);
        }
예제 #29
0
 private void Persist(IEventStoreAggregateId eventStoreAggregateId, IAttributeAggregate aggregate, IAttributeState state)
 {
     EventStore.AppendEvents(eventStoreAggregateId, ((IAttributeStateProperties)state).Version, aggregate.Changes, () => { StateRepository.Save(state); });
     if (AggregateEventListener != null)
     {
         AggregateEventListener.EventAppended(new AggregateEvent <IAttributeAggregate, IAttributeState>(aggregate, state, aggregate.Changes));
     }
 }
예제 #30
0
 public abstract IAttributeAggregate GetAttributeAggregate(IAttributeState state);