예제 #1
0
 public void Release()
 {
     TickerManager.Instance.RemoveFixedTick(this);
     TickerManager.Instance.RemoveTick(this);
     Init();
     _characterConfig = null;
     _action.Release();
     _view.Release();
 }
예제 #2
0
        public override bool Init()
        {
            var characterConfig = new CharacterConfig();

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

            var 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);
        }
예제 #3
0
        public void ChangeView(string location, CharacterConfig config)
        {
            if (_source != null)
            {
                Object.DestroyImmediate(_source);
                _source = null;
            }

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

            _source = Object.Instantiate(o) as GameObject;
            _source.SetActive(true);
            _animator  = _source.GetComponent <Animator>();
            _transform = _source.GetComponent <Transform>();
        }
예제 #4
0
 public void ChangeCharacter(UInt32 roleID)
 {
     if (_characterConfig == null || _characterConfig.characterID != roleID)
     {
         var config = CharacterConfigManager.Instance.GetCharacterConfig(roleID);
         if (config != null)
         {
             _view.ChangeView(config.resName, config);
             _characterConfig = config;
         }
         else
         {
             return;
         }
     }
     _action.ChangeAction(CharacterAction.IDLE, true);
     Init();
 }