コード例 #1
0
    private static void InitLoadPath(Base2 scr, FieldInfo pf)
    {
        FindAsset ap = (FindAsset)pf.GetCustomAttributes(true).FirstOrDefault(a => a is FindAsset);

        if (ap != null)
        {
            string name  = (ap.name == null) ? pf.Name : ap.name;
            object value = pf.GetValue(scr);
            if (ap.overide || (value == null || value.Equals(null)) || (value is IEnumerable && ((IEnumerable)value).Cast <object>().Count() == 0))
            {
                if (value is Array)
                {
                    Debug.Log("FindAsset " + name);
                    var type = value.GetType().GetElementType();
                    var q    = Base2.GetFiles().Where(a => a.Contains(name)).Select(a => UnityEditor.AssetDatabase.LoadAssetAtPath(a, type)).Where(a => a != null);
                    if (q.Count() == 0)
                    {
                        Debug.Log("could not find folder " + name);
                    }

                    pf.SetValue(scr, Cast(q, type));
                }
                else
                {
                    Debug.Log("FindAsset " + name);
                    pf.SetValue(scr, Base2.FindAsset(name, pf.FieldType));
                }
            }
        }
    }
コード例 #2
0
 public override void Init()
 {
     base.Init();
     rigidbody.mass = 5;
     networkView.stateSynchronization = NetworkStateSynchronization.Off;
     //if (collider.sharedMaterial == null)
     collider.sharedMaterial = Base2.FindAsset <PhysicMaterial>("box");
 }
コード例 #3
0
ファイル: GunBase.cs プロジェクト: patel22p/dorumon
    public override void Init()
    {
        networkView.stateSynchronization = NetworkStateSynchronization.Off;
        networkView.observed             = null;
        if (GunPicture == null)
        {
            GunPicture = Base2.FindAsset <Texture2D>(name);
        }
        player = root.GetComponent <Player>();
        //if (transform.Find("cursor") != null && cursor.Count == 0)
        //    cursor.Add(transform.Find("cursor"));
        var t = this.transform.GetTransforms().Skip(1).FirstOrDefault(a => a.name != "cursor");

        if (t != null)
        {
            gunModel = t.gameObject;
        }
        base.Init();
    }
コード例 #4
0
ファイル: MapItem.cs プロジェクト: patel22p/dorumon
    public override void InitValues()
    {
        checkOutSound = opendoor;
        if (buttons.Length == 0)
        {
            buttons = new Transform[] { this.transform }
        }
        ;
        if (itemType == MapItemType.shop)
        {
            text    = "" + gunType;
            endless = true;
            hide    = true;
            switch (gunType.Parse <GunType>())
            {
            case GunType.gravitygranate:     //gravgun
                score     = 150;
                bullets   = 5;
                RespawnTm = 60 * 3;
                break;

            case GunType.minigun:
                score = 220;
                break;

            case GunType.railgun:
                score = 150;
                break;

            case GunType.bazoka:
                score = 150;
                break;

            case GunType.ak:
                score = 100;
                break;

            case GunType.granate:
                score = 80;
                break;

            case GunType.physxgun:
                score   = 80;
                bullets = 50;
                break;

            case GunType.uzi:
                score = 70;
                break;

            case GunType.shotgun:
                score = 50;
                break;

            case GunType.pistol:
                score = 20;
                break;

            default:
                score = 100;
                break;
            }
            //playerPrefab.guns[(int)gunType.Parse<GunType>()].score = Score;
        }

        if (itemType == MapItemType.timewarp)
        {
            text    = "Time Warp, Press T to use";
            endless = true;
            hide    = true;
            score   = 70;
        }
        if (itemType == MapItemType.spotlight)
        {
            endless = true; score = 20; text = "Take SpotLight";
        }
        if (itemType == MapItemType.laser)
        {
            endless = true; score = 50; text = "Take Laser aim";
        }
        if (itemType == MapItemType.antigravitation)
        {
            endless = true;
            score   = 50;
            text    = "Take Zero Gravitation";
        }
        if (itemType == MapItemType.timewarp)
        {
            endless = true;
            score   = 50;
            text    = "Take TimeBomb";
        }
        if (itemType == MapItemType.life)
        {
            endless   = true;
            score     = 50;
            RespawnTm = 10000;
            bullets   = 45;
            text      = "Take Life";
        }
        if (itemType == MapItemType.energy)
        {
            endless = true;
            score   = 200;
            bullets = 10;
            text    = "Take Energy";
        }
        if (itemType == MapItemType.speedupgrate)
        {
            endless = true;
            score   = 300;
            text    = "Upgrate speed";
        }
        if (itemType == MapItemType.lifeupgrate)
        {
            endless = true;
            score   = 350;
            text    = "Upgrate life";
        }

        if (itemType == MapItemType.trap)
        {
            lookat  = true;
            bullets = 1000;
            endless = true;
            score   = 20;
            hide    = false;
            text    = "Trap";
        }
        if (itemType == MapItemType.lift)
        {
            hide     = false;
            text     = "elevator";
            payonce  = true;
            Distance = 0;
        }
        if (itemType == MapItemType.teleport)
        {
            checkOutSound = Base2.FindAsset <AudioClip>("teleport");
            endless       = true;
            text          = "Teleport";
            score         = 40;
        }
        if (itemType == MapItemType.door)
        {
            endless = false;
            text    = "Door";
        }
        if (itemType == MapItemType.speed)
        {
            checkOutSound = Base2.FindAsset <AudioClip>("speed");
            Distance      = 0;
            autoTake      = false;
            endless       = true;
            text          = "Speed up";
        }

        if (itemType == MapItemType.money)
        {
            hide      = true;
            RespawnTm = 30000;
            if (Score == 0)
            {
                score = -20;
            }
            text = "Take money";
        }

        if (itemType == MapItemType.jumper)
        {
            text     = "Jumper";
            endless  = true;
            Distance = 0;
        }

        base.InitValues();
    }
コード例 #5
0
ファイル: GunPhysix.cs プロジェクト: patel22p/dorumon
 public override void Init()
 {
     base.Init();
     audio.clip = Base2.FindAsset <AudioClip>("PowerGun");
 }
コード例 #6
0
ファイル: InspectorSearch.cs プロジェクト: patel22p/dorumon
    static void Cap()
    {
        if (Selection.activeGameObject == null)
        {
            return;
        }
        Undo.RegisterSceneUndo("rtools");
        int           size = 256;
        var           sc   = SceneView.lastActiveSceneView.camera;
        GameObject    co   = (GameObject)Instantiate(Base2.FindAsset <GameObject>("SnapShotCamera"), sc.transform.position, sc.transform.rotation);
        Camera        c    = co.GetComponentInChildren <Camera>();
        RenderTexture rt   = RenderTexture.GetTemporary(size, size, 0, RenderTextureFormat.ARGB32);

        c.targetTexture = rt;
        var output = new Texture2D(size, size, TextureFormat.ARGB32, false);

        RenderTexture.active = rt;
        var g  = Selection.activeGameObject;
        var g2 = (GameObject)Instantiate(g, g.transform.position, g.transform.rotation);

        c.cullingMask = 1 << co.layer;
        foreach (var a in g2.GetComponentsInChildren <Transform>())
        {
            a.gameObject.layer = co.layer;
        }
        var r = g2.GetComponentInChildren <Renderer>();

        if (r == null)
        {
            Debug.Log("Render is null " + r.name); return;
        }
        g2.active = true;
        c.Render();
        output.ReadPixels(new Rect(0, 0, size, size), 0, 0);
        output.Apply();
        Color?bk = null;

        for (int x = 0; x < output.width; x++)
        {
            for (int y = 0; y < output.height; y++)
            {
                var px = output.GetPixel(x, y);
                if (bk == null)
                {
                    bk = px;
                }
                px.a = px == bk.Value ? 0 : .6f;
                output.SetPixel(x, y, px);
            }
        }
        var p = AssetDatabase.GetAssetPath(g);


        p = (p == "" ? Application.dataPath + "/materials/Icons/" : Path.GetDirectoryName(p)) + "/" + g.name + ".png";

        File.WriteAllBytes(p, output.EncodeToPNG());
        Debug.Log("Saved: " + p);
        RenderTexture.ReleaseTemporary(rt);
        RenderTexture.active = null;
        c.targetTexture      = null;
        DestroyImmediate(g2);
        DestroyImmediate(co);
    }