protected void ExecuteEvent(int currentTime) { for (int i = 0; i < currentEvent.Count; i++) { BarrageEvent be = currentEvent[i]; switch (be.eAttribute) { case Attribute.SPEED: if (be.startFrame == currentTime) { be.setOriginValue(speed); } speed = be.Update(speed, currentTime); break; case Attribute.SPEEDDIRECT: if (be.startFrame == currentTime) { be.setOriginValue(speedDirection); } speedDirection = be.Update(speedDirection, currentTime); break; default: break; } if (currentTime >= be.spendTime + be.startFrame) { currentEvent.RemoveAt(i); i--; } }//end for }
protected void ExecuteEvent(int currentTime) { for (int i = 0; i < currentEvent.Count; i++) { BarrageEvent be = currentEvent[i]; switch (be.eAttribute) { case Attribute.ACC: if (be.startFrame == currentTime) { be.setOriginValue(laserData.acceleration); } laserData.acceleration = be.Update(laserData.acceleration, currentTime); break; case Attribute.SPEED: if (be.startFrame == currentTime) { be.setOriginValue(laserData.speed); } laserData.speed = be.Update(laserData.speed, currentTime); break; case Attribute.SPEEDDIRECT: if (be.startFrame == currentTime) { be.setOriginValue(laserData.speedDirec); } laserData.speedDirec = be.Update(laserData.speedDirec, currentTime); break; case Attribute.WIDTH: if (be.startFrame == currentTime) { be.setOriginValue(laserData.width); } laserData.width = (int)be.Update((float)laserData.width, currentTime); break; case Attribute.SELFSNIPE: if (be.result == "开") { this.isSelfSnipe = true; } else { this.isSelfSnipe = false; } break; default: break; } if (currentTime >= be.spendTime + be.startFrame) { currentEvent.RemoveAt(i); i--; } }//end for }
public void setEvent(List <BarrageEvent> barrageEvent) { BarrageEvent newEvent; for (int i = 0; i < barrageEvent.Count; i++) { newEvent = new BarrageEvent(barrageEvent[i]); myEvent.Add(newEvent); } }
protected void ExecuteEvent(int currentTime) { for (int i = 0; i < currentEvent.Count; i++) { BarrageEvent be = currentEvent[i]; switch (be.eAttribute) { case Attribute.ACC: if (be.startFrame == currentTime) { be.setOriginValue(bulletData.acceleration); } bulletData.acceleration = be.Update(bulletData.acceleration, currentTime); if (be.isRandom) { randomEventAcc = (float)ran.NextDouble() * (be.randomEnd - be.randomStart) + be.randomStart; } break; case Attribute.SPEED: if (be.startFrame == currentTime) { be.setOriginValue(bulletData.speed); } bulletData.speed = be.Update(bulletData.speed, currentTime); if (be.isRandom) { randomEventSpeed = (float)ran.NextDouble() * (be.randomEnd - be.randomStart) + be.randomStart; } break; case Attribute.SPEEDDIRECT: if (be.startFrame == currentTime) { be.setOriginValue(bulletData.speedDirec); } bulletData.speedDirec = be.Update(bulletData.speedDirec, currentTime); if (be.isRandom) { randomEventSpeedDirec = (float)ran.NextDouble() * (be.randomEnd - be.randomStart) + be.randomStart; } break; case Attribute.FREQUENCY: if (be.startFrame == currentTime) { be.setOriginValue(this.frequency); } this.frequency = (int)be.Update(this.frequency, currentTime); break; case Attribute.RANDOMRADIUS: if (be.startFrame == currentTime) { be.setOriginValue(this.randomRadius); } this.randomRadius = (int)be.Update(this.randomRadius, currentTime); break; case Attribute.POSITION: this.BindSprite(target); this.relativePosition = Vector2.Zero; break; default: break; } if (currentTime >= be.spendTime + be.startFrame) { currentEvent.RemoveAt(i); i--; } } }
public List <BarrageEvent> ReadEvent(string eventStr) { myEvent = new List <BarrageEvent>(); string oneEvent; string tempString; BarrageEvent newEvent; while (eventStr.Length != 0) { oneEvent = ReadOneEvent(ref eventStr); if (oneEvent != null) { newEvent = new BarrageEvent(); SplitEvent(out tempString, ref oneEvent, '.', '.'); newEvent.startFrame = Convert.ToInt32(tempString); int index = oneEvent.IndexOf('+'); newEvent.rateType = RateType.CONST; if (index != -1) { if (oneEvent[index + 1] == '=') { newEvent.rateType = RateType.PLUS; } } index = oneEvent.IndexOf('-'); if (index != -1) { if (oneEvent[index + 1] == '=') { newEvent.rateType = RateType.MINUS; } } index = oneEvent.IndexOf('!'); if (index != -1) { int temp = index; newEvent.isRandom = true; index++; string num = ""; while (index < oneEvent.Length && oneEvent[index] != '~') { num += oneEvent[index]; index++; } newEvent.randomStart = (float)Convert.ToDouble(num); index++; num = ""; while (index < oneEvent.Length) { num += oneEvent[index]; index++; } newEvent.randomEnd = (float)Convert.ToDouble(num); oneEvent = oneEvent.Remove(temp); } while (oneEvent.Length != 0) { string attribute = ""; string result = ""; int ipos = 0; SplitEvent(out tempString, ref oneEvent, '[', ']'); for (ipos = 0; ipos < tempString.Length; ipos++) { if (tempString[ipos] == '+' || tempString[ipos] == '-') { ipos += 2; break; } else if (tempString[ipos] == '=') { ipos += 1; break; } attribute += tempString[ipos]; } result = tempString.Substring(ipos, tempString.Length - ipos); switch (attribute) { case "速度": newEvent.eAttribute = Attribute.SPEED; newEvent.result = result; newEvent.isContinuous = true; break; case "速度角": newEvent.eAttribute = Attribute.SPEEDDIRECT; newEvent.result = result; break; case "加速度": newEvent.eAttribute = Attribute.ACC; newEvent.result = result; newEvent.isContinuous = true; break; case "加速角": newEvent.eAttribute = Attribute.ACCDIRECT; newEvent.result = result; newEvent.isContinuous = true; break; case "方式": newEvent.eChangeType = StringToChangeType(result); break; case "耗时": newEvent.spendTime = Convert.ToInt32(result); break; case "朝向方式": //处理为两个子弹事件 newEvent.eAttribute = Attribute.DIRECTTYPE; newEvent.result = result; newEvent.isContinuous = false; break; case "朝向角度": myEvent.Add(newEvent); //将前面朝向方式事件加入列表 newEvent = new BarrageEvent(newEvent.startFrame, newEvent.eAttribute, newEvent.result, newEvent.eChangeType, newEvent.rateType, newEvent.spendTime); newEvent.eAttribute = Attribute.HEADANGLE; newEvent.result = result; newEvent.isContinuous = true; break; case "类型": newEvent.eAttribute = Attribute.ID; newEvent.result = result; newEvent.isContinuous = false; break; case "射角": newEvent.eAttribute = Attribute.SPEEDDIRECT; newEvent.result = result; break; case "频率": newEvent.eAttribute = Attribute.FREQUENCY; newEvent.result = result; break; case "随机半径": newEvent.eAttribute = Attribute.RANDOMRADIUS; newEvent.result = result; break; case "位置": newEvent.eAttribute = Attribute.POSITION; newEvent.result = result; break; case "宽度": newEvent.eAttribute = Attribute.WIDTH; newEvent.result = result; break; case "自机狙": newEvent.eAttribute = Attribute.SELFSNIPE; newEvent.result = result; break; default: newEvent.eAttribute = Attribute.DEFAULT; break; }//end switch } myEvent.Add(newEvent);//添加事件 } } myEvent.Sort();//按启动时间排序 return(myEvent); }
void ExecuteEvent(int currentTime) { for (int i = 0; i < currentEvent.Count; i++) { BarrageEvent be = currentEvent[i]; switch (be.eAttribute) { case Attribute.ID: setID(Convert.ToInt32(be.result)); break; case Attribute.DIRECTTYPE: this.directType = StringToDirectType(be.result); break; case Attribute.HEADANGLE: if (be.startFrame == currentTime) { be.setOriginValue(this.bulletHeadAngle); } this.bulletHeadAngle = be.Update(bulletHeadAngle, currentTime); break; case Attribute.ACC: if (be.startFrame == currentTime) { be.setOriginValue(this.acceleration); } this.acceleration = be.Update(acceleration, currentTime); break; case Attribute.ACCDIRECT: if (be.startFrame == currentTime) { be.setOriginValue(this.accelerationDegree); } this.accelerationDegree = be.Update(accelerationDegree, currentTime); break; case Attribute.SPEED: if (be.startFrame == currentTime) { be.setOriginValue(this.speed); } this.speed = be.Update(speed, currentTime); break; case Attribute.SPEEDDIRECT: if (be.startFrame == currentTime) { be.setOriginValue(getSpeedDirection()); } this.speedDirection = be.Update(getSpeedDirection(), currentTime); setSpeedDireciont(this.speedDirection); break; default: break; } if (currentTime >= be.spendTime + be.startFrame) { currentEvent.RemoveAt(i); --i; } } }