Пример #1
0
    private void clearMovableTile(bool isResetUnitStatus)
    {
        if (isResetUnitStatus)
        {
            this.mySelectStatus = UnitSelectStatus.Neutral;
            selectedUnit = null;
        }

        // タイルの選択状態をクリア
        Dictionary<Point, Tile> tileList = TileManager.getTileList();
        foreach (Point point in selectedPoints)
        {
            if (tileList.ContainsKey(point))
            {
                Transform tile = tileList[point].trans.FindChild("Plane");
                tile.GetComponent<Renderer>().enabled = false;
            }
        }
    }
Пример #2
0
 public void Unselect()
 {
     selectStatus = UnitSelectStatus.Unselected;
 }
Пример #3
0
    // Update is called once per frame
    void Update()
    {
        // 移動中は移動処理以外何もできない
        if(mySelectStatus == UnitSelectStatus.Moving)
        {
            var diff = Time.time - _moveStartTime;
            // 目的地に着いた
            if (diff > _time)
            {
                myPoint.x = (int)Math.Round(_moveDst.x, MidpointRounding.AwayFromZero);
                myPoint.z = (int)Math.Round(_moveDst.z, MidpointRounding.AwayFromZero);
                mySelectStatus = UnitSelectStatus.Neutral;

            }
            else
            {
                var rate = diff / _time;
                selectedUnit.position = Vector3.Lerp(_moveSrc, _moveDst, rate);
                return;
            }
        }

        // マップクリック時
        if (Input.GetMouseButtonUp(0))
        {
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit = new RaycastHit();

            switch (mySelectStatus)
            {
                case UnitSelectStatus.Neutral:
                    // ユニット選択
                    if (Physics.Raycast(ray, out hit, 1000000, 1 << 8))
                    {
                        this.mySelectStatus = UnitSelectStatus.Selected;
                        selectedUnit = hit.transform;

                        viewMovableTiles();
                    }
                    break;
                case UnitSelectStatus.Selected:

                    if (Physics.Raycast(ray, out hit, 1000000, 1 << 8))
                    {
                        //TODO:プレイヤーを選択したのでその場で待機するかどうかのメニューを出す
                        Debug.Log("プレイヤーのメニューを表示する");
                    }else {
                        bool selectedClear = false;
                        if (Physics.Raycast(ray, out hit, 1000000, 1 << 9))
                        {
                            // そのタイルの座標へ移動する
                            if (hit.collider.GetComponent<Renderer>().enabled)
                            {
                                mySelectStatus = UnitSelectStatus.Moving;

                                Vector3 movedPos = hit.transform.position;
                                movedPos.y = 1.5f;

                                _moveStartTime = Time.time;
                                _moveSrc = selectedUnit.position;
                                _moveDst = movedPos;

                                this.clearMovableTile(false);
                            } else
                            {
                                selectedClear = true;
                            }
                        }
                        else
                        {
                            // ユニット・床以外がクリックされた
                            selectedClear = true;
                        }

                        if(selectedClear)
                        {
                            clearMovableTile(true);
                        }
                    }
                    break;
                default:
                    break;
            }
        }
    }
Пример #4
0
    void Update()
    {
        //If it's not their turn or already made their action, do nothing
        if (!turn || selectStatus == UnitSelectStatus.Tapped)
        {
            return;
        }


        //If player's turn, put units on standby
        else if (state == UnitState.Disabled && selectStatus != UnitSelectStatus.Tapped)
        {
            if (turn)
            {
                state = UnitState.Standby;
            }
        }

        //If player is active (selected), put them on wait for their first order.
        else if (state == UnitState.Standby)
        {
            if (ActiveCharacterManager.instance.activeUnit == GetComponent <Unit>())
            {
                state = UnitState.WaitForOrder1;
            }
        }

        //If unit is waiting for their first order, choose the correct path depending on selected action
        else if (state == UnitState.WaitForOrder1)
        {
            Picker.instance.PickTargetForMovement();
            //Pick target tile, begin movement
            if (moving)
            {
                state = UnitState.Move;
            }
            //If no movement, we wait for further orders.
            if (ActiveCharacterManager.instance.selectedTile == ActiveCharacterManager.instance.targetTile)
            {
                state = UnitState.WaitForOrder2;
            }
            //Attack

            //Use item
        }

        //If unit is moving, wait for them to end their movement to put them on wait for the second order
        else if (state == UnitState.Move)
        {
            if (!moving)
            {
                state = UnitState.WaitForOrder2;
            }
        }

        //If unit is waiting for their second order, choose the correct path depending on selected action
        else if (state == UnitState.WaitForOrder2)
        {
            GraphUCS.instance.ClearInteractableTiles(); //Watch out for the behaviour of this function
            PathDrawer.instance.DeletePath();
            //Attack
            if (readyForAttack)
            {
                state = UnitState.ReadyForAttack;
            }
            //Use item
            //if(end) {
            state = UnitState.End;
            //}
            //!!
            //state = UnitState.End;
            //!!
        }

        //If ready for attack, wait for attack confirmation
        else if (state == UnitState.ReadyForAttack)
        {
            if (attacking)
            {
                state = UnitState.Attack;
            }
        }

        //If unit has attacked, end their turn
        else if (state == UnitState.Attack)
        {
            if (!attacking)
            {
                state = UnitState.End;
            }
        }

        //If unit has used an item, end their turn
        else if (state == UnitState.UseItem)
        {
        }

        //If unit has ended their action:
        //- Remove from turn list
        //- Disable them
        //- Tap it
        //- Set no active unit
        else if (state == UnitState.End)
        {
            TurnManager.instance.turnList.Remove(GetComponent <Unit>());
            state        = UnitState.Disabled;
            selectStatus = UnitSelectStatus.Tapped;
            ActiveCharacterManager.instance.activeUnit = null;
            end = false;
        }
    }