public void interactWithCurrentCharacter ( HandleChoosenCharacter callBackOnChoosenCharacter, int actionType, IComponent iComponentOfObject ) { if ( _currentCharacter == null ) return; _currentActionType = actionType; _currentObjectIComponent = iComponentOfObject; _currentCharacter.myCallBack = callBackOnChoosenCharacter; bool mayDoAction = false; int[] returnedClossestTile = ToolsJerry.findClossestEmptyTileAroundThisTile ( _currentObjectIComponent.position[0], _currentObjectIComponent.position[1], _currentCharacter.position, _currentCharacter.myID, LevelControl.getInstance ().gameElementsOnLevel[LevelControl.GRID_LAYER_NORMAL][_currentCharacter.position[0]][_currentCharacter.position[1]], 1 ); if ( returnedClossestTile[0] != -1 ) { if ( _currentCharacter.characterValues[CharacterData.CHARACTER_ACTION_TYPE_POWER] > 0 ) { if ( _currentCharacter.characterValues[_currentActionType] > 0 ) { if ( ! _currentCharacter.blocked && ! _currentCharacter.interactAction ) { mayDoAction = true; chosenCharacterCallBack ( _currentCharacter ); } } } else { UIControl.getInstance ().createCharacterBox ( _currentCharacter.myID ); _currentCharacter.myCharacterButton.highlightEnergy (); } } if ( ! mayDoAction ) { MessageCenter.getInstance ().createMarkInPosition ( _currentObjectIComponent.position ); if ( _currentCharacter.myCallBack != null ) { _currentCharacter.myCallBack ( null, true ); } } }
public void handleChooseCharacter ( HandleChoosenCharacter callBackOnChoosenCharacter, int actionType, IComponent iComponentOfObject ) { _currentActionType = actionType; _currentObjectIComponent = iComponentOfObject; List < GameObject > setOfButtons = new List < GameObject > (); int numberOfSelectedCharacters = 0; bool foundOnlyOneCharacterSoAutomaticExecute = false; if ( actionType == CharacterData.CHARACTER_ACTION_TYPE_BUILD_RATE ) { for ( int i = 0; i < LevelControl.getInstance ().charactersOnLevel.Count; i++ ) { if ( LevelControl.getInstance ().charactersOnLevel[i].characterValues[CharacterData.CHARACTER_ACTION_TYPE_POWER] > 0 ) { if ( LevelControl.getInstance ().charactersOnLevel[i].characterValues[_currentActionType] > 0 ) { if ( ! LevelControl.getInstance ().charactersOnLevel[i].blocked ) { int[] currentPositionOfCharacter = ToolsJerry.cloneTile ( LevelControl.getInstance ().charactersOnLevel[i].position ); int[] foundTileAroundComponent = ToolsJerry.findClossestEmptyTileAroundThisTile ( _currentObjectIComponent.position[0], _currentObjectIComponent.position[1], LevelControl.getInstance ().charactersOnLevel[i].position, LevelControl.getInstance ().charactersOnLevel[i].myID, LevelControl.getInstance ().gameElementsOnLevel[LevelControl.GRID_LAYER_NORMAL][currentPositionOfCharacter[0]][currentPositionOfCharacter[1]], 1 ); if (( foundTileAroundComponent[0] != -1 ) || ( ToolsJerry.compareTiles ( _currentObjectIComponent.position, currentPositionOfCharacter ))) { numberOfSelectedCharacters++; } } } } } if ( numberOfSelectedCharacters == 1 ) { foundOnlyOneCharacterSoAutomaticExecute = true; } } numberOfSelectedCharacters = 0; for ( int i = 0; i < LevelControl.getInstance ().charactersOnLevel.Count; i++ ) { if ( LevelControl.getInstance ().charactersOnLevel[i].characterValues[CharacterData.CHARACTER_ACTION_TYPE_POWER] > 0 ) { if ( LevelControl.getInstance ().charactersOnLevel[i].characterValues[_currentActionType] > 0 ) { if ( ! LevelControl.getInstance ().charactersOnLevel[i].blocked ) { int[] currentPositionOfCharacter = ToolsJerry.cloneTile ( LevelControl.getInstance ().charactersOnLevel[i].position ); int[] foundTileAroundComponent = ToolsJerry.findClossestEmptyTileAroundThisTile ( _currentObjectIComponent.position[0], _currentObjectIComponent.position[1], currentPositionOfCharacter, LevelControl.getInstance ().charactersOnLevel[i].myID, LevelControl.getInstance ().gameElementsOnLevel[LevelControl.GRID_LAYER_NORMAL][currentPositionOfCharacter[0]][currentPositionOfCharacter[1]], 1 ); if (( foundTileAroundComponent[0] != -1 ) || ( ToolsJerry.compareTiles ( _currentObjectIComponent.position, currentPositionOfCharacter ))) { numberOfSelectedCharacters++; if ( foundOnlyOneCharacterSoAutomaticExecute ) { _currentCharacter = LevelControl.getInstance ().charactersOnLevel[i]; _currentCharacter.myCallBack = callBackOnChoosenCharacter; chosenCharacterCallBack ( _currentCharacter ); } else setOfButtons.Add ( UIControl.getInstance ().createButtonCharacter ( -2f + i * 2f, -3f, GlobalVariables.HEIGHT_OF_UI_OBJECT, Vector3.one * ZoomAndLevelDrag.UI_SIZE_FACTOR, LevelControl.getInstance ().gameElements[LevelControl.getInstance ().charactersOnLevel[i].myID], chosenCharacterCallBack, LevelControl.getInstance ().charactersOnLevel[i] )); } } } } } if ( numberOfSelectedCharacters == 0 ) { if ( _currentCharacter.interactAction ) { _currentCharacter.interactAction = false; } MessageCenter.getInstance ().createMarkInPosition ( _currentObjectIComponent.position ); noCharacterFoundCallBack (); } else { if ( ! foundOnlyOneCharacterSoAutomaticExecute ) setOfButtons.Add ( UIControl.getInstance ().createButton ( "cancelButton", 0f, -3f, GlobalVariables.HEIGHT_OF_UI_OBJECT + 1f, new Vector3 ( 50f, 50f, 1f ) * ZoomAndLevelDrag.UI_SIZE_FACTOR, null, null, noCharacterFoundCallBack )); } foreach ( GameObject button in setOfButtons ) { button.GetComponent < ButtonManager > ().mySetOfButtons = setOfButtons; } }
public void handleEnemySelected ( HandleChoosenCharacter callBackOnChoosenCharacter, IComponent iComponentOfObject ) { _currentObjectIComponent = iComponentOfObject; foreach ( MNEnemyComponent enemyComponent in LevelControl.getInstance ().enemiesOnLevel ) { if ( enemyComponent == null ) continue; if ( iComponentOfObject.gameObject != enemyComponent.gameObject ) { //enemyComponent.setMayBeAttacked ( false ); enemyComponent.GetComponent < SelectedComponenent > ().setSelected ( false ); } } if ( _currentCharacter != null ) chosenCharacterCallBack ( _currentCharacter ); }