示例#1
0
            public override void OnEnter(RuntimeStateNode lastNode)
            {
                base.OnEnter(lastNode);
                var readyActions = Graph.Entity.Get <ReadyActions>();

                if (readyActions == null)
                {
                    return;
                }
                var actionConfig = readyActions.QueuedChange;
                var targetIndex  = readyActions.QueuedSlot;

                if (actionConfig == null || readyActions.GetAction(targetIndex) == actionConfig)
                {
                    readyActions.RemoveAction(targetIndex);
                    actionConfig = null;
                }
                else
                {
                    readyActions.EquipAction(actionConfig, targetIndex);
                }
                if (targetIndex == 0)
                {
                    Graph.SetVariable(GraphVariables.Equipment, actionConfig != null ? actionConfig.Config.EquipVariable : "");
                    Graph.SetVariable(GraphVariables.WeaponModel, actionConfig != null ? actionConfig.Config.WeaponModel : "");
                }
                readyActions.QueuedChange = null;
            }
示例#2
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     if (!_originalNode.Loop)
     {
         Graph.Entity.Post(new AnimationEventTriggered(Graph.Entity, _originalNode.EventName));
     }
 }
示例#3
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     if (_component == null)
     {
         _component = Graph.Entity.Get <WeaponBobComponent>();
     }
 }
 public virtual void OnEnter(RuntimeStateNode previous)
 {
     if (!string.IsNullOrEmpty(Node.EnterEvent))
     {
         Graph.Entity.Post(new AnimationEventTriggered(Graph.Entity, Node.EnterEvent));
     }
     LastEnter   = previous;
     TimeEntered = TimeManager.Time;
 }
示例#5
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     if (_poseAnimator == null)
     {
         _poseAnimator = Graph.Entity.Get <PoseAnimatorComponent>();
     }
     Setup();
 }
示例#6
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     _component = Graph.Entity.Get <FpPivotComponent>();
     if (_component != null)
     {
         _origin = _component.Tr.localPosition;
     }
     _time = 0;
 }
示例#7
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     if (!_setup)
     {
         _animNode.Animation.LoadAsset(FinishSetup);
     }
     else
     {
         SetupAnimation();
     }
 }
示例#8
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     if (!_setup)
     {
         _spriteNode.Sprite.LoadAsset(FinishSetup);
     }
     else
     {
         SetSprite();
     }
 }
示例#9
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     if (!_setup)
     {
         var op = _spriteNode.Sprite.LoadAssetAsync <SpriteAnimation>();
         op.Completed += FinishSetup;
     }
     else
     {
         SetSprite();
     }
 }
示例#10
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     Graph.SetVariable(GraphVariables.Reloading, true);
     _ammo = Graph.Entity.Get <CurrentAction>().Value?.Ammo;
     if (_ammo == null)
     {
         return;
     }
     UIChargeCircle.ManualStart(_ammo.Config.ReloadText);
     _reloadPerAmmo = _ammo.ReloadSpeed / _ammo.Amount.MaxValue;
     _totalAmmo     = _ammo.Amount.MaxValue - _ammo.Amount.Value;
     _current       = 0;
     _reloadTimer   = 0;
 }
示例#11
0
        protected virtual void SetCurrentNode(RuntimeStateNode node)
        {
            var last = Current;

            if (last != null)
            {
                last.OnExit();
            }
            Current = node;
            if (Current == null)
            {
                GraphCompleted();
                return;
            }
            Current.OnEnter(last);
        }
示例#12
0
        public override bool IsTrue(RuntimeStateNode node)
        {
            switch (Original.Comparison)
            {
            case ComparisonType.Equals:
            case ComparisonType.GreaterThan:
            case ComparisonType.EqualsOrGreaterThan:
            case ComparisonType.EqualsOrLessThan:
                return(Math.Abs(node.Graph.GetVariable <float>(Original.VariableName) - Value) < 0.001f);

            case ComparisonType.LessThan:
            case ComparisonType.NotEqualTo:
                return(Math.Abs(node.Graph.GetVariable <float>(Original.VariableName) - Value) > 0.001f);
            }
            return(false);
        }
示例#13
0
        public override bool IsTrue(RuntimeStateNode node)
        {
            switch (Original.Comparison)
            {
            case ComparisonType.Equals:
            case ComparisonType.GreaterThan:
            case ComparisonType.EqualsOrGreaterThan:
            case ComparisonType.EqualsOrLessThan:
                return(node.Graph.GetVariable <bool>(Original.VariableName) == Value);

            case ComparisonType.LessThan:
            case ComparisonType.NotEqualTo:
                return(node.Graph.GetVariable <bool>(Original.VariableName) != Value);
            }
            return(false);
        }
示例#14
0
        public override bool IsTrue(RuntimeStateNode node)
        {
            switch (Original.Comparison)
            {
            case ComparisonType.Equals:
            case ComparisonType.GreaterThan:
            case ComparisonType.EqualsOrGreaterThan:
            case ComparisonType.EqualsOrLessThan:
                return(node.Graph.Entity.Tags.Contain(Value));

            case ComparisonType.LessThan:
            case ComparisonType.NotEqualTo:
                return(!node.Graph.Entity.Tags.Contain(Value));
            }
            return(false);
        }
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     // if (readyActions == null) {
     //     return;
     // }
     // var actionConfig = readyActions.QueuedChange;
     // var targetIndex = readyActions.QueuedSlot;
     // if (actionConfig == null || readyActions.GetAction(targetIndex) == actionConfig) {
     //     readyActions.RemoveAction(targetIndex);
     //     actionConfig = null;
     // }
     // else {
     //     readyActions.EquipAction(actionConfig, targetIndex);
     // }
     // if (targetIndex == 0) {
     //     Graph.SetVariable(GraphVariables.Equipment, actionConfig != null ? actionConfig.Config.AnimationTrigger : "");
     //     Graph.SetVariable(GraphVariables.WeaponModel, actionConfig != null ? actionConfig.Config.WeaponModel : "");
     // }
     // readyActions.QueuedChange = null;
 }
            public override void OnEnter(RuntimeStateNode lastNode)
            {
                base.OnEnter(lastNode);
                var variable = Graph.GetVariable <string>(_originalNode.VariableName);

                _currentIndex = _originalNode.DefaultIndex;
                for (int i = 0; i < _originalNode.Values.Count; i++)
                {
                    if (variable == _originalNode.Values[i])
                    {
                        _currentIndex = i;
                        break;
                    }
                }
                _completed = false;
                if (ExternalGraph == null)
                {
                    return;
                }
                ExternalGraph.Start();
            }
示例#17
0
            public override void OnEnter(RuntimeStateNode lastNode)
            {
                base.OnEnter(lastNode);
                var action = Graph.Entity.Get <CurrentAction>()?.Value;

                if (action == null)
                {
                    return;
                }
                _actionEntity = action.Entity;
                _owner        = Graph.Entity.GetTemplate <ActionUsingTemplate>();
                _config       = _actionEntity.Get <BlockDamageAction>();
                var model = ItemPool.Spawn(UnityDirs.Models, _config.ModelData, Vector3.zero, Quaternion.identity);

                if (model != null)
                {
                    var spawnPivot = _actionEntity.Get <SpawnPivotComponent>();
                    spawnPivot.SetNewChild(model.Transform);
                    _actionEntity.Add(new RenderingComponent(model.GetComponent <IRenderingComponent>()));
                    _actionEntity.Add(new TransformComponent(model.transform));
                }
                if (!Graph.Entity.Tags.Contain(EntityTags.Player))
                {
                    Graph.Entity.Add(new BlockDamageFlat());
                    _isWaiting = true;
                    _vitalStat = null;
                    return;
                }
                _vitalStat = _owner.Stats.GetVital(_config.TargetVital);
                var skillMulti = 1f;

                if (!string.IsNullOrEmpty(_config.Skill))
                {
                    var skillValue = _owner.Entity.FindStatValue(_config.Skill);
                    skillMulti = Mathf.Clamp(1 - (skillValue * CostVital.SkillPercent), CostVital.SkillMaxReduction, 1);
                }
                Graph.Entity.GetOrAdd <RuleEventListenerComponent>().Handlers.Add(this);
                _fxComponent = action.Fx?.Value;
                _finalCost   = _config.Cost * skillMulti;
            }
示例#18
0
        public override bool IsTrue(RuntimeStateNode node)
        {
            bool isAttacking = false;

            if (node.Graph.GetVariable <bool>(GraphVariables.Attacking))
            {
                isAttacking = true;
                var action = node.Graph.Entity.Get <CurrentAction>().Value;
                if (action == null)
                {
                    isAttacking = false;
                }
                else
                {
                    var actionEntity = action.Entity;
                    for (int i = 0; i < action.Config.Costs.Count; i++)
                    {
                        if (!action.Config.Costs[i].CanAct(node.Graph.Entity, actionEntity))
                        {
                            isAttacking = false;
                            break;
                        }
                    }
                }
            }
            switch (Original.Comparison)
            {
            case ComparisonType.Equals:
            case ComparisonType.GreaterThan:
            case ComparisonType.EqualsOrGreaterThan:
            case ComparisonType.EqualsOrLessThan:
                return(isAttacking == Value);

            case ComparisonType.LessThan:
            case ComparisonType.NotEqualTo:
                return(isAttacking != Value);
            }
            return(isAttacking);
        }
示例#19
0
        public override bool IsTrue(RuntimeStateNode node)
        {
            switch (Original.Comparison)
            {
            case ComparisonType.Equals:
            case ComparisonType.GreaterThan:
            case ComparisonType.EqualsOrGreaterThan:
            case ComparisonType.EqualsOrLessThan:
                if (node.Graph.IsGlobalTriggerActive(Original.Value))
                {
                    return(true);
                }
                break;

            case ComparisonType.LessThan:
            case ComparisonType.NotEqualTo:
                if (!node.Graph.IsGlobalTriggerActive(Original.Value))
                {
                    return(true);
                }
                break;
            }
            return(false);
        }
示例#20
0
 public abstract bool IsTrue(RuntimeStateNode node);
示例#21
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     _sequence.Play();
 }
示例#22
0
 public RuntimeNode(DummyStateNode node, RuntimeStateGraph graph) : base(node, graph)
 {
     _exitNode = GetOriginalNodeExit();
     _timer    = new UnscaledTimer(node._timer);
 }
示例#23
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     _completed = false;
     ExternalGraph.Start();
 }
示例#24
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     Graph.GraphCompleted();
 }
示例#25
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     _input = Graph.Entity.Get <PlayerInputComponent>();
 }
示例#26
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
 }
示例#27
0
 public void ChangeNode(RuntimeStateNode node)
 {
     SetCurrentNode(node);
 }