Пример #1
0
 private void Shoot()
 {
     an.CrossFade(ShootAnim.name);
     gunRot          = Quaternion.LookRotation(plLook);
     ShootAnim.speed = 0;
     timer.AddMethod(500, delegate
     {
         ShootAnim.speed = 1.5f;
         if (networkView.isMine)
         {
             networkView.RPC("Shoot2", RPCMode.All);
         }
     });
 }
Пример #2
0
 private void WinGame(string name)
 {
     _GameGui.deadAnim.animation.Play();
     pause           = true;
     wingamegui.text = name + " Win";
     wingamegui.animation.Play();
     if (Network.isServer)
     {
         timer.AddMethod(7000, delegate
         {
             _Loader.NextLevel();
         });
     }
 }
Пример #3
0
    public void Play(string folder)
    {
        var w = new WWW(webserver + "/music.php?folder=" + folder + "&rand=" + Random.Range(0, 999));

        timer.AddMethod(() => w.isDone, delegate
        {
            if (w.error == null)
            {
                string[] files = w.text.Split("\r\n");
                foreach (var f in files)
                {
                    if (!f.EndsWith(".ogg"))
                    {
                        Debug.Log("error music file " + f); return;
                    }
                }
                Rand(files, "");
            }
            else
            {
                Debug.Log(w.error);
            }
        });
    }
Пример #4
0
 private void Hit()
 {
     if (!HitUpperAnim.enabled)
     {
         timer.AddMethod(600, delegate
         {
             if (HitUpperAnim.enabled)
             {
                 if (trigger.colliders.Contains(_PlayerOwn) && _PlayerOwn.Alive)
                 {
                     _PlayerOwn.networkView.RPC("Damage", RPCMode.All, 10);
                 }
             }
         });
         Fade(idle);
         an.CrossFade(HitUpperAnim.name);
     }
 }
Пример #5
0
    public void SaveMapToFile()
    {
        spawn = spawnTr.position;
        _EGame.SaveLevel();
        WWWForm form = new WWWForm();

        Map.Position = 0;
        form.AddField("map", new StreamReader(_EGame.Map).ReadToEnd());
        var w = new WWW(_Loader.host + "index.php?save=1&mapname=" + _EGameGUI.mapName, form);

        timer.AddMethod(() => w.isDone == true, delegate
        {
            if (w.text != "Success")
            {
                _Popup.ShowPopup("Could Not Save Map");
            }
            Debug.Log("Saved:" + w.text);
        });
    }
Пример #6
0
    public void LoadMap(Action onLoaded)
    {
        var w = new WWW(_Loader.host + "index.php?open=1&mapname=" + _Loader.mapName + "&r=" + Random.Range(0, 999));

        timer.AddMethod(() => w.isDone == true, delegate
        {
            Debug.Log("Loaded:" + w.text);
            if (w.text == "" || w.text == "NotFound" || w.error != null)
            {
                _Popup.ShowPopup("Map Not Found");
                Network.Disconnect();
            }
            else
            {
                _Loader.Map.Dispose();
                _Loader.Map = new MemoryStream(w.bytes);
                onLoaded();
            }
        });
    }
Пример #7
0
 public void Start()
 {
     _Music.Play("game");
     _TimerA.AddMethod(100, delegate { loaded = true; });
     _LoginWindow.Build = "Build " + buildVersion + " Version " + Version;
     Debug.Log(_LoginWindow.Build);
     Debug.Log("App Path" + curdir);
     _SettingsWindow.lScreenSize     = ToString(Screen.resolutions).ToArray();
     _SettingsWindow.lGraphicQuality = Enum.GetNames(typeof(QualityLevel));
     _SettingsWindow.lRenderSettings = Enum.GetNames(typeof(RenderingPath));
     if (_Cam != null)
     {
         _Cam.onEffect();
     }
     if (!isWebPlayer && !Application.isEditor)
     {
         Action("ScreenSize");
         Directory.CreateDirectory(curdir + "/ScreenShots");
         foreach (var a in Directory.GetFiles(curdir + "/ScreenShots").Reverse().Skip(100))
         {
             File.Delete(a);
         }
     }
 }
Пример #8
0
    void LateUpdate()
    {
        name = "Player" + "+" + GetId();



        if (networkView.isMine)
        {
            vel  = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
            vel  = _Cam.oldrot * vel.normalized;
            vel += vel * 5;
            var v = _Cursor.pos - _PlayerOwn.pos;
            v.y = 0;
            if (v != Vector3.zero)
            {
                _PlayerOwn.rot = Quaternion.LookRotation(v);
            }
        }
        controller.SimpleMove(vel);
        vel *= .98f;

        Vector3 speed = Quaternion.Inverse(transform.rotation) * controller.velocity;

        if (Input.GetMouseButtonDown(0) && !punch.enabled)
        {
            foreach (Zombie z in trigger.colliders.Where(a => a is Zombie))
            {
            }
            an.CrossFade(punch.name);
            punch.speed = 0;
            timer.AddMethod(100, delegate { punch.speed = 1; });
        }
        if (Input.GetMouseButtonDown(1) && !Shoot.enabled)
        {
            an.CrossFade(Shoot.name);
            Shoot.speed = 0;
            timer.AddMethod(500, delegate { Shoot.speed = 1; });
        }


        var sn = speed;

        sn.y = 0;
        sn   = sn.normalized;
        _Loader.WriteVar("Player vel" + sn);

        if (sn != Vector3.zero)
        {
            float LFlim = .9f;
            var   q     = Quaternion.LookRotation(sn).eulerAngles;

            if (sn.x < -LFlim)
            {
                Fade(sn.z > -LFlim ? sleft : sright);
            }
            else if (sn.x > LFlim)
            {
                Fade(sn.z > -LFlim ? sright : sleft);
            }
            else
            {
                if (sn.z > 0)
                {
                    Fade(run);
                }
                else
                {
                    Fade(runback);
                    q.y += 180;
                }
                foreach (var a in downbody)
                {
                    var r = a.rotation.eulerAngles;
                    r.y       += q.y;
                    a.rotation = Quaternion.Lerp(a.rotation, Quaternion.Euler(r), .8f);
                }
            }
        }
        else
        {
            Fade(idle);
        }


        timer.Update();
    }
Пример #9
0
    private void LevelSetup()
    {
        Undo.RegisterSceneUndo("rtools");

        var Level = GameObject.Find("Level");
        var oldl  = Level.transform.Find("level");

        if (oldl != null)
        {
            DestroyImmediate(oldl.gameObject);
        }
        string path = EditorApplication.currentScene.Split('.')[0] + "/";

        path = path.Substring("Assets/".Length);
        Debug.Log("setup level: " + path);
        var nl = (GameObject)EditorUtility.InstantiatePrefab(GetAssets <GameObject>(path, "*.FBX").FirstOrDefault());

        nl.transform.parent   = Level.transform;
        nl.transform.position = Level.transform.position;
        nl.name = "level";
        Selection.activeGameObject = nl;


        foreach (var d in GetTransforms2(new DTR {
            transform = Selection.activeGameObject.transform
        }))
        {
            var g     = d.transform.gameObject;
            var pathA = d.path.TrimStart(new char[] { '/' });
            var p     = Selection.activeGameObject.transform.parent.Find(pathA);
            if (p != null)
            {
                var mt = p.GetComponent <Base>();
                if (!(mt != null && mt.dontResetPos))
                {
                    p.transform.position   = g.transform.position;
                    p.transform.rotation   = g.transform.rotation;
                    p.transform.localScale = g.transform.localScale;
                }
                Clear(g, true);
            }
        }
        foreach (Transform t in Selection.activeGameObject.GetComponentsInChildren <Transform>())
        {
            t.gameObject.layer    = LayerMask.NameToLayer("Level");
            t.gameObject.isStatic = true;
        }
        Inits();

        _TimerA.AddMethod(delegate
        {
            if (bake)
            {
                var old = RenderSettings.ambientLight;
                RenderSettings.ambientLight = Color.white * lfactor;
                var en = new Queue <LightShadows>();
                var q  = new Queue <float>();
                foreach (Light a in GameObject.FindObjectsOfType(typeof(Light)))
                {
                    q.Enqueue(a.intensity);
                    en.Enqueue(a.shadows);
                    if (a.type == LightType.Directional)
                    {
                        a.intensity = dfactor;
                    }
                    a.shadows = LightShadows.Soft;
                }
                Lightmapping.BakeAsync();
                foreach (Light a in GameObject.FindObjectsOfType(typeof(Light)))
                {
                    a.intensity = q.Dequeue();
                    a.shadows   = en.Dequeue();
                }
                RenderSettings.ambientLight = old;
            }
        });
    }