コード例 #1
0
    // Constructor - Assume that Boss and Player are at Starting Positions.
    public BlackBoard()
    {
        // Transforms
        BossTransform = null;
        PlyrTransform = null;

        // Health
        PlyrHP = 1.0f;
        BossHP = 1.0f;

        //Current Active Specialist
        ActSpec = ActionSpecialists.AttackSpec;
        PasSpec = PassiveSpecialists.DistanceSpec;

        //Boss Variables
        BossBhvr = BossBehavior.Agressive;

        // Distance Variables
        CurBossLoc = BossLocation.RightSide;
        PlyrLoc = PlayerLocation.LeftFromBoss;
        DestBossLoc = BossLocation.RightSide;
        PlyrDist = PlayerDistance.Far;
        isMovingToOtherSide = false;
        isAtSafeDistance = false;
        isPlyrLinedUp = false;

        // Projectile Variables
        AreBulletsNear = false;
        NumberBulletsNear = 0;
    }
コード例 #2
0
    void ReadPlayerData()
    {
        float BossPosX = BossTransform.position.x;
        float PlyrPosX = PlyrTransform.position.x;
        float DistToPlayer = Mathf.Abs(BossPosX - PlyrPosX);

        // Calculate relative distance of Player from Boss.
        if (DistToPlayer <= TooNearDistance)
        {
            PlyrDist = PlayerDistance.TooNear;
            isBossAtSafeDist = false;
        }

        else if (DistToPlayer <= NearDistance)
        {
            PlyrDist = PlayerDistance.Near;

            if (ReadBlackBoard.BossBhvr == BossBehavior.Agressive)
                isBossAtSafeDist = true;
            else if (ReadBlackBoard.BossBhvr == BossBehavior.Defensive)
                isBossAtSafeDist = false;
        }

        else if (DistToPlayer > NearDistance + 0.5)
        {
            PlyrDist = PlayerDistance.Far;

            if (ReadBlackBoard.BossBhvr == BossBehavior.Agressive)
                isBossAtSafeDist = false;
            else if (ReadBlackBoard.BossBhvr == BossBehavior.Defensive)
                isBossAtSafeDist = true;
        }

        // Calculate which side from the boss the player is.
        if (BossPosX > PlyrPosX)
            PlyrLoc = PlayerLocation.LeftFromBoss;
        else
            PlyrLoc = PlayerLocation.RightFromBoss;

        // Checks if player is lined up with boss.
        if (Physics.Raycast(BossTransform.position, BossTransform.forward, out TargetInfo))
        {
            if (TargetInfo.transform.tag == "Player")
                isPlyrLinedUp = true;
            else
                isPlyrLinedUp = false;
        }
    }