本文整理汇总了C#中Enemy.getLastPosition方法的典型用法代码示例。如果您正苦于以下问题:C# Enemy.getLastPosition方法的具体用法?C# Enemy.getLastPosition怎么用?C# Enemy.getLastPosition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Enemy
的用法示例。
在下文中一共展示了Enemy.getLastPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: loadLevel
public void loadLevel()
{
Stream stream = File.Open(Application.dataPath + "/Levels/" + panelUILoad.transform.FindChild("LabelFile").GetComponent<UILabel>().text, FileMode.Open);
BinaryFormatter bformatter = new BinaryFormatter();
bformatter.Binder = new VersionDeserializationBinder();
Level l = (Level)bformatter.Deserialize(stream);
stream.Close();
//purge
actualLevel.purge(maxWidth, maxHeight, maxVolume);
for(int i=0; i<listUIEnemy.Count; i++)
{
for(int j=0; j<listUIEnemy.ElementAt(i).Value.Count; j++)
{
Destroy(listUIEnemy.ElementAt(i).Value.ElementAt(j));
}
}
listUIEnemy.Clear();
//load
actualLevel.loadLevel(l);
//Recreate the world
var theLevelState = actualLevel.getEntireBlocState();
for(int i=0; i<maxWidth; i++)
{
for(int j=0; j<maxHeight; j++)
{
for(int h=0; h<maxVolume; h++)
{
if(theLevelState[i,j,h] == BLOCSTATE.CUBE)
{
var go = (GameObject)Instantiate(h == 0 ? cubeBase : cubeBloc, new Vector3(j*2, h*2, i*2), cubeBase.transform.rotation);
actualLevel.setCube(i, j, h, go);
go.SetActive(true);
}
if(theLevelState[i,j,h] == BLOCSTATE.SPECIAL)
{
var go = (GameObject)Instantiate(special, new Vector3(j*2, h*2, i*2), special.transform.rotation);
actualLevel.setSpecial(i, j, h, go);
go.SetActive(true);
}
}
}
}
actualLevel.setStartPlayerPosition((int)l.getPlayerSpawn().x, (int)l.getPlayerSpawn().y);
actualLevel.setFinishPlayerPosition((int)l.getPlayerFinish().x, (int)l.getPlayerFinish().y);
playerSpawnValid.SetActive(true);
playerSpawn.transform.position = new Vector3(l.getPlayerSpawn().y*2f, 2f, l.getPlayerSpawn().x*2f);
playerFinishValid.SetActive(true);
playerFinish.transform.position = new Vector3(l.getPlayerFinish().y*2f, 2f, l.getPlayerFinish().x*2f);
//Recréation de la liste d'ennemy
listUIEnemy = new Dictionary<Enemy, List<GameObject>>();
for(int i=0; i<l.getEnemies().Count; i++)
{
var enemy = l.getEnemies().ElementAt(i);
var go = (GameObject)Instantiate(enemy.isHelicopter ? enemyHelicoModel : enemyModel, new Vector3(enemy.startY*2, enemy.isHelicopter ? 6f : 2f, enemy.startX*2), enemyModel.transform.rotation);
if(enemy.isHelicopter){
actualLevel.setStartEnemyPosition(enemy.startX, enemy.startY, go);
}else{
actualLevel.setStartEnemyHelicoPosition(enemy.startX, enemy.startY, go);
}
go.SetActive(true);
go.transform.GetComponent<Enemy>().loadEnemy(enemy);
listUIEnemy.Add(go.transform.GetComponent<Enemy>(), new List<GameObject>());
actualEnemyEdit = go.transform.GetComponent<Enemy>();
for(int j=0; j<enemy.ea.Count; j++)
{
bool isDeplacement = ((int)actualEnemyEdit.getLastAction() <= 3);
actualEnemyEdit.addAction(enemy.ea.ElementAt(j).state, enemy.ea.ElementAt(j).timeWait);
if((int)enemy.ea.ElementAt(j).state <= 3)
{
actualNumberAction = actualEnemyEdit.getNumberOfAction();
placeUIWay(enemy.ea.ElementAt(j).state, actualEnemyEdit.isHelico());
}else{
if(isDeplacement)
{
placeUIAction(actualEnemyEdit.getLastPosition(), actualEnemyEdit.isHelico());
}
}
listUIEnemy[actualEnemyEdit].Last().SetActive(false);
}
}
for(int i=0; i<l.getObjects().Count; i++)
{
var theObj = l.getObjects().ElementAt(i);
if(theObj.isCanon)
{
var go = (GameObject)Instantiate(canonModel, new Vector3(theObj.positionY*2f, 2.2f, theObj.positionX*2f), canonModel.transform.rotation);
actualLevel.setCanon((int)theObj.positionX, (int)theObj.positionY, go);
go.SetActive(true);
go.GetComponent<Canon>().setLook((LOOK)theObj.theLook);
switch(theObj.theLook)
{
case LOOK.DOWN:
go.transform.eulerAngles = new Vector3(0f, 0f, 0f);
break;
//.........这里部分代码省略.........
示例2: UpdateHelico
void UpdateHelico()
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray, out hit)){
//Detection de la position curseur
UpdatePositionMouse(hit);
//Verification de la nouvelle position
if(actualWidthSelected != oldWidthSelected || actualHeightSelected != oldHeightSelected)
{
oldWidthSelected = actualWidthSelected;
oldHeightSelected = actualHeightSelected;
gridWidthSelected = (int)actualWidthSelected/2;
gridHeightSelected = (int)actualHeightSelected/2;
//Actualisation
enemyHelicoCursor.transform.position = new Vector3(actualHeightSelected, 6f, actualWidthSelected);
//Activation des curseur
var blocStateStage = actualLevel.getBlocState(gridWidthSelected, gridHeightSelected, actualSizeSelected);
if((blocStateStage == BLOCSTATE.EMPTY || blocStateStage == BLOCSTATE.HELICOSTART))
{
if(blocStateStage == BLOCSTATE.HELICOSTART)
{
enemyHelicoHover.SetActive(true);
enemyHelicoValid.SetActive(false);
}else{
enemyHelicoHover.SetActive(false);
enemyHelicoValid.SetActive(true);
}
enemyHelicoInvalid.SetActive(false);
}else{
enemyHelicoInvalid.SetActive(true);
enemyHelicoValid.SetActive(false);
enemyHelicoHover.SetActive(false);
}
}
}else{
enemyHelicoInvalid.SetActive(false);
enemyHelicoValid.SetActive(false);
}
if(Input.GetMouseButton(0))
{
if(enemyHelicoValid.activeSelf){
var go = (GameObject)Instantiate(enemyHelicoModel, new Vector3(actualHeightSelected, actualSizeSelected*2, actualWidthSelected), enemyHelicoModel.transform.rotation);
actualLevel.setStartEnemyHelicoPosition(gridWidthSelected, gridHeightSelected, go);
go.SetActive(true);
go.transform.GetComponent<Enemy>().init (enemyLook, new Vector2((float)gridWidthSelected, (float)gridHeightSelected), true, true);
listUIEnemy.Add(go.transform.GetComponent<Enemy>(), new List<GameObject>());
enemyHelicoValid.SetActive(false);
actualMode = EDITMODE.CUBE;
oldWidthSelected = -1;
oldHeightSelected = -1;
}else if(enemyHelicoHover.activeSelf)
{
enemyHelicoHover.SetActive(false);
actualEnemyEdit = actualLevel.getGameObjectAt(gridWidthSelected, gridHeightSelected, 3).transform.GetComponent<Enemy>();
lastEnemyEditPosition = actualEnemyEdit.getLastPosition();
refreshPossiblePositionActionHelico();
panelUIEdit.SetActive(true);
actualMode = EDITMODE.EDITHELICO;
enableEnemyWay(actualEnemyEdit);
oldWidthSelected = -1;
oldHeightSelected = -1;
}
}else if(Input.GetMouseButtonDown(1) && enemyHelicoValid.activeSelf){
enemyLook++;
if((int) enemyLook >= 4)
{
enemyLook = (LOOK) 0;
}
switch(enemyLook)
{
case LOOK.DOWN:
enemyHelicoValid.transform.eulerAngles = new Vector3(0f, 90f, 0f);
enemyHelicoInvalid.transform.eulerAngles = new Vector3(0f, 90f, 0f);
enemyHelicoHover.transform.eulerAngles = new Vector3(0f, 90f, 0f);
break;
case LOOK.UP:
enemyHelicoValid.transform.eulerAngles = new Vector3(0f, -90f, 0f);
enemyHelicoInvalid.transform.eulerAngles = new Vector3(0f, -90f, 0f);
enemyHelicoHover.transform.eulerAngles = new Vector3(0f, -90f, 0f);
break;
case LOOK.RIGHT:
enemyHelicoValid.transform.eulerAngles = new Vector3(0f, 0f, 0f);
enemyHelicoInvalid.transform.eulerAngles = new Vector3(0f, 0f, 0f);
enemyHelicoHover.transform.eulerAngles = new Vector3(0f, 0f, 0f);
break;
case LOOK.LEFT:
enemyHelicoValid.transform.eulerAngles = new Vector3(0f, 180f, 0f);
enemyHelicoInvalid.transform.eulerAngles = new Vector3(0f, 180f, 0f);
enemyHelicoHover.transform.eulerAngles = new Vector3(0f, 180f, 0f);
break;
//.........这里部分代码省略.........