Beispiel #1
0
        /// <summary>
        /// 处理角落的力反馈:攻击角落的敌人,攻击者向远离方向运动
        /// </summary>
        /// <param name="attacker"></param>
        /// <param name="target"></param>
        private static void ProcessCornerPush(Entity attacker, Entity target)
        {
            var hitDef = attacker.GetComponent <HitComponent>().HitDef;

            if (UtilityFuncs.GetFrontStageDist(attacker) < new Number(5) / new Number(10) && hitDef.moveContact)
            {
                Number velX = 0;
                if (hitDef.moveGuarded)
                {
                    velX = hitDef.guardVel.X();
                }
                else if (hitDef.moveHit)
                {
                    var targetMoveComponent = target.GetComponent <MoveComponent>();
                    if (targetMoveComponent.PhysicsType == PhysicsType.Air)
                    {
                        velX = hitDef.airVel.X();
                    }
                    else
                    {
                        velX = hitDef.groundVel.X();
                    }
                }

                var moveComponent = attacker.GetComponent <MoveComponent>();
                if (moveComponent.PhysicsType == PhysicsType.Air)
                {
                    moveComponent.VelAdd(-Number.Abs(velX) * hitDef.airCornerPush, 0);
                }
                else
                {
                    moveComponent.VelAdd(-Number.Abs(velX) * hitDef.groundCornerPush, 0);
                }
            }
        }
Beispiel #2
0
        public static int FrontStageDist(ILuaState lua)
        {
            lua.L_CheckType(1, LuaType.LUA_TLIGHTUSERDATA);
            Entity c    = (Entity)lua.ToUserData(1);
            var    dist = UtilityFuncs.GetFrontStageDist(c);

            lua.PushInteger(dist.AsInt());
            return(1);
        }