예제 #1
0
    public override void TakeAction(AgentHandler agentScript)
    {
        GameObject projectileToFire;
        Projectile projectileScript;

        switch (agentScript.SelectedWeapon)
        {
        case WeaponSelected.MachineGun:
            projectileToFire = PoolSystem.Instance.GetObjectFromPool(agentScript.BulletPrefab, argShouldExpandPool: true, argShouldCreateNonExistingPool: true);
            projectileScript = projectileToFire.GetComponent <Projectile>();

            projectileScript.SetupProjectile(1.0f, 15.0f, agentScript.transform.position);
            projectileScript.LaunchProjectile((GameConstants.Instance.PlayerObject.transform.position - agentScript.transform.position).normalized, null, false);

            agentScript.ChangeAgentEnergyBy(-agentScript.GetMachineGunEnergyCost());
            break;

        case WeaponSelected.RocketLauncher:
            projectileToFire = PoolSystem.Instance.GetObjectFromPool(agentScript.BulletPrefab, argShouldExpandPool: true, argShouldCreateNonExistingPool: true);
            projectileScript = projectileToFire.GetComponent <Projectile>();

            projectileScript.SetupProjectile(1.0f, 15.0f, agentScript.transform.position);
            projectileScript.LaunchProjectile((GameConstants.Instance.PlayerObject.transform.position - agentScript.transform.position).normalized, GameConstants.Instance.PlayerObject, true);

            agentScript.ChangeAgentEnergyBy(-agentScript.GetRocketLauncherEnergyCost());
            break;

        default:
            break;
        }

        agentScript.SetFireProjectileTimer(0.0f);
    }
예제 #2
0
 public void RunChildDecision(AgentHandler agentInformation, bool value)
 {
     if (value)
     {
         if (TrueNode != null)
         {
             TrueNode.MakeDecision(agentInformation);
             return;
         }
         else if (TrueAction != null)
         {
             TrueAction.TakeAction(agentInformation);
             return;
         }
     }
     else
     {
         if (FalseNode != null)
         {
             FalseNode.MakeDecision(agentInformation);
             return;
         }
         else if (FalseAction != null)
         {
             FalseAction.TakeAction(agentInformation);
             return;
         }
     }
     //Debug.Log("No Further Decisions Or Actions!");
 }
예제 #3
0
    public override void Act(GameObject player, AgentHandler agent)
    {
        agent.mState = "Path";
        float distanceThresholdSqrd = 25f;

        //Follow the Found Path
        if (mCondensedPath != null && mCondensedPath.Count > 0)
        {
            if (Vector3.SqrMagnitude(agent.transform.position - agent.BoidController.GetTarget()) < distanceThresholdSqrd)
            {
                int furthestVisisbleIndex = PathHelpers.FindFurthestVisiblePointIndex(mCondensedPath, agent.transform.position, LayerMask.GetMask("Default"));
                agent.BoidController.SetTarget(mCondensedPath[furthestVisisbleIndex]);
                if (Vector3.Angle(agent.transform.forward, (mCondensedPath[furthestVisisbleIndex] - agent.transform.position)) > 30)
                {
                    agent.transform.forward = (mCondensedPath[furthestVisisbleIndex] - agent.transform.position);
                }
            }
            if (Vector3.SqrMagnitude(agent.transform.position - mCondensedPath[mCondensedPath.Count - 1]) < distanceThresholdSqrd)
            {
                agent.BoidController.SetTarget(player.transform.position);
                CalculateNewPath();
            }
        }
        agent.BoidController.SetShouldFlock(true);

        // Find paths for boids using spatial grid
        // give boids some mechanic that allows them to follow a path (Setting target to furthest visible point?)
        // state machine handles the rest..
    }
예제 #4
0
 public override void Act(GameObject player, AgentHandler agent)
 {
     agent.mState = "Chase";
     //Chase Player
     //agent.BoidController.SetTarget(player.transform.position);
     //agent.BoidController.SetShouldFlock(true);
 }
예제 #5
0
    public void SpawnEnemyDrone(Vector3 positionToSpawn)
    {
        GameObject   enemyObject  = PoolSystem.Instance.GetObjectFromPool(mEnemyDrone, argShouldExpandPool: true, argShouldCreateNonExistingPool: true);
        AgentHandler agentHandler = enemyObject.GetComponent <AgentHandler>();

        agentHandler.SetupAgentForSpawning(Mathf.Clamp(mCurrentWave, 0, 3), 20.0f, positionToSpawn);
        agentHandler.SpawnAgent();
    }
 public override void MakeDecision(AgentHandler agentScript)
 {
     if (agentScript.GetEnergy() > 10)
     {
         RunChildDecision(agentScript, true);
     }
     else
     {
         RunChildDecision(agentScript, false);
     }
 }
    public override void TakeAction(AgentHandler agentScript)
    {
        GameConstants.Instance.NumberOfMines++;

        GameObject mineToDeploy = PoolSystem.Instance.GetObjectFromPool(agentScript.MinePrefab, argActivateObject: true, argShouldExpandPool: true, argShouldCreateNonExistingPool: true);
        Mine       mineScript   = mineToDeploy.GetComponent <Mine>();

        mineScript.SpawnMine(agentScript.transform.position);

        agentScript.SetDeployMineTimer(0.0f);
    }
예제 #8
0
 public override void MakeDecision(AgentHandler agentScript)
 {
     if (agentScript.GetEnergy() >= agentScript.GetRocketLauncherEnergyCost())
     {
         RunChildDecision(agentScript, true);
     }
     else
     {
         RunChildDecision(agentScript, false);
     }
 }
예제 #9
0
 public override void MakeDecision(AgentHandler agentScript)
 {
     if (agentScript.GetDeployMineTimer() >= agentScript.GetTimeRequiredToDelopMine() && GameConstants.Instance.NumberOfMines < GameConstants.Instance.MaxNumberOfMines)
     {
         RunChildDecision(agentScript, true);
     }
     else
     {
         RunChildDecision(agentScript, false);
     }
 }
예제 #10
0
 public override void MakeDecision(AgentHandler agentScript)
 {
     if (agentScript.SelectedWeapon == WeaponSelected.RocketLauncher && agentScript.GetFireprojectileTimer() >= agentScript.RocketLauncherFireRate)
     {
         RunChildDecision(agentScript, true);
     }
     else
     {
         RunChildDecision(agentScript, false);
     }
 }
 public override void MakeDecision(AgentHandler agentScript)
 {
     if (agentScript.GetEnergyRegenTimer() >= agentScript.TimeToRegenEnergy)
     {
         RunChildDecision(agentScript, true);
     }
     else
     {
         RunChildDecision(agentScript, false);
     }
 }
예제 #12
0
    public override void TakeAction(AgentHandler agentScript)
    {
        float distanceToPlayer = (GameConstants.Instance.PlayerObject.transform.position - agentScript.transform.position).magnitude;

        distanceToPlayer  = Mathf.Clamp(distanceToPlayer, 0, 100);
        distanceToPlayer *= 0.01f;
        float mSeekWeight = distanceToPlayer * 1f;

        agentScript.BoidController.SetTarget(GameConstants.Instance.PlayerObject.transform.position);
        agentScript.BoidController.SeekPoint(GameConstants.Instance.PlayerObject.transform.position, mSeekWeight);
        agentScript.BoidController.SetShouldFlock(true);
    }
    public override void TakeAction(AgentHandler agentScript)
    {
        GameObject projectileToFire = PoolSystem.Instance.GetObjectFromPool(agentScript.RocketPrefab, argShouldExpandPool: true, argShouldCreateNonExistingPool: true);
        Projectile projectileScript = projectileToFire.GetComponent <Projectile>();

        projectileScript.SetupProjectile(5.0f, 12.0f, agentScript.transform.position);
        projectileScript.LaunchProjectile((GameConstants.Instance.PlayerObject.transform.position - agentScript.transform.position).normalized, GameConstants.Instance.PlayerObject, true);

        agentScript.ChangeAgentEnergyBy(-agentScript.GetRocketLauncherEnergyCost());

        agentScript.SetFireProjectileTimer(0.0f);
    }
    public override void MakeDecision(AgentHandler agentScript)
    {
        Vector3 directionToPlayer = GameConstants.Instance.PlayerObject.transform.position - agentScript.transform.position;

        if (directionToPlayer.magnitude >= agentScript.GetTargetTooCloseRange() && directionToPlayer.magnitude <= agentScript.GetAttackRange())
        {
            RunChildDecision(agentScript, true);
        }
        else
        {
            RunChildDecision(agentScript, false);
        }
    }
    public override void MakeDecision(AgentHandler agentScript)
    {
        float requiredEnergy = (agentScript.SelectedWeapon == WeaponSelected.MachineGun) ? agentScript.GetMachineGunEnergyCost() : agentScript.GetRocketLauncherEnergyCost();

        if (agentScript.GetEnergy() >= requiredEnergy)
        {
            RunChildDecision(agentScript, true);
        }
        else
        {
            RunChildDecision(agentScript, false);
        }
    }
예제 #16
0
    public override void MakeDecision(AgentHandler agentScript)
    {
        float requiredTime = (agentScript.SelectedWeapon == WeaponSelected.MachineGun) ? agentScript.MachineGunFireRate : agentScript.RocketLauncherFireRate;

        if (agentScript.GetFireprojectileTimer() >= requiredTime)
        {
            RunChildDecision(agentScript, true);
        }
        else
        {
            RunChildDecision(agentScript, false);
        }
    }
예제 #17
0
    public override void MakeDecision(AgentHandler agentScript)
    {
        Vector3 directionToPlayer = GameConstants.Instance.PlayerObject.transform.position - agentScript.transform.position;

        if (!Physics.Raycast(agentScript.transform.position, directionToPlayer.normalized, directionToPlayer.magnitude, LayerMask.GetMask("Default")))
        {
            RunChildDecision(agentScript, true);
        }
        else
        {
            RunChildDecision(agentScript, false);
        }
    }
예제 #18
0
    public override void Reason(GameObject player, AgentHandler agent)
    {
        Vector3 directionToPlayer = GameConstants.Instance.PlayerObject.transform.position - agent.transform.position;

        if (!Physics.Raycast(agent.transform.position, directionToPlayer.normalized, directionToPlayer.magnitude, LayerMask.GetMask("Default")))
        {
            if (directionToPlayer.magnitude <= agent.GetAttackRange())
            {
                agent.FSMTransitionPassthrough(fsmTransition.ToAttack);
            }
            else
            {
                agent.FSMTransitionPassthrough(fsmTransition.ToChase);
            }
        }
    }
    public override void MakeDecision(AgentHandler agentScript)
    {
        if (agentScript.GetEnergyRegenTimer() >= agentScript.TimeToRegenEnergy)
        {
            agentScript.ChangeAgentEnergyBy(1);
            agentScript.SetEnergyRegenTimer(0.0f);
        }

        Vector3 directionToPlayer = GameConstants.Instance.PlayerObject.transform.position - agentScript.transform.position;

        if (directionToPlayer.magnitude <= agentScript.GetAttackRange())
        {
            RunChildDecision(agentScript, true);
        }
        else
        {
            RunChildDecision(agentScript, false);
        }
    }
예제 #20
0
 /// <summary>
 /// Internal use, the Bot will initialize the script with its input handlers once its loaded into memory
 /// </summary>
 /// <param name="bot">The reference to the bot's windowhandler</param>
 public void initializeInputs(WindowHandler bot)
 {
     this.EMouse             = bot.MOUSE;
     this.EPreciseMouse      = bot.PMOUSE;
     this.EMenuHandler       = bot.MENU;
     this.ECommunicator      = bot.COMMUNICATOR;
     this.EOverViewHandler   = bot.OVERVIEW;
     this.EStationHandler    = bot.STATION;
     this.MyShip             = bot.SHIP;
     this.ESession           = bot.SESSION;
     this.ECamera            = bot.CAMERA;
     this.EKeyboard          = bot.KEYBOARD;
     this.ELocalHandler      = bot.LOCAL;
     this.EDrawingArea       = bot.DrawingArea;
     this.ELogger            = bot.LOGGER;
     this.ELogger.ScriptName = name;
     this.EAgentHandler      = bot.AGENT;
     ERandom = new Random();
 }
예제 #21
0
    public override void Act(GameObject player, AgentHandler agent)
    {
        agent.mState = "Attack";
        //Attack the Player
        agent.BoidController.SetTarget(player.transform.position);
        agent.BoidController.SetShouldFlock(false);
        float range = agent.GetTargetTooCloseRange();

        if ((range * range) > (player.transform.position - agent.transform.position).sqrMagnitude)
        {
            agent.BoidController.FleePoint(player.transform.position, 5f);
        }

        EditableTree BasicAgentAttackTree = agent.GetBasicAgentDecisionTree();

        if (BasicAgentAttackTree != null)
        {
            BasicAgentAttackTree.mRoot.MakeDecision(agent);
        }
    }
예제 #22
0
    public override void Reason(GameObject player, AgentHandler agent)
    {
        Vector3 directionToPlayer = GameConstants.Instance.PlayerObject.transform.position - agent.transform.position;

        if (Physics.Raycast(agent.transform.position, directionToPlayer.normalized, directionToPlayer.magnitude, LayerMask.GetMask("Default")))
        {
            agent.FSMTransitionPassthrough(fsmTransition.ToLostPlayer);
        }
        else
        {
            EditableTree SwitchToAttackDecisionTree = agent.GetSwitchToAttackDecisionTree();

            if (SwitchToAttackDecisionTree != null)
            {
                SwitchToAttackDecisionTree.mRoot.MakeDecision(agent);
            }

            //if (directionToPlayer.magnitude <= agent.GetAttackRange())
            //agent.FSMTransitionPassthrough(fsmTransition.ToAttack);
        }
    }
 public override void TakeAction(AgentHandler agentScript)
 {
     agentScript.SelectedWeapon = WeaponSelected.MachineGun;
 }
예제 #24
0
 public override void TakeAction(AgentHandler agentScript)
 {
     agentScript.SelectedWeapon = WeaponSelected.RocketLauncher;
 }
 public abstract void Reason(GameObject player, AgentHandler agent);
예제 #26
0
 public virtual void TakeAction(AgentHandler agentInformation)
 {
 }
 public abstract void Act(GameObject player, AgentHandler agent);
예제 #28
0
 public virtual void MakeDecision(AgentHandler agentInformation)
 {
 }
예제 #29
0
 public override void TakeAction(AgentHandler agentScript)
 {
     agentScript.FSMTransitionPassthrough(fsmTransition.ToAttack);
 }
예제 #30
0
 public override void TakeAction(AgentHandler agentScript)
 {
     agentScript.ChangeAgentEnergyBy(1);
     agentScript.SetEnergyRegenTimer(0.0f);
 }