Esempio n. 1
0
    public List <kBulletStatus> estimate(Vector3 targetPosition, eGameForce force)
    {
        int keyH = getLocomotionKey(targetPosition, Vector3.right);
        int keyV = getLocomotionKey(targetPosition, Vector3.forward);

        if (keyH == int.MinValue || keyV == int.MinValue)
        {
            Debug.LogWarning("TargetPosition is illegel!");
            return(null);
        }

        bool hasKeyH = false;
        bool hasKeyV = false;

        hasKeyH = bulletLocomotion.ContainsKey(Mathf.Abs(keyH));
        hasKeyV = bulletLocomotion.ContainsKey(Mathf.Abs(keyV));
        if (!hasKeyH && !hasKeyV)
        {
            return(null);
        }

        List <kBulletStatus> dangerousBullets = new List <kBulletStatus>();

        if (hasKeyH)
        {
            List <kBulletStatus> statusHorizonal = gatherBulletStatus(Mathf.Abs(keyH), targetPosition);
            if (statusHorizonal != null)
            {
                checkBulletStatus(statusHorizonal);
                estimateDangerousBullets(statusHorizonal, ref dangerousBullets);
            }
        }

        if (hasKeyV)
        {
            List <kBulletStatus> statusVertical = gatherBulletStatus(Mathf.Abs(keyV), targetPosition);
            if (statusVertical != null)
            {
                checkBulletStatus(statusVertical);
                estimateDangerousBullets(statusVertical, ref dangerousBullets);
            }
        }

        if (force != eGameForce.UNKNOWN_FORCE)
        {
            for (int i = 0; i < dangerousBullets.Count; ++i)
            {
                kBulletStatus status = dangerousBullets[i];
                //if(status.bullet.force != force || Mathf.Abs(status.distance)/status.bullet.speed > 1.0f)
                if (status.bullet.force != force)
                {
                    dangerousBullets.RemoveAt(i);
                    i = 0;
                }
            }
        }

        return(dangerousBullets);
    }
Esempio n. 2
0
    public List <eMapDirection> getSafeMoveDirections(Vector3 currentPosition, eGameForce force)
    {
        List <eMapDirection> safeDirections = new List <eMapDirection>();

        List <kBulletStatus> list = estimate(currentPosition, force);
        int bulletCount           = list != null ? list.Count : 0;

        if (bulletCount == 0)
        {
            safeDirections.Add(eMapDirection.UNKNOWN);
        }

        int[] result = new int[(int)eMapDirection.TOTAL];
        for (int i = 0; i < (int)eMapDirection.TOTAL; ++i)
        {
            Vector3 newPosition = currentPosition;
            switch ((eMapDirection)i)
            {
            case eMapDirection.TOP:
                newPosition += Vector3.forward * 4.0f;
                break;

            case eMapDirection.RIGHT:
                newPosition += Vector3.right * 4.0f;
                break;

            case eMapDirection.BOTTOM:
                newPosition -= Vector3.forward * 4.0f;
                break;

            case eMapDirection.LEFT:
                newPosition -= Vector3.right * 4.0f;
                break;
            }
            list      = estimate(newPosition, force);
            result[i] = list != null ? list.Count : 0;
            if (result[i] == 0)
            {
                safeDirections.Add((eMapDirection)i);
            }
        }

        return(safeDirections);
    }
Esempio n. 3
0
 public Assignment_bt_Tank_TendencyWander_RandomFire_node14()
 {
     opr_p0 = eGameForce.RED_FORCE;
 }
Esempio n. 4
0
 public Action_bt_Level_Survival_node22()
 {
     method_p0 = eGameForce.RED_FORCE;
     method_p1 = 16f;
     method_p2 = "Tank_Agressive";
     method_p3 = 800;
     method_p4 = 300;
     method_p5 = 1;
     method_p6 = 3;
     method_p7 = 720f;
     method_p8 = 720f;
     method_p9 = 0;
     method_p10.a = 1f;
     method_p10.b = 0f;
     method_p10.g = 1f;
     method_p10.r = 0f;
 }
Esempio n. 5
0
 public Action_bt_Level_Survival_node18()
 {
     method_p0 = eGameForce.BLUE_FORCE;
 }
Esempio n. 6
0
 public Action_bt_Level_DeathMatch_0_node37()
 {
     method_p0 = eGameForce.RED_FORCE;
     method_p1 = 8f;
     method_p2 = "Tank_Nav";
     method_p3 = 1500;
     method_p4 = 500;
     method_p5 = 1;
     method_p6 = 3;
     method_p7 = 180f;
     method_p8 = 180f;
     method_p9 = 0;
     method_p10.a = 1f;
     method_p10.b = 0f;
     method_p10.g = 0f;
     method_p10.r = 1f;
     method_p11 = -1;
 }
Esempio n. 7
0
 public Action_bt_Level_DeathMatch_0_node10()
 {
     method_p0 = eGameForce.BLUE_FORCE;
     method_p1 = 8f;
     method_p2 = "Tank_Wander_RandomFire";
     method_p3 = 2000;
     method_p4 = 1000;
     method_p5 = 1;
     method_p6 = 1;
     method_p7 = 180f;
     method_p8 = 360f;
     method_p10.a = 1f;
     method_p10.b = 1f;
     method_p10.g = 0f;
     method_p10.r = 0f;
     method_p11 = -1;
 }
Esempio n. 8
0
    public behaviac.EBTStatus navigate()
    {
        GameLevelCommon.instance.dangerousBullets = null;
        if (pathResult == null || pathResult.Count == 0)
        {
            return(behaviac.EBTStatus.BT_FAILURE);
        }

        if (isMoving || isRotating)
        {
            return(behaviac.EBTStatus.BT_RUNNING);
        }
        else
        {
            int currect2DX = -1; int currect2DY = -1;
            GameLevelCommon._3dTo2d(transform.localPosition.x, transform.localPosition.z, out currect2DX, out currect2DY);
            AStarPathFinding._2dPosition targetNode = pathResult[0] as AStarPathFinding._2dPosition;

            float target3DX = 0.0f; float target3DZ = 0.0f;
            if (currect2DX == targetNode.x && currect2DY == targetNode.y)
            {
                pathResult.RemoveAt(0);
                if (pathResult.Count == 0)
                {
                    return(behaviac.EBTStatus.BT_SUCCESS);
                }
                else
                {
                    // todo:
                    targetNode = pathResult[0] as AStarPathFinding._2dPosition;
                    GameLevelCommon._2dTo3d(targetNode.x, targetNode.y, out target3DX, out target3DZ);
                    eMapDirection direction = GameLevelCommon.getRelativeDirection(currect2DX, currect2DY, targetNode.x, targetNode.y);

                    if (dodgeFromDanager)
                    {
                        eGameForce dodgeForce = eGameForce.UNKNOWN_FORCE;
                        if (!GameLevelCommon.instance.isMelee)
                        {
                            if (force == eGameForce.RED_FORCE)
                            {
                                dodgeForce = eGameForce.BLUE_FORCE;
                            }
                            else if (force == eGameForce.BLUE_FORCE)
                            {
                                dodgeForce = eGameForce.RED_FORCE;
                            }
                        }
                        List <kBulletStatus> dangerousBullet = GameLevelCommon.instance.dangerRecord.estimate(new Vector3(target3DX, 0, target3DZ), dodgeForce);
                        if (dangerousBullet != null && dangerousBullet.Count > 0)
                        {
                            GameLevelCommon.instance.dangerousBullets = dangerousBullet;
                            GameLevelCommon.instance.creditSystem.addDodgeFromDangerCredit(dangerousBullet.Count);
                            return(behaviac.EBTStatus.BT_FAILURE);
                        }
                    }
                    return(moveToDirection(direction));
                }
            }
            else
            {
                // todo:
                targetNode = pathResult[0] as AStarPathFinding._2dPosition;
                GameLevelCommon._2dTo3d(targetNode.x, targetNode.y, out target3DX, out target3DZ);
                eMapDirection direction = GameLevelCommon.getRelativeDirection(currect2DX, currect2DY, targetNode.x, targetNode.y);

                if (dodgeFromDanager)
                {
                    eGameForce dodgeForce = eGameForce.UNKNOWN_FORCE;
                    if (!GameLevelCommon.instance.isMelee)
                    {
                        if (force == eGameForce.RED_FORCE)
                        {
                            dodgeForce = eGameForce.BLUE_FORCE;
                        }
                        else if (force == eGameForce.BLUE_FORCE)
                        {
                            dodgeForce = eGameForce.RED_FORCE;
                        }
                    }
                    List <kBulletStatus> dangerousBullet = GameLevelCommon.instance.dangerRecord.estimate(new Vector3(target3DX, 0, target3DZ), dodgeForce);
                    if (dangerousBullet != null && dangerousBullet.Count > 0)
                    {
                        GameLevelCommon.instance.dangerousBullets = dangerousBullet;
                        GameLevelCommon.instance.creditSystem.addDodgeFromDangerCredit(dangerousBullet.Count);
                        return(behaviac.EBTStatus.BT_FAILURE);
                    }
                }
                return(moveToDirection(direction));
            }
        }
    }
Esempio n. 9
0
    public eMapDirection getBestMoveDirection(eMapDirection tendencyDirection)
    {
        List <eMapDirection> safeDirections = null;

        if (dodgeFromDanager)
        {
            eGameForce dodgeForce = eGameForce.UNKNOWN_FORCE;
            if (!GameLevelCommon.instance.isMelee)
            {
                if (force == eGameForce.RED_FORCE)
                {
                    dodgeForce = eGameForce.BLUE_FORCE;
                }
                else if (force == eGameForce.BLUE_FORCE)
                {
                    dodgeForce = eGameForce.RED_FORCE;
                }
            }
            safeDirections = GameLevelCommon.instance.dangerRecord.getSafeMoveDirections(transform.localPosition, dodgeForce);
        }
        else
        {
            safeDirections = new List <eMapDirection>();
            safeDirections.Add(eMapDirection.UNKNOWN);
            safeDirections.Add(eMapDirection.LEFT);
            safeDirections.Add(eMapDirection.RIGHT);
            safeDirections.Add(eMapDirection.TOP);
            safeDirections.Add(eMapDirection.BOTTOM);
        }
        List <eMapDirection> targetDirections = new List <eMapDirection>();
        bool isTendencyDirectionAvailable     = false;

        for (int i = 0; i < safeDirections.Count; ++i)
        {
            bool          isDirectionWakable = false;
            eMapDirection direction          = safeDirections[i];
            if (direction == eMapDirection.UNKNOWN)
            {
                isDirectionWakable = true;
            }
            else
            {
                eBrickType brickType = GameLevelCommon.instance.getBrickType(this, direction, 1);
                if (GameLevelCommon.instance.isBrickTypeWakable(brickType, GameLevelCommon.defaultWalkLevel))
                {
                    isDirectionWakable = true;
                }
            }

            if (isDirectionWakable)
            {
                targetDirections.Add(direction);
                if (tendencyDirection == direction)
                {
                    isTendencyDirectionAvailable = true;
                }
            }
        }

        if (targetDirections.Count == 0)
        {
            return(eMapDirection.UNKNOWN);
        }

        if (isTendencyDirectionAvailable)
        {
            return(tendencyDirection);
        }
        else
        {
            int           index  = GameLevelCommon.instance.randomNumberInt(0, targetDirections.Count);
            eMapDirection target = targetDirections[index];
            return(target);
        }
    }
Esempio n. 10
0
 public Action_bt_Level_Survival_node22()
 {
     this.m_resultOption = EBTStatus.BT_SUCCESS;
     method_p0 = eGameForce.RED_FORCE;
     method_p1 = 16f;
     method_p2 = "Tank_Agressive";
     method_p3 = 800;
     method_p4 = 300;
     method_p5 = 1;
     method_p6 = 3;
     method_p7 = 720f;
     method_p8 = 720f;
     method_p9 = 0;
     method_p10.a = 1f;
     method_p10.b = 0f;
     method_p10.g = 1f;
     method_p10.r = 0f;
 }
Esempio n. 11
0
 public Action_bt_Level_Survival_node18()
 {
     this.m_resultOption = EBTStatus.BT_SUCCESS;
     method_p0 = eGameForce.BLUE_FORCE;
 }
Esempio n. 12
0
 public Action_bt_Level_DeathMatch_0_node37()
 {
     this.m_resultOption = EBTStatus.BT_SUCCESS;
     method_p0 = eGameForce.RED_FORCE;
     method_p1 = 8f;
     method_p2 = "Tank_Nav";
     method_p3 = 1500;
     method_p4 = 500;
     method_p5 = 1;
     method_p6 = 3;
     method_p7 = 180f;
     method_p8 = 180f;
     method_p9 = 0;
     method_p10.a = 1f;
     method_p10.b = 0f;
     method_p10.g = 0f;
     method_p10.r = 1f;
     method_p11 = -1;
 }
Esempio n. 13
0
 public Action_bt_Level_DeathMatch_0_node10()
 {
     this.m_resultOption = EBTStatus.BT_SUCCESS;
     method_p0 = eGameForce.BLUE_FORCE;
     method_p1 = 8f;
     method_p2 = "Tank_Wander_RandomFire";
     method_p3 = 2000;
     method_p4 = 1000;
     method_p5 = 1;
     method_p6 = 1;
     method_p7 = 180f;
     method_p8 = 360f;
     method_p10.a = 1f;
     method_p10.b = 1f;
     method_p10.g = 0f;
     method_p10.r = 0f;
     method_p11 = -1;
 }