コード例 #1
0
    /// <summary>
    /// 增加仇恨值,若仇恨目标不在仇恨列表里,则先加入列表
    /// </summary>
    /// <param name="HateSourceID">仇恨目标</param>
    public void AddHateValue(int HateSourceID)
    {
        Individual HateSource = Factory.GetIndividual(HateSourceID);

        if (HateSource == null)
        {
            Logger.Log("HateSource is null", LogType.Hatred);
            return;
        }
        //如果目标的势力和自己相同则不列入仇恨列表
        //if (HateSource.power == individual.power)
        //{
        //    Debug.Log("因为目标是友军,所以不对友军产生仇恨");
        //    return;
        //}

        if (!hatredMap.ContainsKey(HateSource))
        {
            AddHatredList(HateSource);
            //把仇恨目标的名字加入到仇恨列表可视化
            hatredListShow.Add(HateSource.name);
        }
        else
        {
            hatredMap[HateSource] += HateSource.hatredValue;
        }

        //此处更新行为树的最新目标
        SharedTransform sf = GetMostHatedTarget();

        behaviorTree.SetVariable("MostHatredTarget", sf);

        Logger.Log(gameObject.name + "对ID为" + HateSource.gameObject.name + "的对象增加了" + hatredMap[HateSource] + "点仇恨值", LogType.Hatred);
    }
コード例 #2
0
 public override void OnReset()
 {
     target            = null;
     rotationDampening = 10;
     rotateWeapon      = true;
     aimThreshold      = 0.4f;
 }
コード例 #3
0
        public override void Initialize(BehaviourProcessor behaviourProcessor)
        {
            base.Initialize(behaviourProcessor);

            distance = behaviourProcessor.GetData <SharedFloat>(distanceKey);
            target   = behaviourProcessor.GetData <SharedTransform>(targetKey);
        }
コード例 #4
0
ファイル: Pawn_Chase.cs プロジェクト: Jyobeat/RunAway
 public override void OnStart()
 {
     _myTime = 0f;
     //_target = _pawnWithin._player;
     _target = GameObject.FindGameObjectWithTag(_Data._tagPlayer).transform;
     _currentChasing.Value++;
     //_seed.Value = (int)Time.time;
 }
コード例 #5
0
 public override TaskStatus OnUpdate()
 {
     if (this.targetTransform == null)
     {
         Debug.LogWarning("Transform is null");
         return(TaskStatus.Failure);
     }
     this.targetTransform.parent = this.parent.Value;
     return(TaskStatus.Success);
 }
コード例 #6
0
 /// <summary>
 /// Reset the public variables back to their defaults.
 /// </summary>
 public override void OnReset()
 {
     targetTransform = null;
     targetPosition  = Vector3.zero;
     lookAhead       = 1;
     fullSpeed       = 3.5f;
     formationSpeed  = 2f;
     slowdownSpeed   = 1f;
     catchupSpeed    = 3f;
     waitTime        = 0;
     waitToMove      = true;
 }
コード例 #7
0
        public override void OnStart()
        {
            destinationTransform = GetComponent <Transform>();
            var currentGameObject = GetDefaultGameObject(targetGameObject.Value);

            if (currentGameObject != prevGameObject)
            {
                navMeshAgent   = currentGameObject.GetComponent <NavMeshAgent>();
                prevGameObject = currentGameObject;
            }

            destination = destinationTransform.Value.position;
        }
コード例 #8
0
        public void SetNavPoint(Transform navpoint)
        {
            if (_behavior_tree == null)
            {
                return;
            }
            SharedTransform innernav = (SharedTransform)_behavior_tree.GetVariable(AITreeArg.NavTarget);

            if (innernav != null)
            {
                innernav.SetValue(navpoint);
            }
        }
コード例 #9
0
        public override TaskStatus OnUpdate()
        {
            SharedTransform target = (SharedTransform)Owner.GetVariable("target");

            if (target.Value == null)
            {
                Debug.Log("--- HasTarget, false");
                return(TaskStatus.Failure);
            }
            else
            {
                Debug.Log("--- HasTarget, true");
                return(TaskStatus.Success);
            }
        }
コード例 #10
0
    public void Awake()
    {
        // Cache the Character instance which controls this component. Avoids excessive runtime lookups.
        character = GetComponent <Character>();

        // Cache the BehaviorTree controlling the character's AI. May be null if the character does not have a behavior tree
        behaviorTree = GetComponent <BehaviorTree>();

        // If the character has a behavior tree
        if (behaviorTree != null)
        {
            // Cache the variables used to determine the character's behaviour in his behaviour tree
            behaviorTreeAttackTarget   = (SharedTransform)behaviorTree.GetVariable("AttackTarget");
            behaviorTreeFollowDistance = (SharedFloat)behaviorTree.GetVariable("FollowDistance");
        }
    }
コード例 #11
0
 private void drawSharedVariableInput(SharedVariable sv)
 {
     if (sv.type == SharedVariable.SharedType.TRANSFORM)
     {
         SharedTransform sv_transform = sv as SharedTransform;
         sv_transform.value = EditorGUILayout.ObjectField(sv_transform.value, typeof(Transform), false) as Transform;
     }
     else if (sv.type == SharedVariable.SharedType.STRING)
     {
         SharedString sv_string = sv as SharedString;
         sv_string.value = GUILayout.TextField(sv_string.value);
     }
     else if (sv.type == SharedVariable.SharedType.GAMEOBJECT)
     {
         SharedGameObject sv_gameobject = sv as SharedGameObject;
         sv_gameobject.value = EditorGUILayout.ObjectField(sv_gameobject.value, typeof(GameObject), false) as GameObject;
     }
     else if (sv.type == SharedVariable.SharedType.OBJECT)
     {
         SharedObject sv_object = sv as SharedObject;
         sv_object.value = EditorGUILayout.ObjectField(sv_object.value, typeof(UnityEngine.Object), false) as UnityEngine.Object;
     }
     else if (sv.type == SharedVariable.SharedType.FLOAT)
     {
         SharedFloat sv_float = sv as SharedFloat;
         sv_float.value = EditorGUILayout.FloatField(sv_float.value);
     }
     else if (sv.type == SharedVariable.SharedType.INT)
     {
         SharedInt sv_integer = sv as SharedInt;
         sv_integer.value = EditorGUILayout.IntField(sv_integer.value);
     }
     else if (sv.type == SharedVariable.SharedType.BOOL)
     {
         SharedBool sv_bool = sv as SharedBool;
         sv_bool.value = EditorGUILayout.Toggle(sv_bool.value);
     }
     else if (sv.type == SharedVariable.SharedType.VECTOR)
     {
         SharedVector sv_vec = sv as SharedVector;
         sv_vec.value = EditorGUILayout.Vector3Field("", sv_vec.value);
     }
 }
コード例 #12
0
    // Use this for initialization
    void Start()
    {
        Target = GameObject.FindGameObjectWithTag("Player").transform;

        for (int i = 0; i < EnemyNumber; i++)
        {
            GameObject enemy = GameObject.Instantiate(prbEnemy);
            enemy.transform.parent        = this.transform;
            enemy.transform.localPosition = new Vector3(Random.Range(-5f, 5f), 0.5f, Random.Range(-2, 2f));

            enemy.AddComponent <EnemyController>();
            var bt    = enemy.AddComponent <BehaviorTree>();
            var extBt = Resources.Load <ExternalBehaviorTree>("BehaveAI/EnemyAI_001");
            bt.StartWhenEnabled     = true;
            bt.PauseWhenDisabled    = true;
            bt.RestartWhenComplete  = true;
            bt.ResetValuesOnRestart = true;
            bt.ExternalBehavior     = extBt;
            bt.EnableBehavior();
        }
    }
コード例 #13
0
 public override void OnReset()
 {
     this.sharedTransform  = null;
     this.sharedGameObject = null;
 }
コード例 #14
0
ファイル: HasFindTarget.cs プロジェクト: xionggan/BH3
 public override void OnReset()
 {
     targetTransform = null;
 }
コード例 #15
0
ファイル: GetChild.cs プロジェクト: wishes2018/UnityGame
 public override void OnReset()
 {
     targetGameObject = null;
     index = 0;
     storeValue = null;
 }
コード例 #16
0
ファイル: FindChild.cs プロジェクト: dev-celvin/DK
 public override void OnReset()
 {
     targetGameObject = null;
     transformName = null;
     storeValue = null;
 }
コード例 #17
0
 public override void OnReset()
 {
     targetGameObject = null;
     index            = 0;
     storeValue       = null;
 }
コード例 #18
0
 public virtual void OnReset()
 {
     this.sharedGameObject = (SharedGameObject)null;
     this.sharedTransform  = (SharedTransform)null;
 }
コード例 #19
0
ファイル: SetParent.cs プロジェクト: wuxijin999/Plugin
 public override void OnReset()
 {
     targetGameObject = null;
     parent           = null;
 }
コード例 #20
0
 public override void OnReset()
 {
     variable = null;
     compareTo = null;
 }
コード例 #21
0
 public override void OnReset()
 {
     targetTransform = null;
     atkRange        = 0;
 }
コード例 #22
0
 public override void OnReset()
 {
     this.targetGameObject = null;
     this.index            = 0;
     this.storeValue       = null;
 }
コード例 #23
0
 public override void OnReset()
 {
     sharedGameObject = null;
     sharedTransform = null;
 }
コード例 #24
0
 public virtual void OnReset()
 {
     this.targetGameObject = (SharedGameObject)null;
     this.index            = (SharedInt)0;
     this.storeValue       = (SharedTransform)null;
 }
コード例 #25
0
 public override void OnReset()
 {
     targetValue    = null;
     targetVariable = null;
 }
コード例 #26
0
ファイル: SetSharedTransform.cs プロジェクト: dev-celvin/DK
 public override void OnReset()
 {
     targetValue = null;
     targetVariable = null;
 }
コード例 #27
0
 public override void OnReset()
 {
     variable  = null;
     compareTo = null;
 }
コード例 #28
0
 public virtual void OnReset()
 {
     this.targetGameObject = (SharedGameObject)null;
     this.transformName    = (SharedTransform)null;
 }
コード例 #29
0
 public override void OnReset()
 {
     this.targetGameObject = null;
     this.transformName    = null;
 }
コード例 #30
0
ファイル: Pawn_WithinSight.cs プロジェクト: Jyobeat/RunAway
 public override void OnAwake()
 {
     _player = GameObject.FindGameObjectWithTag("Player").transform;
 }
コード例 #31
0
ファイル: SetParent.cs プロジェクト: wishes2018/UnityGame
 public override void OnReset()
 {
     targetGameObject = null;
     parent = null;
 }
コード例 #32
0
ファイル: AiJudgeAngle.cs プロジェクト: sols11/Dawnblade
 // Reset the public variables
 public override void OnReset()
 {
     targetTransform = null;
     judgeDirection  = null;
 }
コード例 #33
0
 public virtual void OnReset()
 {
     this.targetValue    = (SharedTransform)null;
     this.targetVariable = (SharedTransform)null;
 }
コード例 #34
0
ファイル: LookAtPlayer.cs プロジェクト: xionggan/BH3
 public override void OnReset()
 {
     targetGameObject = null;
     lookTransform    = null;
 }
コード例 #35
0
ファイル: FindChild.cs プロジェクト: BAI2018DA/Unity
 public override void OnReset()
 {
     targetGameObject = null;
     transformName    = null;
     storeValue       = null;
 }
コード例 #36
0
 public override void OnReset()
 {
     this.variable  = null;
     this.compareTo = null;
 }