コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (isPaused == false)
        {
            if (isLerping == false)
            {
                if (Input.GetButtonDown("MoveUp"))
                {
                    if ((int)currentTileClass.gridLocation.y + movementRange < bfs.yMax && TileCheck(0, movementRange))
                    {
                        MovePlayer(MoveDirection.Up);
                    }
                }
                else if (Input.GetButtonDown("MoveDown"))
                {
                    if ((int)currentTileClass.gridLocation.y - movementRange >= 0 && TileCheck(0, -movementRange))
                    {
                        MovePlayer(MoveDirection.Down);
                    }
                }
                else if (Input.GetButtonDown("MoveLeft"))
                {
                    if ((int)currentTileClass.gridLocation.x - 1 >= 0 && TileCheck(-movementRange, 0))
                    {
                        MovePlayer(MoveDirection.Left);
                    }
                }
                else if (Input.GetButtonDown("MoveRight"))
                {
                    if ((int)currentTileClass.gridLocation.x + 1 < bfs.xMax && TileCheck(movementRange, 0))
                    {
                        MovePlayer(MoveDirection.Right);
                    }
                }


                #region consoleInput
                else if (Input.GetAxisRaw("MoveVertical") != 0)
                {
                    if (vertAxisInUse == false)
                    {
                        if (Input.GetAxisRaw("MoveVertical") < 0)
                        {
                            if ((int)currentTileClass.gridLocation.y - movementRange >= 0 && TileCheck(0, -movementRange))
                            {
                                MovePlayer(MoveDirection.Down);
                            }
                        }
                        else if (Input.GetAxisRaw("MoveVertical") > 0)
                        {
                            if ((int)currentTileClass.gridLocation.y + movementRange < bfs.yMax && TileCheck(0, movementRange))
                            {
                                MovePlayer(MoveDirection.Up);
                            }
                        }
                    }
                }
                else if (Input.GetAxisRaw("MoveHorizontal") != 0)
                {
                    if (horizontalAxisInUse == false)
                    {
                        if (Input.GetAxisRaw("MoveHorizontal") < 0)
                        {
                            if ((int)currentTileClass.gridLocation.x - 1 >= 0 && TileCheck(-movementRange, 0))
                            {
                                MovePlayer(MoveDirection.Left);
                            }
                        }
                        if (Input.GetAxisRaw("MoveHorizontal") > 0)
                        {
                            if ((int)currentTileClass.gridLocation.x + 1 < bfs.xMax && TileCheck(movementRange, 0))
                            {
                                MovePlayer(MoveDirection.Right);
                            }
                        }
                    }
                }

                #endregion
                ContinuousMovement();
                if (Input.GetButton("Shoot"))
                {
                    shotChargeAmount += Time.deltaTime;
                    if (shotChargeAmount < maxShotChargeTime && shotChargeAmount > 0.05f)
                    {
                        if (chargeParticles[0].isPlaying == false)
                        {
                            chargeParticles[0].Play();
                        }
                    }
                    else if (shotChargeAmount >= maxShotChargeTime && shotFullyCharged == false)
                    {
                        chargeParticles[0].Stop();
                        chargeParticles[1].Play();
                        shotFullyCharged = true;
                    }
                }
                if (Input.GetButtonUp("Shoot") && canShoot == true)
                {
                    canShoot = false;

                    ClearChargeParticles();

                    if (shotFullyCharged == false)
                    {
                        standardShot.Shoot(spellOrigin[0].transform, gameObject);

                        anim.Play("Attack");

                        //objectPooler.SpawnFromPool("PlayerBullet", spellOrigin.transform.position, Quaternion.Euler(0, 0, 90), gameObject.transform);
                    }
                    else
                    {
                        //objectPooler.SpawnFromPool("ChargedPlayerBullet", spellOrigin.transform.position, Quaternion.Euler(0, 0, 90), gameObject.transform);
                        ShootCharged();
                    }
                    shootEvent?.Invoke();

                    shotChargeAmount = 0;

                    StartCoroutine(ShotDelay());
                }

                if (Input.GetButtonDown("Use"))
                {
                    if (cardHolder.spellMiniatures.Count > 0)
                    {
                        cardHolder.UseSpell(gameObject, status, spellOrigin[0].transform);
                        anim.Play("Spell");
                        spellParticles.Play();
                    }
                }
            }



            if (Input.GetAxisRaw("MoveVertical") == 0)
            {
                vertAxisInUse = false;
            }
            if (Input.GetAxis("MoveHorizontal") == 0)
            {
                horizontalAxisInUse = false;
            }



            if (Input.GetButtonUp("StartTurn") && turnBarScript.CurrentTurnTime >= turnBarScript.MaxTurnTime)
            {
                if (isPaused == false)
                {
                    //objectPooler.PauseAll();


                    CombatMenu _tempCombatMenu = canvasAnim.gameObject.GetComponent <CombatMenu>();

                    List <SpellCard> _tempSpellList = new List <SpellCard>();

                    foreach (SpellCard s in _tempCombatMenu.playerCombatInUse)
                    {
                        _tempSpellList.Add(s);
                    }

                    foreach (SpellCard s in _tempSpellList)
                    {
                        _tempCombatMenu.MoveCardToDestination(s, CardDestination.Combat, CardDestination.Graveyard);
                    }

                    cardHolder.Purge();
                    turnBarScript.Pause(false);

                    canvasAnim.Play("MenuSlideIn");

                    //EventSystem.current.SetSelectedGameObject(null);
                    //EventSystem.current.SetSelectedGameObject(firstButton);
                }
                else
                {
                    //canvasAnim.Play("MenuSlideOut");

                    //EventSystem.current.SetSelectedGameObject(null);
                    //objectPooler.UnPauseAll();
                }
            }
        }
    }