Пример #1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        rb.velocity           = transform.TransformDirection(Vector3.forward * 10);
        WorldControlScript    = GameObject.Find("WorldController").GetComponent <WorldControl>();
        PlayerControllScript1 = GameObject.Find("PlayerCube1").GetComponent <PlayerControll>();
        PlayerControllScript2 = GameObject.Find("PlayerCube2").GetComponent <PlayerControll2>();
        if (PlayerControllScript1.ZaWarudo == true || PlayerControllScript2.ZaWarudo == true)
        {
            rb.velocity = rb.velocity * 0;
        }

        distanceMoved += Vector3.Distance(transform.position, startPosition);
        if (distanceMoved > 50000f)
        {
            Invoke("Destroy", 0);
        }
    }
Пример #2
0
    // Update is called once per frame
    void FixedUpdate()
    {
        PlayerOneScript = GameObject.Find("PlayerCube1").GetComponent <PlayerControll>();
        PlayerOneWorld  = PlayerOneScript.ZaWarudo;
        PlayerTwoScript = GameObject.Find("PlayerCube2").GetComponent <PlayerControll2>();
        PlayerTwoWorld  = PlayerOneScript.ZaWarudo;

        if (PlayerOneWorld == true || PlayerTwoWorld == true)
        {
            if (PlayerOneCD == false)
            {
                {
                    ZaWarudo1   = true;
                    PlayerOneCD = true;
                    Invoke("PlayerOneWorldControl", 5f);
                    Invoke("PlayerOneWorldCD", 10f);
                }
            }
        }
    }
Пример #3
0
    void FixedUpdate()
    {
        if (HP < 1)
        {
            Invoke("Death", 0f);
        }
        //placemode
        PlayerControll2       = GameObject.Find("PlayerCube2").GetComponent <PlayerControll2>();
        WorldControlScript    = GameObject.Find("WorldController").GetComponent <WorldControl>();
        TimeCoordinates[0, 0] = transform.position.x;
        TimeCoordinates[0, 1] = transform.position.z;
        TimeCoordinates[0, 2] = transform.rotation.y;
        if (PlayerControll2.ZaWarudo == true)
        {
            placemode = false;
        }
        if (stun == false)
        {
            if (ZaWarudo == true || (ZaWarudo == false && PlayerControll2.ZaWarudo == false))
            {
                //placemode trigger

                if (Input.GetButtonDown("Construction1"))

                {
                    //placecontainter = placemode;
                    rb.velocity = new Vector3(0, 0, 0);
                    placemode   = !placemode;
                    objectLineRenderer.enabled = !objectLineRenderer.enabled;
                }

                //rb.velocity = new Vector3(Input.GetAxis("Horizontal") * 2, 0, Input.GetAxis("Vertical") * 2);
                if (placemode == false)
                {
                    if (Mathf.Abs(Input.GetAxis("Horizontal1")) > 0.0f || Mathf.Abs(Input.GetAxis("Vertical1")) > 0.0f)
                    {
                        rb.velocity = new Vector3(Input.GetAxis("Horizontal1") * speed_coef, 0, Input.GetAxis("Vertical1") * speed_coef);
                        rb.rotation = Quaternion.Euler(new Vector3(0, (Mathf.Atan2(Input.GetAxis("Horizontal1"), Input.GetAxis("Vertical1")) * Mathf.Rad2Deg), 0));
                        rotation    = transform.localEulerAngles.y;
                    }
                    if (Mathf.Abs(Input.GetAxis("Horizontal1")) <= 0.03f && Mathf.Abs(Input.GetAxis("Vertical1")) <= 0.03f)
                    {
                        transform.localEulerAngles = new Vector3(0, rotation, 0);
                        rb.velocity = new Vector3(0, 0, 0);
                    }

                    //if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
                    // {

                    //     transform.forward = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
                    //
                    //    rb.velocity = transform.forward * playerspeed;

                    // }
                    // if (Input.GetAxis("Horizontal") == 0 && Input.GetAxis("Vertical") == 0)
                    // {
                    //     if (stun == false)
                    //    {
                    //        rb.velocity = new Vector3(0, 0, 0);
                    //   }
                    // }
                    //if (new Vector3())
                }
                if (placemode == true)
                {
                    rb.rotation = Quaternion.Euler(new Vector3(0, (Mathf.Atan2(Input.GetAxis("Horizontal1"), Input.GetAxis("Vertical1")) * Mathf.Rad2Deg), 0));
                }


                if (Input.GetButtonDown("Balista1") == true && placemode == true && balistacd < 0f)
                {
                    Rigidbody clone;
                    clone     = Instantiate(trap1, transform.position + new Vector3(0, 0, 2), transform.rotation);
                    balistacd = balistamaxcd;
                    PlaySFX(balistaplacedsfx);
                }
                if (Input.GetButtonDown("Kapkan1") && kapkancd <= 0)

                {
                    kapkancd = kapkanmaxcd;
                }


                if (Input.GetButtonDown("Mine1") && minecd <= 0)

                {
                    minecd = minemaxcd;
                    Vector3 mineoffset;
                    mineoffset.x = Input.GetAxisRaw("Horizontal1");
                    mineoffset.y = 0f;
                    mineoffset.z = Input.GetAxisRaw("Vertical1");
                    Rigidbody mine_clone;
                    mine_clone = Instantiate(mineprefab, transform.position + 3 * mineoffset, transform.rotation);
                }


                if (Input.GetButtonDown("Spikes1") && spikescd <= 0)

                {
                    spikescd = spikesmaxcd;
                    Vector3 spikesoffset;
                    spikesoffset.x = Input.GetAxisRaw("Horizontal1");
                    spikesoffset.y = 0f;
                    spikesoffset.z = Input.GetAxisRaw("Vertical1");
                    Rigidbody mine_clone;
                    mine_clone = Instantiate(spikesprefab, transform.position + 3 * spikesoffset, transform.rotation);
                }
            }



            TimeShift = Input.GetButton("Timeshift1");
            if (TimeShift == true && timeshiftcd < 0f)
            {
                timeshiftcd = timeshiftmaxcd;
                PlaySFX(timeshiftsfx);
                if (stun == true)
                {
                    Invoke("StunOver", 0f);
                }
                stun = true;
                StartCoroutine(Tracer());
                stun = false;
            }
        }
        ZaWarudo = Input.GetButton("Zawarudo1");
        if (ZaWarudo == true && zawarudocd < 0f)
        {
            zawarudocd        = zawarudomaxcd;
            playerlight.color = Color.blue;
            PlaySFX(zawarudosfx);
            if (stun == true)
            {
                Invoke("StunOver", 0f);
            }
            ZaWarudo = true;
            Invoke("PlayerWorldControl", 5f);
        }
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            pausecanvas.enabled = true;
        }
    }