public SerializableObject(bool tisCanon, LOOK ttheLook, int posX, int posY, bool tisRightFirst = false) { isCanon = tisCanon; theLook = ttheLook; isRightFirst = tisRightFirst; positionX = posX; positionY = posY; }
public SerializableEnemy(int tstartX, int tstartY, List<EnemyAction> tea, LOOK tdefaultLook, bool tisHelicopter) { startX = tstartX; startY = tstartY; ea = tea; defaultLook = tdefaultLook; isHelicopter = tisHelicopter; }
public SerializableEnemy(int tstartX, int tstartY, List <EnemyAction> tea, LOOK tdefaultLook, bool tisHelicopter) { startX = tstartX; startY = tstartY; ea = tea; defaultLook = tdefaultLook; isHelicopter = tisHelicopter; }
public void init(LOOK defaultLook, Vector2 tstartPosition, bool editorMode = true, bool tisHelicopter = false) { moveList = new List <EnemyAction>(); startPosition = tstartPosition; nextPosition = startPosition; defaultLookAt = defaultLook; turnEnemy(defaultLookAt, true); isHelicopter = tisHelicopter; }
public void loadEnemy(SerializableEnemy se, bool inEditorLoad = true) { startPosition.x = se.startX; startPosition.y = se.startY; nextPosition = startPosition; if (inEditorLoad) { moveList = new List <EnemyAction>(); } else { moveList = se.ea; } defaultLookAt = se.defaultLook; isHelicopter = se.isHelicopter; turnEnemy(defaultLookAt, true); }
bool turnEnemy(LOOK theLook, bool instant = false) { switch (theLook) { case LOOK.DOWN: transform.eulerAngles = Vector3.SmoothDamp(new Vector3(0f, transform.eulerAngles.y % 360, 0f), new Vector3(0f, transform.eulerAngles.y % 360 >= 350f ? 450f : 90f, 0f), ref velocity, instant ? 0f : 0.2f); return(transform.eulerAngles.y % 360 == 90f); case LOOK.UP: transform.eulerAngles = Vector3.SmoothDamp(new Vector3(0f, transform.eulerAngles.y % 360, 0f), new Vector3(0f, transform.eulerAngles.y % 360 >= 179f ? 270f : -90f, 0f), ref velocity, instant ? 0f : 0.2f); return(transform.eulerAngles.y % 360 == 270f); case LOOK.RIGHT: transform.eulerAngles = Vector3.SmoothDamp(new Vector3(0f, transform.eulerAngles.y % 360, 0f), new Vector3(0f, transform.eulerAngles.y % 360 >= 179f ? 360f : 0f, 0f), ref velocity, instant ? 0f : 0.2f); return(transform.eulerAngles.y % 360 == 0f); case LOOK.LEFT: transform.eulerAngles = Vector3.SmoothDamp(new Vector3(0f, transform.eulerAngles.y % 360, 0f), new Vector3(0f, 180f, 0f), ref velocity, instant ? 0f : 0.2f); return(transform.eulerAngles.y % 360 == 180f); } return(false); }
public void startAction() { timeForAction = 0f; isWaiting = false; switch (moveList[stateIndex].state) { case MOVE.LEFT: isWaiting = false; transform.position = convertToVector3(nextPosition); nextPosition.x++; actualLook = LOOK.LEFT; break; case MOVE.RIGHT: isWaiting = false; transform.position = convertToVector3(nextPosition); nextPosition.x--; actualLook = LOOK.RIGHT; break; case MOVE.UP: isWaiting = false; transform.position = convertToVector3(nextPosition); nextPosition.y++; actualLook = LOOK.UP; break; case MOVE.DOWN: isWaiting = false; transform.position = convertToVector3(nextPosition); nextPosition.y--; actualLook = LOOK.DOWN; break; case MOVE.WAIT: isWaiting = true; break; case MOVE.LOOKLEFT: isWaiting = true; actualLook = LOOK.LEFT; break; case MOVE.LOOKRIGHT: isWaiting = true; actualLook = LOOK.RIGHT; break; case MOVE.LOOKUP: isWaiting = true; actualLook = LOOK.UP; break; case MOVE.LOOKDOWN: isWaiting = true; actualLook = LOOK.DOWN; break; default: isWaiting = true; break; } rotationRefreshed = false; oldDistance = Vector3.Distance(transform.position, convertToVector3(nextPosition)); }
public void setLook(LOOK l) { startLOOK = l; }
public void loadEnemy(SerializableEnemy se, bool inEditorLoad = true) { startPosition.x = se.startX; startPosition.y = se.startY; nextPosition = startPosition; if(inEditorLoad) { moveList = new List<EnemyAction>(); } else{ moveList = se.ea; } defaultLookAt = se.defaultLook; isHelicopter = se.isHelicopter; turnEnemy(defaultLookAt, true); }
public void goOnSpawnHelico() { //Desactivation du curseur if(placementCube.activeSelf) { placementCube.SetActive(false); }else if(deleteCube.activeSelf) { deleteCube.SetActive(false); } if(previousBlocSelected != null) { previousBlocSelected.renderer.enabled = appearCubeCondition(); previousBlocSelected = null; } oldWidthSelected = -1; oldHeightSelected = -1; enemyLook = LOOK.RIGHT; actualMode = EDITMODE.HELICO; rayCastCollider.transform.position = new Vector3(39f, 6f, 39f); actualSizeSelected = 3; actualLevel.setDisplayThisLevel(true, maxWidth, maxHeight, actualSizeSelected); if(isInHidingMode) { actualLevel.setDisplayUpperBlocs(false, maxWidth, maxHeight, maxVolume, actualSizeSelected); } oldWidthSelected = -1; oldHeightSelected = -1; }
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; } oldWidthSelected = -1; oldHeightSelected = -1; } if(Input.GetKeyDown(KeyCode.Escape)) { quitSpawnEnemy(); } UpdateCamera(); }
void UpdateCanon() { 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 canonCursor.transform.position = new Vector3(actualHeightSelected, 2f, actualWidthSelected); //Activation des curseur var blocStateStage = actualLevel.getBlocState(gridWidthSelected, gridHeightSelected, actualSizeSelected); var blocStateGround = actualLevel.getBlocState(gridWidthSelected, gridHeightSelected, actualSizeSelected-1); if(blocStateStage == BLOCSTATE.EMPTY && blocStateGround == BLOCSTATE.CUBE) { canonCursorValid.SetActive(true); canonCursorInvalid.SetActive(false); }else{ canonCursorInvalid.SetActive(true); canonCursorValid.SetActive(false); } } }else{ canonCursorInvalid.SetActive(false); canonCursorValid.SetActive(false); } if(Input.GetMouseButton(0)) { if(canonCursorValid.activeSelf){ var go = (GameObject)Instantiate(canonModel, new Vector3(actualHeightSelected, actualSizeSelected*2 + 0.2f, actualWidthSelected), canonCursorValid.transform.rotation); actualLevel.setCanon(gridWidthSelected, gridHeightSelected, go); go.SetActive(true); go.GetComponent<Canon>().setLook((LOOK)enemyLook); canonCursorValid.SetActive(false); actualMode = EDITMODE.CUBE; oldWidthSelected = -1; oldHeightSelected = -1; } }else if(Input.GetMouseButtonDown(1) && canonCursorValid.activeSelf){ enemyLook++; if((int) enemyLook >= 4) { enemyLook = (LOOK) 0; } switch(enemyLook) { case LOOK.DOWN: canonCursorValid.transform.eulerAngles = new Vector3(0f, 0f, 0f); canonCursorInvalid.transform.eulerAngles = new Vector3(0f, 0f, 0f); break; case LOOK.UP: canonCursorValid.transform.eulerAngles = new Vector3(0f, 180f, 0f); canonCursorInvalid.transform.eulerAngles = new Vector3(0f, 180f, 0f); break; case LOOK.RIGHT: canonCursorValid.transform.eulerAngles = new Vector3(0f, -90f, 0f); canonCursorInvalid.transform.eulerAngles = new Vector3(0f, -90f, 0f); break; case LOOK.LEFT: canonCursorValid.transform.eulerAngles = new Vector3(0f, 90f, 0f); canonCursorInvalid.transform.eulerAngles = new Vector3(0f, 90f, 0f); break; } oldWidthSelected = -1; oldHeightSelected = -1; } UpdateCamera(); }
bool turnEnemy(LOOK theLook, bool instant = false) { switch(theLook) { case LOOK.DOWN: transform.eulerAngles = Vector3.SmoothDamp(new Vector3(0f, transform.eulerAngles.y%360, 0f), new Vector3(0f, transform.eulerAngles.y%360 >= 350f ? 450f : 90f, 0f), ref velocity, instant ? 0f : 0.2f); return transform.eulerAngles.y%360 == 90f; case LOOK.UP: transform.eulerAngles = Vector3.SmoothDamp(new Vector3(0f, transform.eulerAngles.y%360, 0f), new Vector3(0f, transform.eulerAngles.y%360 >= 179f ? 270f : -90f, 0f), ref velocity, instant ? 0f : 0.2f); return transform.eulerAngles.y%360 == 270f; case LOOK.RIGHT: transform.eulerAngles = Vector3.SmoothDamp(new Vector3(0f, transform.eulerAngles.y%360, 0f), new Vector3(0f, transform.eulerAngles.y%360 >= 179f ? 360f : 0f, 0f), ref velocity, instant ? 0f : 0.2f); return transform.eulerAngles.y%360 == 0f; case LOOK.LEFT: transform.eulerAngles = Vector3.SmoothDamp(new Vector3(0f, transform.eulerAngles.y%360, 0f), new Vector3(0f, 180f, 0f), ref velocity, instant ? 0f : 0.2f); return transform.eulerAngles.y%360 == 180f; } return false; }
public void startAction() { timeForAction = 0f; isWaiting = false; switch(moveList[stateIndex].state) { case MOVE.LEFT: isWaiting = false; transform.position = convertToVector3(nextPosition); nextPosition.x++; actualLook = LOOK.LEFT; break; case MOVE.RIGHT: isWaiting = false; transform.position = convertToVector3(nextPosition); nextPosition.x--; actualLook = LOOK.RIGHT; break; case MOVE.UP: isWaiting = false; transform.position = convertToVector3(nextPosition); nextPosition.y++; actualLook = LOOK.UP; break; case MOVE.DOWN: isWaiting = false; transform.position = convertToVector3(nextPosition); nextPosition.y--; actualLook = LOOK.DOWN; break; case MOVE.WAIT: isWaiting = true; break; case MOVE.LOOKLEFT: isWaiting = true; actualLook = LOOK.LEFT; break; case MOVE.LOOKRIGHT: isWaiting = true; actualLook = LOOK.RIGHT; break; case MOVE.LOOKUP: isWaiting = true; actualLook = LOOK.UP; break; case MOVE.LOOKDOWN: isWaiting = true; actualLook = LOOK.DOWN; break; default: isWaiting = true; break; } rotationRefreshed = false; oldDistance = Vector3.Distance(transform.position, convertToVector3(nextPosition)); }
public void init(LOOK defaultLook, Vector2 tstartPosition, bool editorMode = true, bool tisHelicopter = false) { moveList = new List<EnemyAction>(); startPosition = tstartPosition; nextPosition = startPosition; defaultLookAt = defaultLook; turnEnemy(defaultLookAt, true); isHelicopter = tisHelicopter; }