Ejemplo n.º 1
0
    private void Sinhro()
    {
        if (Input.GetButtonDown("Cancel"))
        {
            IMainMenu.ToMenu();
        }
        weapon.texture = (Texture)Resources.Load("Sprites/Weapon_" + player.savable.currentWeapon);
        if (fire)
        {
            Fire();
        }
        //SinhroCross ();
        Transform cm    = IHuman.cameraMainParent;
        Transform fp    = player.firePlace;
        float     speed = Time.deltaTime * 8;

        if (cross)
        {
            rangeView = 30;
            Vector3 v = fp.position - fp.forward + fp.up * 0.02f;
            Debug.DrawRay(v, fp.forward);
            cm.position = Vector3.Slerp(cm.position, v, speed);
        }
        else
        {
            rangeView        = 60;
            cm.localPosition = Vector3.Slerp(cm.localPosition, new Vector3(0, 0.0014f, 0.0013f), speed);
        }
        IHuman.cameraMain.fieldOfView = Mathf.Lerp(IHuman.cameraMain.fieldOfView, rangeView, 0.25f);
        health.text = "" + ((int)player.savable.health) + '\n' + "Зомби сейчас : " + DataCenter.dataCenter.zombies.Length;
        float  t   = ITimecycle.time;
        int    sec = (int)((t - (int)t) * 60);
        string s   = "" + sec;

        if (sec < 10)
        {
            s = "0" + sec;
        }
        killed.text = "Время : " + (int)t + ":" + s;
        IZombie z = IZombie.ZombieNearbyPosition(player.trans.position, 5, false);

        if (z)
        {
            Vector3 v = Vector0.Flat(z.trans.position - player.trans.position);
            v = player.trans.InverseTransformDirection(v);
            Quaternion q = Quaternion.LookRotation(v);
            zAngle = -135 - q.eulerAngles.y;
        }
        else
        {
            zAngle -= Time.deltaTime * 180;
        }
        radar.localEulerAngles = Vector3.forward * (zAngle);
        patronesType.texture   = (Texture)Resources.Load("Sprites/Patrones_" + player.savable.currentWeapon);
        patrones.text          = "" + player.savable.patrones_in [player.savable.currentWeapon] + "/" + player.savable.patrones_ [player.savable.currentWeapon];
    }
Ejemplo n.º 2
0
    private void HumanUpdate()
    {
        savable.health += Time.deltaTime / 2;
        savable.health  = Mathf.Clamp(savable.health, 0, 100);
        float speed = Time.deltaTime * 4;

        currentFrame.addLook = Vector3.Slerp(currentFrame.addLook, Vector3.zero, speed);
        if (heart)
        {
            if (savable.name == "player")
            {
                float   dist = 10000;
                IZombie z    = IZombie.ZombieNearbyPosition(trans.position, 10000, false);
                if (z)
                {
                    dist = (trans.position - z.trans.position).magnitude;
                }
                float vol = 1 / dist;
                heart.volume = vol;
            }
            else
            {
                heart.volume = 0;
            }
        }
        if (agentTrans.localPosition.magnitude > 4f)
        {
            agentTrans.localPosition = agentTrans.localPosition.normalized * 4f;
        }
        walk_speed_k = walkSpeed / 2 + walkSpeed / 2 * (1 - crouch);
        if (savable.name == "player")
        {
            Control();
        }
        else
        {
            AI();
        }
        LookAt();
        if (savable.health < 1)
        {
            Die();
        }
        if (savable.health < 25 && !falled)
        {
            Fall();
        }
    }
Ejemplo n.º 3
0
    private void Update()
    {
        IHuman  h = IHuman.HumanNearbyPosition(trans.position, false, 3);
        IZombie z = IZombie.ZombieNearbyPosition(trans.position, 3, false);

        opened = h || z;

        int r = 0;

        if (opened)
        {
            r = 1;
        }
        float speed = Time.deltaTime * 4f;

        addEuler = Mathf.Lerp(addEuler, r * 120, speed);
        trans.localEulerAngles = new Vector3(startEuler.x, startEuler.y, startEuler.z + addEuler);
    }