C# 代码效率,分阶段
好吧,我正在重温我制作的一个从未完成过的原型游戏,当原型游戏出现时,你并不总能想出最好的主意哈哈。这对我来说很难解释,但基本上屏幕上有可以“吃掉”的游戏对象,然后我用新的点值和纹理使其基本上重新生成 当游戏对象在纹理与屏幕上的嘴相交时被“吃掉”,则调用下一阶段的方法 隐藏扰流板 代码:C# 代码效率,分阶段,c#,.net,windows-phone-7,phase,C#,.net,Windows Phone 7,Phase,好吧,我正在重温我制作的一个从未完成过的原型游戏,当原型游戏出现时,你并不总能想出最好的主意哈哈。这对我来说很难解释,但基本上屏幕上有可以“吃掉”的游戏对象,然后我用新的点值和纹理使其基本上重新生成 当游戏对象在纹理与屏幕上的嘴相交时被“吃掉”,则调用下一阶段的方法 隐藏扰流板 代码: void下一阶段(内部食品) { 开关(foodNumber) { //检测吃了什么食物 案例1: { food1Phase++; 打破 } 案例2: { 第二阶段++ 打破 } 案例3: { food3Phas
void下一阶段(内部食品)
{
开关(foodNumber)
{
//检测吃了什么食物
案例1:
{
food1Phase++;
打破
}
案例2:
{
第二阶段++
打破
}
案例3:
{
food3Phase++;
打破
}
//
}
开关(foodNumber)
{
案例1:
{
开关(相位)
{
//每个阶段都是一组新的纹理、点值和特定的繁殖延迟。
//乘数法告诉我们另一种方法
//吃了什么食物并决定是否增加分数倍增
//位置属性将其重置为屏幕外的位置,然后在屏幕上飞行
//供玩家收集
//delayCompleted false激活另一个开始计时繁殖的方法
//耽搁
案例1:
{
多层存储(“Gay Bacon”);
food1Position.X=-200;
food1Position.Y=60;
food1=contentManager.Load(“Food2Img”);
food1Height=food1.Bounds.Height+20;
food1Width=food1.Bounds.Width+30;
food1Speed.X=0;
food1Speed.Y=0;
delayCompleted=false;
如果(游戏总计时器<30.0)
{
所需时间=游戏总体计时器+4.0;
}
打破
}
案例2:
{
food1=contentManager.Load(“Food6”);
food1Height=food1.Bounds.Height+20;
food1Width=food1.Bounds.Width+30;
food1Position.X=-100;
food1Position.Y=60;
food1Speed.X=0;
food1Speed.Y=0;
多层存储(“培根”);
打破
}
案例3:
{
food1=contentManager.Load(“Food1Img”);
food1Height=food1.Bounds.Height+20;
food1Width=food1.Bounds.Width+30;
food1Position.X=-100;
food1Position.Y=60;
food1Speed.X=0;
food1Speed.Y=0;
vegetableEatenMultiplier();
生命=生命-1;
UpdateLives();
第1阶段=0;
打破
}
}
}
}
案例2:
{
开关(第二阶段)
{
food2=contentManager.Load(“Food4”);
food2Height=food2.Bounds.Height+30;
food2Width=food2.Bounds.Width+30;
food2Position.X=850;
food2位置Y=200;
food2Speed.X=0;
food2Speed.Y=0;
多层存储(“培根”);
打破
}
案例2:
{
food2=contentManager.Load(“Food5”);
food2Height=food2.Bounds.Height+30;
food2Width=food2.Bounds.Width+30;
food2Position.X=850;
food2位置Y=200;
food2Speed.X=0;
food2Speed.Y=0;
vegetableEatenMultiplier();
生命=生命-1;
UpdateLives();
打破
}
案例3:
{
food2=contentManager.Load(“Food2Img”);
food2Height=food2.Bounds.Height+30;
food2Width=food2.Bounds.Width+30;
food2Position.X=850;
food2位置Y=200;
food2Speed.X=0;
food2Speed.Y=0;
第二阶段=0;
多层存储(“牛排”);
打破
}
}
}
案例3:
{
开关(第三阶段)
{
food3位置X=600;
food3Position.Y=-100;
food3Speed.X=0;
food3Speed.Y=0;
第三阶段=0;
多层存储(“Gay Bacon”);
打破
}
}
}
}
}
问题是这对我来说似乎不是很有效,现在是的,我已经想到了创造
void NextPhase(int food)
{
switch (foodNumber)
{
//Detects what food object has been eaten
case 1:
{
food1Phase++;
break;
}
case 2:
{
food2Phase++
break;
}
case 3:
{
food3Phase++;
break;
}
//
}
switch (foodNumber)
{
case 1:
{
switch (food1Phase)
{
//Each phase is a new set of Textures, Points Values and specific spawn delay.
//Multiplier sotrage tells another method
//what food has been eaten and decides whether to increase the score mulitplier
//the position properties reset it to a location off screen and then it flies on screen
//for the player to collect
//delayCompleted false activates another method that starts timing the spawn
//delay
case 1:
{
multiplierStorage("Gay Bacon");
food1Position.X = -200;
food1Position.Y = 60;
food1 = contentManager.Load<Texture2D>("Food2Img");
food1Height = food1.Bounds.Height + 20;
food1Width = food1.Bounds.Width + 30;
food1Speed.X = 0;
food1Speed.Y = 0;
delayCompleted = false;
if (gameOverallTimer < 30.0)
{
timeWanted = gameOverallTimer + 4.0;
}
break;
}
case 2:
{
food1 = contentManager.Load<Texture2D>("Food6");
food1Height = food1.Bounds.Height + 20;
food1Width = food1.Bounds.Width + 30;
food1Position.X = -100;
food1Position.Y = 60;
food1Speed.X = 0;
food1Speed.Y = 0;
multiplierStorage("Bacon");
break;
}
case 3:
{
food1 = contentManager.Load<Texture2D>("Food1Img");
food1Height = food1.Bounds.Height + 20;
food1Width = food1.Bounds.Width + 30;
food1Position.X = -100;
food1Position.Y = 60;
food1Speed.X = 0;
food1Speed.Y = 0;
vegetableEatenMultiplier();
lives = lives - 1;
UpdateLives();
food1Phase = 0;
break;
}
}
}
}
case 2:
{
switch (food2Phase)
{
food2 = contentManager.Load<Texture2D>("Food4");
food2Height = food2.Bounds.Height + 30;
food2Width = food2.Bounds.Width + 30;
food2Position.X = 850;
food2Position.Y = 200;
food2Speed.X = 0;
food2Speed.Y = 0;
multiplierStorage("Bacon");
break;
}
case 2:
{
food2 = contentManager.Load<Texture2D>("Food5");
food2Height = food2.Bounds.Height + 30;
food2Width = food2.Bounds.Width + 30;
food2Position.X = 850;
food2Position.Y = 200;
food2Speed.X = 0;
food2Speed.Y = 0;
vegetableEatenMultiplier();
lives = lives - 1;
UpdateLives();
break;
}
case 3:
{
food2 = contentManager.Load<Texture2D>("Food2Img");
food2Height = food2.Bounds.Height + 30;
food2Width = food2.Bounds.Width + 30;
food2Position.X = 850;
food2Position.Y = 200;
food2Speed.X = 0;
food2Speed.Y = 0;
food2Phase = 0;
multiplierStorage("Steak");
break;
}
}
}
case 3:
{
switch (food3Phase)
{
food3Position.X = 600;
food3Position.Y = -100;
food3Speed.X = 0;
food3Speed.Y = 0;
food3Phase = 0;
multiplierStorage("Gay Bacon");
break;
}
}
}
}
}
switch (foodNumber)
{
case 1:
switch (food1Phase)
{
case 1:
switch (foodNumber << 8 | food1Phase)
{
case (1 << 8 | 1):