예제 #1
0
    public void goWaitAtkPos(float _dis)
    {
        if (deadManager.checkDead)
        {
            return;
        }

        if (points.CheckFull(_dis))
        {
            cancelSelectTarget(false);
            return;
        }

        //找一個點
        tmpPos = points.FindClosePoint(enemyData.atk_Range, myCachedTransform, enemyData.width);
        if (tmpPos == null && chaseTime > 0)
        {
            Debug.Log("找點啦 耖");
            return;
        }
        else if (tmpPos == null && chaseTime <= 0)
        {
            Debug.Log("前往攻擊點這時間到  取消");
            cancelSelectTarget(false);
            return;
        }

        points.AddWillGo_P(tmpPos, correctPos);
        correctPos = tmpPos;
        lastTmpPos = correctPos.position;
        resetChaseTime();
        nowState = states.AtkMove;
        getTatgetPoint(correctPos.position);
    }
예제 #2
0
    //優先攻擊士兵(可選擇打不打玩家)
    public myCorrectTarget CalculationDis_Soldier(EnemyControl _soldierScript, bool canAtkPlay)
    {
        tmpTargetStruct.myTarget = null;
        tmpTargetStruct.goPos    = null;

        //核心 ??

        //人
        if (canAtkPlay && enemy_Player != null)
        {
            if (!enemy_Player.GetComponent <isDead>().checkDead)//player不會被移出去,所以要判斷死了沒
            {
                if (Vector3.SqrMagnitude(enemy_Player.transform.position - _soldierScript.transform.position) < _soldierScript.viewRadius * _soldierScript.viewRadius)
                {
                    tmpPointScript = enemy_Player.MyCreatPoints;
                    if (!tmpPointScript.CheckFull(_soldierScript.enemyData.atk_Range))
                    {
                        tmpTransform = tmpPointScript.FindClosePoint(_soldierScript.enemyData.atk_Range, _soldierScript.transform, _soldierScript.enemyData.width);
                        if (tmpTransform != null)
                        {
                            tmpTargetStruct.nowPointScript = tmpPointScript;
                            tmpTargetStruct.myTarget       = enemy_Player.gameObject;
                            tmpTargetStruct.goPos          = tmpTransform;
                            return(tmpTargetStruct);
                        }
                    }
                }
            }
        }

        //士兵
        if (soldierAmount != 0)
        {
            for (int i = 0; i < soldierAmount; i++)
            {
                if (Vector3.SqrMagnitude(enemySoldierObjs[i].transform.position - _soldierScript.transform.position) < _soldierScript.viewRadius * _soldierScript.viewRadius)
                {
                    tmpPointScript = enemySoldierObjs[i].myCreatPoints;
                    if (!tmpPointScript.CheckFull(_soldierScript.enemyData.atk_Range))
                    {
                        tmpTransform = tmpPointScript.FindClosePoint(_soldierScript.enemyData.atk_Range, _soldierScript.transform, _soldierScript.enemyData.width);
                        if (tmpTransform != null)
                        {
                            if (tmpTargetStruct.myTarget != null)
                            {
                                if (Vector3.SqrMagnitude(enemySoldierObjs[i].transform.position - _soldierScript.transform.position) < Vector3.SqrMagnitude(tmpTargetStruct.myTarget.transform.position - _soldierScript.transform.position))
                                {
                                    tmpTargetStruct.nowPointScript = tmpPointScript;
                                    tmpTargetStruct.myTarget       = enemySoldierObjs[i].gameObject;
                                    tmpTargetStruct.goPos          = tmpTransform;
                                }
                            }
                            else
                            {
                                tmpTargetStruct.nowPointScript = tmpPointScript;
                                tmpTargetStruct.myTarget       = enemySoldierObjs[i].gameObject;
                                tmpTargetStruct.goPos          = tmpTransform;
                            }
                        }
                    }
                }
            }
            if (tmpTargetStruct.myTarget != null)
            {
                return(tmpTargetStruct);
            }
        }

        //塔
        if (towerAmount != 0)
        {
            for (int i = 0; i < towerAmount; i++)
            {
                if (Vector3.SqrMagnitude(enemyTowerObjs[i].transform.position - _soldierScript.transform.position) < _soldierScript.viewRadius * _soldierScript.viewRadius)
                {
                    tmpPointScript = enemyTowerObjs[i].MyCreatPoints;
                    if (!tmpPointScript.CheckFull(_soldierScript.enemyData.atk_Range))
                    {
                        tmpTransform = tmpPointScript.FindClosePoint(_soldierScript.enemyData.atk_Range, _soldierScript.transform, _soldierScript.enemyData.width);
                        if (tmpTransform != null)
                        {
                            if (tmpTargetStruct.myTarget != null)
                            {
                                if (Vector3.SqrMagnitude(enemyTowerObjs[i].transform.position - _soldierScript.transform.position) < Vector3.SqrMagnitude(tmpTargetStruct.myTarget.transform.position - _soldierScript.transform.position))
                                {
                                    tmpTargetStruct.nowPointScript = tmpPointScript;
                                    tmpTargetStruct.myTarget       = enemyTowerObjs[i].gameObject;
                                    tmpTargetStruct.goPos          = tmpTransform;
                                }
                            }
                            else
                            {
                                tmpTargetStruct.nowPointScript = tmpPointScript;
                                tmpTargetStruct.myTarget       = enemyTowerObjs[i].gameObject;
                                tmpTargetStruct.goPos          = tmpTransform;
                            }
                        }
                    }
                }
            }
            if (tmpTargetStruct.myTarget != null)
            {
                return(tmpTargetStruct);
            }
        }

        return(tmpTargetStruct);
    }
예제 #3
0
    //優先攻擊塔(除了反擊不會打玩家)
    public myCorrectTarget CalculationDis_Tower(EnemyControl _soldierScript)
    {
        tmpTargetStruct.myTarget = null;
        tmpTargetStruct.goPos    = null;

        //核心 ??

        //塔
        if (towerAmount != 0)
        {
            for (int i = 0; i < towerAmount; i++)
            {
                if (Vector3.SqrMagnitude(enemyTowerObjs[i].transform.position - _soldierScript.transform.position) < _soldierScript.viewRadius * _soldierScript.viewRadius)
                {
                    tmpPointScript = enemyTowerObjs[i].MyCreatPoints;
                    if (!tmpPointScript.CheckFull(_soldierScript.enemyData.atk_Range))
                    {
                        tmpTransform = tmpPointScript.FindClosePoint(_soldierScript.enemyData.atk_Range, _soldierScript.transform, _soldierScript.enemyData.width);
                        if (tmpTransform != null)
                        {
                            if (tmpTargetStruct.myTarget != null)
                            {
                                if (Vector3.SqrMagnitude(enemyTowerObjs[i].transform.position - _soldierScript.transform.position) < Vector3.SqrMagnitude(tmpTargetStruct.myTarget.transform.position - _soldierScript.transform.position))
                                {
                                    tmpTargetStruct.nowPointScript = tmpPointScript;
                                    tmpTargetStruct.myTarget       = enemyTowerObjs[i].gameObject;
                                    tmpTargetStruct.goPos          = tmpTransform;
                                }
                            }
                            else
                            {
                                tmpTargetStruct.nowPointScript = tmpPointScript;
                                tmpTargetStruct.myTarget       = enemyTowerObjs[i].gameObject;
                                tmpTargetStruct.goPos          = tmpTransform;
                            }
                        }
                    }
                }
            }

            if (tmpTargetStruct.myTarget != null)
            {
                return(tmpTargetStruct);
            }
        }

        //士兵
        if (soldierAmount != 0)
        {
            for (int i = 0; i < soldierAmount; i++)
            {
                if (Vector3.SqrMagnitude(enemySoldierObjs[i].transform.position - _soldierScript.transform.position) < _soldierScript.viewRadius * _soldierScript.viewRadius)
                {
                    tmpPointScript = enemySoldierObjs[i].myCreatPoints;
                    if (!tmpPointScript.CheckFull(_soldierScript.enemyData.atk_Range))
                    {
                        tmpTransform = tmpPointScript.FindClosePoint(_soldierScript.enemyData.atk_Range, _soldierScript.transform, _soldierScript.enemyData.width);
                        if (tmpTransform != null)
                        {
                            if (tmpTargetStruct.myTarget != null)
                            {
                                if (Vector3.SqrMagnitude(enemySoldierObjs[i].transform.position - _soldierScript.transform.position) < Vector3.SqrMagnitude(tmpTargetStruct.myTarget.transform.position - _soldierScript.transform.position))
                                {
                                    tmpTargetStruct.nowPointScript = tmpPointScript;
                                    tmpTargetStruct.myTarget       = enemySoldierObjs[i].gameObject;
                                    tmpTargetStruct.goPos          = tmpTransform;
                                }
                            }
                            else
                            {
                                tmpTargetStruct.nowPointScript = tmpPointScript;
                                tmpTargetStruct.myTarget       = enemySoldierObjs[i].gameObject;
                                tmpTargetStruct.goPos          = tmpTransform;
                            }
                        }
                    }
                }
            }
            if (tmpTargetStruct.myTarget != null)
            {
                return(tmpTargetStruct);
            }
        }

        return(tmpTargetStruct);
    }