//Controller actions for teamwork: includes changing characters and assist moves void teamwork() { int leftIndex = (partyIndex - 1 + numPartners) % numPartners; int rightIndex = (partyIndex + 1) % numPartners; SwitchState leftState = transform.GetChild(leftIndex).GetComponent <SwitchState>(); SwitchState rightState = transform.GetChild(rightIndex).GetComponent <SwitchState>(); //Switching between teammates if (Input.GetKeyDown("e") && rightState.canSwitch()) //Switch right { int prevPartyIndex = partyIndex; partyIndex = rightIndex; if (prevPartyIndex != partyIndex) { StartCoroutine(rotateCharacters()); } } if (Input.GetKeyDown("q") && leftState.canSwitch()) //Switch left { int prevPartyIndex = partyIndex; partyIndex = leftIndex; if (prevPartyIndex != partyIndex) { StartCoroutine(rotateCharacters()); } } //Assist Moves if (Input.GetKeyDown("c") && assistFighter == null && leftState.canSwitch()) //Use left character move { StartCoroutine(assistMoveExecute(leftIndex, player.position)); } if (Input.GetKeyDown("v") && assistFighter == null && rightState.canSwitch()) //Use right character move { StartCoroutine(assistMoveExecute(rightIndex, player.position)); } }
//Update method that checks the status of fighter and make changes to correspond with status (Particularly with switch cooldown) public void updateStatus() { SwitchState thisState = fighter.GetComponent <SwitchState>(); GetComponent <Image>().color = (thisState.canSwitch()) ? defaultColor : cdSwitchColor; if (!fighter.isAlive()) { GetComponent <Image>().color = deathColor; fighterIcon.sprite = Resources.Load <Sprite>("Portraits/Death"); fighterIcon.color = deathColor; } updateExp(); }