Exemplo n.º 1
0
    public AbilityActionStatus Perform(CharacterProperty target)
    {
        mTarget = target;

        mOwner.ReduceMP(mCost);

        if (CoodDownLeft <= 0)
        {
            mLastTime = Time.time;

            for (int i = 0; i < mActions.Count; i++)
            {
                mActions [i].Init();
            }

            currentIndex = 0;


            for (currentIndex = 0; currentIndex < mActions.Count; currentIndex++)
            {
                AbilityAction action = mActions [currentIndex];
                action.SetTarget(mTarget);
                action.Execute();
                AbilityActionStatus status = action.status;
                if (status != AbilityActionStatus.Success)
                {
                    return(status);
                }
            }
        }

        return(AbilityActionStatus.Success);
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        mAnimator            = GetComponent <Animator> ();
        mCharacterProperty   = GetComponent <CharacterProperty> ();
        mTargetingController = GetComponent <TargetingController>();

        mSkills          = new Dictionary <int, Ability> ();
        mActivatedSkills = new Queue <Ability> ();

        InitSkills();

        mAttackColliderDisposable = new SingleAssignmentDisposable();
        mActionController         = GetComponent <AnimatorController>();

        mActionController.OnHitStartAsObservable.Subscribe(info =>
        {
            if (info.ability == -1 || mCastingAbility == null)
            {
                return;
            }

            AbilityActionStatus status = mCastingAbility.Perform(mTarget);
            if (status == AbilityActionStatus.Running)
            {
                mActivatedSkills.Enqueue(mCastingAbility);
            }
        });

        mActionController.OnHitEndAsObservable.Subscribe(info =>
        {
            mCastingAbility = null;
            mTarget         = null;
        });
    }
Exemplo n.º 3
0
 protected void EndAction(AbilityActionStatus value)
 {
     status = value;
     if (status == AbilityActionStatus.Success)
     {
         mActionSubject.OnNext(mAbilityId);
         mActionSubject.OnCompleted();
     }
 }
Exemplo n.º 4
0
 // Update is called once per frame
 void Update()
 {
     if (mActivatedSkills.Count > 0)
     {
         Ability             skill  = mActivatedSkills.Peek();
         AbilityActionStatus status = skill.Update();
         if (status == AbilityActionStatus.Running)
         {
             return;
         }
         else if (status == AbilityActionStatus.Success)
         {
             mActivatedSkills.Dequeue();
         }
         else
         {
             mActivatedSkills.Clear();
         }
     }
 }
Exemplo n.º 5
0
    public AbilityActionStatus Update()
    {
        if (currentIndex < mActions.Count)
        {
            for (; currentIndex < mActions.Count; currentIndex++)
            {
                AbilityAction action = mActions [currentIndex];
                action.SetTarget(mTarget);
                action.Execute();
                AbilityActionStatus status = action.status;
                if (status != AbilityActionStatus.Success)
                {
                    return(status);
                }
            }
        }

        if (onExit != null)
        {
            onExit.OnNext(this);
        }

        return(AbilityActionStatus.Success);
    }
Exemplo n.º 6
0
 protected virtual void Update()
 {
     status = AbilityActionStatus.Success;
 }
Exemplo n.º 7
0
 protected virtual void Start()
 {
     status = AbilityActionStatus.Success;
 }
Exemplo n.º 8
0
 public void Init()
 {
     status = AbilityActionStatus.Resting;
 }