void Rule_Land()
        {
            //timeout catch in case something goes wrong; transition to next state
            LandTimeout.Start(2, () => {
                SetRule("Decide");
            }, false);

            switch (anim.currAnim)
            {
            case 13:                    //jump declination loop
                if (velY <= 0f)
                {
                    Ground();
                    velXZ = Vector3.zero;
                    landClankSFXPlayer.Play();

                    lookAtRay = false;
                    anim.Set(15);       //landing transition
                }
                break;

            case 15:        //13 frames in 30 fps; animation is 13/30 s long. However, we can only ever get here starting from frame 1, as we break out of the switch when we set the animation to this one
                Ground();

                LandedTimer.Start(12f / 30f, () => {
                    LandTimeout.Abort();
                    SetRule("Decide");
                }, false);

                break;

            default:
                break;
            }
        }
        //Running over the ground to next Waypoint
        void Rule_RunAround()
        {
            //stick to ground, set movespeed and other ground-based rules and functionality
            Ground();

            //move and look at where we're headed
            if (!lookAtRay)
            {
                LookAt2D(WPTarget.transform.position, 180);
            }
            SetVelXZ();
            anim.Set(2);

            if (Vector3.Distance(pos, WPTarget.transform.position) <= 0.5f)
            {
                velXZ = Vector3.zero;
                StuckRunning.Abort();

                SetRule("Decide");
                return;
            }

            if (newRule)
            {
                StuckRunning.Start(8f, () => {
                    Debug.LogError(perso.name + ": Got stuck trying to reach Waypoint " + WPTarget + " from Waypoint " + WPCurrent + " at position " + transform.position.ToString() + "!");
                    SetRule("Decide");
                });
            }
        }
        //Given previous Ponder, we now have a bunch of flags to check in order to set up our next course of action. When this logic is completed,
        //  we will have arrived at our plan for the next couple of seconds and/or next couple of "steps" in our behaviour tree.
        //So call Rule_DecisionMade.
        //Naturally, these next steps can always be aborted at any time given a change in circumstances
        //  (Rayman moved, Rayman attacked us, we're low health, we walked somewhere specific, etc.).
        //This would trigger a new cascade of decision-making, essentially starting the whole process anew.
        protected void Rule_WeighDecisions()
        {
            DecisionTimeoutTimer.Abort();       //We're already here; no need to force us here again

            //We have a new plan! Let's see...
            if (mind.newGoal)
            {
                switch (mind.goal)
                {
                case HenchmanMind.Goal.FindThePath:
                    //If we are here, that means we are currently off-grid and looking for a way back in
                    EnqueueDecision("RunAround");     //run to the target (and, once there, we'll have a new connection to examine)
                    break;

                case HenchmanMind.Goal.Patrol:
                    EnqueueDecision("UseWaypointPath");     //start walking on the given path
                    EnqueueDecision("UseWaypointPath");     //let's just queue a couple to see what happens
                    EnqueueDecision("UseWaypointPath");
                    break;

                default:
                    //do nothing for now if we don't have explicit instructions
                    return;
                }

                //---------//

                //Go off-grid and approach Ray
                //...

                //Attack Ray (Shoot, Hook, Barrel)
                //...

                //Idle
                //...

                //--------//

                mind.newGoal = false;
            }
            else
            {
                //Stay the course and steady as she goes...
                switch (mind.goal)
                {
                case HenchmanMind.Goal.Patrol:
                    EnqueueDecision("UseWaypointPath");     //start walking on the given path
                    EnqueueDecision("UseWaypointPath");     //let's just queue a couple to see what happens
                    EnqueueDecision("UseWaypointPath");
                    break;

                default:
                    //do nothing for now if we don't have explicit instructions
                    return;
                }
            }

            SetRule("DecisionMade");
        }
Esempio n. 4
0
 public void Stop(int timeout = 1000)
 {
     if (!Timer.StopAndWait(timeout))
     {
         Timer.Abort();
     }
     State = ClockState.Stopped;
 }
Esempio n. 5
0
        public void WakeUp()
        {
            if (!newRule)
            {
                return;
            }

            SetRule("");
            t_fallAsleep.Abort();
            anim.Set(Anim.WakeUp);
            t_wakeUp.Start(1.75f, () => SetRule("Run"));
        }
        void Rule_WokeUp()
        {
            if (newRule)
            {
                snoringTimer.Abort();
                anim.Set(49);

                //timer for 1s
                wakeUpTimer.Start(1f, () => {
                    SetRule("Surprise");
                });
            }
        }
Esempio n. 7
0
 protected override void OnDeath()
 {
     t_hit.Abort();
     if (ground)
     {
         anim.Set(Anim.CageGroundBreak, 1);
         t_hit.Start(1, () => SetVisibility(false));
     }
     else
     {
         anim.Set(Anim.CageHangingBreak, 1);
     }
     SetShadow(false);
     SetRule("");
 }
Esempio n. 8
0
 public void StopTiming()
 {
     timer.Abort();
 }