コード例 #1
0
ファイル: clsGenerateMap.cs プロジェクト: pcdummy/SharpFlame
 private void SetBaseLevelRamp(clsSetBaseLevelRampArgs Args, PathfinderNode Node)
 {
     if (Node.GetChildNodeCount == 0)
     {
         clsNodeTag tag = (clsNodeTag) Node.Tag;
         modMath.sXY_int _int = modMath.PointGetClosestPosOnLine(Args.Connection.PassageNodeA.Pos, Args.Connection.PassageNodeB.Pos, tag.Pos);
         modMath.sXY_int _int2 = Args.Connection.PassageNodeA.Pos - Args.Connection.PassageNodeB.Pos;
         float magnitude = (float) _int2.ToDoubles().GetMagnitude();
         float num3 = magnitude - Args.RampLength;
         _int2 = _int - Args.Connection.PassageNodeA.Pos;
         float num2 = (float) _int2.ToDoubles().GetMagnitude();
         float num5 = modMath.Clamp_sng((num2 - (num3 / 2f)) / ((float) Args.RampLength), 0f, 1f);
         int index = Node.GetLayer_NodeNum;
         num5 = (float) (1.0 - ((Math.Cos(num5 * 3.1415926535897931) + 1.0) / 2.0));
         if ((num5 > 0f) & (num5 < 1f))
         {
             _int2 = tag.Pos - _int;
             float num6 = (float) _int2.ToDoubles().GetMagnitude();
             if (num6 < Args.RampRadius)
             {
                 float num7 = 1f;
                 if (Args.BaseLevel.NodeLevels[index] == (Args.BaseLevel.NodeLevels[index]))
                 {
                     Args.BaseLevel.NodeLevels[index] = (Args.BaseLevel.NodeLevels[index] * (1f - num7)) + (((Args.Connection.PassageNodeA.Level * (1f - num5)) + (Args.Connection.PassageNodeB.Level * num5)) * num7);
                 }
                 else
                 {
                     Args.BaseLevel.NodeLevels[index] = ((Args.BaseLevel.NodeLevels[index] * (2f - num7)) + (((Args.Connection.PassageNodeA.Level * (1f - num5)) + (Args.Connection.PassageNodeB.Level * num5)) * num7)) / 2f;
                 }
             }
         }
     }
     else
     {
         int num9 = Node.GetChildNodeCount - 1;
         for (int i = 0; i <= num9; i++)
         {
             this.SetBaseLevelRamp(Args, Node.get_GetChildNode(i));
         }
     }
 }
コード例 #2
0
ファイル: clsGenerateMap.cs プロジェクト: pcdummy/SharpFlame
 public PathfinderNode GetRandomChildNode(PathfinderNode InputNode, int MinClearance)
 {
     int num;
     if (InputNode.GetClearance < MinClearance)
     {
         return null;
     }
     if (InputNode.GetChildNodeCount == 0)
     {
         return InputNode;
     }
     do
     {
         num = (int) Math.Round((double) ((float) (App.Random.Next() * InputNode.GetChildNodeCount)));
     }
     while (InputNode.get_GetChildNode(num).GetClearance < MinClearance);
     return this.GetRandomChildNode(InputNode.get_GetChildNode(num), MinClearance);
 }
コード例 #3
0
ファイル: clsGenerateMap.cs プロジェクト: pcdummy/SharpFlame
 private void SetBaseLevel(PathfinderNode Node, int NewLevel, clsBaseNodeLevels BaseLevel)
 {
     if (Node.GetChildNodeCount == 0)
     {
         float num3 = NewLevel;
         int num5 = Node.GetConnectionCount - 1;
         for (int i = 0; i <= num5; i++)
         {
             float num2 = BaseLevel.NodeLevels[Node.get_GetConnection(i).GetOtherNode(Node).GetLayer_NodeNum];
             if (num2 < num3)
             {
                 num3 = num2;
             }
         }
         if ((NewLevel - num3) > 1f)
         {
             BaseLevel.NodeLevels[Node.GetLayer_NodeNum] = num3 + 1f;
         }
         else
         {
             BaseLevel.NodeLevels[Node.GetLayer_NodeNum] = NewLevel;
         }
     }
     else
     {
         int num6 = Node.GetChildNodeCount - 1;
         for (int j = 0; j <= num6; j++)
         {
             this.SetBaseLevel(Node.get_GetChildNode(j), NewLevel, BaseLevel);
         }
     }
 }
コード例 #4
0
ファイル: clsGenerateMap.cs プロジェクト: pcdummy/SharpFlame
 public void CalcNodePos(PathfinderNode Node, ref Position.XY_dbl Pos, ref int SampleCount)
 {
     if (Node.GetLayer.GetNetwork_LayerNum == 0)
     {
         clsNodeTag tag = (clsNodeTag) Node.Tag;
         Pos.X += tag.Pos.X;
         Pos.Y += tag.Pos.Y;
     }
     else
     {
         int num2 = Node.GetChildNodeCount - 1;
         for (int i = 0; i <= num2; i++)
         {
             this.CalcNodePos(Node.get_GetChildNode(i), ref Pos, ref SampleCount);
         }
         SampleCount += Node.GetChildNodeCount;
     }
 }