예제 #1
0
    void gethurt()
    {
        if (health > 0)
        {
            anim.SetTrigger("impact");
            SEcontrol.impactseinter();
            SEcontrol.takedamageseinter();
            if (gamemanage.p2attack)
            {
                gamemanage.p1damage();
            }
            else if (gamemanage.p1attack)
            {
                gamemanage.p2damage();
            }

            health -= 10;
            gamemanage.p1attack = false;
            gamemanage.p2attack = false;
        }
        else
        {
            die();
        }
    }
예제 #2
0
 public void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "target")
     {
         GameObject gm = GameObject.Find("Gamescore");
         if (gm != null)
         {
             //get the scoreMgr component and add to the score
             scoremanage sm = gm.GetComponent <scoremanage>();
             if (sm != null)
             {
                 sm.addscore();
                 SEcontrol.PlayImpactSound();
                 Destroy(this.gameObject);
             }
         }
     }
     else
     {
         GameObject gm = GameObject.Find("Gamescore");
         if (gm != null)
         {
             //get the scoreMgr component and add to the score
             scoremanage sm = gm.GetComponent <scoremanage>();
             if (sm != null)
             {
                 sm.delscore();
                 SEcontrol.PlayMissSound();
                 Destroy(this.gameObject);
             }
         }
     }
 }
예제 #3
0
 // Use this for initialization
 void Start()
 {
     if (This != null)
     {
         Debug.Log("saber:: error, more than one saber instance enoucntered, using previous verison");
     }
     else
     {
         This = this;
     }
 }
예제 #4
0
 // Use this for initialization
 void Start()
 {
     asource = this.gameObject.GetComponent <AudioSource>();
     if (This != null)
     {
         Debug.Log("SoundMgr:: error, more than one SoundMgr instance enoucntered, using previous verison");
     }
     else
     {
         This = this;
     }
 }
예제 #5
0
    public void Tankfire()
    {
        GameObject projInstance =
            (GameObject)Instantiate(buttlet, bullletloc.transform.position, bullletloc.transform.rotation);

        if (projInstance != null)
        {
            SEcontrol.PlayFireSound();
            Rigidbody bullectrg = projInstance.GetComponent <Rigidbody>();
            if (bullectrg != null)
            {
                buttletcontrol = projInstance.transform.forward;     // ?
                buttletcontrol.Scale(new Vector3(bulletspeed, bulletspeed, bulletspeed));
                bullectrg.AddForce(buttletcontrol);
            }
        }
    }
예제 #6
0
 void die()
 {
     anim.SetTrigger("dead");
     SEcontrol.fdieseinter();
     if (player == "p1")
     {
         selectmanage.p1++;
     }
     else
     {
         selectmanage.p2++;
     }
     if (selectmanage.p1 == 2 || selectmanage.p2 == 2)
     {
         SceneManager.LoadScene("win");
     }
     else
     {
         gamemanage.player1exist = false;
         gamemanage.player2exist = false;
         SceneManager.LoadScene("ingame");
     }
 }
예제 #7
0
    public void fsaberconrol()
    {
        axis.x = Input.GetAxis(player + "Vertical");
        axis.z = Input.GetAxis(player + "Horizontal");

        if (health > 0)
        {
            if (anim != null)
            {
                //attackcontrol
                if (Input.GetButtonDown(player + "Fire3"))
                {
                    anim.SetTrigger("attack");
                    SEcontrol.attackseinter();
                    if (player == "p1")
                    {
                        gamemanage.p1attack = true;
                    }
                    else
                    {
                        gamemanage.p2attack = true;
                    }
                    Invoke("resetattack", 1.0f);
                }
                //projectile
                if (Input.GetButtonDown(player + "Fire4"))
                {
                    anim.SetTrigger("projectile");
                    Invoke("projectilemanager", 1.0f);
                    SEcontrol.attackseinter();
                    if (player == "p1")
                    {
                        gamemanage.p1attack = true;
                    }
                    else
                    {
                        gamemanage.p2attack = true;
                    }
                    Invoke("resetattack", 1.0f);
                }


                //crouch
                if (Input.GetButton(player + "Fire1"))
                {
                    anim.SetBool("crouch", true);
                    if (Input.GetButton(player + "Fire5"))
                    {
                        anim.SetBool("crouchblock", true);
                    }
                }
                else
                {
                    anim.SetBool("crouch", false);
                    anim.SetBool("block", false);
                }

                //block
                if (Input.GetButton(player + "Fire5"))
                {
                    anim.SetBool("block", true);
                }
                else
                {
                    anim.SetBool("block", false);
                }

                //taunt
                if (Input.GetButtonDown(player + "Fire6"))
                {
                    anim.SetTrigger("taunt");
                    SEcontrol.tauntseinter();
                }

                //jump
                if (Input.GetButtonDown(player + "Fire2"))
                {
                    anim.SetTrigger("jump");
                    SEcontrol.jumplandseinter();
                }

                //movecontrol
                anim.SetFloat("vaxis", axis.z);
                anim.SetFloat("haxis", axis.x);

                if (axis.x != 0 || axis.z != 0)
                {
                    anim.SetBool("moveornot", true);
                    movement.Set(axis.z, 0f, axis.x);
                    movement = movement.normalized * speed * Time.deltaTime;
                    transform.Translate(movement);
                    SEcontrol.stepseinter();
                }
                else if (axis.x == 0 && axis.z == 0)
                {
                    anim.SetBool("moveornot", false);
                }
            }
        }

        if (health <= 0)
        {
            die();
        }
    }
예제 #8
0
 public void TankCtrlUpdate()
 {
     trackconrol();
     if (Ltext.text == "Forward" && Rtext.text == "Stop")
     {
         transform.Translate(1.0f * Vector3.back * 0.1f);
         transform.Rotate(Vector3.up, 1.0f);
         SEcontrol.PlayTankmove();
     }
     if (Ltext.text == "Backward" && Rtext.text == "Stop")
     {
         transform.Translate(-1.0f * Vector3.back * 0.1f);
         transform.Rotate(Vector3.up, 1.0f);
         SEcontrol.PlayTankmove();
     }
     if (Ltext.text == "Stop" && Rtext.text == "Forward")
     {
         transform.Translate(1.0f * Vector3.back * 0.1f);
         transform.Rotate(Vector3.up, -1.0f);
         SEcontrol.PlayTankmove();
     }
     if (Ltext.text == "Stop" && Rtext.text == "Backward")
     {
         transform.Translate(-1.0f * Vector3.back * 0.1f);
         transform.Rotate(Vector3.up, -1.0f);
         SEcontrol.PlayTankmove();
     }
     if (Ltext.text == "Forward" && Rtext.text == "Forward")
     {
         transform.Translate(1.0f * Vector3.back * 0.1f);
         SEcontrol.PlayTankmove();
     }
     if (Ltext.text == "Backward" && Rtext.text == "Backward")
     {
         transform.Translate(-1.0f * Vector3.back * 0.1f);
         SEcontrol.PlayTankmove();
     }
     if (Ltext.text == "Forward" && Rtext.text == "Backward")
     {
         transform.Rotate(Vector3.up, 1.0f);
         SEcontrol.PlayTankmove();
     }
     if (Ltext.text == "Backward" && Rtext.text == "Forward")
     {
         transform.Rotate(Vector3.up, -1.0f);
         SEcontrol.PlayTankmove();
     }
     if (Ltext.text == "Stop" && Rtext.text == "Stop")
     {
         //SEcontrol.PlayTankidle();
     }
     //directcontrol.x = Input.GetAxis("Horizontal");
     //directcontrol.z = Input.GetAxis("Vertical");
     //Vector3 vDisp = Vector3.back;
     //transform.Translate(directcontrol.z * vDisp * 0.1f);
     //transform.Translate(directcontrol.x * Vector3.left * 0.1f);
     //transform.Rotate(Vector3.up, directcontrol.x);
     if (Input.GetKeyDown("space"))
     {
         Tankfire();
         //up down left right control
     }
 }