示例#1
0
文件: Router.cs 项目: Cdrix/SM
    /// <summary>
    /// Add Current hit point but first needs to move it away from buiding
    /// </summary>
    void AddCurrentHit()
    {
        Dir[] dirsSimpleMap = new Dir[] { Dir.N, Dir.E, Dir.S, Dir.W };
        float moveBy        = _person.PersonDim * 2;

        Vector3[] moveAway = new Vector3[]
        {
            new Vector3(0, 0, moveBy), new Vector3(moveBy, 0, 0),
            new Vector3(0, 0, -moveBy), new Vector3(-moveBy, 0, 0)
        };
        Dir buildWasHitOn = UDir.TellMeWhenHitLanded(currBuilding.Anchors, vectorHit.HitPoint);

        //is needed here so it moves foward along the side and not to the cloeset that coluld be accross the biuilding
        Vector3 otherAnchorOnSide = UPoly.FindOtherCornerOnSide(currBuilding.Anchors, buildWasHitOn, closestAnchorToOrigin);
        var     sideAnchors       = ReturnFirstAndLast(_fin, otherAnchorOnSide, closestAnchorToOrigin);

        anchorOnSideClosestToFin = sideAnchors[0];//the anchor on the side is closer to _fin

        for (int i = 0; i < dirsSimpleMap.Length; i++)
        {
            if (dirsSimpleMap[i] == buildWasHitOn)
            {
                //is moving the vector hit away given the direction
                Vector3 t = vectorHit.HitPoint + moveAway[i];
                t.y = m.IniTerr.MathCenter.y;//so is on same Y value

                t = Sanitize(t);
                //_person.DebugList.Add(UVisHelp.CreateText(t, hitCurrentAdded.ToString()));
                _checkPoints.Add(new CheckPoint(t));
                return;
            }
        }
    }