Пример #1
0
 public AIBehaviorTree(AIGetToTargetActions aiToTarget, AIWeaponActions aiWA, ILivingEntity entity, ProjectileDetector projectileDetector)
 {
     this.aiToTarget         = aiToTarget;
     this.aiWeapon           = aiWA;
     this.entity             = entity;
     this.projectileDetector = projectileDetector;
 }
Пример #2
0
    public void SetupAI(AISettings settings)
    {
        aiEnabled            = false;
        this.maxLP           = settings.MaxLP;
        this.minimumDistance = settings.MinDistance;
        GetComponent <AIWeaponController>().accuracy         = settings.Accuracy;
        GetComponent <AIWeaponController>().cooldown         = settings.CoolDown;
        GetComponent <AIWeaponController>().maxExtraCooldown = settings.MaxExtraCooldown;
        GetComponent <AIWeaponController>().shootDistance    = settings.ShootDistance;
        GetComponent <AIWeaponController>().Setup();
        if (target == null)
        {
            GameObject go = GameObject.FindGameObjectWithTag(enemyTag);
            if (go != null)
            {
                target = go.transform;
            }
        }

        lp = maxLP;
        this.transform.position = new Vector3(RoundedMath.Mult(Mathf.RoundToInt(this.transform.position.x / boxFactor), boxFactor), this.transform.position.y);

        aiMovement         = GetComponent <AIMovement>();
        aiWeaponController = GetComponent <AIWeaponController>();

        ea                    = new EnvironmentAnalyser();
        aiMemory              = new AIMemory(windowSizeX, windowSizeY, this.transform.position, ea, this, boxFactor);
        generalSolver         = new GeneralSolver(aiMemory);
        aiMemory.MaxAreaWidth = settings.MaxAreaWidth;

        aiToTarget      = new AIGetToTargetActions(aiMemory, generalSolver, aiMovement, this.transform, target, this, minimumDistance, this);
        aiWeaponActions = new AIWeaponActions(aiWeaponController);


        projectileDetector = new ProjectileDetector(this.transform, 10, projectileLayer);
        aiBehaviorTree     = new AIBehaviorTree(aiToTarget, aiWeaponActions, this, projectileDetector);
        if (aiType == AIType.AGGRESSIVE)
        {
            aiBehaviorTree.CreateAndStartAggrassiveAI();
        }
        if (aiType == AIType.DEFENSIVE)
        {
            aiBehaviorTree.CreateAndStartDefensiveAI();
        }

        aiEnabled = true;
    }