// Update is called once per frame void Update() { if (!gManager.freezeDisplay) { manageWoundsDisplay(); // Gérer l'apparence des tokens et la mise en place du plateau placementDesTokens(); manageCharacterDisplay(); if (associatedCharacter.isRemovedFromGame()) { GetComponent <Collider>().enabled = false; } // Add action point particules if needed for (int i = bonusActionPointsFX.Count; i < associatedCharacter.actionPoints; i++) { GameObject temp = (GameObject)Instantiate(actionPointFX, transform.position, Quaternion.identity); bonusActionPointsFX.Add(temp); ParticleSystem[] particles = temp.GetComponentsInChildren <ParticleSystem>(); foreach (ParticleSystem p in particles) { p.GetComponent <Renderer>().sortingLayerName = "HUD"; Color newColor = associatedCharacter.affiliationJoueur.GetComponent <PlayerBehavior>().playerColor; p.startColor = new Color(newColor.r, newColor.g, newColor.b, p.startColor.a); } } // Remove action point particules if needed while (bonusActionPointsFX.Count > associatedCharacter.actionPoints) { GameObject fx = bonusActionPointsFX[bonusActionPointsFX.Count - 1]; bonusActionPointsFX.Remove(fx); Destroy(fx); } // Update action point particules animation Vector3 currentCharacterPosition = transform.position; for (int i = 0; i < bonusActionPointsFX.Count; i++) { bonusActionPointsFX[i].transform.rotation = Quaternion.identity; bonusActionPointsFX[i].transform.Rotate(Vector3.forward, (float)i * (360.0f / (float)bonusActionPointsFX.Count) + (-40.0f * Time.time)); bonusActionPointsFX[i].transform.position = currentCharacterPosition + (bonusActionPointsFX[i].transform.right * 0.8f); } } }
private void loadTokens() { // set characters state foreach (var characterData in charactersData) { Token token = GameManager.gManager.GetTokenByNameAndOwnerIndex(characterData.name, characterData.playerIndex); CharacterBehavior chara = token.GetComponent <CharacterBehavior>(); Debug.Assert(chara != null); // Remplacement des valeurs chara.horsJeu = characterData.tokenHorsJeu; chara.tokenPlace = characterData.tokenPlace; chara.wounded = characterData.wounded; chara.freshlyWounded = characterData.freshlyWounded; chara.freshlyHealed = characterData.freshlyHealed; chara.killed = characterData.killed; chara.actionPoints = characterData.actionPoints; SetPreviousState(chara, characterData.previousRow, characterData.previousColumn, characterData.previousAssociatedCharacterName, characterData.previousAssociatedCharacterOwnerIndex); Debug.Assert(chara.transform.parent == GameObject.Find("Personnages").transform, "A character should be child of characterContainer by default"); SetTokenPosition(chara, characterData.row, characterData.column, characterData.associatedCharacterName, characterData.associatedCharacterOwnerIndex, characterData.indexRoomAssociated); if (!chara.isRemovedFromGame() && chara.freshlyHealed) { chara.GetComponent <TokenIHM>().getTokenIcon().GetComponent <SpriteRenderer>().color = Color.green; } } // set items state foreach (var itemData in itemsData) { Token token = GameManager.gManager.GetTokenByNameAndOwnerIndex(itemData.name, itemData.playerIndex); Item item = token.GetComponent <Item>(); Debug.Assert(item != null); // Remplacement des valeurs item.tokenPlace = itemData.tokenPlace; item.horsJeu = itemData.tokenHorsJeu; SetPreviousState(item, itemData.previousRow, itemData.previousColumn, itemData.previousAssociatedCharacterName, itemData.previousAssociatedCharacterOwnerIndex); Debug.Assert(item.transform.parent == GameObject.Find("Items").transform, "An item should be child of itemContainer by default"); SetTokenPosition(item, itemData.row, itemData.column, itemData.associatedCharacterName, itemData.associatedCharacterOwnerIndex, itemData.indexRoomAssociated); } // second pass to place token carried (cannot be done before the holders are placed). foreach (var characterData in charactersData) { if (characterData.tokenHeldName != null) { SetCarriedTokenPosition(characterData); } } // third pass to update previously held tokens' previous position foreach (GameObject g in GameObject.FindGameObjectsWithTag("Token")) { UpdatePreviousPosition(g.GetComponent <Token>()); } removeTargetOfTokensToBePlacedOnDiscoveredRoom(); }