コード例 #1
0
    public void update(float dt)
    {
        if (_CurrentPhase != null)
        {
            if (_CurrentPhase.IsStart == false)
            {
                _CurrentPhase.Starter?.Invoke();
                _CurrentPhase.IsStart = true;
            }
            if (_CurrentPhase.Updator != null)
            {
                var state = _CurrentPhase.Updator.Invoke(dt);
                switch (state)
                {
                case PhaseState.Continue:
                    break;

                case PhaseState.Next:
                    _CurrentPhase.IsStart = false;
                    _PrevPhase            = _CurrentPhase;
                    _CurrentPhase         = _NextPhase;
                    _NextPhase            = getNextPhase(_CurrentPhase);
                    break;

                case PhaseState.Back:
                    _CurrentPhase.IsStart = false;
                    var temp = _PrevPhase;
                    _PrevPhase    = _CurrentPhase;
                    _CurrentPhase = temp;
                    _NextPhase    = getNextPhase(_CurrentPhase);
                    break;
                }
            }
        }
    }
コード例 #2
0
 public PhaseController()
 {
     _PhaseList    = new List <PhaseItem>();
     _PrevPhase    = null;
     _CurrentPhase = null;
     _NextPhase    = null;
 }
コード例 #3
0
 // Start is called before the first frame update
 void Start()
 {
     ball = visibleBall.GetComponent <Rigidbody>();
     gameObject.AddComponent <singleJump>();
     jumpItem = gameObject.GetComponent <singleJump>();
     gameObject.AddComponent <speedUpItem>();
     speedItem = gameObject.GetComponent <speedUpItem>();
     gameObject.AddComponent <PhaseItem>();
     phaseItem = gameObject.GetComponent <PhaseItem>();
     gameObject.AddComponent <TimeSlowItem>();
     slowItem = gameObject.GetComponent <TimeSlowItem>();
 }
コード例 #4
0
 public void startPhase()
 {
     if (_PhaseList == null)
     {
         return;
     }
     if (_PhaseList.Count < 1)
     {
         return;
     }
     _PrevPhase    = null;
     _CurrentPhase = _PhaseList[0];
     _NextPhase    = getNextPhase(_CurrentPhase);
 }
コード例 #5
0
    public void setNextPhase(PhaseUpdator phase)
    {
        if (_PhaseList == null)
        {
            return;
        }
        int phaseId = _PhaseList.FindIndex((p) => p.Updator == phase);

        if (phaseId < 0)
        {
            return;
        }
        if (phaseId >= _PhaseList.Count)
        {
            return;
        }
        _NextPhase = _PhaseList[phaseId];
    }
コード例 #6
0
    private PhaseItem getNextPhase(PhaseItem cur)
    {
        if (_PhaseList == null)
        {
            return(null);
        }
        int currentId = _PhaseList.IndexOf(cur);

        if (currentId < 0)
        {
            return(null);
        }
        ++currentId;
        if (currentId >= _PhaseList.Count)
        {
            return(null);
        }
        return(_PhaseList[currentId]);
    }
コード例 #7
0
        private void phaseItemListSynchronization(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                PhaseItem addedPhaseItem = (PhaseItem)e.NewItems[0];
                if (addedPhaseItem != null)
                {
                    PhaseItemsViewModelList.Add(new PhaseItemViewModel(addedPhaseItem));
                }
                break;

            case NotifyCollectionChangedAction.Remove:
                PhaseItem removedPhaseItem = (PhaseItem)e.OldItems[0];
                if (removedPhaseItem != null)
                {
                    PhaseItemsViewModelList.RemoveAll(p => p.PhaseItem == removedPhaseItem);
                }
                break;
            }
        }
コード例 #8
0
 public PhaseItemViewModel(PhaseItem phaseItem)
 {
     _phaseItem = phaseItem;
     _phaseItem.NoOfRebarsChanged += _phaseItem_NoOfRebarsChanged;
     _phaseItem.SelectedChanged   += _phaseItem_SelectedChanged;
 }