public Fixture(Type testClass, object instance, CaseBehavior caseExecutionBehavior, Case[] cases) { TestClass = testClass; Instance = instance; CaseExecutionBehavior = caseExecutionBehavior; Cases = cases; }
public void placeTokenOnCell(CaseBehavior cell) { tokenPlace = true; caseActuelle = cell.gameObject; cibleToken = null; ciblesTokens.Clear(); }
// Compute and activate all possible actions // by default (null) caseDepart will be character's current cell public void computePossibleActions(CaseBehavior caseDepart = null) { if (caseDepart == null) { caseDepart = caseActuelle.GetComponent <CaseBehavior>(); } int row = caseDepart.row; int column = caseDepart.column; pathfinder = new PathFinding(gManager, row, column, this); if (!surLaRegletteAdverse(caseDepart)) // the movement must stop once on the opponent zone. { caseDepart.selectionnePourDeplacement = true; // Changer le SortingLayer +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ pathfinder.SearchPossibleActions(); activatePossibleActions(); caseDepart.cibleAssociated.GetComponent <Collider>().enabled = false; } }
public bool MoveToTarget(ActionType type, CaseBehavior target) { List <CaseBehavior> path = pathfinder.GetActionPath(type, target); if (path.Count > 0) { gManager.onlineGameInterface.RecordMove(type, this, target); CharacterBehaviorIHM characterIHM = GetComponent <CharacterBehaviorIHM>(); if (!characterIHM.gliding) { characterIHM.gliding = true; characterIHM.moveTargets.Clear(); foreach (CaseBehavior cell in path) { characterIHM.moveTargets.Add(cell.cibleAssociated); cell.cibleAssociated.GetComponent <SpriteRenderer>().color = Color.green; if (cell.affiliationJoueur != null && cell.affiliationJoueur != affiliationJoueur) { break; } } characterIHM.glideToNextPosition(); } return(true); } return(false); }
public List <Token> getPickableTokens() { CaseBehavior currentCell = caseActuelle.GetComponent <CaseBehavior>(); if (currentCell.isNonWoundedEnemyPresent(gameObject)) { return(new List <Token>()); // cannot pick an object when a non wounded enemy is present } List <Token> result = new List <Token>(); foreach (Token token in currentCell.tokens_) { if (token.GetComponent <CharacterBehavior>() != null) { CharacterBehavior otherCharacter = token.GetComponent <CharacterBehavior>(); if (otherCharacter != this && otherCharacter.affiliationJoueur == affiliationJoueur && otherCharacter.wounded && otherCharacter.tokenHolder != this) { result.Add(token); // can autopick wounded ally that the character doesn't already carry } } else // item { // TODO: Fix the case where an ally thief is standing on the pit if (token.GetComponent <Item_Corde>() != null && currentCell.type == CaseBehavior.typeCase.caseFosse && currentCell.isOtherAllyPresent(this)) { continue; // cannot pick a rope on a pit where an ally is standing } if (token.tokenHolder != this) { result.Add(token); // can pick an item that the character doesn't already carry } } } return(result); }
private void StoreDelayedAction(ActionType delayedActionType, CharacterBehavior delayedActionCharacter, CaseBehavior delayedActionTarget) { Logger.Instance.Log("WARNING", "Delayed Record of Jump"); this.delayedActionType = delayedActionType; this.delayedActionCharacter = delayedActionCharacter; this.delayedActionTarget = delayedActionTarget; }
public void placeTokenOnCell(CaseBehavior cell) { transform.position = new Vector3(cell.transform.position.x, cell.transform.position.y, 0); applyNewScale(NORMAL_SCALE_VALUE); tokenHighlight.GetComponent <SpriteRenderer>().sprite = standardHighlight; associatedToken.placeTokenOnCell(cell); }
// Use this for initialization void Start() { gManager = GameManager.gManager; associatedCase = GetComponent <CaseBehavior>(); associatedTile = transform.parent.GetComponent <TileBehaviorIHM>(); clockwiseRotation = transform.parent.GetComponent <TileBehavior>().clockwiseRotation; }
private void ExecuteActionDoor(ActionDoor action) { if (gManager.onlineGameInterface.WaitingForExpectedState()) { gManager.onlineGameInterface.ForceEndReplayAction(); return; } CaseBehavior actionCharacterCell = gManager.getCase(action.y1, action.x1).GetComponent <CaseBehavior>(); CharacterBehavior c = actionCharacterCell.getNonWoundedCharacter(); Debug.Assert(c != null); CharacterBehaviorIHM character = c.GetComponent <CharacterBehaviorIHM>(); character.characterSelection(); if (action.action == ActionType.DESTROYDOOR) { Debug.Assert(character is CB_GuerrierIHM); character.GetComponent <CB_GuerrierIHM>().briserHerse(); } else { Debug.Assert(character is CB_VoleuseIHM); character.GetComponent <CB_VoleuseIHM>().changerEtatHerse(); } gManager.onlineGameInterface.ForceEndReplayAction(); }
void manualTokenExchange() { CaseBehavior currentCell = associatedCharacter.caseActuelle.GetComponent <CaseBehavior>(); gManager.exchangeUI.GetComponent <InfoCharacterPanel>().panelToOpenPosition(); // On ground there can be : // 1) nothing. 1 slot on ground needed. // 2) 1 item. 1 slot needed if I carry an item, 2 slots if I carry a wounded ally // 3) 1 wounded ally. 1 slot needed if I carry a wounded ally, 2 slots if I carry an item. // 4) a non wounded ally or an enemy. 2 slots needed (the right one containing the non pickable character) // 5) 2 tokens. 2 slots needed. int nbSpotOnGround = 0; Token[] tokenOnGround = new Token[2]; foreach (Token token in currentCell.tokens_) { if (token.gameObject != gameObject && token.tokenHolder != associatedCharacter) // not the moving character or its carried token { Debug.Assert(nbSpotOnGround < 2, "Too many tokens on ground"); tokenOnGround[nbSpotOnGround++] = token; } } // if only one token check if another spot is needed if (nbSpotOnGround == 1) { CharacterBehavior chara = tokenOnGround[0].GetComponent <CharacterBehavior>(); if (chara != null && (chara.affiliationJoueur != associatedToken.affiliationJoueur || !chara.wounded)) // case 4: non pickable character on ground { ++nbSpotOnGround; // another spot needed } else if (associatedCharacter.carriedToken != null) { bool carriedTokenIsCharacter = associatedCharacter.carriedToken.GetComponent <CharacterBehavior>() != null; bool groundTokenIsCharacter = chara != null; if (carriedTokenIsCharacter != groundTokenIsCharacter) // case 2 and 3: an item and a wounded character can be on the ground at the same time { ++nbSpotOnGround; // another spot needed } } } displayGroundSpot(nbSpotOnGround); instantiateSpotToken(currentCell, getCarriedSpot(), associatedCharacter.carriedToken); if (nbSpotOnGround <= 1) { instantiateSpotToken(currentCell, getSingleGroundSpot(), tokenOnGround[0]); } else { for (int i = 0; i < nbSpotOnGround; ++i) { instantiateSpotToken(currentCell, getMultipleGroundSpot(i), tokenOnGround[i]); } } }
void SearchAdjacentActions(CaseBehavior currentCell) { // Propagate in all directions for (int dir = 0; dir < 4; ++dir) { checkAdjacentCell(currentCell, dir); } }
// settings public PathFinding(GameManager manager, int row, int column, CharacterBehavior character) { gManager = manager; startCell = gManager.getCase(row, column).GetComponent <CaseBehavior>(); currentCharacter = character; possibleActions = new Dictionary <ActionType, Dictionary <CaseBehavior, ActionDetail> >(); }
public virtual bool canStayOnCell(CaseBehavior currentCase) { if (surLaRegletteAdverse(currentCase)) { return(!currentCase.isOtherNonWoundedCharacterPresent(gameObject)); } else { return(!currentCase.isOtherNonWoundedCharacterPresent(gameObject) && !currentCase.isOpponentPresent(gameObject) && !tooManyTokensToStayOnCell(currentCase) && currentCase.fosseNonBloquante()); } }
public override bool canStayOnCell(CaseBehavior currentCase) { if (surLaRegletteAdverse(currentCase)) { return(true); } else { return(base.canStayOnCell(currentCase)); } }
private void instantiateSpotToken(CaseBehavior cell, GameObject spot, Token token) { if (token != null) { instantiateExchangeableTokens(cell, token.gameObject, spot); } else { gManager.exchangePoints.Add(spot); } }
public void briserHerse() { List <CaseBehavior> hersesAdjacentes = associatedCharacter.pathfinder.GetActivatedCells(ActionType.DESTROYDOOR); CaseBehavior target = hersesAdjacentes[0]; ActionType type = ActionType.DESTROYDOOR; gManager.playSound(abilitySound); target.herse.GetComponent <HerseBehaviorIHM>().manipulate(type); gManager.onlineGameInterface.RecordAction(type, associatedCharacter); endDeplacementIHM(); }
private PlacementTokens FindRevealedTileTarget(CaseBehavior cell) { foreach (GameObject cible in GameObject.FindGameObjectsWithTag("TileRevealedTarget")) { PlacementTokens target = cible.GetComponent <PlacementTokens>(); if (target.caseActuelle == cell) { return(target); } } return(null); }
private void _SwitchCellToCell(Token token1, Token token2) { Debug.Assert(token1.caseActuelle != null); Debug.Assert(token2.caseActuelle != null); CaseBehavior cell1 = token1.caseActuelle.GetComponent <CaseBehavior>(); CaseBehavior cell2 = token2.caseActuelle.GetComponent <CaseBehavior>(); token1.caseActuelle = null; token2.caseActuelle = null; token1.placeTokenOnCell(cell2); token2.placeTokenOnCell(cell1); }
private void _SwitchTargetToCell(Token token1, Token token2) { Debug.Assert(token1.cibleToken != null); Debug.Assert(token2.caseActuelle != null); PlacementTokens cible1 = token1.cibleToken; CaseBehavior cell2 = token2.caseActuelle.GetComponent <CaseBehavior>(); token2.tokenPlace = false; token2.caseActuelle = null; token1.placeTokenOnCell(cell2); token2.placeToken(cible1); }
public List <Token> getAutoPickableTokens() { CaseBehavior currentCell = caseActuelle.GetComponent <CaseBehavior>(); if (currentCell.isOtherNonWoundedCharacterPresent(gameObject)) { return(new List <Token>()); } else { return(getPickableTokens()); } }
public bool tooManyTokensToStayOnCell(CaseBehavior currentCase) { int nbTokens = currentCase.tokens_.Count; if (caseActuelle != currentCase.gameObject) { nbTokens++; if (tokenTranporte != null) { nbTokens++; } } return(nbTokens >= 3); }
public int GetActionPriority(ActionType type, CaseBehavior cell) { int priority = MAX_PRIORITY; if (possibleActions.ContainsKey(type)) { var actions = possibleActions[type]; if (actions.ContainsKey(cell)) { priority = actions[cell].priority; Debug.Assert(priority < MAX_PRIORITY); } } return(priority); }
// Le personnage dépose un token une case donnée public void deposerToken(CaseBehavior ground) { if (tokenTranporte.GetComponent <CharacterBehavior>() != null) { tokenTranporte.transform.parent = GameObject.Find("Personnages").transform; } else { tokenTranporte.transform.parent = GameObject.Find("Items").transform; } //ground.tokens.Add(tokenTranporte); tokenTranporte.GetComponent <Token>().tokenHolder = null; tokenTranporte = null; }
public void changerEtatHerse() { List <CaseBehavior> hersesAdjacentes = new List <CaseBehavior>(); hersesAdjacentes.AddRange(associatedCharacter.pathfinder.GetActivatedCells(ActionType.CLOSEDOOR)); hersesAdjacentes.AddRange(associatedCharacter.pathfinder.GetActivatedCells(ActionType.OPENDOOR)); CaseBehavior target = hersesAdjacentes[0]; AudioClip sound = target.herse.GetComponent <HerseBehavior>().herseOuverte ? sonFermerHerse : sonOuvrirHerse; ActionType type = target.herse.GetComponent <HerseBehavior>().herseOuverte ? ActionType.CLOSEDOOR : ActionType.OPENDOOR; gManager.playSound(sound); target.herse.GetComponent <HerseBehaviorIHM>().manipulate(type); gManager.onlineGameInterface.RecordAction(type, associatedCharacter); endDeplacementIHM(); }
public List <CaseBehavior> enemyCharactersOnSight(CaseBehavior fromCell) { List <CaseBehavior> enemiesOnSight = new List <CaseBehavior>(); List <CaseBehavior> charactersOnSight = getLineOfSight(fromCell); foreach (CaseBehavior cell in charactersOnSight) { CharacterBehavior character = cell.getMainCharacter(); Debug.Assert(character != null); if (!gManager.isActivePlayer(character.affiliationJoueur)) { enemiesOnSight.Add(cell); } } return(enemiesOnSight); }
private bool RegisterAction(ActionType type, CaseBehavior cell, int priority, CaseBehavior previous = null) { if (priority < GetActionPriority(type, cell)) { if (!possibleActions.ContainsKey(type)) { possibleActions[type] = new Dictionary <CaseBehavior, ActionDetail>(); } possibleActions[type][cell] = new ActionDetail(priority, previous); return(true); } else { return(false); } }
public string printDictionaryContent() { string dico = "Actions possibles :\n"; foreach (KeyValuePair <ActionType, Dictionary <CaseBehavior, ActionDetail> > action in possibleActions) { if ((action.Key == ActionType.WALK || action.Key == ActionType.JUMP || action.Key == ActionType.WALLWALK) && action.Value.Count == 1) { break; // only starting celle : no action possible } dico += "\nAction " + action.Key + "\n"; foreach (KeyValuePair <CaseBehavior, ActionDetail> detail in action.Value) { if (action.Key == ActionType.WALK || action.Key == ActionType.JUMP || action.Key == ActionType.WALLWALK) { if (detail.Value.previousCell != null) { CaseBehavior previousCell = detail.Value.previousCell; CaseBehavior cell = detail.Key; dico += action.Key + " from (" + previousCell.row + ", " + previousCell.column + ") to (" + cell.row + ", " + cell.column + ") with priority " + detail.Value.priority + "\n"; } } else if (action.Key == ActionType.REVEAL) { dico += action.Key + " tile " + detail.Key.transform.parent.name + "\n"; } else if (action.Key == ActionType.ATTACK) { dico += action.Key + " character " + detail.Key.getMainCharacter().name + "\n"; } else if (action.Key == ActionType.HEAL) { dico += action.Key + " character " + detail.Key.getMainCharacter().name + "\n"; } else if (action.Key == ActionType.FIREBALL) { dico += action.Key + " on target character " + detail.Key.getMainCharacter().name + "\n"; } else // default { dico += action.Key + " toward cell " + detail.Key.name; } } } return(dico); }
// Lister chaque case valide de la salle pour poser un pion public List <CaseBehavior> getAvailableCells() { List <CaseBehavior> availableCells = new List <CaseBehavior>(); for (int i = 0; i < transform.childCount; i++) { if (transform.GetChild(i).GetComponent <CaseBehavior>() != null) { CaseBehavior currentCase = transform.GetChild(i).GetComponent <CaseBehavior>(); if (currentCase.isAvailable()) { availableCells.Add(currentCase); } } } return(availableCells); }
private void ExecuteActionMove(ActionMove action) { if (gManager.onlineGameInterface.WaitingForExpectedState()) { gManager.onlineGameInterface.ForceEndReplayAction(); return; } CharacterBehavior chara = GetTokenByNameAndPlayerId(action.tokenName, action.playerId).GetComponent <CharacterBehavior>(); CharacterBehaviorIHM charaIHM = chara.GetComponent <CharacterBehaviorIHM>(); if (!chara.selected) { charaIHM.characterSelection(); } // synchronize carried token if (gManager.onlineGameInterface.IsCarrier(action.tokenId)) { int carriedId = gManager.onlineGameInterface.GetCarriedToken(action.tokenId); Token carriedToken = GetTokenById(carriedId); if (chara.tokenTranporte != null && chara.tokenTranporte.GetComponent <Token>() == carriedToken) { charaIHM.deposerToken(); } if (chara.tokenTranporte == null) { charaIHM.ramasserToken(carriedToken.gameObject); } } else { if (chara.tokenTranporte != null) { charaIHM.deposerToken(); } } CaseBehavior target = gManager.getCase(action.y, action.x).GetComponent <CaseBehavior>(); target.cibleAssociated.GetComponent <CibleDeplacementIHM>().moveSelectedTokenToTarget(); // jump will automatically call end movement // for simple walk, end movement is called when leaving movingCharacterContinue state. }
// The first fighter will always be the action character, and the second, the target character. public List <CharacterBehavior> SearchFighters(CharacterBehavior attacker, CharacterBehavior opponent) { List <CharacterBehavior> fighters = new List <CharacterBehavior>(); Queue <CharacterBehavior> queue = new Queue <CharacterBehavior>(); System.Action <CharacterBehavior> SelectFighter = (fighter) => { if (!fighters.Contains(fighter)) { fighters.Add(fighter); queue.Enqueue(fighter); } }; SelectFighter(attacker); SelectFighter(opponent); while (queue.Count > 0) { CharacterBehavior currentFighter = queue.Dequeue(); CaseBehavior currentCell = currentFighter.caseActuelle.GetComponent <CaseBehavior>(); // Propagate in all directions for (int dir = 0; dir < 4; ++dir) { if (!currentCell.debordement(dir) && currentCell.cheminDegage(currentCell.versDirection(dir))) { CaseBehavior nextCell = currentCell.getCaseVers(dir); if (nextCell.isCaseRevealed() && nextCell.cheminDegage(nextCell.versDirection(CaseBehavior.opposee(dir))) && nextCell.enemyFighterPresent(currentFighter.gameObject)) { if (nextCell.isNonWoundedEnemyPresent(currentFighter.gameObject)) { foreach (CharacterBehavior character in nextCell.characters) { SelectFighter(character); } } } } } } return(fighters); }
public ExecutionPlan(Convention convention) { classBehavior = convention.ClassExecution.Behavior; instanceBehavior = convention.InstanceExecution.Behavior; caseBehavior = convention.CaseExecution.Behavior; }
public CaseBehaviorBuilder Wrap(CaseBehaviorAction outer) { Behavior = new WrapBehavior(outer, Behavior); return this; }
public WrapBehavior(CaseBehaviorAction outer, CaseBehavior inner) { this.outer = outer; this.inner = inner; }