コード例 #1
0
ファイル: AI_XunLuo.cs プロジェクト: x00568/ET
        public override async ETTask Execute(AIComponent aiComponent, AIConfig aiConfig, ETCancellationToken cancellationToken)
        {
            Scene clientScene = aiComponent.DomainScene();

            Unit myUnit = Client.UnitHelper.GetMyUnitFromClientScene(clientScene);

            if (myUnit == null)
            {
                return;
            }

            Log.Debug("开始巡逻");

            while (true)
            {
                XunLuoPathComponent xunLuoPathComponent = myUnit.GetComponent <XunLuoPathComponent>();
                Vector3             nextTarget          = xunLuoPathComponent.GetCurrent();
                int ret = await myUnit.MoveToAsync(nextTarget, cancellationToken);

                if (ret != 0)
                {
                    return;
                }
                xunLuoPathComponent.MoveNext();
            }
        }
コード例 #2
0
        public override async ETTask Execute(AIComponent aiComponent, AIConfig aiConfig, ETCancellationToken cancellationToken)
        {
            Scene clientScene = aiComponent.DomainScene();

            Unit myUnit = Client.UnitHelper.GetMyUnitFromClientScene(clientScene);

            if (myUnit == null)
            {
                return;
            }

            // 停在当前位置
            clientScene.GetComponent <SessionComponent>().Session.Send(new C2M_Stop());

            Log.Debug("开始攻击");

            for (int i = 0; i < 100000; ++i)
            {
                Log.Debug($"攻击: {i}次");

                // 因为协程可能被中断,任何协程都要传入cancellationToken,判断如果是中断则要返回
                bool timeRet = await TimerComponent.Instance.WaitAsync(1000, cancellationToken);

                if (!timeRet)
                {
                    return;
                }
            }
        }
コード例 #3
0
        public AIConfig GetAIConfig()
        {
            AIConfig config = Databases.GetDatabase <AIConfig>(false).GetValue("Hero_H0001");

            config.XmlSerializableName = "Hero_" + GetName();
            return(config);
        }
コード例 #4
0
        /// <summary>
        /// What the instruction should do
        /// </summary>
        protected override void _Process()
        {
            // Parameters
            string countValues = _GetParameter(PatchInstructionParameter.ParameterName.distributionValues);

            // Using TduFile impl
            string   xmlFullPath  = LibraryConstants.GetSpecialFile(LibraryConstants.TduSpecialFile.AIConfig);
            AIConfig aiConfigFile = TduFile.GetFile(xmlFullPath) as AIConfig;

            if (aiConfigFile == null || !aiConfigFile.Exists)
            {
                throw new Exception("Invalid AI configuration file: " + xmlFullPath);
            }
            // Parsing distribution values
            string[] countCouples = countValues.Split(new[] { Tools.SYMBOL_VALUE_SEPARATOR2 }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string anotherCouple in countCouples)
            {
                string[] zoneValue = anotherCouple.Split(Tools.SYMBOL_VALUE_SEPARATOR);

                if (zoneValue.Length == 2)
                {
                    int zoneId = int.Parse(zoneValue[0]);

                    aiConfigFile.SetTrafficVehicleCountPerKilometer(zoneId, zoneValue[1]);
                }
                else
                {
                    throw new Exception("Invalid count parameter specified: " + anotherCouple);
                }
            }

            // Saving
            aiConfigFile.Save();
        }
コード例 #5
0
ファイル: AI.cs プロジェクト: DivinityArcane/lulzBot
        public AI()
        {
            /*ConIO.Write("Loading AIML AI files...", "AI");

            try
            {
                Alice = new AIMLbot.Bot();
                Alice.loadSettings("Storage/ai/config/Settings.xml");
                Alice.loadAIMLFromFiles();
            }
            catch (Exception E)
            {
                ConIO.Warning("AI", "Error while loading AI: " + E.Message);
                ConIO.Warning("AI", "AI extension will not be loaded!");
                return;
            }

            Users = new Dictionary<String, User>();*/

            var info = new ExtensionInfo("AI", "DivinityArcane", "1.0");

            Events.AddCommand("ai", new Command(this, "cmd_ai", "DivinityArcane", 100, "AI settings.", "[trig]ai on/off<br/>[trig]ai enable/disable #chan", ext: info));
            Events.AddEvent("recv_msg", new Event(this, "e_onmsg", "Parses and handles AI requests.", "AI", ext: info));

            // Load saved data, if we can.
            Config = Storage.Load<AIConfig>("ai");

            if (Config.WhiteList == null)
                Config.WhiteList = new List<String>();

            //ConIO.Write("AI extension loaded.", "AI");
        }
コード例 #6
0
    static int ReadConfig(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        AIConfig obj = (AIConfig)LuaScriptMgr.GetNetObjectSelf(L, 1, "AIConfig");

        obj.ReadConfig();
        return(0);
    }
コード例 #7
0
    static int GetRandAIName(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 1);
        AIConfig obj = (AIConfig)LuaScriptMgr.GetNetObjectSelf(L, 1, "AIConfig");
        string   o   = obj.GetRandAIName();

        LuaScriptMgr.Push(L, o);
        return(1);
    }
コード例 #8
0
    static int GetConfig(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        AIConfig obj  = (AIConfig)LuaScriptMgr.GetNetObjectSelf(L, 1, "AIConfig");
        uint     arg0 = (uint)LuaScriptMgr.GetNumber(L, 2);

        AIConfig.AI o = obj.GetConfig(arg0);
        LuaScriptMgr.PushObject(L, o);
        return(1);
    }
コード例 #9
0
        public override int Check(AIComponent aiComponent, AIConfig aiConfig)
        {
            long sec = TimeHelper.ClientNow() / 1000 % 15;

            if (sec >= 10)
            {
                return(0);
            }
            return(1);
        }
コード例 #10
0
ファイル: BehaviorTypes.cs プロジェクト: hew351/hew351
 public AIConfig intializeRangedGeneric(AIConfig ai)
 {
     ai.threatZone       = 25.00f;
     ai.idealRange       = 10.0f;
     ai.friendlyMinDis   = 5.0f;
     ai.kiteDistance     = 20.0f;
     ai.minHealth        = 3;
     ai.healthMultiplier = 1.0f;
     ai.attackMultiplier = 1.0f;
     ai.manaMultiplier   = 1.0f;
     ai.movementSpeed    = 10f;
     return(ai);
 }
コード例 #11
0
 public AIConfig intializeMeleeGeneric(AIConfig ai)
 {
     ai.delta = getDelta (5.0f, 10.0f);
     ai.threatZone = 15.00f;
     ai.idealRange = 1.5f;
     ai.friendlyMinDis = 5.0f;
     ai.kiteDistance = 40.0f;
     ai.minHealth = 1;
     ai.healthMultiplier = 5.0f * difficulty;
     ai.attackMultiplier = 1.0f;
     ai.manaMultiplier = 0.0f;
     ai.movementSpeed = 10f * movSpMultiplier * (1.0f - (1.0f - difficulty));
     return ai;
 }
コード例 #12
0
ファイル: HeroLogic.cs プロジェクト: Enanyy/LuaGame-slua
 public void Tick(string config, ref BTInput input)
 {
     if (string.IsNullOrEmpty(config))
     {
         return;
     }
     if (mBattleLogicDic.ContainsKey(config) == false)
     {
         BTRoot root = new BTRoot();
         AIConfig.ReadXML(config, root);
         mBattleLogicDic.Add(config, root);
     }
     mBattleLogicDic[config].Tick(ref input);
 }
コード例 #13
0
    public void AssignConfig(AIConfig defaultConfig)
    {
        // look up config, attached to bot
        var builder = GetComponent <BotBuilder>();

        if (builder != null && builder.aiConfig != null)
        {
            config = builder.aiConfig;
        }
        else
        {
            config = defaultConfig;
        }
    }
コード例 #14
0
ファイル: AIManager.cs プロジェクト: hew351/hew351
    private void AssignModifiers(AIConfig ai)
    {
        StatCollectionClass toSet = gameObject.GetComponent <StatCollectionClass> ();

        //toSet.initialHealth = 100.0f;

        if (ai.healthMultiplier > 0)
        {
            toSet.initialHealth = toSet.health * ai.healthMultiplier;
            toSet.health        = toSet.initialHealth;
            Debug.Log("Assigning health");
        }
        else
        {
            Debug.LogError("Health and health multiplier must be intialized before applying AssignModifiers.");
        }

        if (ai.attackMultiplier > 0)
        {
            toSet.baseMeleeDamage  = toSet.strength * ai.attackMultiplier;
            toSet.baseRangedDamage = toSet.intellect * ai.attackMultiplier;
            Debug.Log("Assigning baseattack");
        }
        else
        {
            Debug.LogError("Strength/Intellect and attack multiplier must be intialized before applying AssignModifiers.");
        }

        if (toSet.strength > 0 && toSet.intellect > 0)
        {
            toSet.baseDefense = toSet.strength / 2 + toSet.intellect / 2;
            Debug.Log("Assigning basedefense");
        }
        else
        {
            Debug.LogError("Strength and intellect must be intialized before applying AssignModifiers.");
        }

        if (ai.manaMultiplier > 0)
        {
            toSet.initialMana = toSet.intellect * ai.manaMultiplier;
            toSet.mana        = toSet.initialMana;
            Debug.Log("Assigning mana");
        }
        else
        {
            Debug.LogError("intellect and mana multiplier must be intialized before applying AssignModifiers.");
        }
    }
コード例 #15
0
 public AIConfig intializeRangedBoss(AIConfig ai)
 {
     ai.delta = getDelta (5.0f, 10.0f);
     ai.AIType = "boss";
     ai.threatZone = 25.00f;
     ai.idealRange = 10.0f;
     ai.friendlyMinDis = 5.0f;
     ai.kiteDistance = 20.0f;
     ai.minHealth = 3;
     ai.healthMultiplier = 1.0f;
     ai.attackMultiplier = 1.0f;
     ai.manaMultiplier = 1.0f;
     ai.movementSpeed = 10f * movSpMultiplier;
     return ai;
 }
コード例 #16
0
    public void Init(Character controlledCharacter, Character enemyCharacter, AIConfig config)
    {
        MoveDirection       = 1;
        ControlledCharacter = controlledCharacter;
        EnemyCharacter      = enemyCharacter;
        Config = config;
        InitPath();
        ControlledCharacter.SetInput(this);
        var random = UnityEngine.Random.Range(-Config.SpeedRandom, Config.SpeedRandom);

        SpeedPatrol  = Config.SpeedPatrol + random;
        SpeedPursuit = Config.SpeedPursuit + random;

        Renderer = ControlledCharacter.GetRenderer;
    }
コード例 #17
0
ファイル: AIManager.cs プロジェクト: hew351/hew351
    void Start()
    {
        AIConfig mob = AIBuilder("mob", weightedLevel);

        gameObject.AddComponent <PathManager> ().mobSp  = mob.movementSpeed;
        gameObject.AddComponent <AIBehavior> ().rb      = mob;
        gameObject.GetComponent <AIBehavior> ().pathing = gameObject.GetComponent <PathManager> ();
        gameObject.AddComponent <DecisionTree>();
        gameObject.AddComponent <CollisionHandler> ();


        //AI START//
        behavior = gameObject.GetComponent <DecisionTree> ();

        behavior.startDeciding();
    }
コード例 #18
0
    static int _CreateAIConfig(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 0)
        {
            AIConfig obj = new AIConfig();
            LuaScriptMgr.PushObject(L, obj);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: AIConfig.New");
        }

        return(0);
    }
コード例 #19
0
ファイル: EnemySpawn.cs プロジェクト: Evilkitty1341/cmpt306
    private int statPerEnemy; // This will be determined after the number of enemies for a group is determined

    #endregion Fields

    #region Methods

    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /*
        Spawns a single preconfigured AI. Used for boss spawning atm.
    */
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public void SpawnSingle(Vector3 pos)
    {
        AIConfig ai = new AIConfig();
        ManualAI mAI = new ManualAI();

        ai = mAI.LevelOneBoss(ai);
        GameObject enemy;

        enemy = Instantiate(spawnObjectBoss) as GameObject;

        enemy.GetComponent<AIManager>().config = ai;
        enemy.GetComponent<AIManager>().decisionType = "boss";
        enemy.GetComponent<AIManager>().enabled = true;

        enemy.transform.localScale = new Vector3(10f, 10f, 0f);
        // Set position to selected spawn point
        enemy.transform.position = pos;
    }
コード例 #20
0
    public void Start()
    {
        AIConfig.Init();

        topShow = new HeroTopShow();
        show    = new BattleShow();

        logic = new HeroLogic();

        status = BattleStatus.Prepare;


        if (battleData == null)
        {
            InitBattleTest();
        }
        for (int i = 0; i < battleData.attackList.Count; ++i)
        {
            var heroData = battleData.attackList[i];

            heroData.x = 1;
            heroData.y = 0;
            heroData.z = 1;

            GetHeroConfig(ref heroData);


            mCreateQueue.Enqueue(heroData);
        }

        for (int i = 0; i < battleData.defenseList.Count; ++i)
        {
            var heroData = battleData.defenseList[i];
            heroData.x = 2;
            heroData.y = 0;
            heroData.z = 2;
            GetHeroConfig(ref heroData);
            mCreateQueue.Enqueue(heroData);
        }
    }
コード例 #21
0
    static int set_configs(IntPtr L)
    {
        object   o   = LuaScriptMgr.GetLuaObject(L, 1);
        AIConfig obj = (AIConfig)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name configs");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index configs on a nil value");
            }
        }

        obj.configs = (Dictionary <uint, AIConfig.AI>)LuaScriptMgr.GetNetObject(L, 3, typeof(Dictionary <uint, AIConfig.AI>));
        return(0);
    }
コード例 #22
0
    static int get_names(IntPtr L)
    {
        object   o   = LuaScriptMgr.GetLuaObject(L, 1);
        AIConfig obj = (AIConfig)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name names");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index names on a nil value");
            }
        }

        LuaScriptMgr.PushObject(L, obj.names);
        return(1);
    }
コード例 #23
0
    static int set_names(IntPtr L)
    {
        object   o   = LuaScriptMgr.GetLuaObject(L, 1);
        AIConfig obj = (AIConfig)o;

        if (obj == null)
        {
            LuaTypes types = LuaDLL.lua_type(L, 1);

            if (types == LuaTypes.LUA_TTABLE)
            {
                LuaDLL.luaL_error(L, "unknown member name names");
            }
            else
            {
                LuaDLL.luaL_error(L, "attempt to index names on a nil value");
            }
        }

        obj.names = (List <string>)LuaScriptMgr.GetNetObject(L, 3, typeof(List <string>));
        return(0);
    }
コード例 #24
0
ファイル: AIController.cs プロジェクト: saint-angels/fencing
    public void Run()
    {
        aiConfig = Root.ConfigManager.AI;

        StartCoroutine(FightRoutine());
    }
コード例 #25
0
ファイル: AIManager.cs プロジェクト: hew351/hew351
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /*
     *      The AIBuilder method creates a config for a AI enabled entity.
     *      Currently it psuedorandomly assigns stats, eventually options for chosen stats and weighted random stats
     *      will be added.
     *      The AIBuilder will require switch logic to pick a set of nonconflicting behaviors.
     */
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    public AIConfig AIBuilder(string type, int rWeight)
    {
        if (rWeight > (maxStatValue * numOfStats))
        {
            Debug.LogError("Weight is too high for the number of stats given their maximums.");
            Debug.Break();
        }
        StatCollectionClass member = gameObject.GetComponent <StatCollectionClass>();

        decisionType = type;
        bool AImade       = false;
        bool isMelee      = false;
        bool isHybrid     = false;
        bool isAggressive = false;
        bool isStalker    = false;
        bool hasMagic     = false;
        bool isCautious   = false;

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /*
         *      We need to vary the stats based on weight.
         *      Look at the weight and see if the even split (average) is between the values is over statMax (our maximum
         *      normalized stat value).
         *      If it is, assign randomly from a range between statmin to statMax.
         *      Otherwise assign randomly statmin to the dividend of weight total with # of stats and add the modulus
         *      remainder. This will give stats that fairly equalized to the weight. Let AdjustStats fix any underages or
         *      overages.
         */
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        int[] split = new int[numOfStats];

        if ((rWeight / numOfStats) > maxStatValue)           //Upper bound on stats, might not be needed if things are weighted right.
        {
            int remain = rWeight;
            for (int i = 0; i < numOfStats; i++)
            {
                split [i] = Random.Range(minStatValue, maxStatValue);
                //For Testing: print ("Random value for stat #" + i.ToString () + " : " + split [i].ToString ());
                remain = remain - split [i];
            }
        }
        else
        {
            for (int i = 0; i < numOfStats; i++)
            {
                split [i] = Random.Range(minStatValue, (rWeight / numOfStats) + rWeight % numOfStats);
                //For Testing: print ("Random value for stat #" + i.ToString () + " : " + split [i].ToString ());
            }
        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /*
         *      Sum all the stats together to so we can compare it to weight.
         *      Calculate the expected sum and actual sum diff for our AdjustStats call.
         */
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        int sumR;

        AdjustStats(split, rWeight);

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /*
         *       Finally check that the final sum is correct.
         *       If the sum is correct set AImade true and carry on!
         *       Otherwise throw nasty errors and annoy us.
         *       TODO Have this loop back to AdjustStats, error if it fails to properly adjust it again.(We should never
         *       hit this second call ideally.)
         */
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        //Testing
        //for(int j = 0; j < numOfStats; j++){
        //print("Final random stats" + split[j].ToString());
        //}
        //

        sumR = sumArray(split);
        //print ("The sum is " + sumR.ToString () + " It is supposed to be " + rWeight.ToString ());

        if (sumR == rWeight)
        {
            AImade = true;
        }


        if (AImade)
        {
            AssignStats(split);
        }
        else
        {
            Debug.LogError("AIManager failed to create a proper AIBuild");
        }

        AIConfig config = new AIConfig();

                #pragma warning disable
        BehaviorTypes assignBehavior = new BehaviorTypes();
                #pragma warning restore

        switch (type)
        {
        case "mob":
            if (member.health > 0)
            {
                //Visual adjustments for health thresholds.
            }
            if (member.mana > 0)
            {
                //Visual adjustments for mana thresholds.
                hasMagic = true;
            }
            if (member.strength > 6)
            {
                isMelee      = true;
                isAggressive = true;
                //Visual adjustments for being melee.
            }
            if (member.intellect > 6 && member.strength >= member.intellect)
            {
                isCautious = true;
                isHybrid   = true;
                //Visual adjustments for being cautious.
            }
            if (member.intellect > 6 && member.intellect >= member.strength)
            {
                isStalker = true;
                //Visual adjustments for being a stalker.
            }

            config.isMelee      = isMelee;
            config.isHybrid     = isHybrid;
            config.hasMagic     = hasMagic;
            config.isAggressive = isAggressive;
            config.isCautious   = isCautious;
            config.isStalker    = isStalker;

            if (isHybrid)
            {
                config = assignBehavior.intializeHybridGeneric(config);
            }
            else if (isMelee)
            {
                config = assignBehavior.intializeMeleeGeneric(config);
            }
            else
            {
                config = assignBehavior.intializeRangedGeneric(config);
            }


            AssignModifiers(config);
            config.isMade = AImade;
            break;

        case "npc":
            //Stuff might go here?
            break;

        case "boss":
            //Boss mechanics to be decided.
            break;

        default:
            Debug.LogError(type + ": is not a supported type.");
            break;
        }


        print(config.ToString());

        return(config);
    }
コード例 #26
0
ファイル: AIManager.cs プロジェクト: hew351/hew351
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /*
        The AIBuilder method creates a config for a AI enabled entity.
        Currently it psuedorandomly assigns stats, eventually options for chosen stats and weighted random stats
        will be added.
        The AIBuilder will require switch logic to pick a set of nonconflicting behaviors.
    */
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    public AIConfig AIBuilder(string type, int rWeight)
    {
        if(rWeight > (maxStatValue * numOfStats)){
            Debug.LogError("Weight is too high for the number of stats given their maximums.");
            Debug.Break();
        }
        StatCollectionClass member = gameObject.GetComponent<StatCollectionClass>();
        decisionType = type;
        bool AImade = false;
        bool isMelee = false;
        bool isHybrid = false;
        bool isAggressive = false;
        bool isStalker = false;
        bool hasMagic = false;
        bool isCautious = false;

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /*
            We need to vary the stats based on weight.
            Look at the weight and see if the even split (average) is between the values is over statMax (our maximum
            normalized stat value).
            If it is, assign randomly from a range between statmin to statMax.
            Otherwise assign randomly statmin to the dividend of weight total with # of stats and add the modulus
            remainder. This will give stats that fairly equalized to the weight. Let AdjustStats fix any underages or
            overages.
        */
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        int[] split = new int[numOfStats];

        if ((rWeight / numOfStats) > maxStatValue) { //Upper bound on stats, might not be needed if things are weighted right.
            int remain = rWeight;
            for (int i = 0; i < numOfStats; i++) {
                split [i] = Random.Range (minStatValue, maxStatValue);
                //For Testing: print ("Random value for stat #" + i.ToString () + " : " + split [i].ToString ());
                remain = remain - split [i];
            }
        } else {
            for (int i = 0; i < numOfStats; i++) {
                split [i] = Random.Range (minStatValue, (rWeight / numOfStats) + rWeight % numOfStats);
                //For Testing: print ("Random value for stat #" + i.ToString () + " : " + split [i].ToString ());
            }
        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /*
         	Sum all the stats together to so we can compare it to weight.
         	Calculate the expected sum and actual sum diff for our AdjustStats call.
        */
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        int sumR;
        AdjustStats (split, rWeight);

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /*
             Finally check that the final sum is correct.
         	 If the sum is correct set AImade true and carry on!
             Otherwise throw nasty errors and annoy us.
             TODO Have this loop back to AdjustStats, error if it fails to properly adjust it again.(We should never
             hit this second call ideally.)
        */
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        //Testing
        //for(int j = 0; j < numOfStats; j++){
            //print("Final random stats" + split[j].ToString());
        //}
        //

        sumR = sumArray (split);
        //print ("The sum is " + sumR.ToString () + " It is supposed to be " + rWeight.ToString ());

        if (sumR == rWeight) {
            AImade = true;
        }

        if (AImade) {
            AssignStats(split);
        } else {
            Debug.LogError ("AIManager failed to create a proper AIBuild");
        }

        AIConfig config = new AIConfig ();

        #pragma warning disable
        BehaviorTypes assignBehavior = new BehaviorTypes ();
        #pragma warning restore

        switch(type){
        case "mob":
            if(member.health > 0){
                //Visual adjustments for health thresholds.
            }
            if(member.mana > 0){
                //Visual adjustments for mana thresholds.
                hasMagic = true;
            }
            if(member.strength > 6){
                isMelee = true;
                isAggressive = true;
                //Visual adjustments for being melee.
            }
            if(member.intellect > 6 && member.strength >= member.intellect){
                isCautious = true;
                isHybrid = true;
                //Visual adjustments for being cautious.
            }
            if(member.intellect > 6 && member.intellect >= member.strength){
                isStalker = true;
                //Visual adjustments for being a stalker.
            }

            config.isMelee = isMelee;
            config.isHybrid = isHybrid;
            config.hasMagic = hasMagic;
            config.isAggressive = isAggressive;
            config.isCautious = isCautious;
            config.isStalker = isStalker;

            if(isHybrid)
                config = assignBehavior.intializeHybridGeneric (config);
            else if(isMelee)
                config = assignBehavior.intializeMeleeGeneric (config);
            else
                config = assignBehavior.intializeRangedGeneric (config);

            AssignModifiers(config);
            config.isMade = AImade;
            break;
        case "npc":
            //Stuff might go here?
            break;
        case "boss":
            //Boss mechanics to be decided.
            break;
        default:
            Debug.LogError (type + ": is not a supported type.");
            break;
        }

        print(config.ToString ());

        return config;
    }
コード例 #27
0
ファイル: AIManager.cs プロジェクト: hew351/hew351
    private void AssignModifiers(AIConfig ai)
    {
        StatCollectionClass toSet = gameObject.GetComponent<StatCollectionClass> ();

        //toSet.initialHealth = 100.0f;

        if (ai.healthMultiplier > 0) {
            toSet.initialHealth = toSet.health * ai.healthMultiplier;
            toSet.health = toSet.initialHealth;
            Debug.Log("Assigning health");
        }
        else
            Debug.LogError ("Health and health multiplier must be intialized before applying AssignModifiers.");

        if (ai.attackMultiplier > 0) {
            toSet.baseMeleeDamage = toSet.strength * ai.attackMultiplier;
            toSet.baseRangedDamage = toSet.intellect * ai.attackMultiplier;
            Debug.Log ("Assigning baseattack");
        }
        else
            Debug.LogError ("Strength/Intellect and attack multiplier must be intialized before applying AssignModifiers.");

        if (toSet.strength > 0 && toSet.intellect > 0) {
            toSet.baseDefense = toSet.strength / 2 + toSet.intellect / 2;
            Debug.Log ("Assigning basedefense");
        }
        else
            Debug.LogError ("Strength and intellect must be intialized before applying AssignModifiers.");

        if (ai.manaMultiplier > 0) {
            toSet.initialMana = toSet.intellect * ai.manaMultiplier;
            toSet.mana = toSet.initialMana;
            Debug.Log("Assigning mana");
        }
        else
            Debug.LogError ("intellect and mana multiplier must be intialized before applying AssignModifiers.");
    }
コード例 #28
0
 public SimplePatrolAIModel(AIConfig config)
 {
     _config = config;
     _target = GetNextWaypoint();
 }
コード例 #29
0
ファイル: TduFile.cs プロジェクト: djey47/tdumt
        /// <summary>
        /// Returns the right TDUFile according to specified file.
        /// </summary>
        /// <param name="fileName">file name, without path</param>
        /// <returns>null if file is from an unsupported type</returns>
        public static TduFile GetFile(string fileName)
        {
            TduFile  tduFile = new Regular();
            FileInfo fi      = new FileInfo(fileName);

            // New mapping management

            // Cameras
            if (Regex.IsMatch(fileName, Cameras.FILENAME_PATTERN, RegexOptions.IgnoreCase))
            {
                if (fi.Exists)
                {
                    tduFile = new Cameras(fileName);
                }
                else
                {
                    tduFile = new Cameras();
                }
            }
            // AIConfig
            else if (Regex.IsMatch(fileName, AIConfig.FILENAME_PATTERN, RegexOptions.IgnoreCase))
            {
                if (fi.Exists)
                {
                    tduFile = new AIConfig(fileName);
                }
                else
                {
                    tduFile = new AIConfig();
                }
            }
            // DB
            else if (Regex.IsMatch(fileName, DB.FILENAME_PATTERN, RegexOptions.IgnoreCase))
            {
                if (fi.Exists)
                {
                    tduFile = new DB(fileName);
                }
                else
                {
                    tduFile = new DB();
                }
            }
            // BNK
            else if (Regex.IsMatch(fileName, BNK.FILENAME_PATTERN, RegexOptions.IgnoreCase))
            {
                tduFile = new BNK(fileName);
            }
            // DDS
            else if (Regex.IsMatch(fileName, DDS.FILENAME_PATTERN, RegexOptions.IgnoreCase))
            {
                if (fi.Exists)
                {
                    tduFile = new DDS(fileName);
                }
                else
                {
                    tduFile = new DDS();
                }
            }
            // 2DB
            else if (Regex.IsMatch(fileName, _2DB.FILENAME_PATTERN, RegexOptions.IgnoreCase) ||
                     Regex.IsMatch(fileName, _2DB.FILENAME_OLD_PATTERN, RegexOptions.IgnoreCase))
            {
                if (fi.Exists)
                {
                    tduFile = new _2DB(fileName);
                }
                else
                {
                    tduFile = new _2DB();
                }
            }
            // MAP
            else if (Regex.IsMatch(fileName, MAP.FILENAME_PATTERN, RegexOptions.IgnoreCase))
            {
                if (fi.Exists)
                {
                    tduFile = new MAP(fileName);
                }
                else
                {
                    tduFile = new MAP();
                }
            }
            // XMB
            else if (Regex.IsMatch(fileName, XMB.FILENAME_PATTERN, RegexOptions.IgnoreCase))
            {
                if (fi.Exists)
                {
                    tduFile = new XMB(fileName);
                }
                else
                {
                    tduFile = new XMB();
                }
            }
            // WAV + XMB_WAV
            else if (Regex.IsMatch(fileName, XMB_WAV.FILENAME_PATTERN, RegexOptions.IgnoreCase))
            {
                try
                {
                    if (fi.Exists)
                    {
                        tduFile = new XMB_WAV(fileName);
                    }
                    else
                    {
                        tduFile = new XMB_WAV();
                    }
                }
                catch (FormatException)
                {
                    // standard WAV file
                }
            }
            // PCH
            else if (Regex.IsMatch(fileName, PCH.FILENAME_PATTERN, RegexOptions.IgnoreCase))
            {
                tduFile = new PCH(fileName);
            }
            // DB Resources
            else if (Regex.IsMatch(fileName, DBResource.FILENAME_PATTERN, RegexOptions.IgnoreCase))
            {
                if (fi.Exists)
                {
                    tduFile = new DBResource(fileName);
                }
                else
                {
                    tduFile = new DBResource();
                }
            }
            // DFE
            else if (Regex.IsMatch(fileName, DFE.FILENAME_PATTERN, RegexOptions.IgnoreCase))
            {
                tduFile = new DFE(fileName);
            }
            // IGE
            else if (Regex.IsMatch(fileName, IGE.FILENAME_PATTERN, RegexOptions.IgnoreCase))
            {
                tduFile = new IGE(fileName);
            }
            // Regular by default
            else
            {
                tduFile = new Regular();
            }

            // To update common information
            tduFile._FinalizeLoading(fileName);

            return(tduFile);
        }
コード例 #30
0
ファイル: BehaviorTypes.cs プロジェクト: hew351/hew351
 public void intializeRangedBoss(AIConfig ai)
 {
 }
コード例 #31
0
ファイル: BehaviorTypes.cs プロジェクト: hew351/hew351
 public void intializeMeleeBoss(AIConfig ai)
 {
 }
コード例 #32
0
ファイル: GameSystem.cs プロジェクト: Avatarchik/LockStepDemo
    public void LoadConfig()
    {
        AnnouncementConfigData = new AnnouncementConfig();
        BadgeAttrConfigData    = new BadgeAttrConfig();
        ConstStringConfigData  = new ConstStringConfig();
        CommonConfig           = new CommonConfig();

        AttrNameConfigData        = new AttrNameConfig();
        RoleBaseConfigData2       = new BaseDataConfig2();
        AttrDataConfigData        = new AttrDataConfig();
        TeamLevelConfigData       = new TeamLevelConfig();
        RoleLevelConfigData       = new RoleLevelConfig();
        NPCConfigData             = new NPCDataConfig();
        SkillConfig               = new SkillConfig();
        GoodsConfigData           = new GoodsConfig();
        StoreGoodsConfigData      = new StoreGoodsConfig();
        BaseDataBuyConfigData     = new BaseDataBuyConfig();
        TaskConfigData            = new TaskDataConfig();
        AwardPackConfigData       = new AwardPackDataConfig();
        PractiseConfig            = new PractiseConfig();
        PracticePveConfig         = new PracticePveConfig();
        PractiseStepConfig        = new PractiseStepConfig();
        GameModeConfig            = new GameModeConfig();
        TrainingConfig            = new TrainingConfig();
        TattooConfig              = new TattooConfig();
        EquipmentConfigData       = new EquipmentConfig();
        TourConfig                = new TourConfig();
        GuideConfig               = new GuideConfig();
        FunctionConditionConfig   = new FunctionConditionConfig();
        RoleShapeConfig           = new RoleShapeConfig();
        FashionConfig             = new FashionConfig();
        FashionShopConfig         = new FashionShopConfig();
        VipPrivilegeConfig        = new VipPrivilegeConfig();
        pushConfig                = new PushConfig();
        presentHpConfigData       = new PresentHpConfig();
        LotteryConfig             = new LotteryConfig();
        starAttrConfig            = new StarAttrConfig();
        qualityAttrCorConfig      = new QualityAttrCorConfig();
        skillUpConfig             = new SkillUpConfig();
        RankConfig                = new RankConfig();
        signConfig                = new SignConfig();
        NewComerSignConfig        = new NewComerSignConfig();
        FightingCapacityConfig    = new FightingCapacityConfig();
        BodyInfoListConfig        = new BodyInfoListConfig();
        BadgeSlotsConfig          = new BadgeSlotConfig();
        GoodsComposeNewConfigData = new GoodsComposeNewConfig();

        SceneConfig = new SceneConfig();

        ReboundAttrConfigData    = new ReboundAttrConfig();
        CareerConfigData         = new CareerConfig();
        PotientialEffectConfig   = new PotientialEffectConfig();
        PVPPointConfig           = new PVPPointConfig();
        WinningStreakAwardConfig = new WinningStreakAwardConfig();
        ArticleStrengthConfig    = new ArticleStrengthConfig();
        PhRegainConfig           = new PhRegainConfig();
        MatchAchievementConfig   = new MatchAchievementConfig();
        SpecialActionConfig      = new SpecialActionConfig();
        StealConfig           = new StealConfig();
        CurveRateConfig       = new CurveRateConfig();
        DunkRateConfig        = new DunkRateConfig();
        AIConfig              = new AIConfig();
        AttrReduceConfig      = new AttrReduceConfig();
        qualifyingConfig      = new QualifyingConfig();
        qualifyingNewConfig   = new QualifyingNewConfig();
        qualifyingNewerConfig = new QualifyingNewerConfig();
        bullFightConfig       = new BullFightConfig();
        HedgingConfig         = new HedgingConfig();
        roleGiftConfig        = new RoleGiftConfig();
        DebugConfig           = new DebugConfig();
        shootGameConfig       = new ShootGameConfig();
        MapConfig             = new MapConfig();
        activityConfig        = new ActivityConfig();
        trialConfig           = new TrialConfig();
        gameMatchConfig       = new GameMatchConfig();
        shootSolutionManager  = new ShootSolutionManager();
        talentConfig          = new TalentConfig();
        ladderConfig          = new LadderConfig();
        matchSoundConfig      = new MatchSoundConfig();
        matchMsgConfig        = new MatchMsgConfig();
        MatchPointsConfig     = new MatchPointsConfig();
        AnimationSampleManager.Instance.LoadXml();
    }
コード例 #33
0
ファイル: BehaviorTypes.cs プロジェクト: hew351/hew351
 public void intializeHyrbidBoss(AIConfig ai)
 {
 }
コード例 #34
0
ファイル: Config.cs プロジェクト: HyVong007/Ancient-Empires
        public static Config DeSerialize(byte[] data)
        {
            var cfg = new Config();

            using (var m = new MemoryStream(data))
                using (var r = new BinaryReader(m))
                {
                    // read map
                    cfg.map = Map.DeSerialize(r.ReadBytes(r.ReadInt32()));

                    // read money
                    cfg.money = r.ReadInt32();

                    // read turn time
                    cfg.turnTime = r.ReadSingle();

                    // read army infos
                    cfg.armyInfos = new ArmyInfo[r.ReadInt32()];
                    for (int i = 0; i < cfg.armyInfos.Length; ++i)
                    {
                        cfg.armyInfos[i] = new ArmyInfo()
                        {
                            color = (Army.Color)r.ReadByte(),
                            group = (Army.Group)r.ReadByte(),
                            name  = r.ReadString()
                        }
                    }
                    ;

                    // read playMode
                    cfg.playMode = (PlayMode)r.ReadByte();

                    // read playMode config
                    switch (cfg.playMode)
                    {
                    case PlayMode.CAMPAIGN: break;

                    case PlayMode.SKIRMISH:
                    {
                        cfg.playModeConfig = SkirmishConfig.DeSerialize(r.ReadBytes(r.ReadInt32()));
                        break;
                    }

                    case PlayMode.ONLINE:
                    {
                        cfg.playModeConfig = OnlineConfig.DeSerialize(r.ReadBytes(r.ReadInt32()));
                        break;
                    }

                    case PlayMode.LAN:
                    {
                        cfg.playModeConfig = LANConfig.DeSerialize(r.ReadBytes(r.ReadInt32()));
                        break;
                    }
                    }

                    // read AI config
                    if (r.ReadBoolean())
                    {
                        cfg.aiConfig = AIConfig.DeSerialize(r.ReadBytes(r.ReadInt32()));
                    }

                    return(cfg);
                }
        }
    }
コード例 #35
0
ファイル: Config.cs プロジェクト: HyVong007/Ancient-Empires
        public static byte[] Serialize(object obj)
        {
            var cfg = (Config)obj;

            using (var m = new MemoryStream())
                using (var w = new BinaryWriter(m))
                {
                    // write map
                    byte[] map_data = Map.Serialize(cfg.map);
                    w.Write(map_data.Length);
                    w.Write(map_data);

                    // write money
                    w.Write(cfg.money);

                    // write turn time
                    w.Write(cfg.turnTime);

                    // write army infos
                    w.Write(cfg.armyInfos.Length);
                    foreach (var info in cfg.armyInfos)
                    {
                        w.Write((byte)info.color);
                        //w.Write((byte)info.type);
                        w.Write((byte)info.group);
                        w.Write(info.name);
                    }

                    // write playMode
                    w.Write((byte)cfg.playMode);

                    // write playMode config
                    switch (cfg.playMode)
                    {
                    case PlayMode.CAMPAIGN: break;

                    case PlayMode.SKIRMISH:
                    {
                        byte[] data = SkirmishConfig.Serialize(cfg.playModeConfig);
                        w.Write(data.Length);
                        w.Write(data);
                        break;
                    }

                    case PlayMode.ONLINE:
                    {
                        byte[] data = OnlineConfig.Serialize(cfg.playModeConfig);
                        w.Write(data.Length);
                        w.Write(data);
                        break;
                    }

                    case PlayMode.LAN:
                    {
                        byte[] data = LANConfig.Serialize(cfg.playModeConfig);
                        w.Write(data.Length);
                        w.Write(data);
                        break;
                    }
                    }

                    // write AI config
                    w.Write(cfg.aiConfig != null);
                    if (cfg.aiConfig != null)
                    {
                        byte[] data = AIConfig.Serialize(cfg.aiConfig);
                        w.Write(data.Length);
                        w.Write(data);
                    }

                    return(m.ToArray());
                }
        }
コード例 #36
0
ファイル: ProceduralAI.cs プロジェクト: Evilkitty1341/cmpt306
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    /*
        The AIBuilder method creates a config for a AI enabled entity.
        Currently it psuedorandomly assigns stats, eventually options for chosen stats and weighted random stats
        will be added.
        The AIBuilder will require switch logic to pick a set of nonconflicting behaviors.
    */
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////	
    public AIConfig AIBuilder(string type, int rWeight, int minStatValue, int maxStatValue)
    {
        if(rWeight > (maxStatValue * numOfStats)){
            Debug.LogError("Weight is too high for the number of stats given their maximums.");
            return default(AIConfig);
        }

        GameObject unitySucks = new GameObject ();

        AIConfig config = new AIConfig ();
        config.statExchange = unitySucks.AddComponent<StatCollectionClass> ();

        if (config.statExchange.Equals (null)) {
            Debug.LogError("Unity sucks");
        }

        bool AImade = false;
        bool isMelee = false;
        bool isHybrid = false;
        bool isAggressive = false;
        bool isStalker = false;
        bool hasMagic = false;
        bool isCautious = false;

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /*
            We need to vary the stats based on weight.
            Look at the weight and see if the even split (average) is between the values is over statMax (our maximum
            normalized stat value).
            If it is, assign randomly from a range between statmin to statMax.
            Otherwise assign randomly statmin to the dividend of weight total with # of stats and add the modulus
            remainder. This will give stats that fairly equalized to the weight. Let AdjustStats fix any underages or
            overages.
        */
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        int[] split = new int[numOfStats];

        if ((rWeight / numOfStats) > maxStatValue) { //Upper bound on stats, might not be needed if things are weighted right.
            int remain = rWeight;
            for (int i = 0; i < numOfStats; i++) {
                split [i] = Random.Range (minStatValue, maxStatValue);
                remain = remain - split [i];
            }
        } else {
            for (int i = 0; i < numOfStats; i++) {
                split [i] = Random.Range (minStatValue, (rWeight / numOfStats) + rWeight % numOfStats);
            }
        }

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /*
         	Sum all the stats together to so we can compare it to weight.
         	Calculate the expected sum and actual sum diff for our AdjustStats call.
        */
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        int sumR;
        AdjustStats (split, rWeight, minStatValue, maxStatValue);

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /*
             Finally check that the final sum is correct.
         	 If the sum is correct set AImade true and carry on!
             Otherwise throw nasty errors and annoy us.
             TODO Have this loop back to AdjustStats, error if it fails to properly adjust it again.(We should never
             hit this second call ideally.)
        */
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        sumR = sumArray (split);
        if (sumR == rWeight) {
            AImade = true;
        }

        if (AImade) {
            AssignStats(split, unitySucks.GetComponent<StatCollectionClass>());
        } else {
            Debug.LogError ("AIManager failed to create a proper AIBuild");
        }

        #pragma warning disable
        BehaviorTypes assignBehavior = new BehaviorTypes ();
        #pragma warning restore

        switch(type){
        case "mob":
            if(config.statExchange.health > 0){
            }
            if(config.statExchange.mana > 0){
                hasMagic = true;
            }
            if(config.statExchange.strength > 6){
                isMelee = true;
                isAggressive = true;
            }
            if(config.statExchange.intellect > 6 && config.statExchange.strength >= config.statExchange.intellect){
                isCautious = true;
                isHybrid = true;
            }
            if(config.statExchange.intellect > 6 && config.statExchange.intellect >= config.statExchange.strength){
                isStalker = true;
            }

            if(isMelee && !isHybrid){
                float str = config.statExchange.strength;
                float scale = (1.5f * (1f + str/50f));
                transform.localScale = new Vector3(scale, scale, 0);
                config.AIType = "Melee";
            }else if(isHybrid){
                transform.localScale = new Vector3(2f, 2f, 0);
                config.AIType = "Hybrid";
            }else{
                transform.localScale = new Vector3(1.8f, 1.8f, 0);
                config.AIType = "Ranged";
            }

            config.isMelee = isMelee;
            config.isHybrid = isHybrid;
            config.hasMagic = hasMagic;
            config.isAggressive = isAggressive;
            config.isCautious = isCautious;
            config.isStalker = isStalker;

            if(isHybrid)
                config = assignBehavior.intializeHybridGeneric(config);
            else if(isMelee)
                config = assignBehavior.intializeMeleeGeneric(config);
            else
                config = assignBehavior.intializeRangedGeneric(config);

            AssignModifiers(config);
            config.isMade = AImade;
            break;
        case "npc":
            //Stuff might go here?
            break;
        case "boss":
            if(config.statExchange.health > 0){
            }
            if(config.statExchange.mana > 0){
                hasMagic = true;
            }
            if(config.statExchange.strength > 6){
                isMelee = true;
                isAggressive = true;
            }
            if(config.statExchange.intellect > 6 && config.statExchange.strength >= config.statExchange.intellect){
                isCautious = true;
                isHybrid = true;
            }
            if(config.statExchange.intellect > 6 && config.statExchange.intellect >= config.statExchange.strength){
                isStalker = true;
            }

            if(isMelee && !isHybrid){
                float str = config.statExchange.strength;
                float scale = (1.5f * (1f + str/50f));
                transform.localScale = new Vector3(scale, scale, 0);
                config.AIType = "Melee";
            }else if(isHybrid){
                transform.localScale = new Vector3(2f, 2f, 0);
                config.AIType = "Hybrid";
            }else{
                transform.localScale = new Vector3(1.8f, 1.8f, 0);
                config.AIType = "Ranged";
            }
            config.isMelee = isMelee;
            config.isHybrid = isHybrid;
            config.hasMagic = hasMagic;
            config.isAggressive = isAggressive;
            config.isCautious = isCautious;
            config.isStalker = isStalker;

            if(isHybrid)
                config = assignBehavior.intializeHybridGeneric(config);
            else if(isMelee)
                config = assignBehavior.intializeMeleeGeneric(config);
            else
                config = assignBehavior.intializeRangedGeneric(config);

            AssignModifiers(config);
            config.isMade = AImade;
            break;
        default:
            Debug.LogError (type + ": is not a supported type.");
            break;
        }
        print(config.ToString ());

        StartCoroutine ("waitToDestroy", unitySucks);
        //Destroy (unitySucks);
        return config;
    }
コード例 #37
0
ファイル: AIManager.cs プロジェクト: mitchlau/TimeTeamProject
    public AIConfig AIBuilder(StatCollectionClass member, string type, int rWeight)
    {
        bool AImade = false;

        AIConfig config = new AIConfig();
        /*
         * TODO PICK AN AI TYPE
        switch(type){
        case "player":
        case "mob":
        case "npc":
        default:
            break;
        }
        */

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // We need to vary the stats based on weight.
        // Look at the weight and see if the even split between the values is over statMax.
        // If it is, assign randomly from statmin to statMax.
        // Otherwise assign randomly statmin to the dividend of weight total with # of stats and add the modulus
        // remainder.
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        int[] split = new int[numOfStats];

        if ((rWeight / numOfStats) > maxStatValue) {
            int remain = rWeight;
            for (int i = 0; i < numOfStats; i++) {
                split [i] = Random.Range (minStatValue, maxStatValue);
                //print ("Random value for stat #" + i.ToString () + " : " + split [i].ToString ());
                remain = remain - split [i];
            }
        } else {
            for (int i = 0; i < numOfStats; i++) {
                split [i] = Random.Range (minStatValue, (rWeight / numOfStats) + rWeight % numOfStats);
                //print ("Random value for stat #" + i.ToString () + " : " + split [i].ToString ());
            }
        }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Sum all the stats together to so we can compare it to weight.
        // Calculate the expected sum and actual sum diff.
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        int sumR;

        AdjustStats (split, rWeight);

        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Finally check that the sum is correct.
        // If the sum is correct set AImade true and carry on!
        // Otherwise throw nasty errors and annoy us.
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        for(int j = 0; j < numOfStats; j++){
            //print("Final random stats" + split[j].ToString());
        }

        sumR = sumArray (split);
        //print ("The sum is " + sumR.ToString () + " It is supposed to be " + rWeight.ToString ());

        if (sumR == rWeight) {
            AImade = true;
        }

        if (AImade) {
            AssignStats(split, member);
            return config;
        } else {
            Debug.LogError ("AIManager failed to create a proper AIBuild");
            return config;
        }
    }
コード例 #38
0
ファイル: ProceduralAI.cs プロジェクト: Evilkitty1341/cmpt306
    public void AssignModifiers(AIConfig ai)
    {
        //toSet.initialHealth = 100.0f;

        if (ai.statExchange.Equals (null)) {
            Debug.LogError("statcollection not found |assignmodifiers|");
            return;
        }

        if (ai.healthMultiplier >= 0) {
            ai.statExchange.initialHealth = ai.statExchange.health * ai.healthMultiplier;
            ai.statExchange.health = ai.statExchange.initialHealth;
            //Debug.Log("Assigning health");
        }
        else
            Debug.LogError ("Health and health multiplier must be intialized before applying AssignModifiers.");

        if (ai.attackMultiplier >= 0) {
            ai.statExchange.baseMeleeDamage = ai.statExchange.strength * ai.attackMultiplier;
            ai.statExchange.baseRangedDamage = ai.statExchange.intellect * ai.attackMultiplier;
            //Debug.Log ("Assigning baseattack");
        }
        else
            Debug.LogError ("Strength/Intellect and attack multiplier must be intialized before applying AssignModifiers.");

        if (ai.statExchange.strength >= 0 && ai.statExchange.intellect >= 0) {
            ai.statExchange.baseDefense = ai.statExchange.strength / 2 + ai.statExchange.intellect / 2;
            //Debug.Log ("Assigning basedefense");
        }
        else
            Debug.LogError ("Strength and intellect must be intialized before applying AssignModifiers.");

        if (ai.manaMultiplier >= 0) {
            ai.statExchange.initialMana = ai.statExchange.intellect * ai.manaMultiplier;
            ai.statExchange.mana = ai.statExchange.initialMana;
            //Debug.Log("Assigning mana");
        }
        else
            Debug.LogError ("intellect and mana multiplier must be intialized before applying AssignModifiers.");
    }