public BehaveResult TickIzquierdaAction(Tree sender)
    {
        if (vecinos[3] == 1)
        {
            float   step  = speed * Time.deltaTime;
            Vector2 dest2 = Vector2.MoveTowards(transform.localPosition, dest, step);
            transform.localPosition = dest2;

            if ((Vector2)transform.localPosition == dest)
            {
                position = dest;
                if (maze.GetComponent <nivel>().hayPastilla((int)position.x, (int)position.y))
                {
                    maze.GetComponent <nivel>().eliminarPastilla((int)position.x, (int)position.y);
                    GetComponent <pacmanLogic>().scoreUp(10);
                }
                vecinos = maze.GetComponent <nivel>().getVecinos(position);
                if (vecinos[3] == 1)
                {
                    dest = position + Vector2.left;
                }
            }
            // Anima al pacman
            Vector2 dir = dest - (Vector2)transform.localPosition;
            GetComponent <Animator>().SetFloat("DirX", dir.x);
            GetComponent <Animator>().SetFloat("DirY", dir.y);
            return(BehaveResult.Running);
        }
        else
        {
            return(BehaveResult.Failure);
        }
    }
Beispiel #2
0
        BehaveResult Tick(Tree sender)
        {
            if (TDObj == null && TDpos == Vector3.zero)
            {
                return(BehaveResult.Failure);
            }

            if ((entity.ProtoID == 90 || entity.ProtoID == 91) && !GetBool("Fly"))
            {
                return(BehaveResult.Failure);
            }

            if ((entity.ProtoID == 93 || entity.ProtoID == 94) && GetBool("Crouch"))
            {
                return(BehaveResult.Failure);
            }

            if (hasAttackEnemy)
            {
                return(BehaveResult.Success);
            }

            if (TDpos != Vector3.zero)
            {
                MoveToPosition(TDpos, SpeedState.Run);
            }
            else if (TDObj != null)
            {
                MoveToPosition(TDObj.transform.position, SpeedState.Run);
            }
            return(BehaveResult.Running);
        }
Beispiel #3
0
        BehaveResult Init(Tree sender)
        {
            if (!GetData <Data>(sender, ref m_Data))
            {
                return(BehaveResult.Failure);
            }

            BehaveGroup group = sender.ActiveAgent as BehaveGroup;

            if (group == null || group.Leader == null)
            {
                return(BehaveResult.Failure);
            }

            if (Random.value > m_Data.prob)
            {
                return(BehaveResult.Failure);
            }

            m_Data.m_StartPatrolTime = Time.time;
            m_Data.m_LastSwitchTime  = 0.0f;
            m_Data.m_Time            = Random.Range(m_Data.minTime, m_Data.maxTime);
            m_Data.m_SwitchTime      = Random.Range(5.0f, 10.0f);

            group.PauseMemberBehave(true);
            return(BehaveResult.Running);
        }
Beispiel #4
0
        BehaveResult Tick(Tree sender)
        {
            BehaveGroup group = sender.ActiveAgent as BehaveGroup;

            if (group == null || group.Leader == null)
            {
                return(BehaveResult.Failure);
            }

            if (group.EscapeEnemy == null)
            {
                return(BehaveResult.Failure);
            }

            if (m_CurEscapeposition == Vector3.zero ||
                PEUtil.SqrMagnitudeH(group.Leader.position, m_CurEscapeposition) < 1.0f * 1.0f ||
                Time.time - m_LastRandomTime > 10.0f)
            {
                m_LastRandomTime = Time.time;

                PeTrans tr = group.Leader.GetComponent <PeTrans>();
                m_CurEscapeposition = GetEscapePosition(group, tr.position, tr.position - group.EscapeEnemy.position, 25.0f, 35.0f);
                if (m_CurEscapeposition == Vector3.zero)
                {
                    return(BehaveResult.Failure);
                }
                else
                {
                    group.MoveToPosition(m_CurEscapeposition, SpeedState.Run);
                }
            }

            return(BehaveResult.Running);
        }
Beispiel #5
0
        BehaveResult Tick(Tree sender)
        {
            if (!GetData <Data>(sender, ref m_Data))
            {
                return(BehaveResult.Failure);
            }

            BehaveGroup group = sender.ActiveAgent as BehaveGroup;

            if (group == null || group.Leader == null)
            {
                return(BehaveResult.Failure);
            }

            if (group.HasAttackEnemy() || group.HasEscapeEnemy())
            {
                return(BehaveResult.Failure);
            }

            if (Time.time - m_Data.m_StartIdleTime > m_Data.m_CurrentIdleTime)
            {
                return(BehaveResult.Success);
            }

            group.PauseMemberBehave(false);
            return(BehaveResult.Running);
        }
Beispiel #6
0
        BehaveResult Tick(Tree sender)
        {
            if (Enemy.IsNullOrInvalid(attackEnemy))
            {
                return(BehaveResult.Failure);
            }

            m_Data.m_AttackCheck = (EAttackCheck)attackEnemy.entityTarget.animCmpt.GetInteger("attackCheck");
            if (m_Data.m_AttackCheck != EAttackCheck.RunAway)
            {
                return(BehaveResult.Failure);
            }

            if (!IsReached(position, m_Data.m_Dirction, false))
            {
                MoveToPosition(m_Data.m_Dirction, SpeedState.Run);
            }
            else
            {
                StopMove();
                FaceDirection(attackEnemy.position - position);
            }

//			if(Time.time - m_Data.m_StarRunTime >= m_Data.RunAwayTime)
//				m_Data.m_AttackCheck = EAttackCheck.None;

            return(BehaveResult.Running);
        }
Beispiel #7
0
        BehaveResult Tick(Tree sender)
        {
            if (attackEnemy == null || attackEnemy.entityTarget == null || attackEnemy.entityTarget.target == null)
            {
                return(BehaveResult.Failure);
            }

            Enemy TargetEnemy = attackEnemy.entityTarget.target.GetAttackEnemy();

            if (TargetEnemy == null)
            {
                return(BehaveResult.Failure);
            }

            if (!NpcTypeDb.CanRun(NpcCmdId, ENpcControlType.Dodge))
            {
                return(BehaveResult.Failure);
            }

            if (attackEnemy.SqrDistanceXZ < 1.0f && attackEnemy.entityTarget.IsAttacking && TargetEnemy.entityTarget == entity)          //) //&& Random.value >= 0.3f
            {
                float   value = Random.value > 0.5f ? -1.0f : 1.0f;
                Vector3 ward  = Random.value > 0.5f ?  value * transform.right : -transform.forward;

                if (Random.value >= 0.3f && attackEnemy.entityTarget.IsAttacking)
                {
                    PEActionParamV param = PEActionParamV.param;
                    param.vec = ward;
                    DoAction(PEActionType.Step, param);
                }

                return(BehaveResult.Success);
            }
            return(BehaveResult.Failure);
        }
 public BehaveResult TickAccelAction(Tree sender)
 {
     //Debug.Log ("Ticked Accel Action");
     //Accelerate the ship if necessary
     if(aiShip.Thrust < 10.0f &&
        ((Vector3.Distance(aiShip.transform.position, playerShip.transform.position) > aiShip.DesiredDistance + 10) ||
         (Vector3.Distance(aiShip.transform.position, playerShip.transform.position) < aiShip.DesiredDistance - 10)))
     {
         aiShip.DesiredThrust = 10.0f;
         //Debug.Log("Thrust set!");
     }
     else
     {
         //Debug.Log(aiShip.name);
         //Debug.Log (playerShip.name);
         aiShip.DesiredThrust = playerShip.transform.GetComponent<ShipController>().DesiredThrust;
         //Debug.Log(aiShip.DesiredThrust);
     }
     if(aiShip.Moving)
     {
         return BehaveResult.Running;
     }
     else
     {
         return BehaveResult.Success;
     }
 }
Beispiel #9
0
    public BehaveResult TickKickBallAction(BLTree sender)
    {
        Debug.Log("Kick Ball");
        ball.rigidbody.AddForceAtPosition(Vector3.forward * 100,ball.transform.position);

        return BehaveResult.Success;
    }
Beispiel #10
0
        Vector3 GetPatrolPosition(Tree sender)
        {
            BehaveGroup group = sender.ActiveAgent as BehaveGroup;

            if (group == null || group.Leader == null)
            {
                return(Vector3.zero);
            }

            PeTrans tr  = group.Leader.GetComponent <PeTrans>();
            Vector3 pos = tr.position;

            if (m_Data.field == (int)MovementField.water)
            {
                return(PEUtil.GetRandomPositionInWater(pos, tr.trans.forward, m_Data.minRadius, m_Data.maxRadius, m_Data.minHeight, m_Data.maxHeight, -135.0f, 135.0f));
            }
            else if (m_Data.field == (int)MovementField.Sky)
            {
                if (group.Leader.IsFly)
                {
                    return(PEUtil.GetRandomPositionInSky(pos, tr.trans.forward, m_Data.minRadius, m_Data.maxRadius, m_Data.minHeight, m_Data.maxHeight, -135.0f, 135.0f));
                }
                else
                {
                    return(PEUtil.GetRandomPositionOnGround(pos, tr.trans.forward, m_Data.minRadius, m_Data.maxRadius, -135.0f, 135.0f));
                }
            }
            else
            {
                return(PEUtil.GetRandomPositionOnGround(pos, tr.trans.forward, m_Data.minRadius, m_Data.maxRadius, -135.0f, 135.0f));
            }
        }
 public BehaveResult TickIdleAction(Tree sender)
 {
     distWithEnemy = 200;
     enemyHealth   = 100;
     Debug.Log("Idling for a while!");
     return(BehaveResult.Success);
 }
Beispiel #12
0
        public void Destroy()
        {
            Stop();

            m_Tree   = null;
            m_Runner = null;
            m_Agent  = null;
        }
Beispiel #13
0
 void Reset(Tree sender)
 {
     if (m_Data != null)
     {
         m_Data.m_AttackCheck = EAttackCheck.None;
         m_Data.m_HasRoll     = false;
     }
 }
Beispiel #14
0
 void Reset(Tree sender)
 {
     if (m_Data != null)
     {
         m_Data.m_Dirction    = Vector3.zero;
         m_Data.m_AttackCheck = EAttackCheck.None;
     }
 }
Beispiel #15
0
 //SEEK
 public BehaveResult TickIsGrabOutOfRangeAction(Tree sender)
 {
     if (wbc.IsGrabOutOfRange())
     {
         return BehaveResult.Success;
     }
     return BehaveResult.Failure;
 }
 public BehaveResult TickEstoyApuntadoAction(Tree sender)
 {
     Debug.Log ("Estoy apuntado?: "+ agente.estoyApuntado());
     if (agente.estoyApuntado())
         return BehaveResult.Success;
     else
         return BehaveResult.Failure;
 }
 /*----Condicion--------------------------------*/
 public BehaveResult TickApuntarAction(Tree sender)
 {
     Debug.Log ("Apuntar enemigo?: "+ agente.enemigoApuntado());
     if (agente.enemigoApuntado())
         return BehaveResult.Success;
     else
         return BehaveResult.Failure;
 }
Beispiel #18
0
        BehaveResult Tick(Tree sender)
        {
            if (!GetData <Data>(sender, ref m_Data))
            {
                return(BehaveResult.Failure);
            }

            if (!TowerIsEnable())
            {
                return(BehaveResult.Failure);
            }

            if (!hasAttackEnemy)
            {
                return(BehaveResult.Failure);
            }

            Transform aim = attackEnemy.CenterBone;

            if (aim == null)
            {
                return(BehaveResult.Failure);
            }

            SetTowerAimPosition(aim);

            if (aim != null && !TowerAngle(aim.position, 5.0f))
            {
                return(BehaveResult.Running);
            }

            if (m_Data.isPitch && !TowerPitchAngle(aim.position, 5.0f))
            {
                return(BehaveResult.Running);
            }

            if (aim != null && !TowerCanAttack(aim.position, attackEnemy.trans))
            {
                return(BehaveResult.Running);
            }

            if (m_Data.m_CanAttack)
            {
                m_Data.SetCDTime(Time.time);
                TowerFire(attackEnemy.skTarget);
                m_Data.m_CanAttack = false;
                return(BehaveResult.Running);
            }

            if (TowerSkillRunning())
            {
                return(BehaveResult.Running);
            }
            else
            {
                return(BehaveResult.Success);
            }
        }
Beispiel #19
0
    public BehaveResult TickFreeTargetsAction(Tree sender)
    {
        if (wbc.DetectsFreeTargets())
        {
            return BehaveResult.Success;
        }

        return BehaveResult.Failure;
    }
Beispiel #20
0
    public BehaveResult TickIsInfectedAction(Tree sender)
    {
        if (rbc.IsInfected())
        {
            return BehaveResult.Success;
        }

        return BehaveResult.Failure;
    }
Beispiel #21
0
    public BehaveResult TickDamageOverTimeAction(Tree sender)
    {
        if (wbc.IsAttachedTargetDead())
        {
            return BehaveResult.Failure;
        }

        return BehaveResult.Running;
    }
Beispiel #22
0
    public BehaveResult TickIdleAction(Tree sender)
    {
        if (rbc.IsInfected() || rbc.IsKilled())
        {
            return BehaveResult.Success;
        }

        return BehaveResult.Running;
    }
Beispiel #23
0
    public BehaveResult TickIdleAction(Tree sender)
    {
        if (wbc.DetectsFreeTargets())
        {
            return BehaveResult.Success;
        }

        return BehaveResult.Running;
    }
Beispiel #24
0
 public override BehaveResult TickAttackAction(BLTree sender, string stringParameter, float floatParameter, IAgent agent, object data)
 {
     if (Time.time > attackRateTimer)
     {
         attackRateTimer = Time.time + enemyObject.timeBetweenAttacks;
         enemyObject.Attack();
     }
     return(BehaveResult.Success);
 }
Beispiel #25
0
    public override BehaveResult TickHasTargetAction(BLTree sender, string stringParameter, float floatParameter, IAgent agent, object data)
    {
        if (currentTarget != null && Vector3.Distance(transform.position, currentTarget.transform.position) < targetMaxDistance)
        {
            return(BehaveResult.Success);
        }

        return(BehaveResult.Failure);
    }
Beispiel #26
0
    //DAMAGE
    public BehaveResult TickIsAttachedAction(Tree sender)
    {
        if (wbc.IsAttached())
        {
            return BehaveResult.Success;
        }

        return BehaveResult.Failure;
    }
Beispiel #27
0
 public BehaveResult Tick(Behave.Runtime.Tree sender, bool init)
 {
     Debug.Log("Ticked Received by unhandled " +
               (BLNewBehaveLibrary0.IsAction(sender.ActiveID) ? "Action " :
                "Decorator ") +
               " ... " + (BLNewBehaveLibrary0.IsAction(sender.ActiveID) ?
                          ((BLNewBehaveLibrary0.ActionType)sender.ActiveID).ToString() :
                          ((BLNewBehaveLibrary0.DecoratorType)sender.ActiveID).ToString()));
     return(BehaveResult.Success);
 }
Beispiel #28
0
 public BehaveResult Tick(Tree sender, bool init)
 {
     Debug.Log("Ticked Received by unhandled " +
     (BLNewBehaveLibrary0.IsAction(sender.ActiveID) ? "Action " :
     "Decorator ") +
     " ... " + (BLNewBehaveLibrary0.IsAction(sender.ActiveID) ?
     ((BLNewBehaveLibrary0.ActionType)sender.ActiveID).ToString() :
     ((BLNewBehaveLibrary0.DecoratorType)sender.ActiveID).ToString()));
     return BehaveResult.Success;
 }
Beispiel #29
0
        BehaveResult Tick(Tree sender)
        {
            if (!GetData <Data>(sender, ref m_Data))
            {
                return(BehaveResult.Failure);
            }

            if (Enemy.IsNullOrInvalid(attackEnemy) || attackEnemy.entityTarget == null || attackEnemy.entityTarget.animCmpt == null)
            {
                return(BehaveResult.Failure);
            }


            m_Data.m_AttackCheck = (EAttackCheck)attackEnemy.entityTarget.animCmpt.GetInteger("attackCheck");
            if (m_Data.m_AttackCheck == EAttackCheck.All)
            {
                m_Data.m_AttackCheck = Random.value > 0.5f ? m_Data.m_AttackCheck = EAttackCheck.RunAway : m_Data.m_AttackCheck = EAttackCheck.Roll;
            }

            if (m_Data.m_AttackCheck != EAttackCheck.Roll)
            {
                return(BehaveResult.Failure);
            }

            if (m_Data.m_HasRoll)
            {
                return(BehaveResult.Failure);
            }

            if (!InRadiu(position, attackEnemy.position, 3.0f))
            {
                return(BehaveResult.Failure);
            }

            if (!IsInEnemyFoward(attackEnemy, entity))
            {
                return(BehaveResult.Failure);
            }

            Vector3        dir   = position - attackEnemy.position;
            PEActionParamV param = PEActionParamV.param;

            param.vec = dir;
            if (!CanDoAction(PEActionType.Step, param))
            {
                return(BehaveResult.Failure);
            }

            PEActionParamV paramV = PEActionParamV.param;

            paramV.vec       = dir;
            m_Data.m_HasRoll = DoAction(PEActionType.Step, paramV);

            return(BehaveResult.Running);
        }
Beispiel #30
0
    IEnumerator Start()
    {
        m_tree = BLSimple.InstantiateTree(BLSimple.TreeType.SimpleCollection_SimpleTree,this);

        while(Application.isPlaying && m_tree != null)
        {
            AIUpdate();
            yield return new WaitForSeconds(1 / m_tree.Frequency);

        }
    }
            public void LoadActionPlanStep(string actionName, OCAction.OCActionArgs arguments)
            {
                TreeType         treeType       = _ActionNameDictionary[actionName];
                Tree             tree           = _TreeTypeDictionary[treeType];
                OCActionPlanStep actionPlanStep = new OCActionPlanStep();

                actionPlanStep.Behaviour = tree;
                actionPlanStep.Arguments = arguments;
                _ActionPlanQueue.Enqueue(actionPlanStep);
                Debug.Log("Enqueued Action Step: " + actionPlanStep.Arguments.ActionName);
            }
Beispiel #32
0
 BehaveResult Tick(Tree sender)
 {
     if (attackEnemy == null || attackEnemy.GroupAttack == EAttackGroup.Attack)
     {
         return(BehaveResult.Failure);
     }
     else
     {
         return(BehaveResult.Success);
     }
 }
Beispiel #33
0
    //Dette er grundstenen i Behave. I stedet for BLNewBehaveLibrary, skriver man sit eget navn
    IEnumerator Start()
    {
        m_Tree = BLNewBehaveLibrary0.InstantiateTree(
            BLNewBehaveLibrary0.TreeType.HeroAI1_NewTree1, this);
        while (Application.isPlaying && m_Tree != null)
        {
            yield return new WaitForSeconds(1 / m_Tree.Frequency);
            AIUpdate();

        }
    }
Beispiel #34
0
    //Dette er grundstenen i Behave. I stedet for BLNewBehaveLibrary, skriver man sit eget navn



    IEnumerator Start()
    {
        m_Tree = BLNewBehaveLibrary0.InstantiateTree(
            BLNewBehaveLibrary0.TreeType.HeroAI1_NewTree1, this);
        while (Application.isPlaying && m_Tree != null)
        {
            yield return(new WaitForSeconds(1 / m_Tree.Frequency));

            AIUpdate();
        }
    }
Beispiel #35
0
            public void LoadActionPlanStep(string actionName, OCAction.OCActionArgs arguments)
            {
                //Debug.Log("OCActionController::LoadActionPlanStep: " + actionName);
                TreeType         treeType       = _ActionNameDictionary[actionName];
                Tree             tree           = _TreeTypeDictionary[treeType];
                OCActionPlanStep actionPlanStep = OCScriptableObject.CreateInstance <OCActionPlanStep>();

                actionPlanStep.Behaviour = tree;
                actionPlanStep.Arguments = arguments;
                _ActionPlanQueue.AddLast(actionPlanStep);
                System.Console.WriteLine(OCLogSymbol.DETAILEDINFO + "Enqueued Action Step: " + actionPlanStep.Arguments.ActionName);
            }
Beispiel #36
0
            public void LoadActionPlanStep(string actionName, OCAction.OCActionArgs arguments)
            {
                Debug.Log("OCActionController::LoadActionPlanStep: " + actionName);
                TreeType         treeType       = _ActionNameDictionary[actionName];
                Tree             tree           = _TreeTypeDictionary[treeType];
                OCActionPlanStep actionPlanStep = OCScriptableObject.CreateInstance <OCActionPlanStep>();

                actionPlanStep.Behaviour = tree;
                actionPlanStep.Arguments = arguments;
                _ActionPlanQueue.AddLast(actionPlanStep);
                Debug.Log("Enqueued Action Step: " + actionPlanStep.Arguments.ActionName);
            }
Beispiel #37
0
    IEnumerator Start()
    {
        enemyObject = GetComponent <Enemy>();

        _tree = BLStandardAI.InstantiateTree(BLStandardAI.TreeType.Enemies_BuzzSaw, this);

        while (Application.isPlaying && _tree != null)
        {
            AIUpdate();
            yield return(new WaitForSeconds(1 / _tree.Frequency));
        }
    }
Beispiel #38
0
        void SetTreeForward(Tree tree, BTAction action)
        {
            try
            {
                int index = (int)System.Enum.Parse(tree.LibraryActions, action.Name);

                MethodInfo start = action.GetType().GetMethod("Start",
                                                              BindingFlags.NonPublic | BindingFlags.Instance);

                MethodInfo init = action.GetType().GetMethod("Init",
                                                             BindingFlags.NonPublic | BindingFlags.Instance,
                                                             null,
                                                             new Type[] { typeof(Tree) },
                                                             null);

                MethodInfo Tick = action.GetType().GetMethod("Tick",
                                                             BindingFlags.NonPublic | BindingFlags.Instance,
                                                             null,
                                                             new Type[] { typeof(Tree) },
                                                             null);

                MethodInfo Reset = action.GetType().GetMethod("Reset",
                                                              BindingFlags.NonPublic | BindingFlags.Instance,
                                                              null,
                                                              new Type[] { typeof(Tree) },
                                                              null);

                if (start != null)
                {
                    start.Invoke(action, null);
                }

                if (init != null)
                {
                    tree.SetInitForward(index, Delegate.CreateDelegate(typeof(TickForward), action, init) as TickForward);
                }

                if (Tick != null)
                {
                    tree.SetTickForward(index, Delegate.CreateDelegate(typeof(TickForward), action, Tick) as TickForward);
                }

                if (Reset != null)
                {
                    tree.SetResetForward(index, Delegate.CreateDelegate(typeof(ResetForward), action, Reset) as ResetForward);
                }
            }
            catch (Exception)
            {
                //Debug.LogWarning(e);
            }
        }
Beispiel #39
0
            public BehaveResult      Tick(Tree sender, bool init)
            {
//			Debug.Log
//			(
//				"Got ticked by unhandled " + (BLOpenCogCharacterBehaviours.IsAction( sender.ActiveID ) ? "action" : "decorator")
//			+ ( BLOpenCogCharacterBehaviours.IsAction( sender.ActiveID )
//				? ((BLOpenCogCharacterBehaviours.ActionType)sender.ActiveID).ToString()
//				: ((BLOpenCogCharacterBehaviours.DecoratorType)sender.ActiveID).ToString()
//				)
//			);

                return(BehaveResult.Failure);
            }
Beispiel #40
0
 public BehaveResult TickHungryAction(Behave.Runtime.Tree sender)
 {
     if (WS.Hunger > 75)
     {
         Debug.Log("Wolfs Stomach is growling.");
         return(BehaveResult.Success);
     }
     else
     {
         Debug.Log("Wolf is fine for now");
         return(BehaveResult.Failure);
     }
 }
 public BehaveResult Tick(Tree sender, bool init)
 {
     //Shows up if there is an action or decorator that is unhandled in code.
     Debug.Log("Got ticked by unhandled " +
         (BLAIDemo.IsAction(sender.ActiveID) ? "action " : "decorator ") +
         (BLAIDemo.IsAction(sender.ActiveID) ?
             ((BLAIDemo.ActionType)sender.ActiveID).ToString()
         :
             ((BLAIDemo.DecoratorType)sender.ActiveID).ToString()
         )
     );
     return BehaveResult.Success;
 }
Beispiel #42
0
        public BTAgent(string btPath, string libraryName, string treeName)
        {
            m_BtPath      = btPath;
            m_LibraryName = libraryName;
            m_TreeName    = treeName;

            m_Pause  = false;
            m_Runner = null;
            m_Agent  = null;

            m_Actions = new List <BTAction>();
            m_Tree    = Reflecter.Instance.Instantiate(libraryName, treeName);
        }
 public BehaveResult TickGotoGameAction(Tree sender)
 {
     gameLoading++;
     Debug.Log("GotoGame ticked! Game loading: " + gameLoading.ToString());
     if (gameLoading < 100)
     {
         return(BehaveResult.Running);
     }
     else
     {
         return(BehaveResult.Success);
     }
 }
Beispiel #44
0
    public BehaveResult TickInfectedAction(Tree sender)
    {
        if (rbc.CheckShouldExplode())
        {
            return BehaveResult.Success;
        }

        if (rbc.IsKilled())
        {
            return BehaveResult.Failure;
        }

        return BehaveResult.Running;
    }
Beispiel #45
0
    public BehaveResult TickSeekAction(Tree sender)
    {
        if (!wbc.IsGrabOutOfRange())
        {
            return BehaveResult.Failure;
        }

        if (wbc.IsAttachedTargetDead())
        {
            return BehaveResult.Success;
        }

        return BehaveResult.Running;
    }
    public BehaveResult Tick(Tree sender, bool init)
    {
        Debug.Log(
            "Tick" +
            (BLNewBehaveLibrary0.IsAction(sender.ActiveID) ? " action " : " decorator ") +
            (BLNewBehaveLibrary0.IsAction(sender.ActiveID) ?
                ((BLNewBehaveLibrary0.ActionType)sender.ActiveID).ToString()
                :
                ((BLNewBehaveLibrary0.DecoratorType)sender.ActiveID).ToString()
                )
            );

        return BehaveResult.Success;
    }
Beispiel #47
0
    IEnumerator Start()
    {
        WS     = GetComponent <WolfStats>();
        nma    = GetComponent <NavMeshAgent>();
        m_Tree = BLWolf.InstantiateTree(
            BLWolf.TreeType.Wolf_Idle, this);

        while (Application.isPlaying && m_Tree != null)
        {
            yield return(new WaitForSeconds(1 / m_Tree.Frequency));

            AIUpdate();
        }
    }
Beispiel #48
0
 public BehaveResult TickTooWoundedAction(Behave.Runtime.Tree sender)
 {
     Debug.Log("Wolf Checks if he is fine.");
     if (WS.Health < 26)
     {
         Debug.Log("Wolfs wounds too great");
         return(BehaveResult.Success);
     }
     else
     {
         Debug.Log("He is fine.");
         return(BehaveResult.Failure);
     }
 }
Beispiel #49
0
    IEnumerator Start()
    {
        m_Tree = BLNewBehaveLibrary0.InstantiateTree(
            BLNewBehaveLibrary0.TreeType.HeroAI1_NewTree1, this);
        stats = gameObject.GetComponent<AIStats>();
        stats.distanceToTarget = 10;
        stats.fatigue = 100;
        stats.oreCap = 150;
        while (Application.isPlaying && m_Tree != null)
        {
            yield return new WaitForSeconds(1 / m_Tree.Frequency);
            AIUpdate();

        }
    }
Beispiel #50
0
 public BehaveResult TickGoToBallAction(BLTree sender)
 {
     if(!hitBall)
     {
         Debug.Log("GotoBall");
         moveVector = ball.transform.position - transform.position;
         moveVector.Normalize();
         transform.position += moveVector * Time.deltaTime * chaseMoveSpeed;
         return BehaveResult.Running;
     }
     else
     {
         return BehaveResult.Success;
     }
 }
Beispiel #51
0
    public BehaveResult TickResetAfterKickAction(BLTree sender)
    {
        if(!rest)
        {
            if(!setupRest)
            {
                Invoke("SetupReset",10);
                setupRest = true;
            }

            Debug.Log("Reset After Kick ball");
            return BehaveResult.Running;
        }
        else
        {
            Debug.Log("Reset After Kick ball");
            return BehaveResult.Success;
        }
    }
Beispiel #52
0
    public BehaveResult TickWaitForBallAction(BLTree sender)
    {
        if(!seeBall)
        {
            Debug.Log("WaitForBall");

            if(rest)
                rest = false;

            moveVector = ball.transform.position - transform.position;
            moveVector.Normalize();
            transform.position += moveVector * Time.deltaTime * idleMoveSpeed;

            return BehaveResult.Running;
        }
        else
        {
            return BehaveResult.Success;
        }
    }
 public BehaveResult TickAlignAction(Tree sender)
 {
     //Debug.Log("Tick Align Action!");
     //align the ship with the player if within desired range
     if(((Vector3.Distance(aiShip.transform.position, playerShip.transform.position) > aiShip.DesiredDistance + 10) ||
         (Vector3.Distance(aiShip.transform.position, playerShip.transform.position) < aiShip.DesiredDistance - 10)) &&
          (aiShip.transform.rotation.eulerAngles.y < playerShip.transform.rotation.eulerAngles.y || aiShip.transform.rotation.eulerAngles.y > playerShip.transform.rotation.eulerAngles.y))
     {
         aiShip.setTargetRotation(playerShip.transform.rotation.eulerAngles.y - transform.rotation.eulerAngles.y);
         aiShip.beginRotation();
         //Debug.Log (this.transform.name + " align to player");
     }
     else if(Vector3.Distance(aiShip.transform.position, playerShip.transform.position) > 100)
     {
         aiShip.setTargetRotation(180);
         aiShip.beginRotation();
         //Debug.Log (this.transform.name + " set rotation");
     }
     return BehaveResult.Success;
 }
	public int	 SelectTopPriority(Tree sender, params int[] IDs)
	{
		return IDs[0];
	}
	public void	 Reset(Tree sender)
	{
	}
	public BehaveResult	 Tick(Tree sender, bool init)
	{
//			Debug.Log
//			(
//				"Got ticked by unhandled " + (BLOpenCogCharacterBehaviours.IsAction( sender.ActiveID ) ? "action" : "decorator")
//			+ ( BLOpenCogCharacterBehaviours.IsAction( sender.ActiveID )
//				? ((BLOpenCogCharacterBehaviours.ActionType)sender.ActiveID).ToString()
//				: ((BLOpenCogCharacterBehaviours.DecoratorType)sender.ActiveID).ToString()
//				)
//			);

		return BehaveResult.Failure;
	}
Beispiel #57
0
    //ACTION PRECHECK
    public BehaveResult TickSetClosestAction(Tree sender)
    {
        wbc.SetClosestTarget();

        return BehaveResult.Success;
    }
Beispiel #58
0
    public BehaveResult TickSetStateSeekAction(Tree sender)
    {
        wbc.SetState(new WBCStateSeek(wbc));

        return BehaveResult.Success;
    }
Beispiel #59
0
    IEnumerator Start()
    {
        wbc = (WBCScript)GetComponent<WBCScript>();
        tree = BLLib.InstantiateTree(BLLib.TreeType.Trees_WBC, this);

        while (Application.isPlaying && tree != null)
        {
            yield return new WaitForSeconds(0.0f);
            AIUpdate();
        }
    }
Beispiel #60
0
 public BehaveResult Tick(Tree sender, bool init)
 {
     return BehaveResult.Failure;
 }