Пример #1
0
    // Update is called once per frame
    void Update()
    {
        goo gooTest = gooPool.GetComponent <goo>();

        if (teleporting == 0)
        {
            if (Input.GetKey(KeyCode.W))
            {
                animator.SetFloat("forward", 1);
                animator.SetFloat("speed", 0);
                animator.SetFloat("right", 0);
                animator.SetFloat("left", 0);
            }
            else
            {
                animator.SetFloat("forward", 0);
            }
            if (Input.GetKey(KeyCode.S))
            {
                animator.SetFloat("speed", 1);
                animator.SetFloat("right", 0);
                animator.SetFloat("left", 0);
                animator.SetFloat("forward", 0);
            }
            else
            {
                animator.SetFloat("speed", 0);
            }
            if (Input.GetKey(KeyCode.D))
            {
                animator.SetFloat("right", 1);
                animator.SetFloat("forward", 0);
                animator.SetFloat("left", 0);
                animator.SetFloat("speed", 0);
            }
            else
            {
                animator.SetFloat("right", 0);
            }
            if (Input.GetKey(KeyCode.A))
            {
                animator.SetFloat("left", 1);
                animator.SetFloat("speed", 0);
                animator.SetFloat("forward", 0);
                animator.SetFloat("right", 0);
            }
            else
            {
                animator.SetFloat("left", 0);
            }

            if (Input.GetKeyDown(KeyCode.W) && controller.velocity.x == 0 && legs == 0)
            {
                if (!audioSource.isPlaying)
                {
                    audioSource.clip = moving;
                    audioSource.Play();
                }
            }
            if (Input.GetKeyDown(KeyCode.S) && !Input.GetKeyDown(KeyCode.W) && controller.velocity.x > 0 && legs == 0)
            {
                if (!audioSource.isPlaying)
                {
                    audioSource.clip = braking;
                    audioSource.Play();
                }
            }


            if (legs == 1)
            {
                float v = Input.GetAxis("Vertical");
                animLegs.SetFloat("speed", v);
                legModel.SetActive(true);
                noLegModel.SetActive(false);
            }
            float yStore = moveDirection.y;
            moveDirection = (transform.forward * Input.GetAxis("Vertical") * moveSpeed) + (transform.right * Input.GetAxis("Horizontal") * moveSpeed);

            moveDirection.y = yStore;
            if (controller.isGrounded)
            {
                moveDirection.y = 0f;
            }
            if (controller.isGrounded && legs == 1 && gooTest.gooJump == 0)
            {
                moveDirection.y = 0f;
                if (Input.GetButtonDown("Jump"))
                {
                    if (!audioSource.isPlaying)
                    {
                        audioSource.clip = jump;
                        audioSource.Play();
                        moveDirection.y = jumpForce;
                    }
                }
            }

            moveDirection.y = moveDirection.y + (Physics.gravity.y * gravityScale * Time.deltaTime);
            controller.Move(moveDirection * Time.deltaTime);
            if (arm == 1)
            {
                armModel.SetActive(true);
                if (Input.GetKey(KeyCode.Q))
                {
                    animationArm.SetFloat("moveArm", 1);
                    if (Input.GetKeyDown(KeyCode.Q))
                    {
                        if (!audioSource.isPlaying)
                        {
                            audioSource.clip = armClip;
                            audioSource.Play();
                        }
                    }
                }
                else
                {
                    animationArm.SetFloat("moveArm", 0);
                }
            }

            if (armM == 1)
            {
                armMagnet.SetActive(true);
            }

            if (controller.transform.position.y > 3 && !controller.isGrounded)
            {
                if (!audioSource.isPlaying)
                {
                    audioSource.clip = fall;
                    audioSource.Play();
                }
            }
        }
    }
Пример #2
0
        private int d2(cla ser, goo fde, int ddf, int dfdf, int dfdd)
        {


            if (dfd(ser))
            {
                if (fde == goo.foo)
                    return 1;
                else
                    return -1;
            }
            if (sdf(ser))
            {
                if (fde == goo.foo)
                    return -1;
                else
                    return 1;
            }
            if (ddf == 0)
            {
                return 0;
            }

            int doo;
            int sh;
            goo shoo;
            if (fde == goo.foo)
            {
                shoo = goo.MinPlayer_Opponent;
                doo = int.MaxValue;
            }
            else
            {
                doo = int.MinValue;
                shoo = goo.foo;
            }
            Tuple<int, int> w;
            cla e;
            Dictionary<Tuple<int, int>, cla> f = new Dictionary<Tuple<int, int>, cla>();
            Stack<Tuple<int, int>> aq = ser.foo();
            while (!g() && aq.Count > 0)
            {
                w = aq.Pop();
                e = new cla(ser, w);

                f[w] = e;

                sh = d2(e, shoo, ddf - 1, dfdf, dfdd);
                if (shoo == goo.foo)
                {
                    doo = Math.Max(doo, sh);
                    dfdf = Math.Max(dfdf, sh);
                    if (doo >= dfdd || doo == 1)
                    {
                        //Console.WriteLine("Tree cutted at depth {0} by alpha beya pruning!", depthLevel);
                        break;
                    }
                }
                else
                {
                    doo = Math.Min(doo, sh);
                    dfdd = Math.Min(dfdd, sh);
                    if (doo <= dfdf || doo == -1)
                    {
                        //Console.WriteLine("Tree cut at depth {0} by alpha beya pruning!", depthLevel);
                        break;
                    }

                }
            }
            return doo;

        }