示例#1
0
 public override void OnBeHitted(HitDef hitDef)
 {
     SetBeHitDefData(hitDef);
     if (hitDef.hitType == (int)HitDef.HitType.Attack)
     {
         AddHP(-hitDef.hitDamage);
         if (!IsAlive() && hitDef.knockAwayType == -1)
         {
             hitDef.knockAwayType = 0;
         }
         SendEvent(new Event()
         {
             type = EventType.PlayEffect, data = EffectDef.ConstructNormal(hitDef.spark, hitDef.sparkPos, this.GetFacing())
         });
         SendEvent(new Event()
         {
             type = EventType.PlaySound, data = new SoundDef()
             {
                 name = hitDef.hitSound, delay = 0, volume = 1
             }
         });
         if (this.GetMoveType() == MoveType.BeingHitted)
         {
             AddBeHitCount();
             hitDef.owner.SetHitCount(this.beHitCount);
         }
         else
         {
             ClearBeHitCount();
             AddBeHitCount();
         }
         if (hitDef.knockAwayType == -1)
         {
             if (this.GetPhysicsType() == PhysicsType.S)
             {
                 this.fsmMgr.ChangeState(5000, true);
             }
             else if (this.GetPhysicsType() == PhysicsType.C)
             {
                 this.fsmMgr.ChangeState(5010, true);
             }
             else if (this.GetPhysicsType() == PhysicsType.A)
             {
                 this.fsmMgr.ChangeState(5020, true);
             }
         }
         else
         {
             this.fsmMgr.ChangeState(5030, true);
         }
     }
     else if (hitDef.hitType == (int)HitDef.HitType.Throw)
     {
         this.fsmMgr.ChangeState(hitDef.p2StateNo, true);
     }
 }
示例#2
0
        public static int HitDefSet(ILuaState lua)
        {
            lua.L_CheckType(1, LuaType.LUA_TLIGHTUSERDATA);
            Unit c = (Unit)lua.ToUserData(1);

            if (c.IsPause())
            {
                return(0);
            }
            HitDef hitDef = GetHitDef(lua);

            c.SetHitDefData(hitDef);
            return(0);
        }
示例#3
0
 //只有指定的Hit能够通过
 public override bool Check(HitDef hitDef)
 {
     if (!IsActive())
     {
         return(true);
     }
     foreach (var hitInfo in this.m_infos)
     {
         if ((hitInfo.hitFlag & hitDef.hitFlag) != 0 && hitInfo.hitType == hitDef.hitType)
         {
             return(true);
         }
     }
     return(false);
 }
示例#4
0
 public override void OnGuardHit(HitDef hitDef)
 {
     SetBeHitDefData(hitDef);
     this.fsmMgr.ChangeState(this.GetPhysicsType() == PhysicsType.S ? 150 : 156);
     AddHP(-hitDef.guardDamage);
     SendEvent(new Event()
     {
         type = EventType.PlayEffect, data = EffectDef.ConstructNormal(hitDef.guardSpark, hitDef.sparkPos, this.GetFacing())
     });
     SendEvent(new Event()
     {
         type = EventType.PlaySound, data = new SoundDef()
         {
             name = hitDef.guardSound, delay = 0, volume = 1
         }
     });
 }
示例#5
0
        public bool CanBeHit(HitDef hitDef)
        {
            if (hitBy != null && !hitBy.Check(hitDef))
            {
                return(false);
            }
            if (noHitBy != null && noHitBy.Check(hitDef))
            {
                return(false);
            }
            int hitFlag = hitDef.hitFlag;

            if ((hitFlag & (int)HitDef.HitFlag.H) != 0)
            {
                if (GetPhysicsType() == PhysicsType.S)
                {
                    return(true);
                }
            }
            if ((hitFlag & (int)HitDef.HitFlag.L) != 0)
            {
                if (GetPhysicsType() == PhysicsType.C)
                {
                    return(true);
                }
            }
            if ((hitFlag & (int)HitDef.HitFlag.A) != 0)
            {
                if (GetPhysicsType() == PhysicsType.A && (this.fsmMgr.stateNo != 5050))
                {
                    return(true);
                }
            }
            if ((hitFlag & (int)HitDef.HitFlag.F) != 0)
            {
                if (GetPhysicsType() == PhysicsType.A && (fsmMgr.stateNo == 5050))
                {
                    return(true);
                }
            }
            if ((hitFlag & (int)HitDef.HitFlag.D) != 0)
            {
            }
            return(false);
        }
示例#6
0
        public bool CanBeGuard(HitDef hitDef)
        {
            int guardFlag = hitDef.guardFlag;

            if ((guardFlag & (int)HitDef.GuardFlag.H) != 0)
            {
                if (GetPhysicsType() == PhysicsType.S)
                {
                    return(true);
                }
            }
            if ((guardFlag & (int)HitDef.GuardFlag.L) != 0)
            {
                if (GetPhysicsType() == PhysicsType.C)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#7
0
        static HitDef GetHitDef(ILuaState lua)
        {
            HitDef hitDef = new HitDef();

            using (var t = new LuaTable(lua)){
                hitDef.hitFlag   = t.GetInt("hitFlag");
                hitDef.guardFlag = t.GetInt("guardFlag");

                hitDef.hitType       = t.GetInt("hitType");
                hitDef.forceLevel    = t.GetInt("forceLevel");
                hitDef.groundType    = t.GetInt("groundType");
                hitDef.knockAwayType = t.GetInt("knockAwayType", -1);
                hitDef.p1StateNo     = t.GetInt("p1StateNo", 0);
                hitDef.p2StateNo     = t.GetInt("p2StateNo", 0);

                hitDef.hitDamage    = t.GetInt("hitDamage");
                hitDef.hitPauseTime = t.GetIntArray("hitPauseTime", 2);
                hitDef.hitSlideTime = t.GetInt("hitSlideTime");
                hitDef.groundVel    = t.GetNumberArray("groundVel", 2);
                hitDef.airVel       = t.GetNumberArray("airVel", 2);

                hitDef.guardDamage    = t.GetInt("guardDamage");
                hitDef.guardPauseTime = t.GetIntArray("guardPauseTime", 2);
                hitDef.guardSlideTime = t.GetInt("guardSlideTime");
                hitDef.guardVel       = t.GetNumberArray("guardVel", 2);

                hitDef.groundCornerPush = t.GetNumber("groundCornerPush", 1);
                hitDef.airCornerPush    = t.GetNumber("airCornerPush", 1);

                hitDef.spark      = t.GetString("spark");
                hitDef.guardSpark = t.GetString("guardSpark");
                hitDef.sparkPos   = t.GetNumberArray("sparkPos", 2);

                hitDef.hitSound   = t.GetString("hitSound");
                hitDef.guardSound = t.GetString("guardSound");
            }
            return(hitDef);
        }
示例#8
0
 public virtual bool Check(HitDef hitDef)
 {
     return(false);
 }
示例#9
0
 public virtual void OnGuardHit(HitDef hitDef)
 {
 }
示例#10
0
 public virtual void OnBeHitted(HitDef hitDef)
 {
 }
示例#11
0
 public void SetBeHitDefData(HitDef hitDef)
 {
     this.status.beHitDefData = hitDef;
 }
示例#12
0
 public void SetHitDefData(HitDef hitDef)
 {
     this.status.hitDefData       = hitDef;
     this.status.hitDefData.owner = this;
 }