コード例 #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
    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);
    }
コード例 #4
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);
    }
コード例 #5
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILURE;

        if (enemyTarget.getState() == EnemyState.NORMAL)
        {
            sAI.GetBlackBoard().target = enemyTarget;
            output = TASK_RETURN_STATUS.SUCCESS;
        }
        return(output);
    }
コード例 #6
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);
    }
コード例 #7
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILURE;

        BlackBoard bd = sAI.GetBlackBoard();

        if (bd.target != null)
        {
            if (bd.target.getState() == EnemyState.NORMAL)
            {
                output = TASK_RETURN_STATUS.SUCCESS;
            }
        }
        return(output);
    }
コード例 #8
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);
    }
コード例 #9
0
    public override TASK_RETURN_STATUS Run(Survivor_AI sAI)
    {
        TASK_RETURN_STATUS output = TASK_RETURN_STATUS.FAILURE;

        Enemy e = FindPriorityTarget(sAI);

        if (e != null)
        {
            BlackBoard b = sAI.GetBlackBoard();

            b.target = e;

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


        BlackBoard blackBoard = sAI.GetBlackBoard();
        bool       b          = isTargetVisible(sAI, blackBoard.target);

        if (b == true)
        {
            output = TASK_RETURN_STATUS.SUCCESS;
        }


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

        Collider[] cols = FindEnemiesInRange(sAI);


        //Enemy e = FindClosestTarget (sAI);
        BlackBoard blackBoard = sAI.GetBlackBoard();

        if (cols != null)
        {
            blackBoard.enemiesInRange = cols;
        }

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

        base.Run(sAI);

        if (GameManager.GetCurrentGold() >= GameManager.GetBulletTowerCost())
        {
            if (!sAI.GetBlackBoard().isNorthEastTowerBought)
            {
                GameManager.PurchaseTower(TOWER_TYPE.BULLET_TOWER, TOWER_POSITION.NORTHEAST);
                sAI.GetBlackBoard().isNorthEastTowerBought = true;
            }

            else if (!sAI.GetBlackBoard().isNorthWestTowerBought)
            {
                GameManager.PurchaseTower(TOWER_TYPE.BULLET_TOWER, TOWER_POSITION.NORTHWEST);
                sAI.GetBlackBoard().isNorthWestTowerBought = true;
            }


            else if (!sAI.GetBlackBoard().isSouthEastTowerBought)
            {
                GameManager.PurchaseTower(TOWER_TYPE.BULLET_TOWER, TOWER_POSITION.SOUTHEAST);
                sAI.GetBlackBoard().isSouthEastTowerBought = true;
            }

            else if (!sAI.GetBlackBoard().isSouthWestTowerBought)
            {
                GameManager.PurchaseTower(TOWER_TYPE.BULLET_TOWER, TOWER_POSITION.SOUTHWEST);
                sAI.GetBlackBoard().isSouthWestTowerBought = true;
            }

            else
            {
                Debug.Log("Every Tower Bought");
            }

            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.FAILURE;

        Enemy bear = FindBearsInRange(sAI);


        BlackBoard blackBoard = sAI.GetBlackBoard();

        blackBoard.isTargetSpecial = false;

        if (bear != null)
        {
            blackBoard.target          = bear;
            blackBoard.isTargetSpecial = true;
            output = TASK_RETURN_STATUS.SUCCESS;
        }

        return(output);
    }
コード例 #14
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);
    }