コード例 #1
0
        private void InitFuzzySets()
        {
            fm              = new FuzzyModule();
            DistToPlayer    = fm.CreateFLV("DistanceToPlayer");
            Distance_Close  = DistToPlayer.AddLeftShoulderSet("Close", 0, 40, 200);
            Distance_Medium = DistToPlayer.AddTriangularSet("Medium", 40, 200, 300);
            Distance_Far    = DistToPlayer.AddRightShoulderSet("Far", 200, 300, 400);

            RangeOfSeight = fm.CreateFLV("RangeOfSeight");
            Seight_Foggy  = RangeOfSeight.AddLeftShoulderSet("Foggy", 0, 1, 5);
            Seight_Dusty  = RangeOfSeight.AddTriangularSet("Dusty", 1, 5, 9);
            Seight_Clear  = RangeOfSeight.AddRightShoulderSet("Clear", 5, 9, 10);

            PlayerDistance         = fm.CreateFLV("PlayerDistance");
            Player_Is_ToClose      = PlayerDistance.AddLeftShoulderSet("ToClose", 0, 40, 200);
            Player_Is_PerfectRange = PlayerDistance.AddTriangularSet("Perfect", 40, 200, 360);
            Player_Is_FarAway      = PlayerDistance.AddRightShoulderSet("Far", 200, 360, 400);

            // Without Combs method, therefore: 3^2 = 9
            fm.AddRule(new FzAND(Distance_Close, Seight_Foggy), Player_Is_ToClose);
            fm.AddRule(new FzAND(Distance_Medium, Seight_Foggy), Player_Is_FarAway);
            fm.AddRule(new FzAND(Distance_Far, Seight_Foggy), Player_Is_FarAway);

            fm.AddRule(new FzAND(Distance_Close, Seight_Dusty), Player_Is_ToClose);
            fm.AddRule(new FzAND(Distance_Medium, Seight_Dusty), Player_Is_PerfectRange);
            fm.AddRule(new FzAND(Distance_Far, Seight_Dusty), Player_Is_FarAway);

            fm.AddRule(new FzAND(Distance_Close, Seight_Clear), Player_Is_ToClose);
            fm.AddRule(new FzAND(Distance_Medium, Seight_Clear), Player_Is_PerfectRange);
            fm.AddRule(new FzAND(Distance_Far, Seight_Clear), Player_Is_PerfectRange);
        }
コード例 #2
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;
    }
コード例 #3
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;
        }
    }
コード例 #4
0
    /// <summary>
    /// Gets all the <see cref="Text"/> components of the screen and place on each
    /// a assigned text and color according to <see cref="Texts"/> and <see cref="Colors"/>.
    /// </summary>
    private void PlaceVictoriousText()
    {
        GameObject textParent = GameObject.Find(GameObjects.CanvasEndTextChild);

        foreach (Transform textChild in textParent.transform)
        {
            Text text = textChild.gameObject.GetComponent <Text>();

            string textData  = "";
            Color  colorData = Colors.DefaultText;

            switch (textChild.gameObject.name)
            {
            case GameObjects.EndTextChildFinal:
                textData  = (IsPlayerVictorious() ? Texts.PlayerVictoryText   : Texts.RivalVictoryText);
                colorData = (IsPlayerVictorious() ? Colors.PlayerWinTextColor : Colors.RivalWinTextColor);
                break;

            case GameObjects.EndTextChildPlayerDistance:
                textData = Texts.PlayerDistanceTextLabel;
                break;

            case GameObjects.EndTextChildPlayerDistanceValue:
                textData  = PlayerDistance.ToString("0.00");
                colorData = Colors.PlayerColor;
                break;

            case GameObjects.EndTextChildRivalDistance:
                textData = Texts.RivalDistanceTextLabel;
                break;

            case GameObjects.EndTextChildRivalDistanceValue:
                textData  = RivalDistance.ToString("0.00");
                colorData = Colors.RivalColor;
                break;
            }

            text.text  = textData;
            text.color = colorData;
        }
    }