Пример #1
0
    public BattleRefreshVo(string brId)
    {
        this.br_id = brId;
        SysBattleRefreshVo dataById = BaseDataMgr.instance.GetDataById <SysBattleRefreshVo>(brId);

        if (dataById == null)
        {
            Debug.LogError("brVo is null error id:" + brId + " 请检查配置表BattleRefresh");
            return;
        }
        if (dataById.trigger_condition != "[]")
        {
            string[] stringValue = StringUtils.GetStringValue(dataById.trigger_condition, '|');
            this.trigerCdn = (GameEvent)((stringValue == null) ? 0 : int.Parse(stringValue[0]));
            this.SetTrigerCondition(stringValue);
        }
        this.delayTime  = dataById.delay_time;
        this.refreshWay = (BattleRefreshWay)dataById.refresh_way;
        if (dataById.locationid != "[]")
        {
            this.posIndex = StringUtils.GetStringToInt(dataById.locationid, ',');
        }
        if (dataById.monster_mainid != "[]")
        {
            string[] stringValue2 = StringUtils.GetStringValue(dataById.monster_mainid, '|');
            this.npcID       = stringValue2[0];
            this.SpawnerType = int.Parse(stringValue2[1]);
            this.teamType    = (TeamType)int.Parse(stringValue2[2]);
            this.npcAI       = (CharacterAIType)int.Parse(stringValue2[3]);
        }
        this.refreshNumber = dataById.refresh_number;
        this.cycleNumber   = dataById.cycle_number;
        this.cycleInterval = dataById.cycle_interval;
    }
Пример #2
0
    IEnumerator SetCharacterCo()
    {
        if (CharacterControlType == CharacterControlType.None)
        {
            OnCharacterSet.Invoke();
            yield break;
        }

        CameraTarget           cameraTarget    = GetComponent <CameraTarget>();
        List <ICharacterBrain> characterBrains = new List <ICharacterBrain>(GetComponentsInChildren <ICharacterBrain>());

        //Clear Character Brains
        foreach (var item in characterBrains)
        {
            item.Dispose();
        }

        yield return(new WaitForEndOfFrame());

        List <ICharacterController> characterControllers = new List <ICharacterController>(GetComponentsInChildren <ICharacterController>());

        //Clear Character Controllers
        foreach (var item in characterControllers)
        {
            item.Dispose();
        }

        yield return(new WaitForEndOfFrame());

        //Add character controller type
        var controllerType = ControllerPhysics.GetBehevior();
        var type           = gameObject.AddComponent(controllerType);

        type.GetComponent <ICharacterController>().Initialize();

        yield return(new WaitForEndOfFrame());

        switch (CharacterControlType)
        {
        case CharacterControlType.Player:
            //Add player bain
            var brain = gameObject.AddComponent <PlayerBrain>();
            brain.GetComponent <ICharacterBrain>().Initialize();

            //Add camera target to make this object trackable by camera
            if (!cameraTarget)
            {
                gameObject.AddComponent <CameraTarget>();
            }
            break;

        case CharacterControlType.AI:
            //Remove camera target
            if (cameraTarget)
            {
                Utilities.DestroyExtended(cameraTarget);
            }

            //Add AI brain based on the type in character data
            var aiType  = CharacterAIType.GetBehevior();
            var aiBrain = gameObject.AddComponent(aiType);
            aiBrain.GetComponent <ICharacterBrain>().Initialize();
            break;
        }
        OnCharacterSet.Invoke();
    }
 public static System.Type GetBehevior(this CharacterAIType characterAIType)
 {
     return(CharacterAIDictionary[characterAIType]);
 }