コード例 #1
0
ファイル: AILinkHelper.cs プロジェクト: Ribosome2/MyAIEngine
    public static bool IsLinkConditionCheck(AILink link,AIUnit linkSrc)
    {
        for (int i = 0; i < link.linkConditionList.Count; i++)
        {
            AILinkCondiction con = link.linkConditionList[i];
            if (con is AiInputCondiction)
            {
                AiInputCondiction input = con as AiInputCondiction;
                if (!CheckInputCondition(input)) return false;
            }
            else if (con is AiTargetStateCondiction)
            {
                AiTargetStateCondiction targetState = con as AiTargetStateCondiction;
                if (!CheckTargetState(targetState, linkSrc))
                {
                    return false;
                }
            }
            else
            {
                Debug.LogError("Not implemented link condition");
            }
        }

        return true;
    }
コード例 #2
0
    public void shoot(GameObject target)
    {
        if (target.GetComponent <AIUnit>().isAlive)
        {
            if (Time.time > nextFire)
            {
                nextFire = Time.time + fireRate;

                StartCoroutine(bulletEffect());

                Vector3 rayOrigin = pointOfFire.position;
                Vector3 rayDir    = target.transform.position - transform.position;

                RaycastHit hit;

                bulletLine.SetPosition(0, pointOfFire.position);

                if (Physics.Raycast(rayOrigin, rayDir, out hit, shootRange))
                {
                    bulletLine.SetPosition(1, hit.point);

                    AIUnit enemyHit = hit.collider.GetComponent <AIUnit>();

                    if (enemyHit != null)
                    {
                        enemyHit.Damage(shootDamage);
                    }
                }
                else
                {
                    bulletLine.SetPosition(1, pointOfFire.position + (rayDir * shootRange));
                }
            }
        }
    }
コード例 #3
0
ファイル: AITestTool.cs プロジェクト: Ribosome2/MyAIEngine
    void CreateAI(string modelName, int aiId, EAiCamp camp, bool asAI)
    {
        AIUnit ai = AIMgr.instance.CreateAI(modelName, aiId);

        ai.aiCamp = camp;
        ai.SwitchAI(asAI);
    }
コード例 #4
0
    private void InitializeAI(BetAmount betAmount)
    {
        AIUnit ai = ai_units.Find(p => (p.m_BetAmount == betAmount));

        mInfo = new List <QuestionAnswerInfo>();

        int correctNum = Random.Range(ai.m_QuestionToAnswer.MinQuestionsToBeAnswered, ai.m_QuestionToAnswer.MaxQuestionsToBeAnswered + 1);

        int TimeToAnswer = 0;

        for (int i = 0; i < MULTIPLAYER_QUESTION_NUMBER; i++)
        {
            QuestionAnswerInfo tInfo = new QuestionAnswerInfo();

            int answerInWithin = Random.Range(ai.MinTimeToAnswer, ai.MaxTimeToAnswer);

            tInfo.AnsweredInTime = answerInWithin;

            TimeToAnswer = (i == 0) ? maxAllowedTime - answerInWithin : TimeToAnswer - answerInWithin;

            tInfo.TimeToAnswerQuestion = TimeToAnswer;//UnityEngine.Random.Range(ai.MinTimeToAnswer, ai.MaxTimeToAnswer);

            mInfo.Add(tInfo);
        }

        FisherYatesShuffle obj = new FisherYatesShuffle(5);

        obj.ShuffleList();
        List <int> correctIndex = obj.ShuffledList;

        for (int i = 0; i < correctNum; i++)
        {
            mInfo[correctIndex[i]].isCorrectAnswer = true;
        }
    }
コード例 #5
0
ファイル: AIHitUnit.cs プロジェクト: Ribosome2/MyAIEngine
    public void Init(AiClipHitData hitData, AIUnit owner)
    {
        mHitData = hitData;
        mOwner   = owner;
        if (mHitData.autoFaceTarget)
        {
            mOwner.FaceToAttackTarget();
        }
        pos           = mOwner.transform.TransformPoint(mHitData.startPosition);
        eulerAngleY   = mOwner.transform.eulerAngles.y;
        moveDirection = mOwner.transform.TransformDirection(mHitData.startDirection).normalized;
        mMoveSpeed    = mHitData.moveSpeed;

        if (string.IsNullOrEmpty(mHitData.entityResName) == false)
        {
            GameObject prefab = Resources.Load(hitData.entityResName) as GameObject;
            if (prefab)
            {
                mHitEntity = Object.Instantiate(prefab) as GameObject;
                mHitEntity.transform.forward  = moveDirection;
                mHitEntity.transform.position = pos;
            }
            else
            {
                Debug.LogError("加载资源" + hitData.entityResName + " 失败");
            }
        }
    }
コード例 #6
0
ファイル: DefendState.cs プロジェクト: fefete/AStarAI
    // Use this for initialization
    void Start()
    {
        aiUnit_  = this.GetComponent <AIUnit>();
        aiSight_ = aiSight_.GetComponent <AISight>();

        subState = SubState.Empty;
    }
コード例 #7
0
 private void CheckTransitions(AIUnit unit)
 {
     foreach (var item in _Transitions)
     {
         item.CheckAndTransition(unit);
     }
 }
コード例 #8
0
    //To use OnTrigger...() methods, you need to attach this script with a game object that have a Collider and a RigidBody.
    //And remember to untick (uncheck) the "Use Gravity" in RigidBody.
    public void OnTriggerEnter(Collider other)
    {
        GameUnit unit   = other.GetComponent <GameUnit>();
        GameUnit myself = this.GetComponentInParent <GameUnit>();

        if (unit != null)
        {
            Renderer unitRenderer = unit.GetComponent <Renderer>();
            if (myself != null && (unit != myself) && unitRenderer.enabled && !unit.hasAuthority && !this.enemiesInRange.Contains(unit))
            {
                this.enemiesInRange.Add(unit);
            }
        }

        AIUnit AIunit = other.GetComponent <AIUnit>();

        if (AIunit != null && !this.otherEnemies.Contains(AIunit))
        {
            this.otherEnemies.Add(AIunit);
        }

        if (this.exitedList.Count > 0)
        {
            this.exitedList.Clear();
        }
        if (this.exitedEnemies.Count > 0)
        {
            this.exitedEnemies.Clear();
        }
    }
コード例 #9
0
        public override void ApplyEffects(AttackableUnit target, IMissile projectile)
        {
            var targetAI = (AIUnit)target;

            FX[] fxs = new FX[]
            {
                new FX(target.Game.NetIdProvider.Pop(), "blindMonk_Q_tar.troy", "", 1f, Owner, targetAI),
                new FX(target.Game.NetIdProvider.Pop(), "blindMonk_Q_tar_indicator.troy", "", 1f, Owner, targetAI),
            };

            CreateFXs(fxs, targetAI, true);

            CurrentTarget = targetAI;

            target.InflictDamages(new World.Spells.Damages(Owner, target, 200, false, DamageType.DAMAGE_TYPE_PHYSICAL, false));

            CreateAction(() =>
            {
                if (CurrentTarget.ObjectAvailable)
                {
                    CurrentTarget.FXManager.DestroyFX("blindMonk_Q_tar.troy");
                    CurrentTarget.FXManager.DestroyFX("blindMonk_Q_tar_indicator.troy");
                }
                CurrentTarget = null;
            }, 3f);
        }
コード例 #10
0
        public void CreateFX(string effectName, string bonesName, float size, AIUnit target, bool add)
        {
            uint netId = Target.Game.NetIdProvider.Pop();
            FX   fx    = new FX(netId, effectName, bonesName, size, Target, target);

            target.FXManager.CreateFX(fx, add);
        }
コード例 #11
0
    public static bool IsLinkConditionCheck(AILink link, AIUnit linkSrc)
    {
        for (int i = 0; i < link.linkConditionList.Count; i++)
        {
            AILinkCondiction con = link.linkConditionList[i];
            if (con is AiInputCondiction)
            {
                AiInputCondiction input = con as AiInputCondiction;
                if (!CheckInputCondition(input))
                {
                    return(false);
                }
            }
            else if (con is AiTargetStateCondiction)
            {
                AiTargetStateCondiction targetState = con as AiTargetStateCondiction;
                if (!CheckTargetState(targetState, linkSrc))
                {
                    return(false);
                }
            }
            else
            {
                Debug.LogError("Not implemented link condition");
            }
        }

        return(true);
    }
コード例 #12
0
    private Vector3 CalculateMoveDelta(float deltaTime)
    {
        Vector3 deltaPos = Vector3.zero;

        mMoveSpeed = AiGroupData.moveSpeed;
        if (CurAiClip.CheckDirectionInput) //用输入控制
        {
            deltaPos = new Vector3(InputManager.inputVector.x, 0,
                                   InputManager.inputVector.y);
            deltaPos   = (relativeForward * deltaPos.z + relativeRight * deltaPos.x) * mMoveSpeed;
            deltaPos.y = 0;
        }
        else if (CurAiClip.runToTarget)  //跑向目标
        {
            //暂时直接往目标方向,
            //todo 算出实际寻路方向
            AIUnit target = AIMgr.instance.FindFirstEnemy(this);
            if (target != null)
            {
                deltaPos   = (target.Position - Position).normalized * mMoveSpeed;
                deltaPos.y = 0;
                FaceToDirection(deltaPos);
            }
        }
        deltaPos  = (deltaPos + Physics.gravity) * deltaTime;
        deltaPos += mExtrenalVelocity.GetMovementByDeltaTime(deltaTime);
        return(deltaPos);
    }
コード例 #13
0
ファイル: AIMgr.cs プロジェクト: Ribosome2/MyAIEngine
    /// <summary>
    /// 为当前的AI查找相对最优先的敌人(可以有多个因素影响,距离,仇恨值等)
    /// </summary>
    /// <param name="srcAi"></param>
    /// <returns></returns>
    public AIUnit FindFirstEnemy(AIUnit srcAi)
    {
#if UNITY_EDITOR
        if (DisableAiAttack && srcAi.aiCamp == EAiCamp.Enemy)
        {
            return(null);
        }
#endif
        AIUnit enemy    = null;
        float  distance = float.MaxValue;
        for (int i = 0; i < listAIs.Count; i++)
        {
            AIUnit ai = listAIs[i];
            if (IsAntiCamp(srcAi, ai))
            {
                float curDist = DistanceBetween(srcAi, ai);
                if (curDist < distance)
                {
                    enemy    = ai;
                    distance = curDist;
                }
            }
        }
        return(enemy);
    }
コード例 #14
0
ファイル: AIDebugWindow.cs プロジェクト: Ribosome2/MyAIEngine
 void OnGUI()
 {
     if (mDebugUnit!=null)
     {
          DrawAIState(mDebugUnit);
     }
     GUILayout.BeginArea(new Rect(position.width*0.6f,0,position.width*0.3f,position.height));
     scrollPos = GUILayout.BeginScrollView(scrollPos);
     List<AIUnit> mAiUnits = AIMgr.instance.listAIs;
     for (int i = 0; i < mAiUnits.Count; i++)
     {
         AIUnit ai = mAiUnits[i];
         if (ai != null)
         {
             GUILayout.BeginHorizontal();
             if (GUILayout.Button(ai.Name))
             {
                 mDebugUnit = ai;
             }
             if (GUILayout.Button("Delete"))
             {
                 AIMgr.instance.DestroyAI(ai);
             }
             GUILayout.EndHorizontal();
         }
     }
     GUILayout.EndScrollView();
     GUILayout.EndArea();
 }
コード例 #15
0
ファイル: AIDebugWindow.cs プロジェクト: Ribosome2/MyAIEngine
    void OnGUI()
    {
        if (mDebugUnit != null)
        {
            DrawAIState(mDebugUnit);
        }
        GUILayout.BeginArea(new Rect(position.width * 0.6f, 0, position.width * 0.3f, position.height));
        scrollPos = GUILayout.BeginScrollView(scrollPos);
        List <AIUnit> mAiUnits = AIMgr.instance.listAIs;

        for (int i = 0; i < mAiUnits.Count; i++)
        {
            AIUnit ai = mAiUnits[i];
            if (ai != null)
            {
                GUILayout.BeginHorizontal();
                if (GUILayout.Button(ai.Name))
                {
                    mDebugUnit = ai;
                }
                if (GUILayout.Button("Delete"))
                {
                    AIMgr.instance.DestroyAI(ai);
                }
                GUILayout.EndHorizontal();
            }
        }
        GUILayout.EndScrollView();
        GUILayout.EndArea();
    }
コード例 #16
0
    public override bool MakeDecision(AIUnit unit)
    {
        // tell if  an enemy is in range
        bool EnemyInRange = SearchForEnemy(unit);

        return(EnemyInRange);
    }
コード例 #17
0
 private void DoActions(AI_Actions[] actionsToDo, AIUnit unit)
 {
     foreach (var item in actionsToDo)
     {
         item.UnitAction(unit);
     }
 }
コード例 #18
0
ファイル: BlindMonkQTwo.cs プロジェクト: sahlie1985/Legends
        public override void OnStartCasting(Vector2 position, Vector2 endPosition, AttackableUnit target)
        {
            this.Casted = true;

            var script = Owner.SpellManager.GetSpell("BlindMonkQOne").GetScript <BlindMonkQOne>();

            AIUnit dashTarget = script.GetTarget();

            SetAnimation("Run", "Spell1b");

            Action onDashEnd = () =>
            {
                Owner.PathManager.DestroyPendingPoint();
                SetAnimation("Run", "Run");
                DestroyFX("blindMonk_W_self_mis.troy");
                DestroyFX(dashTarget, "blindMonk_Q_tar.troy");
                DestroyFX(dashTarget, "blindMonk_Q_tar_indicator.troy");
                dashTarget.InflictDamages(new World.Spells.Damages(Owner, target, 200, false, DamageType.DAMAGE_TYPE_PHYSICAL, false));
                script.DestroyTarget();
                Owner.TryBasicAttack(dashTarget);
            };

            if (Owner != null)
            {
                Owner.Dash(dashTarget.Position, 1800f, false, onDashEnd);

                SwapSpell("BlindMonkQOne", 0);
            }
        }
コード例 #19
0
ファイル: AIHitUnit.cs プロジェクト: Ribosome2/MyAIEngine
    public void Init(AiClipHitData hitData,AIUnit owner)
    {
        mHitData = hitData;
        mOwner = owner;
        if (mHitData.autoFaceTarget)
        {
            mOwner.FaceToAttackTarget();
        }
        pos = mOwner.transform.TransformPoint(mHitData.startPosition);
        eulerAngleY = mOwner.transform.eulerAngles.y;
        moveDirection = mOwner.transform.TransformDirection(mHitData.startDirection).normalized;
        mMoveSpeed = mHitData.moveSpeed;

        if (string.IsNullOrEmpty(mHitData.entityResName) == false)
        {
            GameObject prefab = Resources.Load(hitData.entityResName) as GameObject;
            if (prefab)
            {
                mHitEntity = Object.Instantiate(prefab) as GameObject;
                mHitEntity.transform.forward = moveDirection;
                mHitEntity.transform.position = pos;
            }
            else
            {
                Debug.LogError("加载资源"+hitData.entityResName+" 失败");
            }
        }
    }
コード例 #20
0
ファイル: AIMgr.cs プロジェクト: Ribosome2/MyAIEngine
 public void DestroyAI(AIUnit ai)
 {
     if (listAIs.Contains(ai))
     {
         ai.Destroy();
         listAIs.Remove(ai);
     }
 }
コード例 #21
0
 private bool StunUnit(AIUnit unit)
 {
     if (unit.StunUnit == true && unit.StunTimer <= unit.StunCD)
     {
         return(true);
     }
     return(false);
 }
コード例 #22
0
 public Projectile(uint netId, AIUnit unit, Vector2 startPosition, float speed, Action <AttackableUnit, Projectile> onReach) : base(netId)
 {
     this.Unit          = unit;
     this.OnReach       = onReach;
     this.StartPosition = startPosition;
     this.Position      = startPosition;
     this.Speed         = speed;
 }
コード例 #23
0
    private float GetCloseUpWeight(AIAgent requester, bool linear = true)
    {
        Vector2 position         = requester.transform.position;
        AIUnit  parent           = requester.parent;
        Vector2 cohesionPosition = parent.GetCohesionPosition(requester);

        return(GetWeight(position, cohesionPosition, closeUpBehaviourArea, closeUpBehaviourMaxIntensityArea, linear));
    }
コード例 #24
0
ファイル: AIMgr.cs プロジェクト: Ribosome2/MyAIEngine
 /// <summary>
 /// 销毁所有AI
 /// </summary>
 public void DestroyAllAIs()
 {
     while (listAIs.Count > 0)
     {
         AIUnit ai = listAIs[0];
         DestroyAI(ai);
     }
 }
コード例 #25
0
 public SkillShot(uint netId, AIUnit unit, Vector2 startPosition, float speed, float collisionRadius, Action <AttackableUnit, Projectile> onReach, Vector2 direction, float range, Action <SkillShot> onRangedReached) : base(netId, unit, startPosition, speed, onReach)
 {
     this.Direction       = direction;
     this.Range           = range;
     this.OnRangeReached  = onRangedReached;
     this.CollisionRadius = collisionRadius;
     this.Hitten          = new List <AttackableUnit>();
 }
コード例 #26
0
 public SpellScript GetSpellScript(SpellRecord record, AIUnit owner)
 {
     if (Scripts.ContainsKey(record.Name) == false)
     {
         return(null);
     }
     return((SpellScript)Activator.CreateInstance(Scripts[record.Name], new object[] { owner, record }));
 }
コード例 #27
0
    private void DoAttack(AIUnit unit)
    {
        unit.CDTimer += unit.DeltaT;
        if (unit.TargetPlayerHealth == null)
        {
            return;
        }

        if (Vector3.Distance(unit.transform.position, unit.TargetPlayerHealth.transform.position) < unit.AttackRange)
        {
            unit.WalkAnim = false;
            if (unit.CDTimer >= unit.AttackCD && unit.AttackEnemy == true)
            {
                if (unit.TargetPlayerHealth != null && unit.TargetPlayerHealth.MyHealth > 0)
                {
                    if (unit._MinionType == MinionType.Ghost && unit.TargetPlayerHealth != null)
                    {
                        unit.Agent.transform.LookAt(unit.TargetPlayerHealth.transform.position);
                        MinionRangeAttack Attack = unit.GetComponent <MinionRangeAttack>();
                        if (unit.TargetPlayerHealth != null)
                        {
                            unit.AnimController.SetTrigger("IsAttacking");
                            Attack.RangeAttack(unit.TargetPlayerHealth.transform.position);
                            unit.CDTimer = 0;
                        }
                    }

                    else if (unit._MinionType == MinionType.Golem && unit.TargetPlayerHealth != null && unit.CDTimer >= unit.AttackCD)
                    {
                        unit.CDTimer  = 0;
                        unit.WalkAnim = false;
                        unit.Agent.transform.LookAt(unit.TargetPlayerHealth.transform.position);
                        unit.AttackCount = (unit.AttackCount + 1) % 3;
                        unit.AnimController.SetInteger("AttackState", unit.AttackCount);
                        unit.AnimController.SetTrigger("IsAttacking");
                        unit.StartCoroutine(unit.SetAnimWalking());
                    }
                    else if (unit._MinionType == MinionType.Mummy && unit.TargetPlayerHealth != null)
                    {
                        unit.Agent.transform.LookAt(unit.TargetPlayerHealth.transform.position);

                        // Make a random attack animation
                        int randomAttack = Random.Range(1, 3);
                        unit.AnimController.SetInteger("AttackState", randomAttack);
                        unit.AnimController.SetTrigger("IsAttacking");

                        // unit.SendRPC_Damage();
                        unit.StartCoroutine(unit.SetAnimWalking());
                        unit.CDTimer = 0;
                    }
                }
                else
                {
                    unit.TargetPlayerHealth = null;
                }
            }
        }
    }
コード例 #28
0
ファイル: AIDebugWindow.cs プロジェクト: Ribosome2/MyAIEngine
 void DrawAIState(AIUnit tarUnit)
 {
     GUILayout.Label(tarUnit.AiGroupData.GroupName);
     GUILayout.Label("动画名"+tarUnit.CurAiClip.animationName);
     GUILayout.Label("默认连接"+tarUnit.CurAiClip.defaultLinkClip);
     GUILayout.Label("动画状态停留时长"+tarUnit.CurClipTime);
     GUILayout.Label("Check input"+tarUnit.CurAiClip.CheckDirectionInput);
     GUILayout.Label("Camp:"+tarUnit.aiCamp);
 }
コード例 #29
0
    private bool GoalReached(AIUnit unit)
    {
        if (unit.Agent.remainingDistance <= unit.Agent.stoppingDistance && unit.Agent.pathPending == false)
        {
            return(true);
        }

        return(false);
    }
コード例 #30
0
 /* const global.AttackDelay = 1.6;
  * const global.AttackDelayCastPercent = 0.3;
  *
  * if(CharacterRecord.AttackTotalTime > 0.0)
  * {
  * tmp = fminf(CharacterRecord.AttackTotalTime, CharacterRecord.AttackCastTime);
  * if(tmp > 0.0)
  * {
  * AttackDelayOffsetPercent = (CharacterRecord.AttackTotalTime / global.AttackDelay) + -1.0f;
  * AttackDelayCastOffsetPercent = (tmp / CharacterRecord.AttackTotalTime ) - global.AttackDelayCastPercent;
  * }
  * } */
 public BasicAttack(AIUnit unit, AttackableUnit target, bool critical, bool first = true, AttackSlotEnum slot = AttackSlotEnum.BASE_ATTACK_1)
 {
     this.Unit               = unit;
     this.Target             = target;
     this.Critical           = critical;
     this.DeltaAnimationTime = AnimationTime;
     this.First              = first;
     this.Slot               = slot;
 }
コード例 #31
0
ファイル: AIDebugWindow.cs プロジェクト: Ribosome2/MyAIEngine
 void DrawAIState(AIUnit tarUnit)
 {
     GUILayout.Label(tarUnit.AiGroupData.GroupName);
     GUILayout.Label("动画名" + tarUnit.CurAiClip.animationName);
     GUILayout.Label("默认连接" + tarUnit.CurAiClip.defaultLinkClip);
     GUILayout.Label("动画状态停留时长" + tarUnit.CurClipTime);
     GUILayout.Label("Check input" + tarUnit.CurAiClip.CheckDirectionInput);
     GUILayout.Label("Camp:" + tarUnit.aiCamp);
 }
コード例 #32
0
ファイル: FX.cs プロジェクト: Dr-Chaos/Legends
 public FX(uint netId, string name, string bones, float size, AIUnit source, AIUnit target)
 {
     this.NetId  = netId;
     this.Name   = name;
     this.Bones  = bones;
     this.Size   = size;
     this.Source = source;
     this.Target = target;
 }
コード例 #33
0
        public void AddBuff <T>(AIUnit source) where T : BuffScript
        {
            var buff = BuffScriptManager.Instance.GetBuffScript <T>(Owner, source);

            buff.OnAdded();
            buff.Slot = PopNextSlotId();
            Buffs.Add(buff.Slot, buff);
            Owner.Game.Send(new BuffAddMessage(Owner.NetId, buff.Slot, buff.BuffType, 1, false, buff.BuffName.HashString(), (uint)Owner.GetHash(), 0f, (buff.MaxDuration / 1000f), source.NetId));
        }
コード例 #34
0
    private void LookForPatrol(AIUnit unit)
    {
        // get the postion of the patrol to move
        var tmp = NextPatrol();

        unit.PatrolPoint = FindPoint(tmp.transform.position, 5);
        unit.Agent.SetDestination(unit.PatrolPoint);
        unit.Agent.isStopped = false;
    }
コード例 #35
0
ファイル: AIHitManager.cs プロジェクト: Ribosome2/MyAIEngine
 public void OnEvent(AIUnit unit, EAiEventType eventType)
 {
     if (unit != mOwner)
        {
        return;
        }
        switch (eventType)
        {
        case EAiEventType.SwitchAiClip:
        {
           Reset();
           break;
        }
        }
 }
コード例 #36
0
ファイル: AILinkHelper.cs プロジェクト: Ribosome2/MyAIEngine
    public static bool CheckTargetState(AiTargetStateCondiction targetCon, AIUnit owner)
    {
        AIUnit target = null;

        #region 根据目标类型找到目标
        if (targetCon.targetType == ETargetType.Enemy)
        {
            target = AIMgr.instance.FindFirstEnemy(owner);
        }
        else if (targetCon.targetType == ETargetType.MainPlayer)
        {
            target = AIMgr.instance.GetMainPlayer() as AIUnit;
        }
        else
        {
            Debug.LogError("未实现的角色类型" + targetCon.targetType);
        }
        #endregion

        if (targetCon.targetState == ETargetState.Lost && target == null)
        {
            return true;
        }

        if (targetCon.targetState == ETargetState.InSight && target != null)
        {
            return true;
        }

        if (target != null)
        {
            float dist = AIMgr.instance.DistanceBetween(target, owner);
            if (targetCon.targetState == ETargetState.InAttackRange && dist <= targetCon.targetDistance)
            {
                return true;
            }
            else if (targetCon.targetState == ETargetState.OutOfRange && dist > targetCon.targetDistance)
            {
                return true;
            }
        }

        return false;
    }
コード例 #37
0
ファイル: AIUnit.cs プロジェクト: Ribosome2/MyAIEngine
    public bool CheckHit(AIUnit attacker, AIHitUnit hitUnit)
    {
        if (AIMgr.IsAntiCamp(attacker, this) == false)
        {
            return false;
        }
        bool isHit = false;
        AiClipHitData hitData = hitUnit.mHitData;
        HitCheckBase hitCheck = hitData.hitCheckData;
        switch (hitData.hitCheckData.shapeType)
        {
            case EHitCheckShape.Capsule:
            case EHitCheckShape.Cylinder:
                {
                    if (MathTool.CheckCylinderHit(hitUnit.pos, hitData.hitCheckData.height, hitData.hitCheckData.radius, Controller))
                    {
                        isHit = true;
                    }
                    break;
                }
            case EHitCheckShape.Fan:
                {
                    if (MathTool.CheckFanHit(hitUnit.pos, hitCheck.height, hitCheck.radius, hitCheck.angle, hitUnit.forwardDir, Controller))
                    {
                        isHit = true;
                    }
                    break;
                }
        }

        if (isHit)
        {
            OnGetHit();
        }

        return isHit;
    }
コード例 #38
0
ファイル: AIHitUnit.cs プロジェクト: Ribosome2/MyAIEngine
 private bool IsCannotHit(AIUnit ai)
 {
     return mHitRecord.ContainsKey(ai) && Time.realtimeSinceStartup - mHitRecord[ai] < mHitData.hitInterval;
 }
コード例 #39
0
ファイル: AIHitUnit.cs プロジェクト: Ribosome2/MyAIEngine
 private void RecordHit(AIUnit ai)
 {
     if (mHitRecord.ContainsKey(ai))
     {
         mHitRecord[ai] = Time.realtimeSinceStartup;
     }
     else
     {
         mHitRecord.Add(ai, Time.realtimeSinceStartup);
     }
 }
コード例 #40
0
ファイル: AIHitManager.cs プロジェクト: Ribosome2/MyAIEngine
 public AIHitManager(AIUnit owener)
 {
     mOwner = owener;
     mOwner.AddEventListener(this);
 }
コード例 #41
0
 public AIEventController(AIUnit owener)
 {
     mOwner = owener;
     mOwner.AddEventListener(this);
 }