// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { if (CastRayToUnit(Input.mousePosition) && CastRayToUnit(Input.mousePosition).align == aligns[actionAlign] && CastRayToUnit(Input.mousePosition).alive&& (activeUnit == null || activeUnit.stts == PlayerControl.Status.standBy)) { button.reset(); if (activeUnit != null) { activeUnit.selected = false; activeUnit.leading.markSelection(false); if (activeUnit.actions[0] == true && activeUnit.actions[1] == true && activeUnit.actions[2] == true) { useAP(-activeUnit.moved); activeUnit.returnActions(); } } activeUnit = CastRayToUnit(Input.mousePosition); //if( activeUnit.actions[0] == true || activeUnit.actions[1] == true || activeUnit.actions[2] == true || AP[actionAlign] > activeUnit.moved ) { activeUnit.selected = true; activeUnit.leading.markSelection(true); activeUnit.button.reset(); if (activeUnit.moved == 0 && AP[actionAlign] > 0) { alignText.text = "Turn" + turns + "-" + aligns[actionAlign]; activeUnit.refillActions(); useAP(activeUnit.moved); } } if (activeUnit != null) { if (activeUnit.isMaster && !summonButton.interactable) { summonButton.interactable = true; } else if (!activeUnit.isMaster && summonButton.interactable) { summonButton.interactable = false; } } } if ((Input.GetKey("r") || (button.refillClick && button.isReady)) && activeUnit != null && activeUnit.moved + 1 <= AP[actionAlign] && (activeUnit.actions[0] == false || activeUnit.actions[1] == false || activeUnit.actions[2] == false)) { activeUnit.refillActions(); useAP(activeUnit.moved); button.reset(); button.ready(); } if (Input.GetKey("e")) { PhaseShift(); } }
// Update is called once per frame void Update() { //transform.Rotate( new Vector3( 0, 0, 10f * Time.deltaTime )); if (stts == Status.idol) { if (selected) { TranStts(Status.standBy); setActionText(); } } if (stts == Status.standBy) { if (!selected) { TranStts(Status.idol); } if (Input.GetKey("s") || (button.moveClick && button.isReady)) { if (checkActions(1)) { TranStts(Status.move); PathFind(1, (int)movement.finalValue, false, leading); button.reset(); } else { Debug.Log("Not enough action"); } } if (Input.GetKey("g") || (button.summonClick && button.isReady)) { if (checkActions(2)) { if (isMaster && canSummon) { manager.summonPanel.reset(); TranStts(Status.summonSelect); button.reset(); } } } if (Input.GetKey("a") || (button.attackClick && button.isReady)) { if (checkActions(abilities[0].cost)) { TranStts(Status.ability); activeAbility = abilities[0]; PathFind(activeAbility.castType, activeAbility.range, activeAbility.penetrate, leading); button.reset(); } else { Debug.Log("Not enough Actions"); } } if (Input.GetKey("1")) { if (checkActions(abilities[1].cost)) { TranStts(Status.ability); activeAbility = abilities[1]; PathFind(activeAbility.castType, activeAbility.range, activeAbility.penetrate, leading); button.reset(); } else { Debug.Log("Not enough Actions"); } } if (Input.GetKey("2")) { if (checkActions(abilities[2].cost)) { TranStts(Status.ability); activeAbility = abilities[2]; PathFind(activeAbility.castType, activeAbility.range, activeAbility.penetrate, leading); button.reset(); } else { Debug.Log("Not enough Actions"); } } if (Input.GetKey("3")) { if (checkActions(abilities[3].cost)) { TranStts(Status.ability); activeAbility = abilities[3]; PathFind(activeAbility.castType, activeAbility.range, activeAbility.penetrate, leading); button.reset(); } else { Debug.Log("Not enough Actions"); } } } if (stts == Status.move) { if (!selected) { ClearReachable(); button.ready(); button.reset(); TranStts(Status.idol); } if (Input.GetMouseButtonDown(0)) { if (CastRayToTile(Input.mousePosition) && reachable.Contains(CastRayToTile(Input.mousePosition))) { leading.unit = null; moveTo(CastRayToTile(Input.mousePosition)); TranStts(Status.standBy); ClearReachable(); button.ready(); costAction(1); } } if (Input.GetMouseButtonDown(1)) { ClearReachable(); button.ready(); button.reset(); TranStts(Status.standBy); } } if (stts == Status.ability) { if (!selected) { activeAbility = null; ClearReachable(); button.ready(); button.reset(); TranStts(Status.idol); } if (Input.GetMouseButtonDown(0)) { if (CastRayToTile(Input.mousePosition) && reachable.Contains(CastRayToTile(Input.mousePosition))) { Tile targetTile = CastRayToTile(Input.mousePosition); if (activeAbility.cast(targetTile)) { costAction(activeAbility.cost); button.ready(); button.reset(); if (!activeAbility.spc) { activeAbility = null; ClearReachable(); TranStts(Status.standBy); } else { TranStts(Status.special); } } /*if( enemy.alive) { * new Combat( this, enemy, true, true, 0 ); * ClearReachable(); * button.ready(); * TranStts(Status.standBy); * * actions[0] = false; * setActionText(); * }*/ } } if (Input.GetMouseButtonDown(1)) { activeAbility = null; ClearReachable(); button.ready(); button.reset(); TranStts(Status.standBy); } } if (stts == Status.special) { if (!selected) { activeAbility = null; ClearReachable(); button.ready(); button.reset(); TranStts(Status.idol); } if (Input.GetMouseButtonDown(0)) { if (CastRayToTile(Input.mousePosition) && reachable.Contains(CastRayToTile(Input.mousePosition))) { Tile targetTile = CastRayToTile(Input.mousePosition); if (activeAbility.special(targetTile)) { ClearReachable(); button.ready(); button.reset(); if (!activeAbility.spc) { activeAbility = null; TranStts(Status.standBy); } else { TranStts(Status.special); } } } } if (Input.GetMouseButtonDown(1)) { activeAbility = null; ClearReachable(); button.ready(); button.reset(); TranStts(Status.standBy); } } if (stts == Status.summonSelect) { if (!selected) { ClearReachable(); button.ready(); button.reset(); manager.summonPanel.gameObject.SetActive(false); TranStts(Status.idol); } if (manager.summonPanel.clickedButton >= 0 && manager.buildTable.Count > manager.summonPanel.clickedButton && manager.buildTable[manager.summonPanel.clickedButton].GetComponent <PlayerControl>().cost <= manager.getFantasies()) { PathFind(3, 2, true, leading); manager.summonPanel.gameObject.SetActive(false); TranStts(Status.summon); } if (Input.GetMouseButtonDown(1)) { ClearReachable(); button.ready(); button.reset(); manager.summonPanel.gameObject.SetActive(false); TranStts(Status.standBy); } } if (stts == Status.summon) { if (!selected) { ClearReachable(); button.ready(); button.reset(); TranStts(Status.idol); } if (Input.GetMouseButtonDown(0)) { if (CastRayToTile(Input.mousePosition) && reachable.Contains(CastRayToTile(Input.mousePosition))) { Tile targetTile = CastRayToTile(Input.mousePosition); if (targetTile.unit == null) { manager.addUnit(targetTile, manager.summonPanel.clickedButton); manager.costFantasies(manager.buildTable[manager.summonPanel.clickedButton].GetComponent <PlayerControl>().cost); ClearReachable(); canSummon = false; costAction(2); button.ready(); button.reset(); TranStts(Status.standBy); } } } if (Input.GetMouseButtonDown(1)) { ClearReachable(); button.ready(); button.reset(); manager.summonPanel.reset(); TranStts(Status.summonSelect); } } if (HP.remain <= 0 && alive == true) { HP.remain = 0; Debug.Log("YOU DIED!!!"); Instantiate(YouDied, transform.position, new Quaternion(0, 0, 0, 0)); GetComponent <SpriteRenderer>().color = new Color(0.5f, 0.5f, 0.5f); alive = false; if (isMaster) { manager.masterFallen(); } } if (HP.remain > HP.finalValue) { HP.remain = HP.finalValue; } HPtm.text = "" + HP.remain + "/" + mind.remain; }