Пример #1
0
        public override bool Init()
        {
            CharacterConfig characterConfig = new CharacterConfig();

            characterConfig.characterID        = 1;
            characterConfig.characterName      = "虞姬";
            characterConfig.resName            = "yuji";
            characterConfig.runSpeed           = 10f;
            characterConfig.attackContinueTime = 0.5f;

            CharacterActionConfig actionConfig = new CharacterActionConfig();

            actionConfig.actionType = CharacterAction.IDLE;
            actionConfig.canRotate  = false;
            actionConfig.frameCount = 32;
            actionConfig.nextActions.Clear();
            characterConfig.actionConfig[actionConfig.actionType] = actionConfig;

            actionConfig            = new CharacterActionConfig();
            actionConfig.actionType = CharacterAction.RUN;
            actionConfig.canRotate  = true;
            actionConfig.frameCount = 18;
            actionConfig.nextActions.Clear();
            characterConfig.actionConfig[actionConfig.actionType] = actionConfig;

            actionConfig            = new CharacterActionConfig();
            actionConfig.actionType = CharacterAction.ATTACK1;
            actionConfig.canRotate  = false;
            actionConfig.frameCount = 24;
            actionConfig.nextActions.Clear();
            actionConfig.nextActions.Add(CharacterAction.ATTACK2);
            characterConfig.actionConfig[actionConfig.actionType] = actionConfig;

            actionConfig            = new CharacterActionConfig();
            actionConfig.actionType = CharacterAction.ATTACK2;
            actionConfig.canRotate  = false;
            actionConfig.frameCount = 26;
            actionConfig.nextActions.Clear();
            actionConfig.nextActions.Add(CharacterAction.ATTACK3);
            characterConfig.actionConfig[actionConfig.actionType] = actionConfig;

            actionConfig            = new CharacterActionConfig();
            actionConfig.actionType = CharacterAction.ATTACK3;
            actionConfig.canRotate  = false;
            actionConfig.frameCount = 30;
            actionConfig.nextActions.Clear();
            characterConfig.actionConfig[actionConfig.actionType] = actionConfig;

            _characterConfigs[characterConfig.characterID] = characterConfig;
            return(true);
        }
Пример #2
0
        public void ChangeView(string location, CharacterConfig config)
        {
            if (MainGameObject != null)
            {
                Object.DestroyImmediate(MainGameObject);
                MainGameObject = null;
            }

            Object o = Resources.Load("Prefabs/Role/" + location);

            MainGameObject = Object.Instantiate(o) as GameObject;
            if (MainGameObject != null)
            {
                MainGameObject.SetActive(true);
                _animator     = MainGameObject.GetComponent <Animator>();
                MainTransform = MainGameObject.GetComponent <Transform>();
            }
        }
 public void ChangeCharacter(uint roleID)
 {
     if (ThisConfig == null || ThisConfig.characterID != roleID)
     {
         CharacterConfig config = CharacterConfigManager.Instance.GetCharacterConfig(roleID);
         if (config != null)
         {
             ThisView.ChangeView(config.resName, config);
             ThisConfig = config;
         }
         else
         {
             return;
         }
     }
     ThisActionUnit.ChangeAction(CharacterAction.IDLE, true);
     Init();
 }