void ResetEndedInput() { int removedCount = 0; List <GeneralMOInput> tmpInputs = new List <GeneralMOInput>(generalMOInputs); foreach (GeneralMOInput gmoi in generalMOInputs) { //first check whether any input is ended if (gmoi.phase == IPhase.Ended) { //if input is ended remove it from list tmpInputs.Remove(gmoi); //Since list has changed decrease index of remaining general input`s removedCount++; } else //if input is not ended decrease inputs index by removedCount { GeneralMOInput indexChangedInput = tmpInputs.Find(x => x.index == gmoi.index);// -= removedCount; indexChangedInput.index -= removedCount; tmpInputs[gmoi.index - 1] = indexChangedInput; } } generalMOInputs = tmpInputs; /*if (generalMOInputs.Count > 0 && generalMOInputs[0].phase == IPhase.Ended) * { * generalMOInputs.RemoveAt(0); * }*/ }
public bool SetInputs() { ResetEndedInput(); if (MOExtendedInputs.isInputEntered() && generalMOInputs.Count == 0) // for now works with only one input { GeneralMOInput tmpGi = new GeneralMOInput(); tmpGi.phase = IPhase.Began; tmpGi.startPosition = MOExtendedInputs.GetPoint(); tmpGi.currentPosition = tmpGi.startPosition; tmpGi.lastFramePosition = tmpGi.startPosition; tmpGi.delta = Vector2.zero; tmpGi.index = generalMOInputs.Count + 1; generalMOInputs.Add(tmpGi); return(true); } else if (MOExtendedInputs.isInput()) { GeneralMOInput tmpGi = generalMOInputs[0]; tmpGi.lastFramePosition = tmpGi.currentPosition; // Before changing current position update last frame poisition tmpGi.currentPosition = MOExtendedInputs.GetPoint(); tmpGi.delta = tmpGi.currentPosition - tmpGi.lastFramePosition; if (tmpGi.delta.magnitude < 0.2f && tmpGi.delta.magnitude > -0.2f) { tmpGi.phase = IPhase.Stationary; } else { tmpGi.phase = IPhase.Moved; } generalMOInputs[0] = tmpGi; return(true); } else if (generalMOInputs.Count > 0)// && isinput değilse { GeneralMOInput tmpGi = generalMOInputs[0]; tmpGi.phase = IPhase.Ended; tmpGi.lastFramePosition = tmpGi.currentPosition; // Before changing current position update last frame poisition tmpGi.currentPosition = MOExtendedInputs.GetPoint(); tmpGi.delta = tmpGi.currentPosition - tmpGi.lastFramePosition; generalMOInputs[tmpGi.index - 1] = tmpGi; return(true); } return(false); }