示例#1
0
        static void Main(string[] args)
        {
            var interior = InteriorResource.Load("test.dif");

            InteriorResource.Save(interior, "test3.dif");
            var interior2 = InteriorResource.Load("test3.dif");
        }
示例#2
0
    protected override void ProcessResource(InteriorResource r)
    {
        base.ProcessResource(r);

        GameObject tool = Instantiate(toolPrefab, transform.position, transform.rotation);

        SecureObject(tool);
    }
示例#3
0
    /*
     * private void OnTriggerEnter2D(Collider2D collision)
     * {
     *  HandleCollision(collision);
     * }
     *
     * private void OnTriggerExit2D(Collider2D collision)
     * {
     *  if (collision.tag == "Interior Resource" && overResource == collision.gameObject.GetComponent<InteriorResource>())
     *  {
     *      overResource = null;
     *      //Debug.Log("Station: resource over removed");
     *  }
     * }
     *
     * protected bool resourceOver = false;
     * protected InteriorResource overResource;
     * protected virtual void HandleCollision(Collider2D collision)
     * {
     *  if (collision.tag == "Interior Resource")
     *  {
     *      Debug.Log("Station: Collided with resource");
     *      overResource = collision.gameObject.GetComponent<InteriorResource>();
     *      if (activated && !overResource.IsHeld && TryCollectResource(overResource))
     *      {
     *          CollectResource(overResource);
     *      }
     *  }
     *
     *  UpdateResourcePips();
     * }
     */

    protected void CollectResource(InteriorResource r)
    {
        IncreaseResources(r);
        r.Consume();
        //overResource = null;

        UpdateResourcePips();
    }
示例#4
0
    protected override void ProcessResource(InteriorResource r)
    {
        float value = r != null ? r.Value : 1;

        Ship.AddBoostSpeedMultStack(value * boostMultPerResource, value * Duration);
        if (r != null)
        {
            base.ProcessResource(r);
        }
    }
示例#5
0
        static void Main(string[] args)
        {
            var dif = InteriorResource.Load(args[0]);

            var csxexporter = new CSXExporter();

            var w = new StreamWriter(File.OpenWrite(args[0] + ".csx"));

            csxexporter.ExportCSX(dif.detailLevels[0], w);
        }
示例#6
0
 protected override void IncreaseResources(InteriorResource r)
 {
     if (Ship.NumEngineBoostStacks < maxStacks)
     {
         ResourceCount++;
         if (ResourceCount >= ResourceRequirement)
         {
             ProcessResource(r);
             ResourceCount = 0;
         }
     }
 }
示例#7
0
 protected override void IncreaseResources(InteriorResource r)
 {
     if (GetCurrentStacksOnShip() < maxStacks)
     {
         ResourceCount++;
         if (ResourceCount >= ResourceRequirement)
         {
             ProcessResource(r);
             ResourceCount = 0;
         }
     }
 }
示例#8
0
 protected override void IncreaseResources(InteriorResource r)
 {
     if (Ship.Shields < Ship.MaxShields)
     {
         ResourceCount++;
         if (ResourceCount >= ResourceRequirement)
         {
             ProcessResource(r);
             ResourceCount = 0;
         }
     }
 }
示例#9
0
 protected override void IncreaseResources(InteriorResource r)
 {
     if (pipDurationStacks.Count < maxStacks)
     {
         ResourceCount++;
         if (ResourceCount >= ResourceRequirement)
         {
             ProcessResource(r);
             pipDurationStacks.Add(duration);
             ResourceCount = 0;
         }
     }
 }
示例#10
0
    protected virtual void IncreaseResources(InteriorResource r)
    {
        resourceCount++;
        if (resourceCount >= resourceRequirement)
        {
            ProcessResource(r);
            resourceCount = 0;

            aSource.PlayOneShot(doEffectSFX, 0.5f);
        }
        else
        {
            aSource.PlayOneShot(addResourceSFX, 0.5f);
        }
    }
示例#11
0
    protected override void ProcessResource(InteriorResource r)
    {
        float value = r != null ? r.Value : 1;

        if (leftGun)
        {
            Ship.AddBoostFireRateStackLeft(value * boostMultPerResource, value * Duration);
        }
        if (rightGun)
        {
            Ship.AddBoostFireRateStackRight(value * boostMultPerResource, value * Duration);
        }


        if (r != null)
        {
            base.ProcessResource(r);
        }
    }
示例#12
0
    // Interior Player will call this when it interacts with a station while holding a PickupItem
    public virtual void TryProcessItem(PickupItem item)
    {
        if (Activated)
        {
            InteriorResource ir = item.GetComponent <InteriorResource>();
            if (ir == null)
            {
                ir = item.GetComponentInChildren <InteriorResource>();
            }
            if (ir == null && item.transform.parent != null)
            {
                ir = item.transform.parent.GetComponent <InteriorResource>();
            }

            if (ir != null && TryCollectResource(ir))
            {
                CollectResource(ir);
            }
        }
    }
示例#13
0
 protected virtual bool TryCollectResource(InteriorResource r)
 {
     return(true);
 }
示例#14
0
 protected virtual void ProcessResource(InteriorResource r)
 {
     AddScore();
 }
示例#15
0
        static void Main(string[] args)
        {
            Console.WriteLine("obj2difSharp v1.0");

            if (args.Length == 0)
            {
                Console.WriteLine("Usage obj2difSharp <filename> [-f] [-r]");
                Console.WriteLine("filename: the path to the file to convert to dif");
                Console.WriteLine("(optional) f: flip normals");
                Console.WriteLine("(optional) r: reverse vertex order");
            }
            else
            {
                var objreader = new ObjReader();
                objreader.Parse(args[0]);

                var flipnormal   = false;
                var reverseverts = false;
                foreach (var arg in args)
                {
                    if (arg == "-f")
                    {
                        flipnormal = true;
                    }

                    if (arg == "-r")
                    {
                        reverseverts = true;
                    }
                }

                var builders = new List <DifBuilder>();
                var builder  = new DifBuilder();
                builders.Add(builder);
                builder.FlipNormals = flipnormal;
                var tricount = 0;
                foreach (var group in objreader.Groups)
                {
                    foreach (var face in group.Faces)
                    {
                        if (tricount > 16384) //Max limits reached
                        {
                            builder             = new DifBuilder();
                            builder.FlipNormals = flipnormal;
                            builders.Add(builder);
                            tricount = 0;
                        }
                        tricount++;
                        if (reverseverts)
                        {
                            builder.AddTriangle(group.Points[face.v3], group.Points[face.v2], group.Points[face.v1], group.UV[face.uv3], group.UV[face.uv2], group.UV[face.uv1], group.Normals[face.n3], Path.GetFileNameWithoutExtension(face.material));
                        }
                        else
                        {
                            builder.AddTriangle(group.Points[face.v1], group.Points[face.v2], group.Points[face.v3], group.UV[face.uv1], group.UV[face.uv2], group.UV[face.uv3], group.Normals[face.n1], Path.GetFileNameWithoutExtension(face.material));
                        }
                    }
                }

                Console.WriteLine("Building Difs");

                for (int i = 0; i < builders.Count; i++)
                {
                    var build = builders[i];
                    var dif   = new InteriorResource();
                    build.Build(ref dif);
                    InteriorResource.Save(dif, Path.ChangeExtension(args[0], null) + i + ".dif");
                }
            }
        }
示例#16
0
 protected override void ProcessResource(InteriorResource r)
 {
     Ship.AddEnergyBall(r.Value);
     base.ProcessResource(r);
 }
示例#17
0
 protected override void ProcessResource(InteriorResource r)
 {
     Ship.RepairDamage(r.Value);
     base.ProcessResource(r);
 }
示例#18
0
 protected override bool TryCollectResource(InteriorResource r)
 {
     return(securedObject == null);
 }
示例#19
0
 protected override void ProcessResource(InteriorResource r)
 {
     Ship.AddWeaponSpread(r.Value * Duration);
     base.ProcessResource(r);
 }
示例#20
0
 protected override void ProcessResource(InteriorResource r)
 {
     Ship.AddShields(r.Value);
     UpdateResourcePips();
     base.ProcessResource(r);
 }
示例#21
0
        public void Build(ref InteriorResource ir)
        {
            Console.WriteLine("Building BSP");
            var bspnodes = new List <BSPBuilder.BSPNode>();

            foreach (var poly in polygons)
            {
                var leafnode = new BSPBuilder.BSPNode();
                leafnode.IsLeaf  = true;
                leafnode.Polygon = poly;
                var n = new BSPBuilder.BSPNode();
                n.Front = leafnode;
                n.Plane = new Plane(poly.Vertices[0], poly.Normal);
                bspnodes.Add(n);
            }

            var BSPBuilder = new BSPBuilder();
            var root       = BSPBuilder.BuildBSPRecursive(bspnodes);

            polygons.Clear();
            Console.WriteLine("Gathering Polygons");
            root.GatherPolygons(ref polygons);

            interior = new Interior();

            Console.WriteLine("Exporting BSP");
            var orderedpolys = new List <Polygon>();

            ExportBSP(root, ref orderedpolys);

            var groupedPolys = new List <List <Polygon> >();

            int fullpolycount = orderedpolys.Count / 8;
            int rem           = orderedpolys.Count % 8;

            for (int i = 0; i < orderedpolys.Count - rem; i += 8)
            {
                var polysList = new List <Polygon>();
                for (int j = 0; j < 8; j++)
                {
                    polysList.Add(orderedpolys[i + j]);
                }

                groupedPolys.Add(polysList);
            }
            var lastPolys = new List <Polygon>();

            for (int i = orderedpolys.Count - rem; i < orderedpolys.Count; i++)
            {
                lastPolys.Add(orderedpolys[i]);
            }
            if (lastPolys.Count != 0)
            {
                groupedPolys.Add(lastPolys);
            }

            Console.WriteLine("Exporting Convex Hulls");
            ExportConvexHulls(groupedPolys);

            Console.WriteLine("Exporting Zones");
            if (interior.zones == null)
            {
                interior.zones = new List <Zone>();
            }
            var z = new Zone();

            z.portalStart  = 0;
            z.portalCount  = 0;
            z.surfaceStart = 0;
            z.surfaceCount = interior.surfaces.Count;

            interior.zones.Add(z);

            Console.WriteLine("Exporting ZoneSurfaces");
            if (interior.zoneSurfaces == null)
            {
                interior.zoneSurfaces = new MultiSizeIntList <short, short>();
            }

            if (interior.surfaces.Count > ushort.MaxValue)
            {
                throw new Exception("Max surfaces for zone reached");
            }
            for (int i = 0; i < interior.surfaces.Count; i++)
            {
                interior.zoneSurfaces.Add((short)i);
            }

            interior.boundingBox    = GetBoundingBox();
            interior.boundingSphere = GetBoundingSphere();

            Console.WriteLine("Exporting CoordBins");
            ExportCoordBins();

            Console.WriteLine("Finalizing");
            //Initialize all the null values to default values
            interior.interiorFileVersion = 0;
            interior.materialListVersion = 1;
            interior.coordBinMode        = 0;
            interior.baseAmbientColor    = new ColorF()
            {
                red = 1, green = 1, blue = 1, alpha = 1
            };
            interior.alarmAmbientColor = new ColorF()
            {
                red = 1, green = 1, blue = 1, alpha = 1
            };
            interior.detailLevel          = 0;
            interior.minPixels            = 250;
            interior.hasAlarmState        = false;
            interior.numLightStateEntries = 0;
            interior.animatedLights       = new List <AnimatedLight>();
            interior.lightMaps            = new List <Lightmap>();
            interior.lightStates          = new List <LightState>();
            interior.nameBuffer           = new List <byte>();
            interior.nullSurfaces         = new List <NullSurface>();
            interior.portals              = new List <Portal>();
            interior.stateDataBuffer      = new StateDataBuffer();
            interior.stateDatas           = new List <StateData>();
            interior.texMatIndices        = new List <int>();
            interior.texMatrices          = new List <TexMatrix>();
            interior.texNormals           = new List <Vector3>();
            interior.zonePortalList       = new MultiSizeIntList <short, short>();
            interior.extendedLightMapData = new ExtendedLightmapData()
            {
                extendedData = 0
            };

            ir.detailLevels.Add(interior);
        }