//removes a specified decal public void RemoveDecal(DecalInfo givenInfo, TurnBehaviour turnBehav) { List <Character> tmpList = new List <Character>(); for (int i = decalInfo.Count - 1; i >= 0; i--) { if (decalInfo[i].targets == givenInfo.targets) { for (int k = 0; k < decalInfo[i].projectors.Count; k++) { Destroy(decalInfo[i].projectors[k]); } decalInfo[i].projectors.Clear(); Destroy(decalInfo[i].arrow); if (decalInfo[i].player != givenInfo.player) { tmpList.Add(decalInfo[i].player); } decalInfo.Remove(decalInfo[i]); } } int count = decalInfo.Count; //respawns all other decals that should be on this target to fill in any gaps removing the other one left for (int i = 0; i < tmpList.Count; i++) { RedoDecal(i, tmpList[i], tmpList[i].target.GetComponent <Character>(), turnBehav, tmpList.Count); } }
//using th eother one for redoing the decals didn't work and editing it was too difficult so here this is, a slightly modded version of the instantiate code that uses a passed in number to grab the ring decal element public void RedoDecal(int i, Character character, Character target, TurnBehaviour turnBehaviour, int iter) { if (target != null) { DecalInfo tmpInfo = new DecalInfo(); tmpInfo.player = character; tmpInfo.targets = target; //disc spawning if (iter > 0) { GameObject tmpObj = Instantiate(projector[i]); tmpObj.transform.position = new Vector3(character.target.transform.position.x, tmpObj.transform.position.y, character.target.transform.position.z); //setting colour to character specific colour Material tmpMat = new Material(tmpObj.GetComponent <Projector>().material); tmpMat.SetColor("_Color", character.uiColour); tmpObj.GetComponent <Projector>().material = tmpMat; //tmpObj.GetComponent<Projector>().material.SetColor("_Color", character.uiColour); List <GameObject> tmpList = new List <GameObject>(); tmpList.Add(tmpObj); tmpInfo.projectors = tmpList; //wont spawn an arrow if it's a self/team targeting move, as the arrows look super janked if they do if (character.target.tag != "Player") { //arrow instantiating, spawns an arrow then rotates it towards the enemy from the character GameObject tmpArrow = Instantiate(arrowProjectors); Vector3 midPoint = (character.transform.position + (character.target.transform.position - character.transform.position) / 2); tmpArrow.transform.position = new Vector3(midPoint.x, tmpObj.transform.position.y, midPoint.z); //scales the arrow so it fits between the characters float distance = Vector3.Distance(character.transform.position, character.target.transform.position); tmpArrow.GetComponent <Projector>().orthographicSize = distance / 2; tmpArrow.GetComponent <Projector>().aspectRatio = 1 / Mathf.Pow(tmpArrow.GetComponent <Projector>().orthographicSize, 2); tmpArrow.transform.LookAt(character.target.transform); tmpArrow.transform.eulerAngles = new Vector3(90, tmpArrow.transform.eulerAngles.y, tmpArrow.transform.eulerAngles.z); //setting colour to character specific colour Material tmpMatArr = new Material(tmpArrow.GetComponent <Projector>().material); tmpMatArr.SetColor("_Color", character.uiColour); tmpArrow.GetComponent <Projector>().material = tmpMatArr; //tmpArrow.GetComponent<Projector>().material.SetColor("_Color", character.uiColour); tmpInfo.arrow = tmpArrow; } //storing the decal info into a list decalInfo.Add(tmpInfo); } } }
// Use this for initialization void Start() { //turn on feedback scripts FloatingTextController.DamageEnemy(); FloatingTextController.DamageAlly(); FloatingTextController.Miss(); FloatingTextController.HealEnemy(); FloatingTextController.HealAlly(); RPG.BattleManager battleManager = RPG.BattleManager.Instance; battleManager.stateManager = this; turnBehaviour = GetComponent <TurnBehaviour>(); decalUI = GetComponent <DecalUI>(); confirmMenu = GetComponent <MoveConfirmMenu>(); camMovement = GetComponent <CameraMovement>(); storeTargets = new List <Character>(); if (camera == null) { camera = Camera.main; } characters = new List <Character>(); enemies = new List <Character>(); deadCharactersREVIVE = new List <Character>(); // Activate own and enemy team from battleManager, and move enemy team into this scene battleManager.playerTeam.gameObject.SetActive(true); battleManager.enemyTeam.gameObject.SetActive(true); SceneManager.MoveGameObjectToScene(battleManager.enemyTeam.gameObject, gameObject.scene); enemyBehav = battleManager.enemyTeam.GetComponentsInChildren <EnemyBehaviour>(true); GameObject go = Instantiate(selector); selector = go; selector.SetActive(false); // move Selector into this scene SceneManager.MoveGameObjectToScene(selector, this.gameObject.scene); //game over menu stuff GameOverUI = GameObject.Find("GameOverMenu"); GameOverTextLose = GameObject.Find("LoseText"); GameOverTextWin = GameObject.Find("WinText"); GameOverUI.SetActive(false); GameOverNext.gameObject.SetActive(false); GameOverInfo.gameObject.SetActive(false); GameOverTextLose.SetActive(false); GameOverTextWin.SetActive(false); descriptionUI.gameObject.SetActive(false); //grabbing players/enemies from the scene to fill lists characters.AddRange(battleManager.playerTeam.GetComponentsInChildren <Character>(true)); //sort player list based on their choiceOrder number(so you can make it that the closest one to the screen picks first ect) List <Character> sortedList = characters.OrderBy(o => o.ChoiceOrder).ToList(); characters = sortedList; battleUIController = GetComponent <BattleUIController>(); battleUIController.UISetup(characters); //setting all characters to be inactive foreach (Character chara in characters) { chara.ActivePlayer = false; } //TODO place characters in scene positions based on this order (ie List<Transform> playerPositions and List<Transform> enemyPositions) enemies.AddRange(battleManager.enemyTeam.GetComponentsInChildren <Character>(true)); //////PLACES CHARACTERS TO PRE-SET LOCATIONS foreach (Character chara in characters) { //chara.GetComponent<ButtonBehaviour>().Setup(buttonBehaviourObjects); chara.GetComponent <TargetSelection>().Init(this.gameObject, camera); } // place player team in set positions for (int i = 0; i < playerPositions.Count && i < characters.Count; ++i) { characters[i].transform.position = playerPositions[i].position; characters[i].transform.rotation = playerPositions[i].rotation; } ////// List <Character> tmp = new List <Character>(); //when battle reentered, forces any dead characters to act like it foreach (Character chara in characters) { if (chara.Hp <= 0) { tmp.Add(chara); Death(chara, tmp); } } //moving enemies into position for (int i = 0; i < enemyPositions.Count && i < enemies.Count; ++i) { enemies[i].transform.position = enemyPositions[i].position; enemies[i].transform.rotation = enemyPositions[i].rotation; } //shows enemy ui foreach (Character enemy in enemies) { enemy.GetComponent <EnemyUI>().enemyUISetup(uiCanvas); } foreach (Character enemy in enemies) { enemy.GetComponent <EnemyUI>().ShowUI(); } turnBehaviour.Setup(characters, enemies); result = EBattleResult.Flee; // initialize XP to 0 xpEarned = 0; //starting game loops StartCoroutine(GameLoop()); }
// Use this for initialization void Start() { manager = GetComponent <StateManager>(); turnBehaviour = GetComponent <TurnBehaviour>(); }