Пример #1
0
 public override void Start(object param)
 {
     IsSubFace = false;
     SendEvent(BehaviorPlan.ActionEventType.start);
     bec = (BehaviorExecutionContext)param;
     Apply(bec);
     if (endTime.Type == SyncPointType.Absolute)
     {
         Thread.Sleep((int)Math.Round(Math.Max(0, endTime.AbsoluteValue - BehaviorPlan.Instance.SolveSyncPoint(startTime)) * 1000));
         End(bec);
     }
 }
Пример #2
0
 public bool Launch(BehaviorExecutionContext bec)
 {
     if (!RequiredAction || (RequiredAction && ParentNode != null && (ParentNode as Required).IsValid()))
     {
         if (startTime.Offset > 0)
         {
             tAction = new Thread(new ParameterizedThreadStart(OffsetStart));
             BehaviorManager.Instance.DebugIf("all", "Launching action(offset): " + Id);
             tAction.Start(bec);
         }
         else
         {
             tAction = new Thread(new ParameterizedThreadStart(Start));
             BehaviorManager.Instance.DebugIf("all", "Launching action: " + Id);
             tAction.Start(bec);
         }
         return true;
     }
     else
     {
         return false;
     }
 }
Пример #3
0
 public override void End(BehaviorExecutionContext bec)
 {
     ClientsInterface body = bec.Character.Clients;
     base.End(bec);
 }
Пример #4
0
        protected void PerformGaze(BehaviorExecutionContext bec)
        {
            ClientsInterface body = bec.Character.Clients;
            bool trackfaces = false;
            Vector v = new Vector(2);
            v[0]=0;
            v[1]=0;
            /*bool cameraSurface = false;
            bool screenSurface = false;*/
            string target = Target.ToLower();
            if (target == "trackfaces")
            {
                trackfaces = true;
                /*case "camera": cameraSurface = true; break;
                case "screen": screenSurface = true; break;*/
            }
            else if (target.Contains("h:") || target.Contains("v:"))
            {
                string[] split = target.Split(' ');
                foreach (string param in split)
                {
                    if (param.StartsWith("h:")) {
                        try {
                            v[0] = double.Parse(param.Substring(2).Trim());
                        }catch{}
                    }
                    if (param.StartsWith("v:"))
                    {
                        try
                        {
                            v[1] = double.Parse(param.Substring(2).Trim());
                        }
                        catch { }
                    }
                }
                body.Gaze(Id, (double)v[0], (double)v[1], Speed, trackfaces);
                return;
            }

            if (trackfaces || Target == "" || !TrackingManager.Instance.Trackers.ContainsKey(Target))
            {
                double angle = OffsetAngle;
                //if (angle == 0) angle = 90;
                
                switch (OffsetDirection)
                {
                    case Direction.Down:
                        v[1] = -angle;
                        break;
                    case Direction.Up:
                        v[1] = angle;
                        break;
                    case Direction.Left:
                        v[0] = angle;
                        break;
                    case Direction.Right:
                        v[0] = -angle;
                        break;
                    case Direction.DownLeft:
                        v[0] = angle;
                        v[1] = -angle;
                        break;
                    case Direction.DownRight:
                        v[0] = -angle;
                        v[1] = -angle;
                        break;
                    case Direction.UpLeft:
                        v[0] = angle;
                        v[1] = angle;
                        break;
                    case Direction.UpRight:
                        v[0] = -angle;
                        v[1] = angle;
                        break;
                    default:
                        v[0] = angle;
                        v[1] = angle;
                        break;
                }
                body.Gaze(Id, (double)v[0], (double)v[1], Speed, trackfaces);
            }
            else
            {
                body.Gaze(Id, (double)TrackingManager.Instance.Trackers[Target].HorizontalAngle, (double)TrackingManager.Instance.Trackers[Target].VerticalAngle, Speed, trackfaces);
            }
        }
Пример #5
0
 public override void End(BehaviorExecutionContext bec)
 {
     bec.Character.Clients.StopSound(Id);
 }
Пример #6
0
        public override void Start(object param)
        {
            SendEvent(BehaviorPlan.ActionEventType.start);
            bec = (BehaviorExecutionContext)param;
            AwaitingIds = new List<string>();
            foreach (FaceFacs ff in Facs)
            {
                AwaitingIds.Add(ff.Id);
                ff.AnimationEnd += new FaceFacs.AnimationEndHandler(SubFaceEnded);
                ff.Apply(bec);
            }
            foreach (FaceLexeme fl in Lexemes)
            {
                AwaitingIds.Add(fl.Id);
                fl.AnimationEnd += new FaceLexeme.AnimationEndHandler(SubFaceEnded);
                fl.Apply(bec);
            }

            if (endTime.Type == SyncPointType.Absolute)
            {
                Thread.Sleep((int)Math.Round(Math.Max(0, endTime.AbsoluteValue - BehaviorPlan.Instance.SolveSyncPoint(startTime)) * 1000));
                End(bec);
            }
        }
Пример #7
0
 public override void End(BehaviorExecutionContext bec)
 {
     bec.Character.Clients.Pointing(Id, "", Speed);
 }
Пример #8
0
 public override void End(BehaviorExecutionContext bec)
 {
     bec.Character.Clients.Head(Id, "", Repetitions, Frequency);
 }
Пример #9
0
 public void Remove(BehaviorExecutionContext bec)
 {
 }
Пример #10
0
 public void Apply(BehaviorExecutionContext bec)
 {
     ClientsInterface body = bec.Character.Clients;
     body.FaceLexeme(Id,Lexeme);
     bec.Character.AnimationEnd += new Character.AnimationEndHandler(LexemeEnd);
 }
Пример #11
0
 public virtual void Failed(BehaviorExecutionContext bec)
 {
     if (RequiredAction && ParentNode != null) (ParentNode as Required).Failed();
     SendEvent(BehaviorPlan.ActionEventType.endx);
 }
Пример #12
0
 public virtual void Event(BehaviorPlan.ActionEventType ev, BehaviorExecutionContext bec)
 {
     switch (ev)
     {
         case BehaviorPlan.ActionEventType.start: Launch(bec);
             break;
         case BehaviorPlan.ActionEventType.end: End(bec);
             break;
     }
 }
Пример #13
0
        public virtual void End(BehaviorExecutionContext bec)
        {
            SendEvent(BehaviorPlan.ActionEventType.end);
		}
Пример #14
0
 public void Apply(BehaviorExecutionContext bec)
 {
     ClientsInterface body = bec.Character.Clients;
     body.FaceFacs(Id, AU, Side, Amount);
     bec.Character.AnimationEnd += new Character.AnimationEndHandler(FacsEnd);
 }