コード例 #1
0
        public override Goal Suggest(LineSegmentPath path, KinematicData character, Goal goal)
        {
            // procurar ponto do segmento mais próximo ao centro da esfera
            Vector3 closest = path.GetPosition(MathHelper.closestParamInLineSegmentToPoint(path.StartPosition, path.EndPosition, center));
            // Check if we pass through the center point
            Vector3 newPt;

            if (closest.sqrMagnitude == 0)
            {
                // Get any vector at right angles to the segment
                Vector3 dirn = path.EndPosition - path.StartPosition;
                //pode nao ser esta func TO DO
                Vector3 newdirn = Vector3.Cross(dirn, Vector3.Cross(dirn, Vector3.right));
                newPt = center + newdirn * radius * margin;
            }
            else
            {
                // Otherwise project the point out beyond the radius
                newPt = center + (closest - center) * radius * margin / closest.sqrMagnitude;
            }

            // Set up the goal and return
            goal.position = newPt;
            return(goal);
        }
コード例 #2
0
ファイル: MapConstraint.cs プロジェクト: IAJ-g04/Project2
        public override Goal Suggest(LineSegmentPath path, KinematicData character, Goal goal)
        {
            if (this.chars.KinematicData.velocity.sqrMagnitude > 1.5f)
            {
                this.chars.KinematicData.velocity *= 0.01f;
            }
            return(goal);

            /* // procurar ponto do segmento mais próximo ao centro da esfera
             * Vector3 closest = path.GetPosition(MathHelper.closestParamInLineSegmentToPoint(path.StartPosition, path.EndPosition, chars.KinematicData.position));
             * // Check if we pass through the center point
             *
             * Vector3 newPt;
             * float i = 1.0f;
             * while (i < 25.0f)
             * {
             *   for(int a = 0; a < 360; a++)
             *   {
             *       float nx = (float) (closest.sqrMagnitude * i * Math.Cos((a * (Math.PI / 180))));
             *       float ny = (float) (closest.sqrMagnitude * i * Math.Sin((a * (Math.PI / 180))));
             *       newPt = new Vector3(nx, closest.y,ny);
             *       if (navMeshP.IsPointOnGraph(newPt))
             *       {
             *           goal.position = newPt;
             *           return goal;
             *       }
             *   }
             *   i = i + 0.25f;
             * }
             * return goal;
             * // Set up the goal and return*/
        }
コード例 #3
0
ファイル: SteeringPipeline.cs プロジェクト: IAJ-g04/Project2
        public override MovementOutput GetMovement()
        {
            Goal g = new Goal();

            foreach (Targeter t in Targeters)
            {
                g.UpdateChannels(t.GetGoal(Character));
            }

            foreach (Decomposer d in Decomposers)
            {
                g = d.Decompose(Character, g);
            }

            // bool ValidPath = false; TO DO esta parte ta uma bequita meh

            for (int i = 0; i <= MaxConstraintSteps; i++)
            {
                Actuator.goal = g;
                LineSegmentPath path = Actuator.GetPath();
                foreach (Constraint c in Constraints)
                {
                    if (c.WillViolate(path))
                    {
                        g = c.Suggest(path, Character, g);
                        continue;
                    }
                }
                return(Actuator.GetMovement());
            }
            return(DeadlockMovement.GetMovement());
        }
コード例 #4
0
 public override Boolean WillViolate(LineSegmentPath path)
 {
     //maybe not right func TO DO
     if (MathHelper.closestParamInLineSegmentToPoint(path.StartPosition, path.EndPosition, center) < radius)
     {
         return(true);
     }
     return(false);
 }
コード例 #5
0
ファイル: DefaultActuator.cs プロジェクト: IAJ-g04/Project2
        public override LineSegmentPath GetPath()
        {
            LineSegmentPath segment;
            if (goal.hasPosition) {
                segment = new LineSegmentPath(this.Character.position, goal.position);               
            }
            else{
                segment = new LineSegmentPath(this.Character.position, this.Character.position);               
            }

            return segment;
        }
コード例 #6
0
ファイル: TrollConstraint.cs プロジェクト: IAJ-g04/Project2
        public override Boolean WillViolate(LineSegmentPath path)
        {
            Vector3 impactPoint = path.GetPosition(MathHelper.closestParamInLineSegmentToPoint(path.StartPosition, path.EndPosition, Troll.KinematicData.position));
            Vector3 direction   = Troll.KinematicData.position - impactPoint;
            float   distance    = Vector3.Magnitude(direction);

            if (distance < TrollRadius)
            {
                // Debug.Log("VIOLATE!");
                return(true);
            }
            //   Debug.Log("NO VIOLATE!");
            return(false);
        }
コード例 #7
0
ファイル: MapConstraint.cs プロジェクト: IAJ-g04/Project2
 public override Boolean WillViolate(LineSegmentPath path)
 {
     /* List<NavigationGraphNode> nodes = (List<NavigationGraphNode>)Utils.Reflection.GetInstanceField(typeof(RAINNavigationGraph), path, "_pathNodes");
      *
      * foreach (NavigationGraphNode nvn in nodes) {
      *   if (nvn.Position.Equals((chars.KinematicData.position + chars.KinematicData.velocity * 0.8f)))
      *   {
      *       return false;
      *   }
      * }
      * return true;*/
     if (navMeshP.IsPointOnGraph((chars.KinematicData.position + chars.KinematicData.velocity * 0.5f)))
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
コード例 #8
0
 public abstract Goal Suggest(LineSegmentPath path, KinematicData character, Goal goal);
コード例 #9
0
 public abstract Boolean WillViolate(LineSegmentPath path);