Exemplo n.º 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;
            }
Exemplo n.º 2
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     if (!_originalNode.Loop)
     {
         Graph.Entity.Post(new AnimationEventTriggered(Graph.Entity, _originalNode.EventName));
     }
 }
Exemplo n.º 3
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     if (_component == null)
     {
         _component = Graph.Entity.Get <WeaponBobComponent>();
     }
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     if (_poseAnimator == null)
     {
         _poseAnimator = Graph.Entity.Get <PoseAnimatorComponent>();
     }
     Setup();
 }
Exemplo n.º 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;
 }
Exemplo n.º 7
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     if (!_setup)
     {
         _animNode.Animation.LoadAsset(FinishSetup);
     }
     else
     {
         SetupAnimation();
     }
 }
Exemplo n.º 8
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     if (!_setup)
     {
         _spriteNode.Sprite.LoadAsset(FinishSetup);
     }
     else
     {
         SetSprite();
     }
 }
Exemplo n.º 9
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     if (!_setup)
     {
         var op = _spriteNode.Sprite.LoadAssetAsync <SpriteAnimation>();
         op.Completed += FinishSetup;
     }
     else
     {
         SetSprite();
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 15
0
 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;
 }
Exemplo n.º 16
0
            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();
            }
Exemplo n.º 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;
            }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 20
0
 public abstract bool IsTrue(RuntimeStateNode node);
Exemplo n.º 21
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     _sequence.Play();
 }
Exemplo n.º 22
0
 public RuntimeNode(DummyStateNode node, RuntimeStateGraph graph) : base(node, graph)
 {
     _exitNode = GetOriginalNodeExit();
     _timer    = new UnscaledTimer(node._timer);
 }
Exemplo n.º 23
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     _completed = false;
     ExternalGraph.Start();
 }
Exemplo n.º 24
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     Graph.GraphCompleted();
 }
Exemplo n.º 25
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
     _input = Graph.Entity.Get <PlayerInputComponent>();
 }
Exemplo n.º 26
0
 public override void OnEnter(RuntimeStateNode lastNode)
 {
     base.OnEnter(lastNode);
 }
Exemplo n.º 27
0
 public void ChangeNode(RuntimeStateNode node)
 {
     SetCurrentNode(node);
 }