예제 #1
0
    // Update is called once per frame
    void Update()
    {
        transform.position += new Vector3(vitesse, 0, 0);
        if (Time.fixedTime - temps >= ecart)
        {
            temps = Time.fixedTime;

            //On tire dans les 4 directions
            //gob = (GameObject)(Instantiate(obj,transform.position,new Quaternion()));
            gob = SimplePool.Spawn(obj, transform.position, new Quaternion());
            gob.transform.localScale = new Vector3(0.6f, 0.6f, 1);
            ProjectileSimple proj = gob.GetComponent <ProjectileSimple>();
            proj.setVitesse(0.02f);
            proj.setDirection(new Vector2(0, -1));
            proj.setDegat(1);

            //gob = (GameObject)(Instantiate(obj,transform.position,new Quaternion()));
            gob = SimplePool.Spawn(obj, transform.position, new Quaternion());
            gob.transform.localScale = new Vector3(0.6f, 0.6f, 1);
            proj = gob.GetComponent <ProjectileSimple>();
            proj.setVitesse(0.02f);
            proj.setDirection(new Vector2(0, 1));
            proj.setDegat(1);

            //gob = (GameObject)(Instantiate(obj,transform.position,new Quaternion()));
            gob = SimplePool.Spawn(obj, transform.position, new Quaternion());
            gob.transform.localScale = new Vector3(0.6f, 0.6f, 1);
            proj = gob.GetComponent <ProjectileSimple>();
            proj.setVitesse(0.02f);
            proj.setDirection(new Vector2(1, 0));
            proj.setDegat(1);

            //gob = (GameObject)(Instantiate(obj,transform.position,new Quaternion()));
            gob = SimplePool.Spawn(obj, transform.position, new Quaternion());
            gob.transform.localScale = new Vector3(0.6f, 0.6f, 1);
            proj = gob.GetComponent <ProjectileSimple>();
            proj.setVitesse(0.02f);
            proj.setDirection(new Vector2(-1, 0));
            proj.setDegat(1);
        }
    }
예제 #2
0
파일: Joueur.cs 프로젝트: SeverinM/Space
    // Update is called once per frame
    void Update()
    {
        if (suivre && (Input.GetAxis("Mouse X") != 0) || (Input.GetAxis("Mouse Y") != 0))           //Le joueur ne suit la souris que si un mouvement est detecté
        {
            LerpPosition       = 0;
            Cursor.visible     = true;
            transform.position = new Vector3(transform.position.x, transform.position.y, 0);
        }

        if (Cursor.visible)
        {
            LerpPosition      += Time.fixedDeltaTime * 4;
            transform.position = Vector3.Lerp(transform.position, Camera.main.ScreenToWorldPoint(Input.mousePosition), LerpPosition);
            transform.position = new Vector3(transform.position.x, transform.position.y, 0);
        }

        if (Input.GetKey(KeyCode.LeftArrow))
        {
            transform.position += new Vector3(-Variables.sensiX, 0, 0);
            Cursor.visible      = false;
        }

        if (Input.GetKey(KeyCode.RightArrow))
        {
            transform.position += new Vector3(Variables.sensiX, 0, 0);
            Cursor.visible      = false;
        }

        if (Input.GetKey(KeyCode.UpArrow))
        {
            transform.position += new Vector3(0, Variables.sensiY, 0);
            Cursor.visible      = false;
        }

        if (Input.GetKey(KeyCode.DownArrow))
        {
            transform.position += new Vector3(0, -Variables.sensiY, 0);
            Cursor.visible      = false;
        }

        if ((Input.GetMouseButton(0) || Input.GetKey(KeyCode.Space) || Variables.autoFire) && Time.fixedTime - temps >= ecart)
        {
            GameObject.Find("Son").GetComponent <AudioSource> ().clip = sontir;
            GameObject.Find("Son").GetComponent <AudioSource> ().Play();

            temps = Time.fixedTime;

            //instance = (GameObject)(Instantiate (gob, transform.position , new Quaternion ()));
            instance     = SimplePool.Spawn(gob, transform.position, new Quaternion());
            instance.tag = "AllyBullet";
            instance.GetComponent <SpriteRenderer> ().color = Color.white;

            instance.transform.Rotate(Vector3.forward * -270);
            ProjectileSimple proj = instance.GetComponent <ProjectileSimple> ();
            proj.setVitesse(0.07f);
            proj.setDirection(new Vector2(0, 0.1f));
            proj.setPosition(transform.position);
            proj.setDegat(degat);
            if (boost2)
            {
                proj.setPerforant(true);
            }
            else
            {
                proj.setPerforant(false);
                proj.setDegat(degat);
            }

            if (boost)
            {
                //instance = (GameObject)(Instantiate (gob, transform.position , new Quaternion ()));
                instance = SimplePool.Spawn(gob, transform.position, new Quaternion());
                instance.transform.Rotate(Vector3.forward * -300);
                instance.tag = "AllyBullet";
                instance.GetComponent <SpriteRenderer> ().color = Color.white;

                proj = instance.GetComponent <ProjectileSimple> ();
                proj.setVitesse(0.07f);
                proj.setDirection(new Vector2(0.05f, 0.1f));
                proj.setPosition(transform.position);
                proj.setDegat(degat);
                if (boost2)
                {
                    proj.setPerforant(true);
                }
                else
                {
                    proj.setPerforant(false);
                    proj.setDegat(degat);
                }

                //instance = (GameObject)(Instantiate (gob, transform.position , new Quaternion ()));
                instance     = SimplePool.Spawn(gob, transform.position, new Quaternion());
                instance.tag = "AllyBullet";
                instance.GetComponent <SpriteRenderer> ().color = Color.white;

                instance.transform.Rotate(Vector3.forward * -240);
                proj = instance.GetComponent <ProjectileSimple> ();
                proj.setVitesse(0.07f);
                proj.setDirection(new Vector2(-0.05f, 0.1f));
                proj.setPosition(transform.position);
                proj.setDegat(degat);
                if (boost2)
                {
                    proj.setPerforant(true);
                }
                else
                {
                    proj.setPerforant(false);
                    proj.setDegat(degat);
                }
            }
        }

        if (Time.fixedTime > temps2 + retard && invincible)
        {
            ChangerEtat();
        }

        if (temps3 < Time.fixedTime)           //A chaque frame on verifie que le bonus est terminé
        {
            boost = false;
            ecart = 0.2f;
        }

        if (temps5 < Time.fixedTime && boost2)
        {
            degat  = 1;
            boost2 = false;
        }
    }