Example #1
0
    //End of behaviour methods
    //A lot of the variables here should be loaded into an ini file, for customisation
    public SteeringBehaviour(AIEntity own)
    {
        this.owner = own;
        entityFlags = 0;
        boxLength = 5;
        weightEvade = 0.5;
        weightPursuit = 0.5;
        weightArrive = 0.5;
        weightFlee = 0.5;
        weightSeek = 0.5;
        weightWander = 0.5;
        weightWallAvoidance = 0.5;
        weightObstacleAvoidance = 0.5;
        useCellPartitioning = false;
        numberOfFeelers = 3;
        summingMethod = SumMethod.priority;
        wanderDist = SteeringBehaviour.wanderDistance;
        wanderRad = SteeringBehaviour.wanderRadius;
        wanderJit = SteeringBehaviour.wanderJitter;
        currentAccel = AccelerationType.medium;
        waypointSeekDistance = 5;
        entityViewDistance = 10;
        feelersForWall = new Vector[3];

        double sigma = UnityEngine.Random.Range(0.0f, 180.0f)*3.14;
        wanderTarget = new Vector(wanderDist*Mathf.Cos((float)sigma), wanderDist*Mathf.Sin((float)sigma));

        //Set the path data here, when the class has been made.
    }
Example #2
0
 public static float AttackAction(AIEntity pEntity)
 {
     //距离小,处于交战
     if (Vector3.Distance(pEntity.AIPos, pEntity.PlayerPos) < 20.0f &&
         pEntity.GetComponent <getPlayer> ().engage)
     {
         return(0.6f);
     }
     return(0.0f);
 }
Example #3
0
 public static float EscapeAction(AIEntity pEntity)
 {
     // 生命值小于百分之三十就跑
     if (pEntity.GetComponent <trapAI> ().HPNow < pEntity.GetComponent <trapAI> ().HP * 0.3f &&
         Vector3.Distance(pEntity.AIPos, pEntity.PlayerPos) < 20.0f)
     {
         return(0.7f);
     }
     return(0.0f);
 }
Example #4
0
 // 分配下标
 public static int[] Allocation(AIEntity pSponsor, AIEntity[] pResponsers)
 {
     // 发起者下标默认为0,因此响应者下标从1开始
     int[] ti = new int[pResponsers.Length];
     for (int i = 0; i < pResponsers.Length; i++)
     {
         ti [i] = i + 1;
     }
     return(ti);
 }
Example #5
0
    public static void SM_Walkaway(AIEntity pEntity)
    {
        Vector3 tDir = pEntity.AIPos - pEntity.PlayerPos;

        pEntity.GetComponent <AIMove> ().mDirection = tDir.normalized;
        pEntity.GetComponent <AIMove> ().mVelocity  = pEntity.GetComponent <shieldAI> ().walkVel;
        pEntity.GetComponent <AIMove> ().mMoveFunc  = MoveFunc.Complex;      //simple穿模寻路 complex避障寻路

        pEntity.GetComponent <staComponent> ().staNow -= pEntity.GetComponent <staComponent> ().staWalk *Time.deltaTime;
    }
Example #6
0
    /// <summary>
    /// Spawn a Minion From its Identifier
    /// </summary>
    /// <param name="entityIdentifier">Entity Identifier to spawn</param>
    /// <param name="pos">Position</param>
    /// <param name="rot">Rotation</param>
    public AIEntity SpawnMinion(string entityIdentifier, Vector3 pos, Quaternion rot)
    {
        MinionData def         = GameDataManager.instance.GetEntityData(entityIdentifier) as MinionData;
        GameObject obj         = SpawnManager.instance.InstantiatePool(def.m_prefab, pos, rot);
        AIEntity   iaComponent = obj.GetComponent <AIEntity>();

        iaComponent.InitializeEntity(def, Guid.NewGuid().ToString());
        NetworkServer.Spawn(obj);
        return(iaComponent);
    }
Example #7
0
 public static void Test_Group_Return_Enter(AIEntity pLeader, AIEntity[] pMembers, int pid)
 {
     pLeader.GetComponent <AIMove> ().mDirection = Vector3.zero;
     pLeader.GetComponent <AIMove> ().mVelocity  = 0.0f;
     for (int i = 0; i < pMembers.Length; i++)
     {
         pMembers [i].GetComponent <AIMove> ().mDirection = Vector3.zero;
         pMembers [i].GetComponent <AIMove> ().mVelocity  = 0.0f;
     }
 }
Example #8
0
    // Token: 0x06001A14 RID: 6676 RVA: 0x000D4F88 File Offset: 0x000D3188
    private static bool PossibleHijackTarget(AIEntity _aie, UID _owner)
    {
        if (!(_aie != null) || _owner.IsAlly(_aie.m_UID) || !_aie.ValidHijackTarget())
        {
            return(false);
        }
        StateReturnToBase stateReturnToBase = (StateReturnToBase)_aie.m_Stack.Find(typeof(StateReturnToBase), true);

        return(stateReturnToBase == null || stateReturnToBase.m_Why != StateReturnToBase.Why.Cloned);
    }
Example #9
0
    public static float Gre2Runaway(AIEntity pEntity)
    {
        float dis = Vector3.Distance(pEntity.AIPos, pEntity.mPlayer.transform.position);

        if (dis > 10.0f)
        {
            return(0.0f);
        }
        return((10.0f - dis) / 10.0f);
    }
Example #10
0
    // 是的,很蛋疼...
    public static void TM_Aim_Enter(AIEntity pEntity)
    {
//		Debug.Log ("TMAim");
        pEntity.GetComponent <trapAI> ().fireRate = pEntity.GetComponent <trapAI> ().fireRateInit;
        if (pEntity.GetComponent <AIEmotion> ().mtempName == "Angry")
        {
            pEntity.GetComponent <trapAI> ().fireRate *= 0.5f;
        }
        pEntity.GetComponent <trapAI> ().aimFinish = false;
    }
Example #11
0
    public static void Battle(AIEntity pEntity)
    {
        GameObject tObject = pEntity.GetComponent <ObstacleComponent> ().hitObject;

        pEntity.GetComponent <BaseAIComponent> ().mAIRT.transform.forward = tObject.transform.position - pEntity.GetComponent <BaseAIComponent> ().mAIRT.transform.position;
        if (tObject != null)
        {
            GameObject.Destroy(tObject);
        }
    }
Example #12
0
 public static void Engage_Exit(AIEntity pSponsor, AIEntity[] pResponsers, int pid)
 {
     // 把射击关闭
     Debug.Log("SM3TM1 Engage Exit");
     if (pid == 0)
     {
         pSponsor.GetComponent <trapAI> ().shootPoint.GetComponent <GytFirePos> ().fireRate = 1000.0f;
         pSponsor.GetComponent <trapAI> ().shootPoint.GetComponent <GytFirePos> ().shoot    = false;
     }
 }
Example #13
0
        private object IOnEntityEffect(StandardEntityFluidEffect effect, EntityEffectSourceData sourceData, float relativeValue)
        {
            if (sourceData == null || effect.ResolveTargetType() != EntityFluidEffectKeyDatabase.Instance?.Health)
            {
                return(null);
            }

            EntityStats stats = effect.EntityStats;

            if (stats == null)
            {
                return(null);
            }

            float newValue     = Mathf.Clamp(effect.Value + relativeValue, effect.MinValue, effect.MaxValue);
            float updatedValue = newValue - effect.Value;

            sourceData.Value = updatedValue;

            AIEntity entity = stats.GetComponent <AIEntity>();

            if (entity != null)
            {
                if (updatedValue > 0)
                {
                    return(Interface.CallHook("OnEntityHeal", entity, sourceData));
                }
                else if (updatedValue < 0)
                {
                    return(Interface.CallHook("OnEntityTakeDamage", entity, sourceData));
                }

                return(null);
            }

            HNetworkView networkView = stats.networkView;

            if (networkView != null)
            {
                PlayerSession session = GameManager.Instance.GetSession(stats.networkView.owner);
                if (session != null)
                {
                    if (updatedValue > 0)
                    {
                        return(Interface.CallHook("OnPlayerHeal", session, sourceData));
                    }
                    else if (updatedValue < 0)
                    {
                        return(Interface.CallHook("OnPlayerTakeDamage", session, sourceData));
                    }
                }
            }

            return(null);
        }
Example #14
0
            public void Execute(Entity e)
            {
                AIEntity entity = (AIEntity)e;

                // check point 1
                {
                    // damaged first
                    if (entity.triggerDamage)
                    {
                        entity.target        = entity.triggerDamage;
                        entity.triggerDamage = null;
                        entity.Event         = eEntityState.Search;
                        return;
                    }

                    // check target in sight
                    if (Facade_AI.DetectTarget(entity.property, entity.property.tb.sightRange, out entity.target))
                    {
                        Debug.Log("- Detect palyer!!");

                        // check runaway condition (life)
                        if (entity.Ai.IsRunawayCondition())
                        {
                            entity.Event = eEntityState.Runaway;
                            return;
                        }
                        // check distance for attacking or
                        Vector3 distance = entity.target.transform.position - entity.property.transform.position;
                        if (distance.magnitude < entity.property.tb.attackRange)
                        {
                            entity.Event = eEntityState.Attack;
                        }
                        else
                        {
                            entity.Event = eEntityState.Chase;
                        }
                        return;
                    }
                }

                // check point 2
                {
                    // change next moving position
                    if (!entity.Ai.IsMoving)
                    {
                        if (Facade_NavMesh.RandomRangePoint(
                                entity.property.transform.position,
                                entity.property.tb.wander_min_range,
                                entity.property.tb.wander_max_range, out entity.destination))
                        {
                            entity.Ai.agent.destination = entity.destination;
                        }
                    }
                }
            }
Example #15
0
 public void NotifyDeath(AIEntity _whoDied, AIEventNotification _event)
 {
     if (_whoDied.transform == this.m_Target)
     {
         this.Cancel();
     }
     else
     {
         this.TargetHijackEnd(_whoDied.transform);
     }
 }
Example #16
0
    public static void FSM_Runaway(AIEntity pEntity)
    {
        //pEntity.GetComponent<myAI> ().tempHP += 2;
        Vector3 tDir = pEntity.AIPos - pEntity.PlayerPos;

        pEntity.GetComponent <AIMove> ().mDirection = tDir.normalized;
        pEntity.GetComponent <AIMove> ().mVelocity  = pEntity.GetComponent <myAI> ().mWalkVelocity;
        pEntity.GetComponent <AIMove> ().mMoveFunc  = MoveFunc.Complex;
        //pEntity.GetComponent<AIForward> ().mForward = tDir.normalized;
        pEntity.GetComponent <myAI> ().tired += 8.0f;
    }
Example #17
0
    // This method spawns each enemy wave for the teams
    // Sends data to each minion playerstats script
    void SpawnMinion(WaveData wave)
    {
        AIEntity minionEntity = ServerEntitySpawner.instance.SpawnMinion(wave.m_entityIdentifier, wave.m_position.position, transform.rotation);

        waypointScript         = minionEntity.GetComponent <WaypointProgressTracker>();
        minionScript           = minionEntity.GetComponent <AIEntity>();
        waypointScript.circuit = circuitScript;
        minionEntity.name      = wave.m_entityIdentifier + waveNumber.ToString();
        (minionScript.EntityLogic as MinionWaveLogic).XOffset = wave.m_position.position.x;
        waveNumber++;
    }
Example #18
0
    public static float yali_Transfer(AIEntity pEntity)
    {
        int sum = 0;

        //	Debug.Log ("yali");
        for (int i = 0; i < 20; i++)
        {
            Debug.Log("yali");
        }
        return(0.1f);
    }
Example #19
0
 public static float TM_Aim_Fire(AIEntity pEntity)
 {
     if (pEntity.GetComponent <trapAI> ().aimFinish)
     {
         return(1.0f);           //瞄准完毕就射击
     }
     else
     {
         return(0.0f);
     }
 }
Example #20
0
    // 射击,确定方向,初始化射击时间
    public static void TM_Fire_Enter(AIEntity pEntity)
    {
//		Debug.Log ("TMFire");
        pEntity.GetComponent <trapAI> ().fired    = false;
        pEntity.GetComponent <trapAI> ().fireRate = -1f;
        Vector3 dir = pEntity.PlayerPos - pEntity.AIPos;

        pEntity.GetComponent <AIMove> ().mDirection = dir.normalized;
        pEntity.GetComponent <AIMove> ().mVelocity  = 0;
        pEntity.GetComponent <AIMove> ().mMoveFunc  = MoveFunc.JUSTROTATE;
    }
Example #21
0
    public static void TM_Recorder(AIEntity pEntity)
    {
        //记录上一帧数据,通过一个实体(其中包含AI与player),更新旧数据

        pEntity.GetComponent <AIState> ().LastEntityData.GetComponent <SMREComponent> ().AIPos     = pEntity.AIPos;
        pEntity.GetComponent <AIState> ().LastEntityData.GetComponent <SMREComponent> ().PlayerPos = pEntity.PlayerPos;
        pEntity.GetComponent <AIState> ().LastEntityData.GetComponent <SMREComponent> ().MaxHP     =
            pEntity.mPlayer.GetComponent <GYTPlayerControl> ().MaxHP;
        pEntity.GetComponent <AIState> ().LastEntityData.GetComponent <SMREComponent> ().HP =
            pEntity.mPlayer.GetComponent <GYTPlayerControl> ().HP;
    }
Example #22
0
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        //ai = animator.GetComponent<AI>();
        ai = animator.GetComponent <AIEntity>();

        ai.na.speed = movementSpeed;



        //Debug.Log(ai.name + " is entering " + stateName + " state on frame " + Time.frameCount + ".");
    }
Example #23
0
 public static void SM_Rest(AIEntity pEntity)
 {
     if (pEntity.GetComponent <shieldAI> ().restTime > 0.0f)       // 没休息完
     {
         pEntity.GetComponent <shieldAI> ().restTime -= Time.deltaTime;
     }
     else        // 休息完毕
     {
         pEntity.GetComponent <shieldAI> ().rest = false;
     }
 }
Example #24
0
 public static float AttackAction(AIEntity pEntity)
 {
     //距离小,处于交战,能力未发动
     if (Vector3.Distance(pEntity.AIPos, pEntity.PlayerPos) < 7.0f &&
         pEntity.GetComponent <getPlayer> ().engage&&
         pEntity.GetComponent <shieldAI> ().powerEnd)
     {
         return(0.7f);
     }
     return(0.0f);
 }
Example #25
0
 public static float ApproachAction(AIEntity pEntity)
 {
     // 距离中等,且处于交战(发现玩家)
     if (Vector3.Distance(pEntity.AIPos, pEntity.PlayerPos) > 6.0f &&
         Vector3.Distance(pEntity.AIPos, pEntity.PlayerPos) < 20.0f &&
         pEntity.GetComponent <getPlayer> ().engage)
     {
         return(0.6f);
     }
     return(0.0f);
 }
Example #26
0
 public static float SM_Charge_ShieldF(AIEntity pEntity)
 {
     if (pEntity.GetComponent <shieldAI> ().powerEnd)
     {
         return(1.0f);
     }
     else
     {
         return(0.0f);
     }
 }
Example #27
0
 public static void SM_Hook(AIEntity pEntity)
 {
     // 关于钩子的判断,就放在钩子里边吧...保持5s之后退出。
     if (pEntity.GetComponent <shieldAI> ().powerDelay > 0.0f)
     {
         pEntity.GetComponent <shieldAI> ().powerDelay -= Time.deltaTime;
     }
     else
     {
         pEntity.GetComponent <shieldAI> ().powerEnd = true;
     }
 }
Example #28
0
 public static float EscapeAction(AIEntity pEntity)
 {
     // 生命值小于百分之三十.超级打击完毕,处于交战中,距离小于20,跑路
     if (pEntity.GetComponent <SSHComponent> ().HPNow < pEntity.GetComponent <SSHComponent> ().HP * 0.3f &&
         pEntity.GetComponent <shieldAI> ().powerEnd&&
         pEntity.GetComponent <getPlayer> ().engage&&
         Vector3.Distance(pEntity.AIPos, pEntity.PlayerPos) < 20.0f)
     {
         return(0.8f);
     }
     return(0.0f);
 }
Example #29
0
    //逃亡,生命值过低
    //理论上说,只要玩家一扭头,马上就跑,跑累了,才考虑举盾格挡的
    public static float SM_ShieldB_Walkaway(AIEntity pEntity)
    {
        //首先是盾牌是否存活QAQ(刚性),与玩家的距离(软性)
        if (!pEntity.GetComponent <SSHComponent> ().hasShield)
        {
            return(1.0f);
        }
        Transform p = pEntity.mPlayer.transform;
        Transform a = pEntity.mAI.transform;

        return(1.0f - Vector3.Angle(p.forward, p.position - a.position) / 180.0f);
    }
Example #30
0
 public static void SM_Die(AIEntity pEntity)
 {
     if (pEntity.GetComponent <shieldAI> ().dieTime > 0.0f)
     {
         pEntity.GetComponent <shieldAI> ().dieTime -= Time.deltaTime;
     }
     else
     {
         GameObject.Destroy(pEntity.GetComponent <BaseAIComponent> ().mAIRT);
         ECSWorld.MainWorld.deleteEntity(pEntity);
     }
 }
Example #31
0
 // Token: 0x06001A16 RID: 6678 RVA: 0x000D50B0 File Offset: 0x000D32B0
 private bool TargetIsResearcher(AIEntity aie)
 {
     if (aie != null)
     {
         VIP component = aie.GetComponent <VIP>();
         if (component != null)
         {
             return(VIP.IsResearcher(aie));
         }
     }
     return(false);
 }
Example #32
0
 public ArrayList getNeighboursInRange(AIEntity target, double range)
 {
     ArrayList list = new ArrayList();
     foreach( KeyValuePair<int, AIEntity> ent in entityDictionary){
         AIEntity temp = ent.Value;
         Vector to = temp.getPosition() - target.getPosition();
         double ran = range + temp.boundingRadius();
         if(temp.entityID() != target.entityID() && to.lengthSquared() < ran*ran)
             list.Add(temp);
     }
     return list;
 }
Example #33
0
 public void discharge(AIEntity receiver, Telegram msg)
 {
     if(receiver.handlesMessage(msg) ==false) {
         ;//throw error. - FILL OUT
     }
 }
Example #34
0
 public void addEntity(AIEntity a)
 {
     Debug.Log("Entity Added");
     entityDictionary.Add(a.entityID(),a);
 }
Example #35
0
 public void removeEntity(AIEntity a)
 {
     entityDictionary.Remove(a.entityID());
 }
Example #36
0
 public void setTarget(AIEntity targ)
 {
     target = targ;
 }
Example #37
0
        public State_Walk(string name, AIEntity entity) : base(name, entity)
        {
            m_script = m_entity.GetComponent<personBehaviour>();
            step = m_script.speed * Time.deltaTime;
			m_transform = m_entity.transform;
		}
Example #38
0
 Vector pursueEntity(AIEntity entityToCatch)
 {
     Vector targetPos = entityToCatch.getPosition() - this.owner.getPosition();
     double relativeHead = owner.getHeadingDirection().dotProduct(entityToCatch.getHeadingDirection());
     if(targetPos.dotProduct(owner.getHeadingDirection()) > 0 &&
         relativeHead < -0.9) {
         return this.seek(entityToCatch.getPosition());
     }
     double lookAhead = Math.sqrt(vecToTarg.lengthSquared()) /
                         (owner.getMaxSpeed() + Math.sqrt(entityToCatch.currentSpeedSquared()));
     return this.seek(entityToCatch.getPosition() + (entityToCatch.getVelocity() * lookAhead));
 }
Example #39
0
 Vector evadeEntity(AIEntity entityToEvade)
 {
     Vector toTarget = entityToEvade.getPosition() - owner.getPosition();
     double range = 1000;
     if(toTarget.lengthSquared() > range)return Vector(0,0);
     double lookAhead = Math.sqrt(vecToTarg.lengthSquared()) /
                         (owner.getMaxSpeed() + Math.sqrt(entityToEvade.currentSpeedSquared()));
     return this.flee(entityToEvade.getPosition + (entityToEvade.getVelocity()*lookAhead));
 }
Example #40
0
 public void setTargetEntity(AIEntity e)
 {
     target = e;
 }
Example #41
0
 public void setPursuerEntity(AIEntity e)
 {
     pursuer = e;
 }
Example #42
0
 public void setFriendEntity(AIEntity e)
 {
     friend = e;
 }