Exemple #1
0
        /// <summary>
        /// Executes current chain of circumstances.
        /// </summary>
        /// <returns>Chain result.</returns>
        public TResult Execute()
        {
            if (_thrownExceptions.Any())
            {
                _thrownExceptions.Clear();
            }
            LinkedListNode <Circumstance> current = _circumstances.First;

            while (current != null)
            {
                Circumstance circumstance = current.Value;
                try {
                                        #pragma warning disable S1751
                    return(circumstance.GetResult());

                                        #pragma warning restore S1751
                } catch (Exception e) {
                    bool isConditionFailed = e is Circumstance.ConditionFailedException;
                    if (!isConditionFailed)
                    {
                        _thrownExceptions.Add(e.InnerException);
                    }
                    current = current.Next;
                }
            }
            return(default(TResult));
        }
Exemple #2
0
        override public object Execute(Reasoner ts, Unifier un, ITerm[] args)
        {
            CheckArguments(args);

            Circumstance C      = ts.GetCircumstance();
            Trigger      teGoal = new Trigger(TEOperator.add, TEType.achieve, (Literal)args[0]);

            // search in PA
            foreach (ExecuteAction a in C.GetPendingActions().Values)
            {
                if (a.GetIntention().HasTrigger(teGoal, un))
                {
                    return(un.Unifies(args[1], aAct));
                }
            }

            // search in PI
            Dictionary <string, Intention> pi = C.GetPendingIntentions();

            foreach (string reason in pi.Keys)
            {
                if (pi[reason].HasTrigger(teGoal, un))
                {
                    return(un.Unifies(args[1], new StringTermImpl(reason)));
                }
            }

            return(false);
        }
        public override bool DropInt(Circumstance C, Literal goal, Unifier un)
        {
            Unifier bak                  = un.Clone();
            bool    isCurrentInt         = false;
            IEnumerator <Intention> iint = C.GetAllIntentions();

            while (iint.Current != null)
            {
                Intention i  = iint.Current;
                IPlanBody pb = i.Peek().GetPlan().GetBody();
                while (pb != null)
                {
                    if (pb.GetBodyType() == BodyType.Body_Type.achieve || pb.GetBodyType() == BodyType.Body_Type.achieveNF)
                    {
                        if (un.Unifies(pb.GetBodyTerm(), goal))
                        {
                            C.DropIntention(i);
                            isCurrentInt = isCurrentInt || i.Equals(C.GetSelectedIntention());
                            un           = bak.Clone();
                            break;
                        }
                    }
                    pb = pb.GetBodyNext();
                }
            }
            return(isCurrentInt);
        }
Exemple #4
0
 public EnumeratorImpl(Circumstance C, Unifier un, Trigger g, ITerm intAsTerm)
 {
     this.g         = g;
     this.un        = un;
     this.C         = C;
     this.intAsTerm = intAsTerm;
     intIterator    = C.GetAllIntentions();
 }
Exemple #5
0
 public override void Fail(Circumstance c)
 {
     if (Size() >= forkPoint && fd.isAnd)
     { // the fail is above fork, is an fork and, remove the others
         foreach (Intention ifo in fd.intentions)
         {
             c.DropIntention(ifo);
         }
     }
 }
Exemple #6
0
        public void DropEvt(Circumstance C, Literal l, Unifier un)
        {
            Trigger te = new Trigger(TEOperator.add, TEType.achieve, l);

            //search in E
            C.RemoveEvents(te, un);

            // search in PE (only the event need to be checked, the related intention is handled by dropInt)
            C.RemovePendingEvents(te, un);
        }
Exemple #7
0
        // Default procedure for checking messages, move message from local mbox to C.mbox
        public new void CheckMail()
        {
            Circumstance C  = GetReasoner().GetCircumstance();
            Message      im = mbox.Dequeue();

            while (im != null)
            {
                C.AddMsg(im);
                im = mbox.Dequeue();
            }
        }
Exemple #8
0
            //static EnumeratorImpl()
            //{
            //    Find();
            //}

            public EnumeratorImpl(Circumstance c, Literal l, ITerm intAsTerm, Unifier un, Trigger teFroml)
            {
                this.C          = c;
                this.l          = l;
                this.intAsTerm  = intAsTerm;
                this.un         = un;
                curStep         = Step.selEvt;
                solution        = null;
                evtIterator     = null;
                intendInterator = null;
                this.teFromL    = teFroml;
                Find(); //Movido del bloque estático aquí para que funcione
            }
Exemple #9
0
 internal List <object> GetExportVals()
 {
     return(new List <object>
     {
         Id,
         SiteId.DBExport(),
         HfId.DBExport(),
         Reason.DBExport(Reasons),
         ReasonId.DBExport(),
         Circumstance.DBExport(Circumstances),
         CircumstanceId.DBExport(),
         FormId.DBExport()
     });
 }
Exemple #10
0
 public MyRunnable2(Circumstance c, Intention si, string sEvt, bool dropped, bool stopByTimeout, Trigger te, ILogicalFormula formula, ITerm elapsedTimeTerm, Reasoner rs, Unifier un, long startTime)
 {
     this.c               = c;
     this.si              = si;
     this.sEvt            = sEvt;
     this.dropped         = dropped;
     this.stopByTimeout   = stopByTimeout;
     this.te              = te;
     this.formula         = formula;
     this.elapsedTimeTerm = elapsedTimeTerm;
     this.rs              = rs;
     this.un              = un;
     this.startTime       = startTime;
 }
Exemple #11
0
            public WaitEvent(Trigger te, ILogicalFormula f, Unifier un, Reasoner ts, long timeout, ITerm elapsedTimeTerm)
            {
                this.te              = te;
                this.formula         = f;
                this.un              = un;
                this.ts              = ts;
                c                    = ts.GetCircumstance();
                si                   = c.GetSelectedIntention();
                this.elapsedTimeTerm = elapsedTimeTerm;

                // register listener
                c.AddEventListener(this);

                if (te != null)
                {
                    sEvt = te.ToString();
                }
                else if (formula != null)
                {
                    sEvt = formula.ToString();
                }
                else
                {
                    sEvt = "time" + (timeout);
                }
                sEvt = si.GetID() + "/" + sEvt;
                c.AddPendingIntention(sEvt, si);

                //startTime = System.currentTimeMillis(); //hay que usar el de c# o el de unity? MISTERIO
                startTime = DateTime.Now.Millisecond;
                // Seguramente lo que querramos en C# no son los milisegundos desde el año 1970... sino algo así: Environment.TickCount
                DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

                startTime = (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;

                if (timeout >= 0)
                {
                    Agent.GetExecutor().AddTask(new MyRunnable1(this));

                    //agent.getscheduler().schedule(new runnable()
                    //{
                    //    public void run()
                    //    {
                    //        resume(true);
                    //    }
                    //    }, timeout, timeunit.milliseconds);
                }
            }
Exemple #12
0
        public virtual void DropDesireInEvent(Reasoner rs, Event e, Intention i)
        {
            Circumstance C = rs.GetCircumstance();

            C.RemoveEvent(e);
            if (i != null)
            {
                if (rs.HasDesireListener())
                {
                    foreach (Desire gl in rs.GetDesiresListeners())
                    {
                        gl.DesireFinished(e.GetTrigger(), Desire.FinishStates.achieved);
                    }
                    i.Peek().RemoveCurrentStep();
                    rs.ApplyClrInt(i);
                    C.AddRunningIntention(i);
                }
            }
        }
        /**
         * Drops an intention based on a goal argument
         *
         * returns true if the current intention is dropped
         */
        public virtual bool DropInt(Circumstance C, Literal goal, Unifier un)
        {
            Unifier bak                  = un.Clone();
            Trigger g                    = new Trigger(TEOperator.add, TEType.achieve, goal);
            bool    isCurrentInt         = false;
            IEnumerator <Intention> iint = C.GetAllIntentions();

            while (iint.Current != null)
            {
                Intention i = iint.Current;
                if (i.HasTrigger(g, un))
                {
                    C.DropIntention(i);
                    isCurrentInt = isCurrentInt || i.Equals(C.GetSelectedIntention());
                    un           = bak.Clone();
                }
            }
            return(isCurrentInt);
        }
        public override object Execute(Reasoner ts, Unifier un, ITerm[] args)
        {
            CheckArguments(args);
            Circumstance C = ts.GetCircumstance();

            C.ClearRunningIntentions();
            C.ClearPendingIntentions();
            C.ClearPendingActions();

            // drop intentions in E
            IEnumerator <Event> ie = C.GetEventsPlusAtomic();

            while (ie.Current != null)
            {
                Event e = ie.Current;
                if (e.IsInternal())
                {
                    C.RemoveEvent(e);
                }
            }

            //drop intentions in PE
            foreach (string ek in C.GetPendingEvents().Keys)
            {
                Event e = C.GetPendingEvents()[ek];
                if (e.IsInternal())
                {
                    C.RemovePendingEvent(ek);
                }
            }

            AtStdLib atia = ts.GetAgent().GetIA(AtStdLib.atAtom) as AtStdLib;

            atia.CancelAts();
            return(true);
        }
Exemple #15
0
        public void FindDesireAndDrop(Reasoner rs, Literal l, Unifier un)
        {
            Trigger      g   = new Trigger(TEOperator.add, TEType.achieve, l);
            Circumstance C   = rs.GetCircumstance();
            Unifier      bak = un.Clone();

            IEnumerator <Intention> itinit = C.GetRunningIntentionsPlusAtomic();

            while (itinit.MoveNext())
            {
                Intention i = itinit.Current;
                if (DropDesire(i, g, rs, un) > 1)
                {
                    C.DropRunningIntention(i);
                    un = bak.Clone();
                }
            }

            // dropping the current intention?
            DropDesire(C.GetSelectedIntention(), g, rs, un);
            un = bak.Clone();

            //dropping G in Events
            IEnumerator <Event> ie = C.GetEventsPlusAtomic();

            while (ie.MoveNext())
            {
                Event e = ie.Current;
                //Test in the intention
                Intention i = e.GetIntention();
                int       r = DropDesire(i, g, rs, un);
                if (r > 0)
                {
                    C.RemoveEvent(e);
                    if (r == 1)
                    {
                        C.ResumeIntention(i);
                    }
                    un = bak.Clone();
                }
                else
                {
                    //Test in the event
                    Trigger t = e.GetTrigger();
                    if (i != Intention.emptyInt && !i.IsFinished())
                    {
                        t = t.Capply(i.Peek().GetUnif());
                    }
                    if (un.Unifies(g, t))
                    {
                        DropDesireInEvent(rs, e, i);
                        un = bak.Clone();
                    }
                }
            }

            //dropping G in Pending Events
            foreach (string ek in C.GetPendingEvents().Keys)
            {
                //Test in the intention
                Event     e = C.GetPendingEvents()[ek];
                Intention i = e.GetIntention();
                int       r = DropDesire(i, g, rs, un);
                if (r > 0)
                {
                    C.RemovePendingEvent(ek);
                    if (r == 1)
                    {
                        C.ResumeIntention(i);
                    }
                    un = bak.Clone();
                }
                else
                {
                    //test in the event
                    Trigger t = e.GetTrigger();
                    if (i != Intention.emptyInt && !i.IsFinished())
                    {
                        t = t.Capply(i.Peek().GetUnif());
                    }
                    if (un.Unifies(g, t))
                    {
                        DropDesireInEvent(rs, e, i);
                        un = bak.Clone();
                    }
                }
            }

            //Dropping from pending Actions
            foreach (ExecuteAction a in C.GetPendingActions().Values)
            {
                Intention i = a.GetIntention();
                int       r = DropDesire(i, g, rs, un);
                if (r > 0)                            //i was changed
                {
                    C.RemovePendingAction(i.GetID()); // remove i from PA
                    if (r == 1)                       // i must continue running
                    {
                        C.ResumeIntention(i);         // and put the intention back in I
                    }                                 // if r > 1, the event was generated and i will be back soon
                    un = bak.Clone();
                }
            }

            //Dropping from pending intentions
            foreach (Intention i in C.GetPendingIntentions().Values)
            {
                int r = DropDesire(i, g, rs, un);
                if (r > 0)
                {
                    C.RemovePendingIntention(i.GetID());
                    if (r == 1)
                    {
                        C.ResumeIntention(i);
                    }
                    un = bak.Clone();
                }
            }
        }
Exemple #16
0
        public override object Execute(Reasoner ts, Unifier un, ITerm[] args)
        {
            CheckArguments(args);

            suspendIntention = false;

            Circumstance C = ts.GetCircumstance();

            if (args.Length == 0)
            {
                // suspend the current intention
                Intention i = C.GetSelectedIntention();
                suspendIntention = true;
                i.SetSuspended(true);
                C.AddPendingIntention(SELF_SUSPENDED_INT + i.GetID(), i);
                return(true);
            }

            // use the argument to select the intention to suspend.

            Trigger g = new Trigger(TEOperator.add, TEType.achieve, (Literal)args[0]);

            // ** Must test in PA/PI first since some actions (as .suspend) put intention in PI

            // suspending from Pending Actions
            foreach (ExecuteAction a in C.GetPendingActions().Values)
            {
                Intention ia = a.GetIntention();
                if (ia.HasTrigger(g, un))
                {
                    ia.SetSuspended(true);
                    C.AddPendingIntention(SUSPENDED_INT + ia.GetID(), ia);
                }
            }

            // suspending from Pending Intentions
            foreach (Intention ii in C.GetPendingIntentions().Values)
            {
                if (ii.HasTrigger(g, un))
                {
                    ii.SetSuspended(true);
                }
            }

            IEnumerator <Intention> itint = C.GetRunningIntentionsPlusAtomic();

            while (itint.MoveNext())
            {
                Intention i = itint.Current;
                if (i.HasTrigger(g, un))
                {
                    i.SetSuspended(true);
                    C.RemoveRunningIntention(i);
                    C.AddPendingIntention(SUSPENDED_INT + i.GetID(), i);
                }
            }

            // suspending the current intention? <-(Esta interrogación ya venía, lo juro)
            Intention ci = C.GetSelectedIntention();

            if (ci != null && ci.HasTrigger(g, un))
            {
                suspendIntention = true;
                ci.SetSuspended(true);
                C.AddPendingIntention(SELF_SUSPENDED_INT + ci.GetID(), ci);
            }

            // suspending G in Events
            int c = 0;
            IEnumerator <Event> ie = C.GetEventsPlusAtomic();

            while (ie.MoveNext())
            {
                Event e = ie.Current;
                ci = e.GetIntention();
                if (un.Unifies(g, e.GetTrigger()) || (ci != null && ci.HasTrigger(g, un)))
                {
                    C.RemoveEvent(e);
                    C.AddPendingEvent(SUSPENDED_INT + e.GetTrigger() + (c++), e);
                    if (ci != null)
                    {
                        ci.SetSuspended(true);
                    }
                }
            }
            return(true);
        }
 public GameEndedEventArgs(Circumstance reason)
 {
     Reason = reason;
 }
Exemple #18
0
        public AttackValues CalculateAttackValues(Combatant attacker, Weapon weapon, Circumstance circumstance)
        {
            var result = new AttackValues();

            var skillDice = attacker.ResolveAttackSkill(WeaponCategory.Pistols);

            result.AttackDice = attacker.Agility + skillDice;

            if (weapon.HasSmartLink && attacker.HasSmartLink)
            {
                result.AttackDice += 2;
            }
            else if (weapon.HasLaserSight)
            {
                result.AttackDice++;
            }

            result.DefendingArmourType = ArmourType.Ballistic;

            result.ArmourPiercingModifier = weapon.ArmourPiercing;

            if (skillDice == 0)
            {
                result.AttackDice -= 1; //unskilled penalty
            }

            result.BaseDamageValue = weapon.DamageCode.Value;
            result.DamageType      = weapon.DamageCode.Type;

            //ammo type
            switch (weapon.AmmoType)
            {
            case AmmoType.APDS:
            {
                result.ArmourPiercingModifier -= 4;
                break;
            }

            case AmmoType.Explosive:
            {
                result.ArmourPiercingModifier--;
                result.BaseDamageValue++;
                break;
            }

            case AmmoType.HighExplosive:
            {
                result.ArmourPiercingModifier -= 2;
                result.BaseDamageValue        += 2;
                break;
            }

            case AmmoType.Flechette:
            {
                result.ArmourPiercingModifier += 5;
                result.BaseDamageValue        += 2;
                result.DefendingArmourType     = ArmourType.Impact;
                break;
            }

            case AmmoType.GelRounds:
            {
                result.DamageType              = DamageType.Stun;
                result.ArmourPiercingModifier += 2;
                break;
            }

            default:
            {
                break;
            }
            }

            //should check here if the combatant has enough ammo for desired burst or if it needs to be limited? Or should this already have been passed?

            result.RecoilPenalty = 0;
            //burst modifiers
            result.RecoilPenalty = -circumstance.NumberOfShotsInBurst + 1;
            if (circumstance.IsSecondShot)
            {
                result.RecoilPenalty--;
            }
            result.RecoilPenalty += weapon.RecoilCompensation; //how to handle basic and full compensation (for items with stocks for example)

            result.BurstDamageModifier  = 0;
            result.BurstDefenceModifier = 0;
            switch (circumstance.BurstType)
            {
            case BurstType.Narrow:
            {
                result.BurstDamageModifier += circumstance.NumberOfShotsInBurst - 1;
                break;
            }

            case BurstType.Wide:
            {
                result.BurstDefenceModifier -= (circumstance.NumberOfShotsInBurst - 1);
                break;
            }

            default:
            {
                break;
            }
            }
            return(result);
        }
Exemple #19
0
 /// <summary>
 /// Adds a <paramref name="circumstance"/> to the end of the list.
 /// </summary>
 /// <param name="circumstance">Circumstance.</param>
 private void AddLast(Circumstance circumstance)
 {
     _circumstances.AddLast(circumstance);
 }
Exemple #20
0
        public static IEnumerator <Unifier> AllDesires(Circumstance C, Literal l, ITerm intAsTerm, Unifier un)
        {
            Trigger teFroml = new Trigger(TEOperator.add, TEType.achieve, l);

            return(new EnumeratorImpl(C, l, intAsTerm, un, teFroml));
        }
Exemple #21
0
 // Start is called before the first frame update
 void Start()
 {
     currentCircumstance_1 = Circumstance.DUMMY;
     currentCircumstance_2 = Circumstance.DUMMY;
     StartCoroutine(ManageIterate());
 }
Exemple #22
0
        /**
         * returns all unifications for intentions with some goal
         */
        public static IEnumerator <Unifier> AllIntentions(Circumstance C, Literal l, ITerm intAsTerm, Unifier un)
        {
            Trigger g = new Trigger(TEOperator.add, TEType.achieve, l);

            return(new EnumeratorImpl(C, un, g, intAsTerm));
        }
 // 생성자
 public Message(PlayerNumber playerNum, Circumstance circumstanceInfo, float inputTime)
 {
     player       = playerNum;
     circumstance = circumstanceInfo;
     dispatchTime = inputTime;
 }
Exemple #24
0
    // current, 즉 메시지 타입과 우선순위에 따라 적절한 대화창 출력
    IEnumerator Animating(Message current)
    {
        bool isPlaying = false;

        Debug.Log("ANIMATING 실행");

        if (current.player == PlayerNumber.P1)
        {
            currentCircumstance_1 = current.circumstance;
        }
        else if (current.player == PlayerNumber.P2)
        {
            currentCircumstance_2 = current.circumstance;
        }
        else if (current.player == PlayerNumber.ALL)
        {
            currentCircumstance_1 = current.circumstance;
            currentCircumstance_2 = current.circumstance;
        }

        // 이미 플레이중인 애니메이션이 있다면 그 애니메이션 실행 중지
        if (current.player == PlayerNumber.P1 && dialogueAnim1p.GetBool("Moving") == true)
        {
            dialogueAnim1p.SetBool("Moving", false);
            isPlaying = true;
        }
        else if (current.player == PlayerNumber.P2 && dialogueAnim2p.GetBool("Moving") == true)
        {
            dialogueAnim2p.SetBool("Moving", false);
            isPlaying = true;
        }
        else if (current.player == PlayerNumber.ALL)
        {
            if (dialogueAnim1p.GetBool("Moving") == true && dialogueAnim2p.GetBool("Moving") == true)
            {
                dialogueAnim1p.SetBool("Moving", false);
                dialogueAnim2p.SetBool("Moving", false);
                isPlaying = true;
            }
        }

        // 만약 애니메이션이 이미 플레이 중이라면 0.5초 대기(유저에게 메시지 내용 보여주기 위함)
        if (isPlaying)
        {
            yield return(new WaitForSeconds(0.5f));
        }

        // 운석충돌상황
        if (current.circumstance == Circumstance.ALERT)
        {
            text1p.text = "운석에 맞았어...! 꽉 잡아!";
            text2p.text = "걱정해 주는척 하지마라";

            anim1p.SetTrigger("HoldOn");
            anim2p.SetTrigger("HoldOn");
        }
        // 엔진 교체 상황
        else if (current.circumstance == Circumstance.ENGINECHANGED)
        {
            text1p.text = "엔진 위치가 변경 되었어.";
            text2p.text = "어쩌라고, 싫으면 내리던가.";
        }
        // 스타트시 메시지1
        else if (current.circumstance == Circumstance.START_1)
        {
            text1p.text = "난 화성으로 간다. 넌 지구?";
        }
        // 스타트 2
        else if (current.circumstance == Circumstance.START_2)
        {
            text2p.text = "그래, 난 지구로 갈 거야.";
        }
        // 스타트 3
        else if (current.circumstance == Circumstance.START_3)
        {
            text1p.text = "나 운전 잘하는데~";
        }
        // 스타트시 4
        else if (current.circumstance == Circumstance.START_4)
        {
            text2p.text = "내가 너보다 더 운전 잘해";
        }
        // 2번째 엔진 꺼진 경우
        else if (current.circumstance == Circumstance.ENGINE_2OFF)
        {
            text1p.text = "2번 엔진 꺼졌다!";
        }
        // 1번째 엔진 꺼진 경우
        else if (current.circumstance == Circumstance.ENGINE_1OFF)
        {
            text2p.text = "1번 엔진에서 연기난다!";
        }
        // 3번째 엔진 꺼진 경우
        else if (current.circumstance == Circumstance.ENGINE_3OFF)
        {
            text2p.text = "3번 엔진 연료 부족!";
        }
        // 같은 버튼 (1번엔진) 누른경우
        else if (current.circumstance == Circumstance.SAMEBUTTON_1)
        {
            text1p.text = "야, 1번 엔진은 내 거야";
            text2p.text = "아 비켜 비켜!";

            anim1p.SetTrigger("Evading");
            anim2p.SetTrigger("Blocking");
        }
        // 같은 버튼 (2번엔진) 누른경우
        else if (current.circumstance == Circumstance.SAMEBUTTON_2)
        {
            text2p.text = "2번 엔진 건들지마.";
            text1p.text = "나도 2번 써야 해";

            anim2p.SetTrigger("Evading");
            anim1p.SetTrigger("Blocking");
        }
        // 같은 버튼 (3번엔진) 누른경우
        else if (current.circumstance == Circumstance.SAMEBUTTON_3)
        {
            text1p.text = "3번 엔진 내 건데~";
            text2p.text = "같이 좀 쓰자";

            anim1p.SetTrigger("Evading");
            anim2p.SetTrigger("Blocking");
        }

        // 1P 메시지 인 경우
        if (current.player == PlayerNumber.P1)
        {
            dialogueAnim1p.SetBool("Moving", true);
        }
        else if (current.player == PlayerNumber.P2)
        {
            dialogueAnim2p.SetBool("Moving", true);
        }
        else if (current.player == PlayerNumber.ALL)
        {
            dialogueAnim1p.SetBool("Moving", true);
            dialogueAnim2p.SetBool("Moving", true);
        }

        // 플레이 중이 아니었던 경우
        if (!isPlaying)
        {
            yield return(new WaitForSeconds(2f));
        }
        // 플레이 중이었어서 이전 애니메이션이 꺼졌던 경우
        else
        {
            yield return(new WaitForSeconds(2.5f));
        }

        // 다시 Moving을 False로 해서 애니메이션 종료
        if (current.player == PlayerNumber.P1 && dialogueAnim1p.GetBool("Moving") == true)
        {
            dialogueAnim1p.SetBool("Moving", false);
        }
        else if (current.player == PlayerNumber.P2 && dialogueAnim2p.GetBool("Moving") == true)
        {
            dialogueAnim2p.SetBool("Moving", false);
        }
        else if (current.player == PlayerNumber.ALL)
        {
            if (dialogueAnim1p.GetBool("Moving") == true && dialogueAnim2p.GetBool("Moving") == true)
            {
                dialogueAnim1p.SetBool("Moving", false);
                dialogueAnim2p.SetBool("Moving", false);
            }
        }


        currentCircumstance_1 = Circumstance.DUMMY;
        currentCircumstance_2 = Circumstance.DUMMY;
        Debug.Log("ANIMATING 종료");
    }
Exemple #25
0
 public virtual void Fail(Circumstance c)
 {
 }
Exemple #26
0
        public virtual KeyValuePair <Event, int> FindEventForFailure(Trigger tevent, PlanLibrary pl, Circumstance c)
        {
            Trigger failTrigger           = new Trigger(TEOperator.del, tevent.GetTEType(), tevent.GetLiteral());
            IEnumerator <IntendedPlan> ii = GetEnumerator();
            int posInStak = Size();

            // synchronized (pl.GetLock())
            while (!pl.HasCandidatePlan(failTrigger) && ii.MoveNext())
            {
                IntendedPlan ip = ii.Current;
                tevent      = ip.GetTrigger();
                failTrigger = new Trigger(TEOperator.del, tevent.GetTEType(), tevent.GetLiteral());
                posInStak--;
            }
            if (tevent.IsDesire() && tevent.IsAddition() && pl.HasCandidatePlan(failTrigger))
            {
                return(new KeyValuePair <Event, int>(new Event(failTrigger.Clone(), this), posInStak));
            }
            else
            {
                return(new KeyValuePair <Event, int>(null, 0));
            }
        }
Exemple #27
0
 public object AllDesires(Circumstance circumstance, Literal body, object p, Unifier unifier)
 {
     throw new NotImplementedException();
 }
Exemple #28
0
            public override KeyValuePair <Event, int> FindEventForFailure(Trigger tevent, PlanLibrary pl, Circumstance c)
            {
                KeyValuePair <Event, int> t = (KeyValuePair <Event, int>)base.FindEventForFailure(tevent, pl, c);

                if (t.Value <= forkPoint)
                {
                    if (fd.isAnd)
                    {
                        fd.intentions.Remove(this);
                        foreach (Intention ifo in fd.intentions)
                        {
                            c.DropIntention(ifo);
                        }
                    }
                    else
                    {
                        return(new KeyValuePair <Event, int>(null, t.Value));
                    }
                }
                return(t);
            }
Exemple #29
0
        override public object Execute(Reasoner ts, Unifier un, ITerm[] args)
        {
            CheckArguments(args);

            Trigger      g = new Trigger(TEOperator.add, TEType.achieve, (Literal)args[0]);
            Circumstance C = ts.GetCircumstance();

            // Search the goal in PI
            IEnumerator <string> ik = C.GetPendingIntentions().Keys.GetEnumerator();

            while (ik.MoveNext())
            {
                string    k = ik.Current;
                Intention i = C.GetPendingIntentions()[k];
                if (i.IsSuspended() && i.HasTrigger(g, un))
                {
                    i.SetSuspended(false);
                    bool notify = true;
                    if (k.StartsWith(SuspendStdLib.SUSPENDED_INT))   // if not SUSPENDED_INT, it was suspended while already in PI, so, do not remove it from PI, just change the suspeded status
                    {
                        ik.Dispose();

                        // add it back in I if not in PA
                        if (!C.GetPendingActions().ContainsKey(i.GetID()))
                        {
                            C.ResumeIntention(i);
                            notify = false; // the resumeIntention already notifies
                        }
                    }

                    // notify meta event listeners
                    if (notify && C.GetListeners() != null)
                    {
                        foreach (ICircumstanceListener el in C.GetListeners())
                        {
                            el.IntentionResumed(i);
                        }
                    }

                    // remove the IA .suspend in case of self-suspend
                    if (k.StartsWith(SuspendStdLib.SELF_SUSPENDED_INT))
                    {
                        i.Peek().RemoveCurrentStep();
                    }

                    //System.out.println("res "+g+" from I "+i.getId());
                }
            }

            // Search the goal in PE
            ik = C.GetPendingEvents().Keys.GetEnumerator();
            while (ik.MoveNext())
            {
                string k = ik.Current;
                if (k.StartsWith(SuspendStdLib.SUSPENDED_INT))
                {
                    Event     e = C.GetPendingEvents()[k];
                    Intention i = e.GetIntention();
                    if (un.Unifies(g, e.GetTrigger()) || (i != null && i.HasTrigger(g, un)))
                    {
                        ik.Dispose();
                        C.AddEvent(e);
                        if (i != null)
                        {
                            i.SetSuspended(false);
                        }
                    }
                }
            }
            return(true);
        }