Ejemplo n.º 1
0
 public void PulledOutOfStuckObject()
 {
     for (int i = 0; i < abstractPhysicalObject.stuckObjects.Count; i++)
     {
         if (abstractPhysicalObject.stuckObjects[i] is AbstractPhysicalObject.AbstractSpearStick && (abstractPhysicalObject.stuckObjects[i] as AbstractPhysicalObject.AbstractSpearStick).Spear == abstractPhysicalObject)
         {
             abstractPhysicalObject.stuckObjects[i].Deactivate();
             break;
         }
         if (abstractPhysicalObject.stuckObjects[i] is AbstractPhysicalObject.AbstractSpearAppendageStick && (abstractPhysicalObject.stuckObjects[i] as AbstractPhysicalObject.AbstractSpearAppendageStick).Spear == abstractPhysicalObject)
         {
             abstractPhysicalObject.stuckObjects[i].Deactivate();
             break;
         }
     }
     stuckInObject     = null;
     stuckInAppendage  = null;
     stuckInChunkIndex = 0;
 }
Ejemplo n.º 2
0
 public void LodgeInCreature(SharedPhysics.CollisionResult result, bool eu)
 {
     stuckInObject = result.obj;
     ChangeMode(Mode.StuckInCreature);
     if (result.chunk != null)
     {
         stuckInChunkIndex = result.chunk.index;
         if (arrowDamageBonus > 0.9f && room.GetTile(room.GetTilePosition(stuckInChunk.pos) + throwDir).Terrain == Room.Tile.TerrainType.Solid && room.GetTile(stuckInChunk.pos).Terrain == Room.Tile.TerrainType.Air)
         {
             stuckInWall = room.MiddleOfTile(stuckInChunk.pos) + throwDir.ToVector2() * (10f - stuckInChunk.rad);
             stuckInChunk.MoveFromOutsideMyUpdate(eu, stuckInWall.Value);
             stuckRotation    = Custom.VecToDeg(rotation);
             stuckBodyPart    = -1;
             pinToWallCounter = 300;
         }
         else if (stuckBodyPart == -1)
         {
             stuckRotation = Custom.Angle(throwDir.ToVector2(), stuckInChunk.Rotation);
         }
         base.firstChunk.MoveWithOtherObject(eu, stuckInChunk, new Vector2(0f, 0f));
         Debug.Log("Add arrow to creature chunk " + stuckInChunk.index);
         new AbstractPhysicalObject.AbstractSpearStick(abstractPhysicalObject, (result.obj as Creature).abstractCreature, stuckInChunkIndex, stuckBodyPart, stuckRotation);
     }
     else if (result.onAppendagePos != null)
     {
         stuckInChunkIndex = 0;
         stuckInAppendage  = result.onAppendagePos;
         stuckRotation     = Custom.VecToDeg(rotation) - Custom.VecToDeg(stuckInAppendage.appendage.OnAppendageDirection(stuckInAppendage));
         Debug.Log("Add arrow to creature Appendage");
         new AbstractPhysicalObject.AbstractSpearAppendageStick(abstractPhysicalObject, (result.obj as Creature).abstractCreature, result.onAppendagePos.appendage.appIndex, result.onAppendagePos.prevSegment, result.onAppendagePos.distanceToNext, stuckRotation);
     }
     if (room.BeingViewed)
     {
         for (int i = 0; i < 8; i++)
         {
             room.AddObject(new WaterDrip(result.collisionPoint, -base.firstChunk.vel * Random.value * 0.5f + Custom.DegToVec(360f * Random.value) * base.firstChunk.vel.magnitude * Random.value * 0.5f, waterColor: false));
         }
     }
 }
Ejemplo n.º 3
0
 public override void RecreateSticksFromAbstract()
 {
     for (int i = 0; i < abstractPhysicalObject.stuckObjects.Count; i++)
     {
         if (abstractPhysicalObject.stuckObjects[i] is AbstractPhysicalObject.AbstractSpearStick && (abstractPhysicalObject.stuckObjects[i] as AbstractPhysicalObject.AbstractSpearStick).Spear == abstractPhysicalObject && (abstractPhysicalObject.stuckObjects[i] as AbstractPhysicalObject.AbstractSpearStick).LodgedIn.realizedObject != null)
         {
             AbstractPhysicalObject.AbstractSpearStick abstractSpearStick = abstractPhysicalObject.stuckObjects[i] as AbstractPhysicalObject.AbstractSpearStick;
             stuckInObject     = abstractSpearStick.LodgedIn.realizedObject;
             stuckInChunkIndex = abstractSpearStick.chunk;
             stuckBodyPart     = abstractSpearStick.bodyPart;
             stuckRotation     = abstractSpearStick.angle;
             ChangeMode(Mode.StuckInCreature);
         }
         else if (abstractPhysicalObject.stuckObjects[i] is AbstractPhysicalObject.AbstractSpearAppendageStick && (abstractPhysicalObject.stuckObjects[i] as AbstractPhysicalObject.AbstractSpearAppendageStick).Spear == abstractPhysicalObject && (abstractPhysicalObject.stuckObjects[i] as AbstractPhysicalObject.AbstractSpearAppendageStick).LodgedIn.realizedObject != null)
         {
             AbstractPhysicalObject.AbstractSpearAppendageStick abstractSpearAppendageStick = abstractPhysicalObject.stuckObjects[i] as AbstractPhysicalObject.AbstractSpearAppendageStick;
             stuckInObject    = abstractSpearAppendageStick.LodgedIn.realizedObject;
             stuckInAppendage = new Appendage.Pos(stuckInObject.appendages[abstractSpearAppendageStick.appendage], abstractSpearAppendageStick.prevSeg, abstractSpearAppendageStick.distanceToNext);
             stuckRotation    = abstractSpearAppendageStick.angle;
             ChangeMode(Mode.StuckInCreature);
         }
     }
 }
Ejemplo n.º 4
0
 public override void Violence(BodyChunk source, Vector2?directionAndMomentum, BodyChunk hitChunk, Appendage.Pos hitAppendage, DamageType type, float damage, float stunBonus)
 {
     if (type == DamageType.Stab && parry > 0f)
     {
         int num3 = (int)Math.Min(UnityEngine.Random.value + 10f, 25f);
         for (int i = 0; i < num3; i++)
         {
             room.AddObject(new Spark(source.pos + Custom.DegToVec(UnityEngine.Random.value * 360f) * 5f * UnityEngine.Random.value, source.vel * -0.1f + Custom.DegToVec(UnityEngine.Random.value * 360f) * Mathf.Lerp(0.2f, 0.4f, UnityEngine.Random.value) * source.vel.magnitude, new Color(1f, 1f, 1f), graphicsModule as LizardGraphics, 10, 170));
         }
         return;
     }
     base.Violence(source, directionAndMomentum, hitChunk, hitAppendage, type, damage, stunBonus);
 }