Example #1
0
 public static AiDataParser Me()
 {
     if (It == null)
     {
         It = new AiDataParser();
     }
     return(It);
 }
Example #2
0
        /**添加控制脚本**/
        override protected void AddScript(GameObject go) // go 为 Box2d刚体对象 如400_2014
        {
            if (go.GetComponent <ActionControler>() != null)
            {
                return;
            }
            Controller             = go.AddComponent <ActionControler>();
            Controller.Me          = this;
            Controller.Me.Animator = Controller.Me.GoCloth.GetComponent <Animator>();
            //改变怪物的速度
            (Controller as ActionControler).ChangeSpeed((GetVo() as MonsterVo).MonsterVO.speed / GameConst.PIXEL_TO_UNITY);
            //增加状态控制脚本
            var statuController = go.AddComponent <MonsterStatuController>();

            statuController.MeControler = Controller as ActionControler;
            Controller.StatuController  = statuController;

            //增加技能控制脚本
            SkillController skillController = Controller.SkillController = go.AddComponent <SkillController>();

            skillController.MeController = Controller as ActionControler;

            Controller.AnimationEventController = GoCloth.GetComponent <AnimationEventController>() ?? GoCloth.AddComponent <AnimationEventController>();
            Controller.AnimationEventController.skillController = Controller.SkillController;

            //增加抓投控制脚本;
            var projectileController = GoCloth.GetComponent <GraspThrowController>() ?? GoCloth.AddComponent <GraspThrowController>();

            projectileController.MeController = Controller as ActionControler;
            Controller.GraspThrowController   = projectileController;
            Controller.AnimationEventController.GraspThrowController = Controller.GraspThrowController;

            //增加动画参数控制脚本
            Controller.AnimationParameter = GoCloth.GetComponent <AnimationParameter>() ?? GoCloth.AddComponent <AnimationParameter>();

            //增加移动控制脚本
            var monsterMoveController = go.AddComponent <MonsterMoveController>();

            monsterMoveController.AnimationEventController = Controller.AnimationEventController;
            monsterMoveController.MeController             = Controller as ActionControler;
            Controller.MoveController = monsterMoveController;
            monsterMoveController.AnimationParameter = Controller.AnimationParameter;

            //增加攻击控制脚本
            var attackController = go.AddComponent <MonsterAttackController>();

            attackController.MeController = Controller as ActionControler;
            Controller.AttackController   = attackController;

            //增加受击控制脚本
            var beAttackedController = go.AddComponent <MonsterBeAttackedController>();

            beAttackedController.meController = Controller as ActionControler;
            Controller.BeAttackedController   = beAttackedController;

            //增加死亡控制脚本
            var deathController = go.AddComponent <MonsterDeathController>();

            deathController.MeController = Controller as ActionControler;

            //增加AI控制脚本
            string aiList = (GetVo() as MonsterVo).MonsterVO.ai_list;

            //var aiController = go.AddComponent<MonsterAiController>();
            //aiController.MeController = Controller as ActionControler;
            //Controller.AiController = aiController;



            if (aiList == "850002")
            {
                listAiDataCtr = AiDataParser.Me().Parser(aiList);
            }

            /*// 将要做
             * _aiData = new AiData();
             * listAiDataCtr = new List<AiData>();
             *
             * SysMonsterAiVo monsterAiVo = BaseDataMgr.instance.GetDataById<SysMonsterAiVo>(uint.Parse(aiList));
             * string strAiValue = monsterAiVo.AiValue; // 122=720000,100|218=1;104=5|200=930035
             *
             * _aiData.ID = int.Parse(aiList);
             * string[] strEachState = strAiValue.Split(';');
             * for (int i = 0; i < strEachState.Length; i++)
             * {
             * string[] strConditionState = strEachState[i].Split('|');
             *
             * // 122=720000,100
             * string[] strConditionValue = strConditionState[0].Split('=');
             * _aiData.conditionType = int.Parse(strConditionValue[0]);
             *
             * string []value = strConditionValue[1].Split(',');
             * for (int k = 0; k < value.Length; k++)
             * {
             *    _aiData.conditionParamList.Add(int.Parse(value[k]));
             * }
             *
             * // 218=1
             * string[] strActionValue = strConditionState[1].Split('=');
             * _aiData.actionType = int.Parse(strActionValue[0]);
             * value = strActionValue[1].Split(',');
             * for (int k = 0; k < value.Length; k++)
             *    _aiData.actionParamList.Add(int.Parse(value[k]));
             *
             * listAiDataCtr.Add(_aiData); // 一个条件就一个 _aiData;
             * }
             */



            if (aiList != null && aiList.Contains("1"))
            {
                Controller.AiController = go.AddComponent <MonsterAiController_Far>(); // 添加远程脚本
                go.GetComponent <MonsterAiController_Far>().MeController = Controller as ActionControler;
                //Debug.Log("****添加新AI脚本MonsterAiController_Far");
            }
            else if (aiList != null && aiList.Contains("2"))
            {
                Controller.AiController = go.AddComponent <MonsterAiController_Far2>(); // 添加远程脚本
                go.GetComponent <MonsterAiController_Far2>().MeController = Controller as ActionControler;
                Debug.Log("****添加新AI脚本MonsterAiController_Far2");
            }
            else
            {
                Controller.AiController = go.AddComponent <MonsterAiController>();
                go.GetComponent <MonsterAiController>().MeController = Controller as ActionControler;
            }

            BoxCollider2D         = GoCloth.GetComponent <BoxCollider2D>();
            BoxCollider2D.enabled = false;
            SetStandClothGoPosition();

            GetMeVoByType <MonsterVo>().Controller = Controller as ActionControler;

            InitBoxColliderData();
        }