Ejemplo n.º 1
0
		public void ApplyCharacterAction(
			ICharacterAction characterAction,
			InputActionParameterSet parameterSet)
		{
			parameterSet.SetParameter("character", this.Character);
			characterAction.ApplyAction(parameterSet);
		}
Ejemplo n.º 2
0
    public ICharacterAction DequeueAction(ActionTree parent)
    {
        ICharacterAction rv;

        if (leftNode != null)
        {
            rv = leftNode.DequeueAction(this);
        }
        else
        {
            rv = root;
            if (parent != null)
            {
                // There should now be nothing to my left.  Remove myself from the equation,
                // and make my parent look to my right from now on.
                parent.leftNode = rightNode;
            }
            else if (rightNode != null)
            {
                // Replace self with minimum action of the right node, removing it in the process.
                root = rightNode.DequeueAction(null);
            }
            else
            {
                root = null; // IS THIS CORRECT?
            }
        }

        return(rv);
    }
Ejemplo n.º 3
0
        public InfluencedInteraction(
            int limiter,
            IEnumerable <Trait> strongTraitInfluences,
            IEnumerable <State> strongStateInfluences,
            ICharacterAction action
            ) : this(limiter) {
            foreach (Trait trait in strongTraitInfluences)
            {
                if (trait == null)
                {
                    continue;
                }
                this.strongTraitInfluences[trait.type] = trait;
            }

            foreach (State state in strongStateInfluences)
            {
                if (state == null)
                {
                    continue;
                }
                this.strongStateInfluences[state.name] = state;
            }

            actionID = action.ID;
        }
 public PlayerWeaponStateAdapter(PlayerEntity playerEntity, ICharacterAction action, ICharacterPosture characterPosture, UiContext uiContext)
 {
     _playerEntity     = playerEntity;
     _action           = action;
     _characterPosture = characterPosture;
     _uiContext        = uiContext;
 }
 void OnPlayerClickedEnemy(IEvent e)
 {
     if (e is PlayerSelectedActionTargetEvent clk)
     {
         if (clk.Target == character)
         {
             awaitedAction          = clk.Action;
             spriteRenderer.enabled = true;
         }
     }
     else if (e is CombatActionEvent act)
     {
         if (act.Target == character && act.Action == awaitedAction)
         {
             spriteRenderer.enabled = false;
             awaitedAction          = null;
         }
     }
     else if (e is CharacterActionCancelledEvent cancelledEvent)
     {
         if (cancelledEvent.Action == awaitedAction)
         {
             spriteRenderer.enabled = false;
             awaitedAction          = null;
         }
     }
 }
Ejemplo n.º 6
0
		public GameInputMap CreateMapping(string name, ICharacterAction characterAction)
		{
			name = name.ToLower();

			// Intentionally not checking if the key already exists; we want the exception to rise.
			this.mappings.Add(name, characterAction);
			return this;
		}
Ejemplo n.º 7
0
		public bool CanApplyCharacterAction(
			ICharacterAction characterAction,
			InputActionParameterSet parameterSet)
		{
			// Make sure to clone the parameterset so we don't destroy/alter it.
			// (Probably doesn't matter? but feels like good practice).
			var clonedSet = parameterSet.Clone().SetParameter("character", this.Character);
			return characterAction.CanApplyAction(clonedSet);
		}
Ejemplo n.º 8
0
 public void SetupChangeWeaponAnimation(ICharacterAction action)
 {
     if (null == action)
     {
         return;
     }
     WeaponAnimation.MountWeapon                    = action.Select;
     WeaponAnimation.UnMountWeapon                  = action.Holster;
     WeaponAnimation.ChangeWeapon                   = action.SwitchWeapon;
     WeaponAnimation.InterruptPlayerAnimation       = action.InterruptAction;
     WeaponAnimation.InterruptChangeWeaponAnimation = action.InterruptSwitchWeapon;
 }
Ejemplo n.º 9
0
        /* Actions */

        public bool PerformAction(string id, ICollection <IEntity> targets)
        {
            ICharacterAction action = BrainRepo.GetAction(id);

            if (action == null)
            {
                return(false);
            }

            action.Perform(GetActionInfo(targets));
            return(true);
        }
Ejemplo n.º 10
0
    public void UpdatePlay(float playback_time)
    {
        if (gameObject.activeInHierarchy == false)
        {
            return;
        }

        try
        {
            PlaybackTime = playback_time;

            if (m_PlayingActions.Count > 0)
            {
                for (int i = 0; i < m_PlayingActions.Count;)
                {
                    ICharacterAction action = m_PlayingActions[i];
                    if ((BattleBase.Instance == null || BattleBase.Instance.IsPause != ePauseType.Pause || action.IsPause == false) && action.Update(PlaybackTime) == false)
                    {
                        m_PlayingActions.RemoveAt(i);
                        if (action == MainAction)
                        {
                            MainAction = null;
                        }
                    }
                    else
                    {
                        ++i;
                    }
                }
            }

            if (m_AnimationAdoptor != null && IsUpdateAnimation)
            {
                m_AnimationAdoptor.Update(PlaybackTime, m_FreezeCount > 0);
            }
            Tween.UpdatePlay(PlaybackTime);

            UpdateParticles();
            if (Application.isPlaying == true && m_DefaultEffect != null && m_PlayingDefaultEffect == null)
            {
                m_PlayingDefaultEffect = PlayParticle(m_DefaultEffect);
            }
            else if (m_PlayingDefaultEffect != null && m_PlayingDefaultEffect.IsPlaying == true && m_PlayingDefaultEffect.IsFinish == false && CharacterAnimation.IsDeadEnd)
            {
                m_PlayingDefaultEffect.Finish();
            }
        }
        catch (System.Exception ex)
        {
            throw new System.Exception(string.Format("[{0}] {1}", gameObject.name, ex.Message), ex);
        }
    }
Ejemplo n.º 11
0
    public void EnqueueAction(ICharacterAction a)
    {
        a.SetStartingTick(currentTick);

        if (initiativeTracker == null)
        {
            initiativeTracker = new ActionTree(a);
        }
        else
        {
            initiativeTracker.EnqueueAction(a);
        }


        //PerformNextAction ();
    }
Ejemplo n.º 12
0
        private void Awake()
        {
            character = GetComponent <ICharacterAction>();

            if (PickUpArea)
            {
                if (AreaTrigger == null)
                {
                    AreaTrigger = PickUpArea.GetComponent <TriggerProxy>();
                    if (AreaTrigger == null)
                    {
                        AreaTrigger = PickUpArea.gameObject.AddComponent <TriggerProxy>();
                    }
                }
            }
            else
            {
                Debug.LogWarning("Please set a Pick up Area");
            }
        }
Ejemplo n.º 13
0
    public void EnqueueAction(ICharacterAction action)
    {
        // This case should only happen IF all other actions
        // have been dequeued.
        if (root == null)
        {
            root = action;
            return;
        }

        // NOTE: The = means that for actions completing on the same tick,
        // actions enqueued later wil complete first.  This makes sense because
        // those actions would logically be faster, so making them complete first
        // is consistent.

        if (action.GetCompletionTick() <= root.GetCompletionTick())
        {
            if (leftNode == null)
            {
                leftNode = new ActionTree(action);
            }
            else
            {
                leftNode.EnqueueAction(action);
            }
        }
        else
        {
            if (rightNode == null)
            {
                rightNode = new ActionTree(action);
            }
            else
            {
                rightNode.EnqueueAction(action);
            }
        }
    }
Ejemplo n.º 14
0
 private void PerformNextAction()
 {
     if (initiativeTracker == null)
     {
         return;
     }
     else
     {
         waiting = false;
         ICharacterAction a = initiativeTracker.DequeueAction(null);
         if (a != null)
         {
             a.DoAction();
             currentTick = a.GetCompletionTick();
             if (!(a is PauseAction))
             {
                 Debug.Log("Action" + a.GetType() + " completed at tick " + currentTick);
             }
         }
         waiting = true;
         EnqueueAction(a.GetInitiatingAI().GetNextAction());
     }
 }
Ejemplo n.º 15
0
 public CharacterActionCancelledEvent(ICharacter character, ICharacterAction action) : base(character)
 {
     this.action = action;
 }
Ejemplo n.º 16
0
 public void NormalAttack(INormalAttack normalAttack)
 {
     _characterAction = new Attack(normalAttack);
     _characterAction.Execute(_characterTo);
 }
 public PlayerSelectedActionTargetEvent(ICharacter user, ICharacter target, ICharacterAction action)
 {
     this.user   = user;
     this.action = action;
     this.target = target;
 }
Ejemplo n.º 18
0
 public void SpecialAttack(ISpecialPower specialPower)
 {
     _characterAction = new SpecialAttack(specialPower);
     _characterAction.Execute(_characterTo);
 }
Ejemplo n.º 19
0
 public void RegisterAction(ICharacterAction a)
 {
     actions[a.ID] = a;
 }
Ejemplo n.º 20
0
 public void AddAction(ICharacterAction action)
 {
     m_PlayingActions.Add(action);
 }
Ejemplo n.º 21
0
 public CombatActionEvent(ICombatReader combat, ICharacter target, ICharacter actionDoer, ICharacterAction action) : base(combat)
 {
     this.target     = target;
     this.actionDoer = actionDoer;
     this.action     = action;
 }
Ejemplo n.º 22
0
 public ActionTree(ICharacterAction action)
 {
     root      = action;
     leftNode  = null;
     rightNode = null;
 }