コード例 #1
0
    void SearchForFireballs()
    {
        if (fireballs.Length > 0)
        {
            foreach (Fireball f in fireballs)
            {
                float range = 1.0f;

                Survivor_AI sAI = FindClosestSurvivorToFireBall(f);

                float distance = Vector3.Distance(sAI.GetSurvivor().transform.position, f.transform.position);

                if (distance < range)
                {
                    ResetSurvivorsBT();

                    sAI.GetBlackBoard().incomingFireball = f;

                    sAI.GetBlackBoard().currentSurvivorPosition = sAI.GetSurvivor().transform.position;

                    Task BT_Evade_Fireball = new Sequence_EvadeFireballs();

                    sAI.SetBehaviorTree(BT_Evade_Fireball);
                }
            }
        }
    }
コード例 #2
0
    void SurvivorFlee()
    {
        List <Enemy> enemies = GameManager.getAllEnemies();

        if (enemies.Count > 0)
        {
            foreach (Enemy e in enemies)
            {
                float range = 5.0f;

                Survivor_AI sAI = FindClosestSurvivorToTarget(e);

                float distance = Vector3.Distance(sAI.GetSurvivor().transform.position, e.transform.position);

                if (distance < range)
                {
                    ResetSurvivorsBT();

                    Task BT_Flee_Zombie = new Sequence_FleeZombie();

                    sAI.GetBlackBoard().target = e;

                    sAI.GetBlackBoard().currentSurvivorPosition = sAI.GetSurvivor().transform.position;

                    sAI.SetBehaviorTree(BT_Flee_Zombie);
                }
            }
        }
    }
コード例 #3
0
    Enemy FindClosestBunny(Survivor_AI sAI, List <Enemy> bunnies)
    {
        Enemy output       = null;
        float closestSoFar = Mathf.Infinity;

        for (int i = 0; i < bunnies.Count; i++)
        {
            Enemy e = bunnies[i];

            if (e.getState() != EnemyState.DEAD)
            {
                float dist = (e.transform.position - sAI.GetSurvivor().transform.position).magnitude;
                if (dist < closestSoFar && dist < sAI.GetSurvivor().currentWeapon.getRange())
                {
                    output       = e;
                    closestSoFar = dist;
                }
            }
        }
        if (output != null)   //Debug.Log("Survivor " + sAI.GetSurvivor().name +
                              //" is Targeting enemy position " + output.transform.position
        {
        }
        return(output);
    }
コード例 #4
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED;

        if (sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.GRENADE_LAUNCHER).getAmmo() > 0)
        {
            if ((sAI.transform.position - sAI.GetBlackboard().enemyTarget.transform.position).magnitude <= 10)
            {
                sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.GRENADE_LAUNCHER);
                output = TASK_RETURN_STATUS.SUCCEED;
            }
        }

        return(output);
    }
コード例 #5
0
 public void MoveSurvivorBack(Survivor_AI sAI)
 {
     sAI.GetSurvivor().MoveTo(sAI.GetCurrDefensePoint().transform.position);
     sAI.mvmtTracker  = Moving.NOT_MOVING_ON_ASTAR;
     SearchingForLoot = false;
     Invoke("SearchForLoot", 20.0f);
 }
コード例 #6
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILURE;

        if (sAI.GetBlackBoard().target.state != EnemyState.DEAD)
        {
            Vector3 runTo = sAI.GetSurvivor().transform.position + ((sAI.GetSurvivor().transform.position -
                                                                     sAI.GetBlackBoard().target.gameObject.transform.position) * 5);

            sAI.GetSurvivor().MoveTo(runTo);

            output = TASK_RETURN_STATUS.SUCCESS;
        }

        return(output);
    }
コード例 #7
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED;
        Blackboard         bb     = sAI.GetBlackboard();

        if (bb.distFromTarget < 10.0f)
        {
            if (sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.SHOTGUN).getAmmo() > 0)
            {
                sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.SHOTGUN);
                output = TASK_RETURN_STATUS.SUCCEED;
            }
        }

        return(output);
    }
コード例 #8
0
    bool isTargetVisible(Survivor_AI sAI, Enemy e)
    {
        bool output = false;

        if (e != null)
        {
            Survivor   survivor = sAI.GetSurvivor();
            RaycastHit hit;

            Vector3 offset = (Vector3.up * 0.5f);

            Vector3 dir = e.transform.position - survivor.transform.position;
            dir += offset;

            dir.Normalize();

            int layerMask = 1 << LayerMask.NameToLayer("Player");
            layerMask = ~layerMask;

            if (Physics.Raycast(survivor.transform.position + offset, dir, out hit, 1000.0f, layerMask))
            {
                if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Enemy"))
                {
                    //if (hit.collider.gameObject.GetInstanceID () == e.gameObject.GetInstanceID ())
                    //{
                    output = true;
                    //}
                }
            }
        }
        return(output);
    }
コード例 #9
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED;

        WEAPON_TYPE prevType = sAI.GetSurvivor().GetCurrentWeapon().type;

        sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.GRENADE_LAUNCHER);
        if (sAI.GetSurvivor().GetCurrentWeapon().getAmmo() > 0)
        {
            Enemy target = sAI.GetBlackboard().enemyTarget;
            sAI.GetSurvivor().Fire(target.transform.position + (sAI.GetEnemyHeightOffset() * Vector3.up));
            sAI.GetSurvivor().SwitchWeapons(prevType);
            output = TASK_RETURN_STATUS.SUCCEED;
        }
        return(output);
    }
コード例 #10
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.SUCCESS;

        sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.PISTOL);

        return(output);
    }
コード例 #11
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.SUCCESS;

        FindPath(sAI, sAI.GetSurvivor().transform.position, targetPoint);


        return(output);
    }
コード例 #12
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILURE;

        if (GameManager.GetAmmo(WEAPON_TYPE.SNIPER) > 0)
        {
            BlackBoard bd = sAI.GetBlackBoard();

            Weapon w = sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.SNIPER);

            float distFromTarget = Vector3.Distance(bd.target.transform.position,
                                                    sAI.transform.position);

            if (distFromTarget < w.getRange())
            {
                sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.SNIPER);
                output = TASK_RETURN_STATUS.SUCCESS;
            }
        }
        return(output);
    }
コード例 #13
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED;
        Blackboard         bb     = sAI.GetBlackboard();

        if (sAI.mvmtTracker == Moving.MOVING_ON_ASTAR)
        {
            return(output);
        }

        if (bb.distFromTarget < 35.0f && bb.distFromTarget > 25.0f)
        {
            if (sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.ASSAULT).getAmmo() > 0)
            {
                sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.ASSAULT);
                output = TASK_RETURN_STATUS.SUCCEED;
            }
        }

        return(output);
    }
コード例 #14
0
 public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
 {
     if (sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.SHOTGUN).getAmmo() < 10)
     {
         //while (GameManager.GetCurrentGold() >= 25)
         //{
         GameManager.PurchaseAmmo(WEAPON_TYPE.SHOTGUN);
         GameManager.PurchaseAmmo(WEAPON_TYPE.SHOTGUN);
         //}
     }
     return(TASK_RETURN_STATUS.SUCCEED);
 }
コード例 #15
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED;
        Blackboard         bb     = sAI.GetBlackboard();

        if (sAI.mvmtTracker == Moving.MOVING_ON_ASTAR)
        {
            return(output);
        }

        if (bb.distFromTarget > 25.0f && bb.distFromTarget < 37.0f && bb.enemyTarget.getEnemyType() == EnemyType.ZOMBEAR)
        {
            if (sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.SNIPER).getAmmo() > 0) //&& sAI.GetBlackboard().enemyTarget.getEnemyType() != EnemyType.ZOMBUNNY)
            {
                sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.SNIPER);
                output = TASK_RETURN_STATUS.SUCCEED;
            }
        }

        return(output);
    }
コード例 #16
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.SUCCESS;


        if (sAI.GetBlackBoard().target.getEnemyType() == EnemyType.ZOMBUNNY)
        {
            sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.PISTOL);
        }

        if (sAI.GetBlackBoard().target.getEnemyType() == EnemyType.HELLEPHANT)
        {
            sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.SNIPER);
        }

        if (sAI.GetBlackBoard().target.getEnemyType() == EnemyType.CLOWN)
        {
            sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.PISTOL);
        }

        return(output);
    }
コード例 #17
0
    Enemy FindClosestHellephant(Survivor_AI sAI, List <Enemy> hellephant)
    {
        Enemy output       = null;
        float closestSoFar = Mathf.Infinity;

        for (int i = 0; i < hellephant.Count; i++)
        {
            Enemy e = hellephant[i];

            if (e.getState() != EnemyState.DEAD)
            {
                float dist = (e.transform.position - sAI.GetSurvivor().transform.position).magnitude;
                if (dist < closestSoFar && dist < sAI.GetSurvivor().currentWeapon.getRange())
                {
                    output       = e;
                    closestSoFar = dist;
                }
            }
        }

        //if (output != null) { Debug.Log("Enemy Type: " + output.name); }
        return(output);
    }
コード例 #18
0
    Enemy FindClosestClown(Survivor_AI sAI, List <Enemy> clowns)
    {
        Enemy output = null;

        float closestSoFar = Mathf.Infinity;

        for (int i = 0; i < clowns.Count; i++)
        {
            Enemy e = clowns[i];

            if (e.getState() != EnemyState.DEAD)
            {
                float dist = (e.transform.position - sAI.GetSurvivor().transform.position).magnitude;
                if (dist < closestSoFar && dist < sAI.GetSurvivor().currentWeapon.getRange())
                {
                    output       = e;
                    closestSoFar = dist;
                }
            }
        }

        return(output);
    }
コード例 #19
0
    Enemy FindClosestTarget(Survivor_AI sAI)
    {
        Enemy        output       = null;
        float        closestSoFar = Mathf.Infinity;
        List <Enemy> enemies      = GameManager.getAllEnemies();

        for (int i = 0; i < enemies.Count; i++)
        {
            Enemy e = enemies[i];

            if (e.getState() != EnemyState.DEAD)
            {
                float dist = (e.transform.position - sAI.GetSurvivor().transform.position).magnitude;
                if (dist < closestSoFar && dist < sAI.GetSurvivor().currentWeapon.getRange())
                {
                    output       = e;
                    closestSoFar = dist;
                }
            }
        }

        return(output);
    }
コード例 #20
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILURE;

        base.Run(sAI);

        if (sAI.GetBlackBoard().target.state == EnemyState.DEAD)
        {
            sAI.GetSurvivor().MoveTo(sAI.GetBlackBoard().currentSurvivorPosition);

            output = TASK_RETURN_STATUS.SUCCESS;
        }

        return(output);
    }
コード例 #21
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILURE;

        BlackBoard blackBoard = sAI.GetBlackBoard();
        Enemy      target     = blackBoard.target;

        if (target != null)
        {
            sAI.GetSurvivor().Fire(target.transform.position + (Vector3.up * sAI.enemyHeightOffset));

            output = TASK_RETURN_STATUS.SUCCESS;
        }

        return(output);
    }
コード例 #22
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        //TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED;


        //if(sAI.transform.position != sAI.GetCurrDefensePoint().transform.position)
        //{
        sAI.GetSurvivor().MoveTo(sAI.GetCurrDefensePoint().transform.position);
        // }
        //else
        //{
        //output = TASK_RETURN_STATUS.SUCCEED;
        //}

        return(TASK_RETURN_STATUS.SUCCEED);
    }
コード例 #23
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED;
        Blackboard         bb     = sAI.GetBlackboard();

        if (bb.distFromTarget <= 25.0f) //&& bb.distFromTarget >= 10.0f)
        {
            //if (sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.PISTOL).getAmmo() > 0)
            //{
            sAI.GetSurvivor().SwitchWeapons(WEAPON_TYPE.PISTOL);
            output = TASK_RETURN_STATUS.SUCCEED;
            //}
        }

        return(output);
    }
コード例 #24
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED;

        Enemy target = sAI.GetBlackboard().enemyTarget;


        if (target != null)
        {
            sAI.GetSurvivor().Fire(target.transform.position + (sAI.GetEnemyHeightOffset() * Vector3.up));
            output = TASK_RETURN_STATUS.SUCCEED;
        }



        return(output);
    }
コード例 #25
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILED;

        Enemy e = FindClosestBearTarget(sAI);

        if (e != null)
        {
            if (sAI.GetBlackboard().distFromTarget < 40.0f && (sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.SNIPER).getAmmo() > 0 || sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.ASSAULT).getAmmo() > 0))
            {
                sAI.GetBlackboard().enemyTarget = e;
                output = TASK_RETURN_STATUS.SUCCEED;
            }
        }

        return(output);
    }
コード例 #26
0
    void FindPath(Survivor_AI sAI, Vector3 startPoint, Vector3 endPoint)
    {
        List <PathNode> path = pathfinder.CreatePath(startPoint, endPoint);

        if (path != null)
        {
            for (int i = 0; i < path.Count; i++)
            {
                if (sAI.transform.position != path[i].transform.position)
                {
                    sAI.GetSurvivor().MoveTo(path[i].transform.position);
                }

                else
                {
                    // pop the current node of the list
                    path.Remove(path[i]);
                }
            }
        }
    }
コード例 #27
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        if (sAI.GetSurvivor().GetWeapon(WEAPON_TYPE.SNIPER).getAmmo() <= 12)
        {
            //while (GameManager.GetCurrentGold() > 50)
            if (GameManager.GetCurrentGold() > 160)
            {
                GameManager.PurchaseAmmo(WEAPON_TYPE.SNIPER);
                GameManager.PurchaseAmmo(WEAPON_TYPE.SNIPER);
                GameManager.PurchaseAmmo(WEAPON_TYPE.SNIPER);
            }
            else if (GameManager.GetCurrentGold() > 80)
            {
                GameManager.PurchaseAmmo(WEAPON_TYPE.SNIPER);
                GameManager.PurchaseAmmo(WEAPON_TYPE.SNIPER);
            }
            else if (GameManager.GetCurrentGold() > 40)
            {
                GameManager.PurchaseAmmo(WEAPON_TYPE.SNIPER);
            }
        }

        return(TASK_RETURN_STATUS.SUCCEED);
    }