Пример #1
0
    protected Node GetDrink(SmartCharacter user)
    {
        return new Sequence(
            user.Node_Require(StateName.RoleActor, StateName.IsStanding, ~StateName.RightHandOccupied, ~StateName.IsIncapacitated),
            this.Node_Require(StateName.RoleDispenser),
            user.Node_GoTo(this.StandPoint.position),
            user.Node_OrientTowards(this.DrinkButton.transform.position),
            new DecoratorCatch(
                () => //if terminates, make sure the right hand interaction and headlook is stopped
                {
                    user.Character.StopInteraction(FullBodyBipedEffector.RightHand);
                    user.Character.HeadLookStop();
                },
                new Sequence(
                    user.Node_StartInteraction(FullBodyBipedEffector.RightHand, this.DrinkButton),
                    user.Node_WaitForTrigger(FullBodyBipedEffector.RightHand),
                    new SequenceParallel(
                        //user.Node_HeadLook(this.DrinkPickup.transform.position),
                        user.Node_OrientTowards(this.DrinkPickup.transform.position)),
                    user.Node_StopInteraction(FullBodyBipedEffector.RightHand),
                    new LeafWait(1000),
                    new LeafInvoke(() => GenerateDrink()),
                    new LeafWait(500))),
            user.ST_Pickup(DrinkHolder, DrinkPickup),
            user.Node_Set(StateName.HoldingDrink, StateName.RightHandOccupied),
            user.Node_GoTo(this.LeavePoint.position));

    }
Пример #2
0
 protected Node Attend(SmartCharacter user)
 {
     return new Sequence(
         user.Node_GoTo(TellerStandPoint.position),
         user.Node_OrientTowards(CustomerStandPoint.position),
         user.Node_Set(StateName.IsImmobile),
         user.Node_Set(this.Id, RelationName.IsAttending),
         this.Node_Set(StateName.IsOccupied));
 }
Пример #3
0
 protected Node GetTicket(SmartCharacter user)
 {
     return new Sequence(
         new LeafInvoke(() => GenerateTicket()),
         user.Node_GoTo(StandPoint.position),
         user.Node_OrientTowards(TicketHolder.transform.position),
         user.ST_Pickup(TicketHolder, InteractionTake),
         new DecoratorCatch(
             () => GameObject.Destroy(user.HoldPropRightHand.CurrentProp.gameObject),
             user.Node_GoTo(rect.RandomPoint(GoToEdge1.position.y))),
         new LeafInvoke(() => GameObject.Destroy(user.HoldPropRightHand.CurrentProp.gameObject)));
 }
Пример #4
0
 /// <summary>
 /// Subtree for the user switching the lamp on/off.
 /// </summary>
 /// <param name="switchTo">THe desired state of StateName.IsTurnedOn after executing the tree.</param>
 private Node ST_Switch(SmartCharacter user, StateName switchTo)
 {
     return new Sequence(
         user.Node_Require(StateName.RoleActor, StateName.IsStanding),
         this.Node_Require(StateName.RoleTelevision, ~switchTo),
         user.Node_GoTo(turnOnOffStandPoint.position),
         user.Node_OrientTowards(onOffSwitch.transform.position),
         user.Node_StartInteraction(FullBodyBipedEffector.LeftHand, onOffSwitch),
         user.Node_WaitForTrigger(FullBodyBipedEffector.LeftHand),
         user.Node_StopInteraction(FullBodyBipedEffector.LeftHand),
         this.Node_Set(switchTo)
         );
 }
Пример #5
0
 /// <summary>
 /// Subtree for the user switching the lamp on/off.
 /// </summary>
 /// <param name="switchTo">THe desired state of StateName.IsTurnedOn after executing the tree.</param>
 private Node ST_Switch(SmartCharacter user, StateName switchTo)
 {
     return new Sequence(
         user.Node_Require(StateName.RoleActor, StateName.IsStanding),
         this.Node_Require(StateName.RoleLamp, ~switchTo),
         user.Node_GoTo(standPoint.position),
         user.Node_OrientTowards(lightSwitch.transform.position),
         user.Node_StartInteraction(FullBodyBipedEffector.RightHand, lightSwitch.interactionObject),
         user.Node_WaitForFinish(FullBodyBipedEffector.RightHand),
         user.Node_StopInteraction(FullBodyBipedEffector.RightHand),
         new LeafInvoke(() => lightSwitch.Set(switchTo > 0)),
         this.Node_Set(switchTo)
         );
 }
Пример #6
0
    private static Node Coerce(
        SmartCharacter aggressor,
        SmartCharacter target,
        Val<float> distance)
    {
        return new Sequence(
            aggressor.Node_GoToUpToRadius(Val.V(() => target.transform.position), distance),
            aggressor.Node_OrientTowards(Val.V(() => target.transform.position)),
            aggressor.Node_Icon("stickup"),
            new SequenceParallel(
                aggressor.Behavior.ST_PlayHandGesture("pistolaim", 4000),
                new Sequence(
                    new LeafWait(2000),
                    target.Node_OrientTowards(Val.V(() => aggressor.transform.position)))));

    }
Пример #7
0
 protected Node PickupWeapon(SmartCharacter user)
 {
     return new Sequence(
         new Selector(
             new Sequence(
                 new LeafAssert(() => (user.transform.position - this.transform.position).magnitude < 1.0f),
                 new LeafInvoke(() => user.Character.NavStop())),
             user.Node_GoToUpToRadius(Val.V(() => this.transform.position), 1.0f)),
         user.Node_OrientTowards(Val.V(() =>this.transform.position)),
         user.Node_StartInteraction(FullBodyBipedEffector.RightHand, this.InteractionTakeGun),
         new LeafWait(500),
         new LeafInvoke(() => this.Holder.CurrentProp.FadeOut()),
         new LeafWait(500),
         new LeafInvoke(() => user.HoldPropRightHand.Attach(this.Holder.Release())),
         new LeafInvoke(() => user.GetRightProp().FadeIn()),
         user.Node_StopInteraction(FullBodyBipedEffector.RightHand),
         new LeafWait(1000),
         this.Node_Set(~StateName.HoldingWeapon, ~StateName.IsOccupied),
         user.Node_Set(StateName.HoldingWeapon, StateName.RightHandOccupied));
 }
Пример #8
0
 /// <summary>
 /// Subtree for Give. Here holdingState should be the StateName corresponding
 /// to the state for holding the object exchanged, e.g. HoldingWallet, HoldingBall.
 /// beforeGive and afterGive can be used to specify actions to be done both before the give starts
 /// (but after they have met and oriented towards each other) and to be done after the give ends.
 /// </summary>
 protected Node ST_Give(SmartCharacter user, StateName holdingState, Node beforeGive, Node afterGive)
 {
     return new Sequence(
         user.Node_Require(StateName.RoleActor, StateName.IsStanding, holdingState, ~StateName.IsIncapacitated),
         this.Node_Require(StateName.RoleActor, StateName.IsStanding, ~holdingState, ~StateName.IsIncapacitated),
         new SequenceParallel(
             user.Node_GoToUpToRadius(new Val<Vector3>(this.transform.position), 1.0f),
             this.Node_OrientTowards(new Val<Vector3>(user.transform.position)),
         user.Node_OrientTowards(new Val<Vector3>(this.transform.position))),
         beforeGive,
         new SequenceParallel(
             user.Node_StartInteraction(FullBodyBipedEffector.RightHand, this.InteractionGive),
             new Sequence(
                 new LeafWait(1000),
                 this.Node_StartInteraction(FullBodyBipedEffector.RightHand, this.InteractionTake)),
             user.Node_WaitForTrigger(FullBodyBipedEffector.RightHand),
             this.Node_WaitForTrigger(FullBodyBipedEffector.RightHand)),
         new LeafInvoke(() => this.HoldPropRightHand.Attach(user.HoldPropRightHand.Release())),
         user.Node_Set(~holdingState),
         afterGive,
         this.Node_Set(holdingState),
         new SequenceParallel(
             user.Node_StopInteraction(FullBodyBipedEffector.RightHand),
             this.Node_StartInteraction(FullBodyBipedEffector.RightHand, this.InteractionHoldRight)));
 }
Пример #9
0
 /// <summary>
 /// ABAS
 /// </summary>
 /// <param name="userA"></param>
 /// <param name="userB"></param>
 /// <param name="myAnims"></param>
 /// <param name="userAnims"></param>
 /// <returns></returns>
 public Node ST_DistractAndSteal(
     SmartCharacter userA,
     SmartCharacter userB) {
         Vector3 origPosition = userB.transform.position;
     return new Sequence(
         userA.Node_WaveTo(this),
         this.Node_OrientTowards(Val.V(() => userA.transform.position)),
         this.Node_GoToUpToRadius(Val.V(() => userA.transform.position), 1.2f),
         new SequenceParallel(
             userB.Node_HeadLook(Val.V(() => this.MarkerHead.position)),
         new SequenceParallel(
                 userA.ST_JustTalk(this),
                 new Sequence(
                     userB.Node_OrientTowards(Val.V(() => this.transform.position)),
                     new LeafWait(2000),
                     this.Steal(userB),
                     new LeafWait(1800),
                     userB.Node_GoTo(Val.V(() => origPosition)),
                     userB.Node_WaveTo(userA),
                     userA.Node_GoToUpToRadius(Val.V(() => userB.transform.position), 1.2f),
                     userB.ST_TalkHappily(userA))))
     
     );
 }
Пример #10
0
 /// <summary>
 /// ABAS
 /// </summary>
 /// <param name="userA"></param>
 /// <param name="userB"></param>
 /// <param name="myAnims"></param>
 /// <param name="userAnims"></param>
 /// <returns></returns>
 public Node ST_ConverseThree(
     SmartCharacter userA,
     SmartCharacter userB) {
     return new Sequence(
         new SequenceParallel(
             Node_CallForAttention(userA),
             userA.Node_GoToUpToRadius(Val.V(() => this.transform.position), 1.2f),
             userB.Node_GoToUpToRadius(Val.V(() => this.transform.position), 1.2f)),
             userB.Node_HeadLook(Val.V(() => this.MarkerHead.position)),
             userB.Node_PlayHandGesture(Val<string>.V(() => "Dismiss"), Val<long>.V(() => 2000L)),
         new Sequence(
                 ST_TalkHappily(userA)),
                 new SequenceParallel(
                     userA.Node_OrientTowards(Val.V(() => userB.transform.position)),
                     userB.ST_TalkHappily(this),
                     ST_TalkHappily(userA))
     );
 }
Пример #11
0
 protected Node Coerce(SmartCharacter user)
 {
     return new Sequence(
         // user.Node_Require(StateName.RoleActor, StateName.HoldingWeapon, StateName.IsStanding,
             // ~StateName.IsIncapacitated),
         // this.Node_Require(StateName.RoleActor, StateName.IsStanding, ~StateName.IsIncapacitated),
         new DecoratorForceStatus(
             RunStatus.Success,
             new Sequence(
                 new LeafAssert(() => WaypointFront == null),
                 this.ST_DoApproach(user, 1.0f))),
         new DecoratorForceStatus(
             RunStatus.Success,
             new Sequence(
                 new LeafAssert(() => WaypointFront != null),
                 user.Node_GoTo(Val.V(() => WaypointFront.position)),
                 user.Node_OrientTowards(this.transform.position),
                 this.Node_OrientTowards(Val.V(() => user.transform.position)))),
         //this.ST_DoApproach(user, 1.0f),
         user.Node_Icon("exclamation"),
         new LeafWait(2000),
         user.Node_Icon(null));
 }
Пример #12
0
 public Node TakeKeysFromBehind(SmartCharacter user)
 {
     return new Sequence(
         user.Node_GoTo(new Val<Vector3>(() => this.WaypointBack.transform.position)),
         user.Node_OrientTowards(Val.V(() => this.transform.position)),
         //this.Node_Icon("key"),
         user.Node_StartInteraction(FullBodyBipedEffector.RightHand, this.InteractionStealWallet),
         // user.Node_WaitForTrigger(FullBodyBipedEffector.RightHand),
         user.Node_StopInteraction(FullBodyBipedEffector.RightHand),
         // this.Node_Icon(null),
         // user.Node_Icon("key"),
         new LeafWait(1000)//,
         // user.Node_Icon(null),
         // this.Node_Set(~StateName.HasKeys),
         // user.Node_Set(StateName.HasKeys));
     );    
 }
Пример #13
0
 protected Node ST_Take(SmartCharacter user, StateName holdingState, Node afterTake)
 {
     return new Sequence(
         user.Node_Require(StateName.RoleActor, StateName.IsStanding, ~StateName.HoldingBall, ~StateName.HoldingWallet, ~StateName.IsIncapacitated),
         this.Node_Require(StateName.RoleTable, holdingState),
         user.Node_GoTo(this.StandPoint.position),
         new SequenceParallel(
             user.Node_HeadLook(this.PropPickup.transform.position),
             user.Node_OrientTowards(this.PropPickup.transform.position)),
         new DecoratorCatch(
             () => { user.Character.StopInteraction(FullBodyBipedEffector.RightHand); user.Character.HeadLookStop(); },
             new Sequence(
                user.Node_StartInteraction(FullBodyBipedEffector.RightHand, this.PropPickup),
                user.Node_WaitForTrigger(FullBodyBipedEffector.RightHand),
                new LeafInvoke(() => user.HoldPropRightHand.Attach(this.PropHolder.Release())),
                user.Node_HeadLookStop())),
         this.Node_Set(~holdingState),
         afterTake,
         user.Node_Set(holdingState),
         user.Node_StartInteraction(FullBodyBipedEffector.RightHand, user.InteractionHoldRight),
         user.Node_WaitForTrigger(FullBodyBipedEffector.RightHand),
         new LeafWait(300));
 }
Пример #14
0
 private static Node BeginCoerce(
     SmartCharacter coercer,
     SmartCharacter target)
 {
     return new Sequence(
         coercer.Node_OrientTowards(Val.V(() => target.transform.position)),
         coercer.Node_Icon("shouting"),
         new LeafInvoke(() => coercer.trackTarget = target.transform),
         new LeafAffordance("RaiseGun", coercer, coercer),
         target.Node_OrientTowards(Val.V(() => coercer.transform.position)),
         new LeafWait(2000),
         coercer.Node_Icon(null));
 }
Пример #15
0
 private static Node ApproachUpTo(SmartCharacter approacher, SmartCharacter target, float distance)
 {
     return new Sequence(
         approacher.Node_GoToUpToRadius(Val.V(() => target.transform.position), distance),
         approacher.Node_OrientTowards(Val.V(() => target.transform.position)));
 }
Пример #16
0
 protected Node TellerPutMoney(SmartCharacter user)
 {
     return new Sequence(
         this.Node_Require(StateName.RoleTeller, StateName.HoldingWallet),
         user.Node_Require(StateName.RoleTeller, StateName.IsStanding, ~StateName.RightHandOccupied, ~StateName.IsIncapacitated),
         this.Node_Require(user.Id, RelationName.IsAdjacentTo),
         user.Node_GoTo(TellerStandPoint.position),
         user.Node_OrientTowards(CustomerStandPoint.position),
         user.ST_Pickup(HoldPropIntermediate, InteractionIntermediateTeller),
         user.ST_Put(HoldPropStorage, InteractionStorage),
         this.Node_Set(~StateName.HoldingWallet));
 }
Пример #17
0
 protected Node TellerPutHidden(SmartCharacter user)
 {
     return new Sequence(
         user.Node_GoTo(TellerStandPoint.position),
         user.Node_OrientTowards(CustomerStandPoint.position),
         user.ST_Pickup(HoldPropIntermediate, InteractionIntermediateTeller),
         new LeafInvoke(() => user.GetRightProp().FadeOut()),
         user.ST_Put(HoldPropStorage, InteractionStorage));
 }
Пример #18
0
 protected Node GiveBriefcase(SmartCharacter user)
 {
     return new Sequence(
         user.Node_GoToUpToRadius(Val.V(() => this.transform.position), 1.5f),
         new SequenceParallel(
             user.Node_OrientTowards(Val.V(() => this.transform.position)),
             this.Node_OrientTowards(Val.V(() => user.transform.position))),
         new SequenceParallel(
             user.Node_StartInteraction(FullBodyBipedEffector.LeftHand, this.InteractionGive),
             new Sequence(
                 new LeafWait(1000),
                 this.Node_StartInteraction(FullBodyBipedEffector.LeftHand, this.InteractionTake)),
             user.Node_WaitForTrigger(FullBodyBipedEffector.LeftHand),
             this.Node_WaitForTrigger(FullBodyBipedEffector.LeftHand)),
         new LeafInvoke(() => this.HoldPropLeftHand.Attach(user.HoldPropLeftHand.Release())),
         user.Node_Set(~StateName.HasBackpack),
         this.Node_Set(StateName.HasBackpack),
         new SequenceParallel(
             user.Node_StopInteraction(FullBodyBipedEffector.LeftHand),
             this.Node_StopInteraction(FullBodyBipedEffector.LeftHand)));
 }
Пример #19
0
 protected Node StandInFront(SmartCharacter user)
 {
     return new Sequence(
         user.Node_GoTo(CustomerStandPoint.position),
         user.Node_OrientTowards(TellerStandPoint.position),
         user.Node_NudgeTo(CustomerStandPoint.position));
 }
Пример #20
0
 protected Node TakeWeaponIncapacitated(SmartCharacter user)
 {
     return new Sequence(
         user.Node_GoToUpToRadius(Val.V(() => this.WaypointFront.position), 1.0f),
         user.Node_OrientTowards(Val.V(() => this.transform.position)),
         //TODO new interaction object to take the weapon?
         user.Node_StartInteraction(FullBodyBipedEffector.RightHand, this.InteractionGive),
         user.Node_WaitForTrigger(FullBodyBipedEffector.RightHand),
         new LeafInvoke(() => user.HoldPropRightHand.Attach(this.HoldPropRightHand.Release())),
         this.Node_Set(~StateName.RightHandOccupied, ~StateName.HoldingWeapon),
         user.Node_Set(StateName.RightHandOccupied, StateName.HoldingWeapon),
         new LeafInvoke(() => Debug.Log("Here2")),
         user.Node_StopInteraction(FullBodyBipedEffector.RightHand));
 }