Пример #1
0
        /// <summary>
        /// 根据当前角色姿势判断要播放的动画
        /// 根据攻击类型播放特定特效
        /// 播放文字特效,音效
        /// 扣血计算
        /// 摄像机拉近效果
        /// 空中的连击重力判定
        /// </summary>
        /// <param name="hit"></param>
        /// <param name="remainingFrames"></param>
        /// <param name="location"></param>
        public void GetHit(Hit hit, int remainingFrames, Vector3 location)
        {
            // 根据角色状态获取需要播放的动画
            // Get what animation should be played depending on the character's state
            if (myPhysicsScript.isGrounded())
            {
                //if (currentState == PossibleStates.Crouch)
                //{
                //    currentHitAnimation = "getHitLow";
                //}
                //else
                if (hit.hitType == HitType.Launcher)
                {
                    currentHitAnimation = "getHitAir";
                }
                else
                {
                    currentHitAnimation = "getHitHigh";
                }
            }
            else
            {
                currentHitAnimation = "getHitAir";
            }

            // 拉扯技能?
            // Set position in case of pull enemy in
            if (hit.pullEnemyIn.enemyBodyPart != BodyPart.none && hit.pullEnemyIn.characterBodyPart != BodyPart.none)
            {
                Vector3 newPos = myHitBoxesScript.getPosition(hit.pullEnemyIn.enemyBodyPart);
                if (newPos != Vector3.zero)
                {
                    pullInLocation = transform.position + (hit.pullEnemyIn.position.position - newPos);
                    pullInSpeed    = hit.pullEnemyIn.speed;
                }
            }
            // 不同攻击类型,不同特效?
            // Differenciate hit types
            GameObject hitEffect      = null;
            float      effectKillTime = 0;

            if (hit.hitStrengh == HitStrengh.Weak)
            {
                hitEffect = GetHitData(UFE.config.hitOptions.weakHit, ref effectKillTime);
            }
            if (hit.hitStrengh == HitStrengh.Medium)
            {
                hitEffect = GetHitData(UFE.config.hitOptions.mediumHit, ref effectKillTime);
            }
            if (hit.hitStrengh == HitStrengh.Heavy)
            {
                hitEffect = GetHitData(UFE.config.hitOptions.heavyHit, ref effectKillTime);
            }
            if (hit.hitStrengh == HitStrengh.Crumple)
            {
                hitEffect = GetHitData(UFE.config.hitOptions.crumpleHit, ref effectKillTime);
            }
            if (hit.hitStrengh == HitStrengh.Custom1)
            {
                hitEffect = GetHitData(UFE.config.hitOptions.customHit1, ref effectKillTime);
            }
            if (hit.hitStrengh == HitStrengh.Custom2)
            {
                hitEffect = GetHitData(UFE.config.hitOptions.customHit2, ref effectKillTime);
            }
            if (hit.hitStrengh == HitStrengh.Custom3)
            {
                hitEffect = GetHitData(UFE.config.hitOptions.customHit3, ref effectKillTime);
            }

            // Cancel current move if any
            if (!hit.armorBreaker && currentMove != null && currentMove.armor > 0)
            {
                currentMove.armor--;
            }
            else
            {
                storedMove = null;
                KillCurrentMove();
            }

            // Create hit effect
            if (location != Vector3.zero && hitEffect != null)
            {
                GameObject pTemp = (GameObject)Instantiate(hitEffect, location, Quaternion.identity);
                Destroy(pTemp, effectKillTime);
            }

            // 打击时文字特效
            // Cast First Hit if true
            //if (!firstHit && !opControlsScript.firstHit)
            //{
            //    opControlsScript.firstHit = true;
            //    UFE.FireAlert(SetStringValues(UFE.config.selectedLanguage.firstHit, opInfo), opInfo);
            //}
            //UFE.FireHit(myHitBoxesScript.getStrokeHitBox(), opControlsScript.currentMove, opInfo);

            //打击扣血计算
            // Convert Percentage
            if (hit.damageType == DamageType.Percentage)
            {
                hit.damageOnHit = myInfo.lifePoints * (hit.damageOnHit / 100);
            }

            // Damage deterioration
            float damage = 0;

            if (!hit.damageScaling || UFE.config.comboOptions.damageDeterioration == Sizes.None)
            {
                damage = hit.damageOnHit;
            }
            else if (UFE.config.comboOptions.damageDeterioration == Sizes.Small)
            {
                damage = hit.damageOnHit - (hit.damageOnHit * (float)comboHits * .1f);
            }
            else if (UFE.config.comboOptions.damageDeterioration == Sizes.Medium)
            {
                damage = hit.damageOnHit - (hit.damageOnHit * (float)comboHits * .2f);
            }
            else if (UFE.config.comboOptions.damageDeterioration == Sizes.High)
            {
                damage = hit.damageOnHit - (hit.damageOnHit * (float)comboHits * .4f);
            }
            if (damage < UFE.config.comboOptions.minDamage)
            {
                damage = UFE.config.comboOptions.minDamage;
            }

            // Lose life
            //isDead = DamageMe(damage);


            // Stun
            // Hit stun deterioration (the longer the combo gets, the harder it is to combo)
            stunned = true;

            int stunFrames = 0;

            if (hit.hitStunType == HitStunType.FrameAdvantage)
            {
                stunFrames = hit.frameAdvantageOnHit + remainingFrames;
            }
            else
            {
                stunFrames = hit.hitStunOnHit;
            }

            if (stunFrames < 1)
            {
                stunFrames = 1;
            }
            if (stunFrames < UFE.config.comboOptions.minHitStun)
            {
                stunTime = UFE.config.comboOptions.minHitStun;
            }
            stunTime = (float)stunFrames / (float)UFE.config.fps;
            if (!hit.resetPreviousHitStun)
            {
                if (UFE.config.comboOptions.hitStunDeterioration == Sizes.Small)
                {
                    stunTime -= (float)comboHits * .01f;
                }
                else if (UFE.config.comboOptions.hitStunDeterioration == Sizes.Medium)
                {
                    stunTime -= (float)comboHits * .02f;
                }
                else if (UFE.config.comboOptions.hitStunDeterioration == Sizes.High)
                {
                    stunTime -= (float)comboHits * .04f;
                }
            }
            comboHits++;
            if (isDead)
            {
                stunTime = 999;
            }

            // 致眩晕时播放动画减速
            // Set deceleration of hit stun animation so it can look more natural
            hitStunDeceleration = character.GetComponent <Animation>()[currentHitAnimation].length / Mathf.Pow(stunTime, 2);

            // Stop any previous hit stun and play animation at hit animation speed
            character.GetComponent <Animation>().Stop(currentHitAnimation);
            character.GetComponent <Animation>()[currentHitAnimation].speed = (character.GetComponent <Animation>()[currentHitAnimation].length / stunTime) * 1.5f;
            character.GetComponent <Animation>().Play(currentHitAnimation);

            // 锁屏,拉近摄像机
            // Freeze screen depending on how strong the hit was
            //HitPause();
            //Invoke("HitUnpause", GetFreezingTime(hit.hitStrengh));

            // hit state 1 -> 0
            // Reset hit to allow for another hit while the character is still stunned
            float freezingTime = GetFreezingTime(hit.hitStrengh) * 1.2f;

            myHitBoxesScript.Invoke("resetHit", freezingTime);

            // 给动作添加力
            // Add force to the move
            // Air juggle deterioration (the longer the combo, the harder it is to push the opponent higher)
            float verticalPush = hit.pushForce.y;

            if (verticalPush > 0 || isDead ||
                hit.hitType == HitType.HardKnockdown ||
                hit.hitType == HitType.Knockdown)
            {
                if (UFE.config.comboOptions.airJuggleDeterioration == Sizes.None)
                {
                    verticalPush = hit.pushForce.y;
                }
                else if (UFE.config.comboOptions.airJuggleDeterioration == Sizes.Small)
                {
                    verticalPush = hit.pushForce.y - (hit.pushForce.y * (float)comboHits * .1f);
                }
                else if (UFE.config.comboOptions.airJuggleDeterioration == Sizes.Medium)
                {
                    verticalPush = hit.pushForce.y - (hit.pushForce.y * (float)comboHits * .2f);
                }
                else if (UFE.config.comboOptions.airJuggleDeterioration == Sizes.High)
                {
                    verticalPush = hit.pushForce.y - (hit.pushForce.y * (float)comboHits * .4f);
                }
                if (verticalPush < UFE.config.comboOptions.minPushForce)
                {
                    verticalPush = UFE.config.comboOptions.minPushForce;
                }
            }

            if (hit.hitType == HitType.Knockdown || hit.hitType == HitType.HardKnockdown)
            {
                myPhysicsScript.resetForces(true, true, true);
            }

            myPhysicsScript.resetForces(hit.resetPreviousHorizontalPush, hit.resetPreviousVerticalPush, true);
            myPhysicsScript.addForce(new Vector2(hit.pushForce.x, verticalPush), 1);
        }
Пример #2
0
        void FixedUpdate()
        {
            if (isHit > 0)
            {
                isHit -= Time.deltaTime;
                return;
            }
            transform.Translate(movement * Time.deltaTime);

            //if (opHitBoxesScript.testCollision(blockableArea) != Vector3.zero)
            //{
            //    opControlsScript.CheckBlocking(true);
            //}

            if (data.projectileCollision)
            {
                RaycastHit raycastHit = new RaycastHit();
                if (Physics.SphereCast(transform.position, data.hitRadius * (data.speed * .1f), Vector3.forward, out raycastHit, 1, opProjectileMask))
                {
                    if (data.impactPrefab != null)
                    {
                        GameObject hitEffect = (GameObject)Instantiate(data.impactPrefab, transform.position, Quaternion.Euler(0, 0, data.directionAngle));
                        Destroy(hitEffect, 1);
                    }
                    totalHits--;
                    if (totalHits <= 0)
                    {
                        Destroy(gameObject);
                    }
                    isHit = .3f;
                    transform.Translate(movement * -1 * Time.deltaTime);
                }
            }
            if (data.projectileCollision)
            {
                RaycastHit raycastHit = new RaycastHit();
                if (Physics.SphereCast(transform.position, data.hitRadius * (data.speed * .1f), Vector3.forward, out raycastHit, 1, opProjectileMask))
                {
                    if (data.impactPrefab != null)
                    {
                        GameObject hitEffect = (GameObject)Instantiate(data.impactPrefab, transform.position, Quaternion.Euler(0, 0, data.directionAngle));
                        Destroy(hitEffect, 1);
                    }
                    totalHits--;
                    if (totalHits <= 0)
                    {
                        Destroy(gameObject);
                    }
                    isHit = .3f;
                    transform.Translate(movement * -1 * Time.deltaTime);
                }
            }

            if (opHitBoxesScript.testCollision(transform.position, data.hitRadius))
            {
                //Vector3 newPos = transform.position + Vector3.back;
                if (data.impactPrefab != null)
                {
                    GameObject hitEffect = (GameObject)Instantiate(data.impactPrefab, transform.position, Quaternion.Euler(0, 0, data.directionAngle));
                    Destroy(hitEffect, 1);
                }
                totalHits--;
                if (totalHits <= 0)
                {
                    Destroy(gameObject);
                }

                isHit = opControlsScript.GetFreezingTime(data.hitStrengh) * 1.2f;
                Hit hit = new Hit();
                hit.hitType        = data.hitType;
                hit.hitStrengh     = data.hitStrengh;
                hit.hitStunType    = HitStunType.Frames;
                hit.hitStunOnHit   = data.hitStunOnHit;
                hit.hitStunOnBlock = data.hitStunOnBlock;
                hit.damageOnHit    = data.damageOnHit;
                hit.damageType     = data.damageType;
                hit.resetPreviousHorizontalPush = true;
                hit.pushForce   = data.pushForce;
                hit.pullEnemyIn = new PullIn();
                hit.pullEnemyIn.enemyBodyPart = BodyPart.none;

                //if (!opControlsScript.stunned && opControlsScript.isBlocking && opControlsScript.TestBlockStances(hit.hitType))
                //{
                //    opControlsScript.GetHitBlocking(hit, 20, transform.position);
                //}
                //else if (opControlsScript.potentialParry > 0 && opControlsScript.TestParryStances(hit.hitType))
                //{
                //    opControlsScript.GetHitParry(hit, transform.position);
                //}
                //else
                //{
                opControlsScript.GetHit(hit, 30, Vector3.zero);
                //}

                //opControlsScript.CheckBlocking(false);
            }
        }