コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (thePlayer == null)
        {
            thePlayer = FindObjectOfType <PlayerController> ();
        }
        //if (dialogActive && Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) {
        if (dialogActive && CnInputManager.GetButtonUp("Fire1"))
        {
            PlayerController.isTalking = true;
            //dBox.SetActive (false);
            //dialogActive = false;
            currentLine++;
        }
        if (currentLine >= dialogLines.Length)
        {
            dBox.SetActive(false);
            dialogActive = false;
            currentLine  = 0;
            mcontroller.SwitchTrack(bgmtracks [questId]);
            mcontroller.musicCanPlay   = true;
            thePlayer.canMove          = true;
            PlayerController.isTalking = false;

            if (questId == 0)
            {
                GameObject.Find("door1").SetActive(false);
            }
            else if (questId == 1)
            {
                GameObject.Find("door6").SetActive(false);
            }
        }
        dText.text = dialogLines [currentLine];
    }
コード例 #2
0
 // Update is called once per frame
 void Update()
 {
     if (!isLocalPlayer || skill.isCooldown())
     {
         return;
     }
     if (CnInputManager.GetButtonDown(simpleButtonName))
     {
         skill.ButtonDown();
     }
     if (CnInputManager.GetButtonUp(simpleButtonName) && !cancelSkill)
     {
         skill.ButtonUp();
     }
     if (CnInputManager.GetButtonUp(simpleButtonName) && cancelSkill)
     {
         skill.ButtonCancel();
     }
     if (!isPressButton && CnInputManager.GetButton(simpleButtonName))
     {
         skill.ButtonDirection(CnInputManager.GetAxis(verticalButtonName), CnInputManager.GetAxis(horizontalButtonName));
     }
     if (CnInputManager.GetButtonDown("CancelSkill"))
     {
         cancelSkill = true;
     }
     if (CnInputManager.GetButtonUp("CancelSkill"))
     {
         cancelSkill = false;
     }
 }
コード例 #3
0
        void Update()
        {
            if (!isActive || !hasInputted || !readNextLine)
            {
                return;
            }

            if (CnInputManager.GetButtonUp("Jump"))
            {
                if (!isTyping)
                {
                    startFromLine++;

                    if (startFromLine == endAtLine)
                    {
                        arrow.enabled = false;
                    }

                    if (startFromLine > endAtLine)
                    {
                        DisableTextBox();
                    }
                    else
                    {
                        StartCoroutine(TextScroll(textLines[startFromLine]));
                    }
                }
                else if (isTyping && !cancelTyping)
                {
                    cancelTyping = true;
                }
            }
        }
コード例 #4
0
    void JumpInput()
    {
        if (CnInputManager.GetButtonDown("JumpBtn") && isGrounded)
        {
            isJumping       = true;
            jumpTimeCounter = jumpTime;
            rb.velocity     = new Vector2(rb.velocity.x, jumpForce);
        }

        if (CnInputManager.GetButton("JumpBtn") && isJumping)
        {
            if (jumpTimeCounter > 0)
            {
                rb.velocity      = Vector2.up * jumpForce;
                jumpTimeCounter -= Time.deltaTime;
            }
            else
            {
                isJumping = false;
            }
        }

        if (CnInputManager.GetButtonUp("JumpBtn"))
        {
            isJumping = false;
        }
    }
コード例 #5
0
    // Выстрел
    public void Schoot()
    {
        if (Input.GetKeyDown(KeyCode.Space) || CnInputManager.GetButtonUp("bombButton"))
        {
            bool clone = false;
            if (allBombInMap.Count > 0)
            {
                // Проверяем а есть ли у нас еще бомбы, и не установили ли мы уже бомбу здесь:
                for (int i = 0; i < allBombInMap.Count; i++)
                {
                    Bomb next = allBombInMap[i];
                    if (next.bombPoint.pointPosition == aStar.Vector3toVector3i(this.lostPoint))
                    {
                        clone = true;
                    }
                }
            }

            if (!clone && allBombInMap.Count < bombLimit)
            {
                // Отлично создаем новую бомбу:
                GameObject clone_Bomb = (GameObject)Instantiate(BombPrefab, lostPoint, Quaternion.identity);
                Bomb       bomb       = clone_Bomb.GetComponent <Bomb>();
                bomb.bombPoint = aStar.mapPointDictionary[aStar.Vector3toVector3i(this.lostPoint)];
                // Реализуем возможность управлять взрывной силой через бонусы:
                bomb.power_strenght = powerPomb;
                allBombInMap.Add(bomb);
            }
        }
    }
コード例 #6
0
ファイル: DefaultInput.cs プロジェクト: yhnu/unity-platformer
        public override bool IsActionUp(string action)
        {
            foreach (var i in inputsMap)
            {
                if (i.action == action)
                {
          #if UP_USE_CN_INPUT_MANAGER
                    if (SystemInfo.deviceType == DeviceType.Handheld)
                    {
                        return(CnInputManager.GetButtonUp(i.handheld));
                    }
          #endif

          #if UP_USE_WII_INPUT_MANAGER
                    if (remote != null)
                    {
                        return(!GetWiiButton(i.wii));
                    }
          #endif

                    return(Input.GetButtonUp(i.keyboard));
                }
            }

            Debug.LogWarning("Cannot find action: " + action);
            return(false);
        }
コード例 #7
0
 private void Update()
 {
     if (CnInputManager.GetButtonUp("Jump"))
     {
         NextTutorial();
     }
 }
コード例 #8
0
 // Update is called once per frame
 void Update()
 {
     if (CnInputManager.GetButtonUp("MenuOpen"))
     {
         OpenMenu();
     }
 }
コード例 #9
0
 void ControlWithVirtualPad()
 {
     deltaVec = new Vector2(CnInputManager.GetAxis("Horizontal"), CnInputManager.GetAxis("Vertical"));
     base.Movable(deltaVec);
     base.Shootable(CnInputManager.GetButton("Push"),
                    CnInputManager.GetButton("Pull"),
                    CnInputManager.GetButtonUp("Pull"));
 }
コード例 #10
0
    void Update()
    {
        //Запускаем таймер:
        if (level_time > 0)
        {
            level_time          -= Time.deltaTime;
            level_time_info.text = level_time.ToString();
        }
        else
        {
            // Тут выпускаем гончих:
            for (int i = 0; i < Map.Instance.extra_enemy_in_map_count; i++)
            {
                Map.Instance.createEnemyToMap(1);
            }
            // Пусть и не из оригинала но ставим таймер снова
            level_time = Map.Instance.level_time;
        }

        // Выполняем любой код только если игрок жив
        switch (state)
        {
        case playerState.live:
            // Остальные методы:
            rotate();
            move(nextPosition);
            if (islocalPlayer)
            {
                Schoot();

                // Обрабатываем движение вперед:
                if ((Input.GetAxis("Vertical") > 0) & (!IsMoving) ||
                    (CnInputManager.GetButtonUp("moveButton") && (!IsMoving)))
                {
                    IsMoving = true;

                    nextPosition = getNextPosition(aStar.mapPointDictionary);
                }
            }
            break;

        case playerState.destroy:
            // Проигрываем последнюю анимацию:
            destroy();
            state = playerState.off;
            break;

        case playerState.off:
            StartCoroutine(looses());
            break;

        case playerState.win:
            StartCoroutine(wines());
            // Играем победную анимацию:
            winn();
            break;
        }
    }
コード例 #11
0
 void Update()
 {
     if (waitForPress && CnInputManager.GetButtonUp("Jump"))
     {
         GameManager.instance.AllowPlayerMovement(false);
         startPrintingText();
         waitForPress = false;
     }
 }
コード例 #12
0
    void Move()
    {
        CorectROT();

        position = new Vector3(CnInputManager.GetAxis("Horizontal"), 0f, 0f);



        if (position.x > 0)
        {
            if (CnInputManager.GetButtonDown("Run"))
            {
                speed = run;
                Debug.Log(run);
            }
            else
            {
                // transform.rotation = Quaternion.Euler(0, 0, 0);


                speed = memor_speed;
                Debug.Log(memor_speed);
            }
            gameG.SetFloat("MoveX", position.x, 0.1f, Time.deltaTime);
            RandL = true;
            gameG.SetBool("RandL", RandL);
        }
        else if (position.x < 0)
        {
            if (CnInputManager.GetButtonDown("Run"))
            {
                speed = run;
                Debug.Log(run);
            }
            else
            {
                speed = memor_speed;
                Debug.Log(memor_speed);
            }
            gameG.SetFloat("MoveX", position.x, 0.1f, Time.deltaTime);
            RandL = false;
            gameG.SetBool("RandL", RandL);
        }
        else if (position.x == 0)
        {
            gameG.SetFloat("MoveX", position.x, 0.1f, Time.deltaTime);
        }

        if (CnInputManager.GetButtonUp("Jump") && isJump)
        {
            gameG.ResetTrigger("idle");
            gameG.SetTrigger("Jump");

            GetComponent <Rigidbody2D>().AddForce(new Vector2(0f, Jump), ForceMode2D.Impulse);
        }
    }
コード例 #13
0
    // Update is called once per frame
    void Update()
    {
        if (ifCanMoove)
        {
            horizontalMove = CnInputManager.GetAxisRaw("Horizontal") * Speed;
            animator.SetFloat("Speed", Mathf.Abs(CnInputManager.GetAxisRaw("Horizontal")));
        }

#if UNITY_ANDROID
        if (CnInputManager.GetButtonDown("Run") && controller.m_Grounded)
        {
            stateSpeed = !stateSpeed;
            animator.SetBool("Run", stateSpeed);
            Speed = stateSpeed? runSpeed:walkSpeed;
        }
        //} else if (CnInputManager.GetButtonUp("Run")) {

        //	animator.SetBool("Run", false);
        //	Speed = walkSpeed;
        //}
#else
        if (CnInputManager.GetButton("Run") && controller.m_Grounded)
        {
            animator.SetBool("Run", true);
            Speed = runSpeed;
        }
        else if (CnInputManager.GetButtonUp("Run"))
        {
            animator.SetBool("Run", false);
            Speed = walkSpeed;
        }
#endif

        //GetSword
        if (CnInputManager.GetButtonDown("GetSword"))
        {
            animator.SetBool("Swording", !animator.GetBool("Swording"));

            AttakBTN.SetActive(animator.GetBool("Swording"));
        }

        if (animator.GetBool("Swording") && CnInputManager.GetButtonDown("Fire1") && forAttack)
        {
            animator.SetTrigger("Attack");
            sword.SetActive(true);

            StartCoroutine(WaitSecfloat(1f));
        }


        if (CnInputManager.GetButtonDown("Jump"))
        {
            jump = true;
        }
    }
コード例 #14
0
 // Update is called once per frame
 void Update()
 {
     if (CnInputManager.GetButtonDown(gameObject.name))
     {
         transform.localScale = new Vector3(transform.localScale.x - size_del, transform.localScale.y - size_del);
     }
     if (CnInputManager.GetButtonUp(gameObject.name))
     {
         transform.localScale = new Vector3(transform.localScale.x + size_del, transform.localScale.y + size_del);
     }
 }
コード例 #15
0
        void Update()
        {
            if (CnInputManager.GetButtonUp("Fire2"))
            {
                PauseGame(true);
            }

            if (CnInputManager.GetButtonUp("Fire3"))
            {
                SettingsManager.instance.OpenSettings(true);
            }
        }
コード例 #16
0
 // Update is called once per frame
 void Update()
 {
     if (CnInputManager.GetButtonUp("Potion"))
     {
         if (CurrentPotion > 0)
         {
             CurrentPotion--;
             int healammount = Mathf.RoundToInt((Player.GetComponent <PlayerHealthManager> ().playerHealthMax *HealMultiplier));
             Player.GetComponent <PlayerHealthManager> ().HealPlayer(healammount);
             UpdatePotion();
         }
     }
 }
コード例 #17
0
ファイル: Movimiento.cs プロジェクト: Ethese/CittBlast
        void shipMov()
        {
            rot = transform.rotation;
            pos = transform.position;
            anim.SetBool("IsMoving", false);
            maxSpeed = 0;

            if (CnInputManager.GetAxis("Horizontal") != 0)
            {
                if (isDown == false)
                {
                    // ROTATE the ship.
                    // Grab our rotation quaternion
                    // Grab the Z euler angle
                    float z = rot.eulerAngles.z;
                    // Change the Z angle based on input
                    z -= CnInputManager.GetAxis("Horizontal") * rotSpeed * Time.deltaTime;
                    // Recreate the quaternion
                    rot = Quaternion.Euler(0, 0, z);
                    // Feed the quaternion into our rotation
                    transform.rotation = rot;
                    // Finally, update our position!!
                    transform.position = pos;
                }
            }

            if (CnInputManager.GetAxis("Vertical") == 0)
            {
                isDown = false;
                rot    = Quaternion.Euler(0, 0, 0);
            }

            if (CnInputManager.GetButton("Boost"))
            {
                Debug.Log("wea");
                source.Play();
                maxSpeed = 5f;
                Vector3 velocity = new Vector3(maxSpeed * Time.deltaTime, 0, 0);

                pos += transform.rotation * velocity;

                transform.position = pos;
                anim.SetBool("IsMoving", true);
            }


            if (CnInputManager.GetButtonUp("Boost"))
            {
                source.Stop();
            }
        }
コード例 #18
0
 void OnTriggerStay2D(Collider2D other)
 {
     PlayerController.isTalking = true;
     if (other.gameObject.tag == "Player")
     {
         if (CnInputManager.GetButtonUp("Fire1") && dMan.dialogActive == false)
         {
             dMan.currentLine = 0;
             dMan.dialogLines = myDialogLines;
             dMan.ShowDialog(questId);
             gameObject.SetActive(false);
         }
     }
 }
コード例 #19
0
    // Поворот Игрока на угол:
    // округление углов
    void angler()
    {
        //Это вращение платформы кнопками.
        //------------------------------------------------------------Вращение базы влево---------------------------------------
        if (Input.GetKeyUp(KeyCode.A) || CnInputManager.GetButtonUp("leftButton"))
        {
            baseToLeft();
        }

        //---------------------------------------------------------------Вращение базы вправо------------------------------------
        if (Input.GetKeyUp(KeyCode.D) || CnInputManager.GetButtonUp("rightButton"))
        {
            baseToRight();
        }
    }
コード例 #20
0
    void Update()
    {
        if (!itsMe)
        {
            return;
        }

        int index = -1;

        if (CnInputManager.GetButtonDown("Smile"))
        {
            index = 1;
        }
        else if (CnInputManager.GetButtonDown("Bad"))
        {
            index = 2;
        }
        else if (CnInputManager.GetButtonDown("Angry"))
        {
            index = 3;
        }
        if (CnInputManager.GetButtonUp("Smile") ||
            CnInputManager.GetButtonUp("Bad") ||
            CnInputManager.GetButtonUp("Angry"))
        {
            index = 0;
        }

        if (index != -1)
        {
            if (index == 0)
            {
                NetworkController.instance.SendChangeFace("default@unitychan", 0);
            }
            else if (index == 1)
            {
                NetworkController.instance.SendChangeFace("smile1@unitychan", 1);
            }
            else if (index == 2)
            {
                NetworkController.instance.SendChangeFace("disstract1@unitychan", 1);
            }
            else if (index == 3)
            {
                NetworkController.instance.SendChangeFace("angry2@unitychan", 1);
            }
        }
    }
コード例 #21
0
 // Update is called once per frames
 void Update()
 {
     if (CnInputManager.GetButtonUp("MenuClose"))
     {
         OpenMenu();
     }
     if (CnInputManager.GetButtonUp("Exit"))
     {
         Application.Quit();
         Debug.Log("quit");
     }
     if (CnInputManager.GetButtonUp("New Game"))
     {
         Debug.Log("New game");
     }
 }
コード例 #22
0
    public bool GetKeyUp(myKeyCode keyCode)
    {
        switch (keyCode)
        {
        case myKeyCode.Attack:
            return(CnInputManager.GetButtonUp(attackButton.ButtonName) || Input.GetKeyUp(attackKeyCode));

        case myKeyCode.Jump:
            return(CnInputManager.GetButtonUp(jumpButton.ButtonName) || Input.GetKeyUp(jumpKeyCode));

        case myKeyCode.Skill1:
            return(CnInputManager.GetButtonUp(skill1Button.ButtonName) || Input.GetKeyUp(skill1KeyCode));

        case myKeyCode.Skill2:
            return(CnInputManager.GetButtonUp(skill2Button.ButtonName) || Input.GetKeyUp(skill2KeyCode));
        }
        return(false);
    }
コード例 #23
0
    void Attack()
    {
        if (CnInputManager.GetButtonUp("Attack"))
        {
            CorectRandL();
            gameObject.GetComponent <Animator>().SetTrigger("attack");

            //if (isJump)
            //{
            //    gameObject.GetComponent<Animator>().SetTrigger("idle");
            //}
            //else
            //{
            //    gameObject.GetComponent<Animator>().SetTrigger("Jump");
            //    gameObject.GetComponent<Animator>().ResetTrigger("idle");
            //}
        }
    }
コード例 #24
0
ファイル: FairyShooting.cs プロジェクト: WkcWong/NinjaSword
 void Update()
 {
     if (CnInputManager.GetButtonUp("Shoot") || Input.GetButtonUp("Shoot"))
     {
         shooting = false;
     }
     if (shooting && shot >= 0.1f)
     {
         Instantiate(SpawnObj, transform.position, transform.rotation);
         shot = 0;
         AudioSource.PlayClipAtPoint(laserSound, transform.position);
     }
     shot += Time.deltaTime;
     transform.LookAt(boss);
     if (CnInputManager.GetButtonDown("Shoot") || Input.GetButtonDown("Shoot"))
     {
         shooting = true;
     }
 }
コード例 #25
0
    // Update is called once per frame
    void FixedUpdate()
    {
        position = new Vector3(CnInputManager.GetAxis("Horizontal"), CnInputManager.GetAxis("Vertical"), 0f);

        transform.position += position * Time.deltaTime * 5;

        if (position.x < 0)
        {
            transform.rotation = Quaternion.Euler(0, 180, 0);
        }
        else
        {
            transform.rotation = Quaternion.Euler(0, 0, 0);
        }

        if (CnInputManager.GetButtonUp("Jump"))
        {
            GetComponent <Rigidbody2D>().AddForce(new Vector2(0f, 5f), ForceMode2D.Impulse);
        }
    }
コード例 #26
0
    void FixedUpdate()
    {
        position            = new Vector3(CnInputManager.GetAxis("Horizontal"), CnInputManager.GetAxis("Vertical"), 0f);
        transform.position += position * Time.deltaTime * 4;
        if (position.x < 0)
        {
            transform.rotation = Quaternion.Euler(0, 180, 0);
        }
        else
        {
            transform.rotation = Quaternion.Euler(0, 0, 0);
        }

        if (CnInputManager.GetButtonUp("Jump"))
        {
            Instantiate(dan, transform.position, Quaternion.identity);

            GetComponent <AudioSource>().clip = audioClip[clip];
            GetComponent <AudioSource> ().Play();
        }
    }
コード例 #27
0
    protected override Vector2 GetExpectedVelocity()
    {
        //todo: разобраться, почему не всегда срабатывает прыжок
        //todo: возможно стоит перенести рассчет expectedVelocity в Update() и хранить в поле, здесь только возвращать
        Vector2 expectedVelocity = base.GetExpectedVelocity();

        expectedVelocity.x = walkingSpeed * CnInputManager.GetAxisRaw("Horizontal");

        if (CnInputManager.GetButtonDown("Jump") && Grounded)
        {
            expectedVelocity.y = jumpTakeOffSpeed;
        }
        else if (CnInputManager.GetButtonUp("Jump"))
        {
            if (VelocityCurrent.y > 0)
            {
                expectedVelocity.y = VelocityCurrent.y * 0.5f;
            }
        }

        return(expectedVelocity); //move * maxSpeed;
    }
コード例 #28
0
ファイル: Character.cs プロジェクト: Resinchen/DakotaRunGame
    private void Update()
    {
        CheckGround();
        if (isGrounded)
        {
            State = CharState.Idle;
        }

        if (CnInputManager.GetAxis("Horizontal") != 0)
        {
            Run();
        }
        if (isGrounded && CnInputManager.GetButtonUp("Jump"))
        {
            Jump();
        }

        if (Input.GetKeyDown(KeyCode.Escape))
        {
            SceneManager.LoadScene("menu");
        }
    }
コード例 #29
0
    // Update is called once per frame
    void Update()
    {
        if (CnInputManager.GetButtonUp("RestartLevel"))
        {
            Time.timeScale = 1.0f;
            SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
        }

        if (CnInputManager.GetButtonUp("CloseWeaponsList"))
        {
            WeaponLists.SetActive(false);
        }
        if (CnInputManager.GetButtonUp("OpenWeaponsList"))
        {
            WeaponLists.SetActive(true);
        }

        if (CnInputManager.GetButtonUp("ReturnToMenu"))
        {
            Time.timeScale = 1.0f;
            SceneManager.LoadScene("mainMenu");
        }
    }
コード例 #30
0
    private void Update()
    {
        // Track the current state of the fire button and make decisions based on the current launch force.

        m_AimSlider.value = m_MinLaunchForce;

        //at max charge, not yet fired
        if (m_CurrentLaunchForce >= m_MaxLaunchForce && !m_Fired)
        {
            m_CurrentLaunchForce = m_MaxLaunchForce;
            Fire();
        }

        // have we pressed the fire button for the first time
        else if (CnInputManager.GetButtonDown(m_FireButton))
        {
            m_Fired = false;
            m_CurrentLaunchForce = m_MinLaunchForce;

            m_ShootingAudio.clip = m_ChargingClip;
            m_ShootingAudio.Play();
        }

        //Holding the fire button, not yet fired
        else if (CnInputManager.GetButton(m_FireButton) && !m_Fired)
        {
            m_CurrentLaunchForce += m_ChargeSpeed * Time.deltaTime;

            m_AimSlider.value = m_CurrentLaunchForce;
        }

        //We released the fire button, having not fired yet
        else if (CnInputManager.GetButtonUp(m_FireButton) && !m_Fired)
        {
            Fire();
        }
    }