示例#1
0
        protected Vector3 GetRandomTargetCloseToPc(PCBehavior pc)
        {
            if (pc == null)
            {
                Debug.Log(AIcontext.Get <Team>("SelfTeam"));
            }

            Vector2 randV2 = UnityEngine.Random.insideUnitCircle * pc.PCRange;

            // just another security check
            if (AIcontext.Get <NavMeshAgent>("agent").isOnNavMesh)
            {
                AIcontext.Set <PCBehavior>("PcTarget", pc);

                if (pc == null)
                {
                    return(AIcontext.Get <Transform>("self").position + new Vector3(randV2.x, 1f, randV2.y));
                }
                else
                {
                    // We set target  to some place around the pc (but still inside)
                    return(pc.transform.position + new Vector3(randV2.x, 1f, randV2.y));
                }
            }

            return(pc.trans.position);
        }
示例#2
0
        public override BTState Run()
        {
            AIcontext.Set <Vector3>(
                RandomPositionName,
                positionToReach);

            return(BTState.Success);
        }
示例#3
0
        public override BTState Run()
        {
            AIcontext.Set <Vector3>(
                RandomPositionName,
                GetRandomTargetCloseToPc(
                    PCManager.Instance.GetFirstNeutralEnemyPC(
                        AIcontext.Get <Transform>("self").position,
                        AIcontext.Get <Team>("SelfTeam"),
                        AIcontext.Get <bool>("ShallDebug"))));

            return(BTState.Success);
        }
示例#4
0
        public override BTState Run()
        {
            Transform target = AIcontext.Get <Transform>("Target");

            if (AIcontext.Get <bool>("ShallDebug"))
            {
                Debug.Log(target == null ? "HasTarget -> no" : ("HasTarget -> yes " + target.name));
            }

            //        if (target == null ||
            //!Spawner.Instance.isAlive(target) ||
            //!CheckDistance(target) ||
            //!IsInConeOfSight(target) ||
            //!CanBeSeen(target))
            //        {
            //            AIcontext.Set<Transform>("Target", null);
            //            return BTState.Failure;
            //        }
            if (target == null)
            {
                if (AIcontext.Get <Transform>("self").name == _name)
                {
                    Debug.Log("HasTarget == null");
                }

                AIcontext.Set <Transform>("Target", null);
                return(BTState.Failure);
            }
            if (!Spawner.Instance.isAlive(target))
            {
                AIcontext.Set <Transform>("Target", null);
                return(BTState.Failure);
            }
            if (!CheckDistance(target))
            {
                AIcontext.Set <Transform>("Target", null);
                return(BTState.Failure);
            }
            if (!IsInConeOfSight(target))
            {
                AIcontext.Set <Transform>("Target", null);
                return(BTState.Failure);
            }
            if (!CanBeSeen(target))
            {
                AIcontext.Set <Transform>("Target", null);
                return(BTState.Failure);
            }

            return(BTState.Success);
        }
示例#5
0
        bool EvaluateTargets(List <Transform> enemies)
        {
            if (AIcontext.Get <Transform>("self").name == _name)
            {
                Debug.Log((enemies == null || enemies.Count == 0) ?
                          "SelectTarget -> null or 0 enemies found" :
                          ("SelectTarget -> found : " + enemies.Count + " enemies"));
            }

            EvalueateInConeOfSight(ref enemies);
            if (AIcontext.Get <Transform>("self").name == _name)
            {
                Debug.Log(enemies.Count == 0 ?
                          "EvalueateInConeOfSight -> no enemies were in cone of sight" :
                          ("EvalueateInConeOfSight -> still : " + enemies.Count + " enemies remains"));
            }

            EvaluateSeables(ref enemies);
            if (AIcontext.Get <Transform>("self").name == _name)
            {
                Debug.Log((enemies == null || enemies.Count == 0) ?
                          "EvaluateSeables -> null or 0 enemies were seable" :
                          ("EvaluateSeables -> still : " + enemies.Count + " enemies were seeing."));
            }
            if (enemies.Count > 0)
            {
                AIcontext.Set <Transform>(
                    "Target",
                    GetClosest(enemies));
                if (AIcontext.Get <Transform>("self").name == _name)
                {
                    Debug.Log("EvaluateSeables -> Choose : " + AIcontext.Get <Transform>("Target").name);
                }

                return(true);
            }

            return(false);
        }