コード例 #1
0
    void Start()
    {
        Humanoid h = new Humanoid();
        zombie   z = h as zombie;

        Debug.Log(z);
    }
コード例 #2
0
 // Update is called once per frame
 void Update() // update player information
 {
     // move
     if (health <= 0)
     {
         return;
     }
     updatePosition();
     // be able to shoot every frame
     shoot_cooldown -= Time.deltaTime;
     // Time.deltaTime is a variable, depending on CPU clock time
     // FPS高 => Time.deltaTime smaller
     if (Input.GetMouseButton(0) && shoot_cooldown <= 0)
     {
         // reset cooldown
         shoot_cooldown = 0.1f;
         audio_source.PlayOneShot(audio_clip);
         GameManager.Instance.SetBullets(1);
         // shoot the bullet
         RaycastHit hit;
         bool       hitOrNot = Physics.Raycast(muzzle_transform.position, camera_transform.TransformDirection(Vector3.forward), out hit, 100, layer);
         if (hitOrNot)
         {
             if (hit.collider.tag.Equals("enemy"))
             {
                 zombie zombie = hit.collider.GetComponentInParent <zombie>();
                 zombie.OnDamage(1);
             }
             Instantiate(particle_effect, hit.point, hit.transform.rotation);
         }
     }
 }
コード例 #3
0
    //Shoot gun
    void Shoot()
    {
        GameObject gunShot = Instantiate(GunShot, this.transform.position, this.transform.rotation) as GameObject;

        //weapon animation
        animationController.fireWeapon();

        RaycastHit hit;

        muzzleflash.Play();
        if (Physics.Raycast(cam.transform.position, cam.transform.forward, out hit, range))
        {
            Target target = hit.transform.GetComponent <Target>();
            if (target != null)
            {
                target.TakeDamage(damage);
                Debug.Log("hit character");
            }

            if (hit.rigidbody != null)
            {
                hit.rigidbody.AddForce(-hit.normal * impactForce);
            }

            zombie z = hit.collider.gameObject.GetComponent <zombie>();
            if (z != null)
            {
                z.takeDamage(10);
            }

            GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
            Destroy(impactGO, 0.3f);
        }
    }
コード例 #4
0
    //private void OnTriggerEnter(Collider other)
    //{
    //    if (other.transform.tag == "zombie")
    //    {
    //        Vector3 dir = other.transform.position - transform.position;
    //        //Vector3 knockBackPos = other.transform.position * (-dir.normalized * knockBack);
    //        Vector3 knockBackPos = other.transform.position + (dir.normalized * knockBack);
    //        knockBackPos.y = 1;
    //        other.transform.position = knockBackPos;
    //        Explosion();
    //    }
    //}

    void Damage(Transform zombie, float damageAmount)
    {
        zombie z = zombie.GetComponent <zombie>();

        if (z != null)
        {
            z.TakeDamage(damageAmount);
        }
    }
コード例 #5
0
    // Update is called once per frame
    void Update()
    {
        zombie target = GetZombie();

        if (target != null)
        {
            Debug.DrawLine(transform.position, GetZombie().transform.position, Color.red, 3f);
        }
    }
コード例 #6
0
ファイル: bullet.cs プロジェクト: VanJackal/ZombieHouse
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Debug.Log("hit");
        zombie hit = collision.gameObject.GetComponent <zombie>();

        if (hit != null)
        {
            hit.damage(damage);
        }
        Destroy(gameObject);
    }
コード例 #7
0
    void Update()
    {
        // zombie target = Getzombie(); puede ser una variable null o zombie
        zombie target = Getzombie();

        if (target != null)
        {
            //Debug.DrawLine (); comienza en una posicion y va a otra
            Debug.DrawLine(transform.position, Getzombie().transform.position);
        }
    }
コード例 #8
0
 public void Explode()
 {
     ExplosionSound.Play();
     Collider2D[] objectsInRange = Physics2D.OverlapBoxAll(transform.position, new Vector2(radius, radius), 0);
     foreach (Collider2D col in objectsInRange)
     {
         zombie script = col.GetComponent <zombie>();
         if (script)
         {
             script.TakeDamage(damage);
         }
     }
 }
コード例 #9
0
ファイル: zombir_bumper.cs プロジェクト: jorik041/unity_dave2
    void OnTriggerEnter2D(Collider2D col)
    {
        zombie z = transform.parent.gameObject.GetComponent <zombie>();        //todo проверить, точно ли здесь получать?

        if (col.gameObject.CompareTag("World"))
        {
            switch (z.direction)
            {
            case Directions.LEFT:
                z.direction = Directions.RIGHT;
                break;

            case Directions.RIGHT:
                z.direction = Directions.LEFT;
                break;
            }
            ;
        }
    }
コード例 #10
0
    // Use this for initialization
    void Start()
    {
        zombie zombie = new zombie();
        player player = new player();


        player.TakeDamage(zombie.Attack());
        player.TakeDamage(zombie.AcidPukeAttack());

        player.Die();

        zombie[] zombies = new zombie[100];

        for (int i = 0; i < zombies.Length; i++)
        {
            zombies[i] = new zombie();
            Debug.Log("Creating Zombie #:" + i);
        }
    }
コード例 #11
0
    void Start()
    {
        zombie firstZombie  = new zombie("stubbs");
        zombie secondZombie = new zombie("jackson");
        zombie thirdZombie  = new zombie("bob");
        var    SomeThings   =
            new ThreeThings <zombie>(firstZombie, secondZombie, thirdZombie);

        Debug.Log(SomeThings);
        var whatAmI = 1;

        Debug.Log(whatAmI.GetType());
        var mixedThings = new TwoThings <zombie, float>();

        mixedThings.AssignThings(firstZombie, 1.0f);
        LogTwoThings(mixedThings.GetFirstThing(), mixedThings.GetSecondThing());
        var t = GetComponent <Transform>();

        if (t is Transform)
        {
            t.localPosition = new Vector3(1, 0, 0);
        }
    }
コード例 #12
0
ファイル: Generics.cs プロジェクト: yuurule/OkitaUnity
    void Start()
    {
        zombie firstZombie  = new zombie("stubbs");
        zombie secondZombie = new zombie("jackson");
        zombie thirdZombie  = new zombie("bob");
        // var keyword is very open keyword - It tells the computer to expect any data type and it means to implicitly get a type once it's been assigned.
        // Only after the actual object is crated and assigned to the identifier that was created with var will the identifier turn into a type.
        var SomeThings = new ThreeThings <zombie>(firstZombie, secondZombie, thirdZombie);

        Debug.Log(SomeThings);
        var whatAmI = 1;

        Debug.Log(whatAmI.GetType());
        var mixedThings = new TwoThings <zombie, float>();

        mixedThings.AssignThings(firstZombie, 1.0f);
        LogTwoThings(mixedThings.GetFirstThing(), mixedThings.GetSecondThing());
        var t = GetComponent <Transform>();

        if (t is Transform)
        {
            t.localPosition = new Vector3(1, 0, 0);
        }
    }
コード例 #13
0
 private void Start()
 {
     animator           = GetComponent <Animator>();
     zombieScript       = GetComponent <zombie>();
     transform.position = new Vector2(transform.position.x, transform.position.y + 0.5f);
 }
コード例 #14
0
 void Start()
 {
     BaseScript = transform.root.GetComponent <zombie>();
 }
コード例 #15
0
        private void oyunSecme()
        {
            RadioButton radioBtn = this.Controls.OfType <RadioButton>()
                                   .Where(x => x.Checked).FirstOrDefault();

            if (radioBtn != null)
            {
                switch (radioBtn.Name)
                {
                case "radio_faceLock":

                    faceLock faceLock = new faceLock();
                    this.Hide();
                    faceLock.Show();
                    break;

                case "radio_snap":

                    snap snap = new snap();
                    this.Hide();
                    //snap.Show();
                    break;

                case "radio_shyPanda":

                    shypanda shypanda = new shypanda();
                    this.Hide();
                    shypanda.Show();
                    break;

                case "radio_zombieEscape":

                    zombie zombie = new zombie();
                    this.Hide();
                    zombie.Show();
                    break;

                case "radio_chameleon":

                    chameleon chameleon = new chameleon();
                    this.Hide();
                    chameleon.Show();
                    break;


                case "radio_colors":

                    colors color = new colors();
                    this.Hide();
                    color.Show();
                    break;

                case "radio_imageText":

                    imageToTextGame game = new imageToTextGame();
                    this.Hide();
                    game.Show();
                    break;

                case "radio_figureGame":

                    figureGame figure = new figureGame();
                    this.Hide();
                    figure.Show();
                    break;

                case "radio_rockPaperScissors":

                    rockpaperscissors rockpaperscissors = new rockpaperscissors();
                    this.Hide();
                    rockpaperscissors.Show();
                    break;

                case "radio_titanic":

                    titanic titanic = new titanic();
                    this.Hide();
                    titanic.Show();
                    break;
                }
            }
        }
コード例 #16
0
    //"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
    void Start()
    {
        // al momento de presionar  play en unity  el  crea a los zombies y  aldeanos y se va sumado ala  variable del limite
        //
        Numero_zombi = Random.Range(5, limite + 1);
        Numero_gente = limite - Numero_zombi;
        Numero_gente = Random.Range(0, Numero_gente + 1);

        for (int i = 0; i < Numero_zombi; i++) // usa los casos de  los colores  para los zombies hasta que se cumpla
        {
            colorzombie = Random.Range(0, 3);
            zombie z = new zombie(colorzombie);
        }



        // array para almacenar los datos de los nombre  de los aldeanos

        string[] Nombre = new string[]
        {
            "rodrigo",
            "robin",
            "torrez",
            "pequeñi",
            "don juan",
            "blue",
            "saltin",
            "sergio",
            "estevan",
            "tu tia en tanga",
            "tu colega ",
            "camilo",
            "crespos",
            "alexis",
            "hay te va sam pedro :v",
            "fly",
            "jason",
            "andrey",
            "atreus",
            "artion",
            "alegandra",
            "zeus",
            "mauricio",
            "puto el que lo lea",
            "el wilson bolso ",
            "el brayan",
            "el benites ",
            "carlos",
        };
        for (int i = 0; i < Numero_gente; i++) // genera a los aldenos  y su nombre y edad hasta que cumpla su condicion
        {
            intNombre   = Random.Range(0, 20);
            NNombre     = Nombre[intNombre];
            Numero_edad = Random.Range(15, 100);

            Gente genera_gente = new Gente(NNombre, Numero_edad);


            print("darmensaje " + " hola mi nombre es " + NNombre + " y tengo " + Numero_edad);
        }
    }
コード例 #17
0
    void Start()
    {
        Ezombi = Random.Range(5, limitecreacion + 1);
        Ngente = limitecreacion - Ezombi;
        Ngente = Random.Range(0, Ngente + 1);

        for (int i = 0; i < Ezombi; i++)
        {
            colorzombie = Random.Range(0, 3);
            zombie z = new zombie(colorzombie);
        }



        //string[] names = new string[]
        //     {
        //          "stubbs",
        //          "rob",
        //          "white"
        //     };
        //for (int i = 0; i < names.Length; i++)
        //{
        //    zombie z = new zombie(names[i], Random.Range(10, 15));
        //    Debug.Log(z.name);
        //}



        string[] Nombre = new string[]
        {
            "stubbs",
            "rob",
            "toreto",
            "pequeño tim",
            "don carlos",
            "carlos 1",
            "carlos 2",
            "sergio",
            "stevan",
            "tu tia en tanga",
            "panzerotte del sena ",
            "cj",
            "hay te voy sam pedro",
            "san peludo",
            "alexianismo :v",
            "puto alexis",
            "jason",
            "andrey",
            "atreus",
            "artion",
            "kratos",
            "zeus",
            "loki",
            "puto el que lo lea",
            "wilson",
            "el brayan",
            "venites ",
            "sam pedro",
        };
        for (int i = 0; i < Ngente; i++)
        {
            //Gente z = new Gente(Nombre[i], Random.Range(0,9));
            //Debug.Log(z.Nombres);

            intNombre = Random.Range(0, 20);
            NNombre   = Nombre[intNombre];
            Nedad     = Random.Range(15, 100);

            Gente gentevivita = new Gente(NNombre, Nedad);


            Debug.Log(" hola mi nombre es " + NNombre + " y tengo " + Nedad);
        }
    }
コード例 #18
0
    void Start()
    {
        zombieSingle = GetComponent <zombie>();        // get reference to the zombie instance

        target = guidePoints.guidePointsArray[0];
    }
コード例 #19
0
ファイル: survivorAI.cs プロジェクト: Nican/imgd4100
    public void doShoot(survivorAI enemy, zombie zombie)
    {
        //Debug.Log("doing AI shooting");
        if(enemy != null)
            rotateToShoot(enemy.transform);
        else
            rotateToShoot(zombie.transform);
        float random = Random.Range (0.0f, 100.0f);
        if(random < skill.defence)
        {
            if(SwitchToNight())
            {
                zombie.isDead = true;
                if(zombie.decayTime==0f) zombie.setDT(Time.time+1f);
                zombie.gameObject.tag = "Untagged";
                zombie.gameObject.transform.renderer.material.color = Color.gray;
                doBulletEffect(zombie.gameObject.transform);
            }
            else
            {
                enemy.isDead = true;
                enemy.setDT(Time.time+1f);
                enemy.gameObject.tag = "Untagged";
                enemy.gameObject.transform.renderer.material.color = Color.gray;
                doBulletEffect(enemy.gameObject.transform);
            }
        }

        ammo -= 1;
        lastShoot = Time.fixedTime;

        Debug.Log("Shooting!");
    }