public static Vector3[] CreateConvexHull(ConvexHullShape shape)
        {
            var hull = new ShapeHull(shape);

            hull.BuildHull(shape.Margin);

            int          vertexCount = hull.NumIndices;
            UIntArray    indices     = hull.Indices;
            Vector3Array points      = hull.Vertices;

            var vertices = new Vector3[vertexCount * 2];

            int v = 0;

            for (int i = 0; i < vertexCount; i += 3)
            {
                Vector3 v0 = points[(int)indices[i]];
                Vector3 v1 = points[(int)indices[i + 1]];
                Vector3 v2 = points[(int)indices[i + 2]];

                Vector3 v01    = v0 - v1;
                Vector3 v02    = v0 - v2;
                Vector3 normal = Vector3.Cross(v01, v02);
                normal.Normalize();

                vertices[v++] = v0;
                vertices[v++] = normal;
                vertices[v++] = v1;
                vertices[v++] = normal;
                vertices[v++] = v2;
                vertices[v++] = normal;
            }

            return(vertices);
        }
Example #2
0
        static uint e_Check(IntPtr ptr)
        {
            var values = new UIntArray(ptr);
            Critter virgin = Global.GetCritter(values[0]);
            if(virgin == null)
                return 0;

            GameVar virginState = Global.GetGlobalVar(GVars.den_virgin);
            if(virginState == null)
            {
                Global.Log( "GetGlobalVar(GVAR_den_virgin) fail." );
            }
            else
            {
                if(virgin.Stat[Stats.Var0] == 0 && virginState.Value == IsAway)
                {
                    virginState.Value = IsHome;
                    virgin.AddWalkPlane(0, HomeX, HomeY, Direction.SouthEast, false, 2);
                }
                else
                {
                    virgin.Stat[Stats.Var0]--;
                }
            }

            return 60 * 60;
        }
Example #3
0
        private bool FindPatrolHex(ref ushort hexX, ref ushort hexY)
        {
            var map = GetCritter ().GetMap ();
            if (map == null) {
                return false;
            }

            UIntArray entires = new UIntArray ();
            UInt16Array hexXs = new UInt16Array ();
            UInt16Array hexYs = new UInt16Array ();

            var entireCount = map.GetEntires (entireNumber, entires, hexXs, hexYs);
            if (entireCount == 0)
                return false;

            for (int i = 0; i < 10; i++) {
                var index = Global.Random (0, (int)entireCount - 1);
                if (hexX != hexXs [index] && hexY != hexYs [index]) {
                    hexX = hexXs [index];
                    hexY = hexYs [index];
                    return true;
                }
            }
            //not found any suitable entire
            return false;
        }
        public static void CreateConvexHull(ConvexHullShape shape, Mesh mesh)
        {
            ShapeHull hull = new ShapeHull(shape);

            hull.BuildHull(shape.Margin);

            List <UnityEngine.Vector3> verts = new List <UnityEngine.Vector3>();
            List <int> tris = new List <int>();

            //int vertexCount = hull.NumVertices;
            UIntArray    indices = hull.Indices;
            Vector3Array points  = hull.Vertices;

            for (int i = 0; i < indices.Count; i += 3)
            {
                verts.Add(points[(int)indices[i]].ToUnity());
                verts.Add(points[(int)indices[i + 1]].ToUnity());
                verts.Add(points[(int)indices[i + 2]].ToUnity());
                tris.Add(i);
                tris.Add(i + 1);
                tris.Add(i + 2);
            }

            mesh.vertices  = verts.ToArray();
            mesh.triangles = tris.ToArray();
            mesh.RecalculateBounds();
            mesh.RecalculateNormals();
        }
Example #5
0
        static uint e_Check(IntPtr ptr)
        {
            var     values = new UIntArray(ptr);
            Critter virgin = Global.GetCritter(values[0]);

            if (virgin == null)
            {
                return(0);
            }

            GameVar virginState = Global.GetGlobalVar(GVars.den_virgin);

            if (virginState == null)
            {
                Global.Log("GetGlobalVar(GVAR_den_virgin) fail.");
            }
            else
            {
                if (virgin.Stat[Stats.Var0] == 0 && virginState.Value == IsAway)
                {
                    virginState.Value = IsHome;
                    virgin.AddWalkPlane(0, HomeX, HomeY, Direction.SouthEast, false, 2);
                }
                else
                {
                    virgin.Stat[Stats.Var0]--;
                }
            }

            return(60 * 60);
        }
Example #6
0
        public static void CreateConvexHull(ConvexHullShape shape, Mesh mesh)
        {
            ShapeHull hull = new ShapeHull(shape);

            hull.BuildHull(shape.Margin);

            int          vertexCount = hull.NumIndices;
            UIntArray    indices     = hull.Indices;
            Vector3Array points      = hull.Vertices;

            UnityEngine.Vector3[] vertices = new UnityEngine.Vector3[vertexCount];
            for (int i = 0; i < vertexCount; i++)
            {
                vertices[i] = points[(int)indices[i]].ToUnity();
            }
            int[] tris = new int[indices.Count];
            for (int i = 0; i < indices.Count; i++)
            {
                tris[i] = (int)indices[i];
            }
            mesh.vertices  = vertices;
            mesh.triangles = tris;
            mesh.RecalculateBounds();
            mesh.RecalculateNormals();
        }
Example #7
0
        /// <summary>
        /// Initialize SharedConfigMemoryRegion.
        /// </summary>
        /// <param name="sharedConfigMemoryRegion"></param>
        /// <returns></returns>
        public static SharedConfigMemoryRegion InitializeMemoryRegion(this SharedConfigMemoryRegion sharedConfigMemoryRegion)
        {
            // Initialize memory allocator.
            //
            var allocator = sharedConfigMemoryRegion.Allocator;

            allocator.AllocationBlockOffset = Utils.Align((uint)sharedConfigMemoryRegion.CodegenTypeSize(), 256);
            allocator.AllocationBlockSize   = (uint)sharedConfigMemoryRegion.MemoryHeader.MemoryRegionSize - allocator.AllocationBlockOffset;

            allocator.FreeOffset          = allocator.AllocationBlockOffset;
            allocator.AllocationCount     = 0;
            allocator.LastAllocatedOffset = 0;

            // Allocate array for shared config offsets.
            //
            uint            elementCount    = 2048;
            AllocationEntry allocationEntry = sharedConfigMemoryRegion.Allocate(default(UIntArray).CodegenTypeSize() + (sizeof(uint) * elementCount));

            sharedConfigMemoryRegion.ConfigsArrayOffset = (uint)allocationEntry.Buffer.Offset(sharedConfigMemoryRegion.Buffer) + (uint)default(AllocationEntry).CodegenTypeSize();

            UIntArray configsOffsetArray = sharedConfigMemoryRegion.ConfigsOffsetArray;

            configsOffsetArray.Count = elementCount;

            return(sharedConfigMemoryRegion);
        }
Example #8
0
        Mesh CreateConvexHullShape(ConvexHullShape shape)
        {
            ShapeHull hull = new ShapeHull(shape);

            hull.BuildHull(shape.Margin);

            UIntArray    hullIndices = hull.Indices;
            Vector3Array points      = hull.Vertices;


            int vertexCount = hull.NumIndices;
            int faceCount   = hull.NumTriangles;

            bool index32 = vertexCount > 65536;

            Mesh mesh = new Mesh(device, faceCount, vertexCount,
                                 MeshFlags.SystemMemory | (index32 ? MeshFlags.Use32Bit : 0), VertexFormat.Position | VertexFormat.Normal);


            SlimDX.DataStream indices = mesh.LockIndexBuffer(LockFlags.Discard);
            int i;

            if (index32)
            {
                for (i = 0; i < vertexCount; i++)
                {
                    indices.Write(i);
                }
            }
            else
            {
                for (i = 0; i < vertexCount; i++)
                {
                    indices.Write((short)i);
                }
            }
            mesh.UnlockIndexBuffer();

            SlimDX.DataStream verts = mesh.LockVertexBuffer(LockFlags.Discard);
            Vector3           scale = Vector3.Multiply(shape.LocalScaling, 1.0f + shape.Margin);

            for (i = 0; i < vertexCount; i += 3)
            {
                verts.Write(Vector3.Modulate(points[(int)hullIndices[i]], scale));
                verts.Position += 12;
                verts.Write(Vector3.Modulate(points[(int)hullIndices[i + 1]], scale));
                verts.Position += 12;
                verts.Write(Vector3.Modulate(points[(int)hullIndices[i + 2]], scale));
                verts.Position += 12;
            }
            mesh.UnlockVertexBuffer();

            mesh.ComputeNormals();
            shapes.Add(shape, mesh);

            return(mesh);
        }
        /// <summary>
        /// Internal lookup. TProxy type is deduced by the caller.
        /// </summary>
        /// <typeparam name="TProbingPolicy">HashTable lookup policy.</typeparam>
        /// <typeparam name="TProxy">Codegen proxy type.</typeparam>
        /// <param name="sharedConfigMemoryRegion"></param>
        /// <param name="codegenKey"></param>
        /// <param name="slotIndex"></param>
        /// <returns></returns>
        public static SharedConfig <TProxy> Get <TProbingPolicy, TProxy>(
            this SharedConfigMemoryRegion sharedConfigMemoryRegion,
            ICodegenKey codegenKey,
            ref uint slotIndex)
            where TProbingPolicy : IProbingPolicy
            where TProxy : ICodegenProxy, new()
        {
            TProbingPolicy probingPolicy = default;

            uint probingCount = 0;

            slotIndex = 0;

            var configsArray = new UIntArray()
            {
                Buffer = sharedConfigMemoryRegion.Buffer + (int)sharedConfigMemoryRegion.ConfigsArrayOffset
            };

            uint elementCount = configsArray.Count;
            ProxyArray <uint> sharedConfigsOffsets = configsArray.Elements;

            SharedConfig <TProxy> sharedConfig = default;

            while (true)
            {
                slotIndex = probingPolicy.CalculateIndex(codegenKey, ref probingCount, elementCount);

                uint sharedConfigOffsets = sharedConfigsOffsets[(int)slotIndex];

                if (sharedConfigOffsets == 0)
                {
                    // Slot entry is empty.
                    //
                    sharedConfig.Buffer = IntPtr.Zero;
                    break;
                }

                // Compare the object keys.
                // Create a proxy to the shared config.
                //
                sharedConfig.Buffer = sharedConfigMemoryRegion.Buffer + (int)sharedConfigOffsets;

                // Compare key with the proxy.
                //
                bool foundEntry = codegenKey.CodegenTypeIndex() == sharedConfig.Header.CodegenTypeIndex &&
                                  codegenKey.CompareKey(sharedConfig.Config);
                if (foundEntry)
                {
                    break;
                }

                ++probingCount;
            }

            return(sharedConfig);
        }
Example #10
0
        // Событие 2
        static uint e_AnnouncementMorning(IntPtr values_ptr)
        {
            var     values = new UIntArray(values_ptr);
            Critter boy    = Global.GetCritter(values[0]);

            if (boy != null)
            {
                boy.SayMsg(Say.NormOnHead, TextMsg.Text, Str.Morning);
            }
            return(24 * 60 * 60);
        }
        /// <summary>
        /// Initializes the shared config dictionary stored in the memory region.
        /// </summary>
        /// <param name="sharedConfigDictionary"></param>
        public static void InitializeSharedConfigDictionary(this SharedConfigDictionary sharedConfigDictionary)
        {
            uint            elementCount    = 2048;
            AllocationEntry allocationEntry = sharedConfigDictionary.Allocator.Allocate(default(UIntArray).CodegenTypeSize() + (sizeof(uint) * elementCount));

            sharedConfigDictionary.OffsetToConfigsArray = (uint)allocationEntry.Buffer.Offset(sharedConfigDictionary.Buffer) + (uint)default(AllocationEntry).CodegenTypeSize();

            UIntArray configsOffsetArray = sharedConfigDictionary.ConfigsOffsetArray;

            configsOffsetArray.Count = elementCount;
        }
        /// <summary>
        /// Internal lookup. TProxy type is deduced by the caller.
        /// </summary>
        /// <typeparam name="TProxy">Codegen proxy type.</typeparam>
        /// <param name="sharedConfigDictionary"></param>
        /// <param name="codegenKey"></param>
        /// <param name="slotIndex"></param>
        /// <returns></returns>
        internal static SharedConfig <TProxy> Get <TProxy>(
            SharedConfigDictionary sharedConfigDictionary,
            ICodegenKey codegenKey,
            ref uint slotIndex)
            where TProxy : ICodegenProxy, new()
        {
            TProbingPolicy probingPolicy = default;

            uint probingCount = 0;

            slotIndex = 0;

            UIntArray configsArray = sharedConfigDictionary.ConfigsOffsetArray;

            uint elementCount = configsArray.Count;
            ProxyArray <uint> sharedConfigsOffsets = configsArray.Elements;

            SharedConfig <TProxy> sharedConfig = default;

            while (true)
            {
                slotIndex = probingPolicy.CalculateIndex(codegenKey, ref probingCount, elementCount);

                uint offsetToSharedConfig = sharedConfigsOffsets[(int)slotIndex];

                if (offsetToSharedConfig == 0)
                {
                    // Slot entry is empty.
                    //
                    sharedConfig.Buffer = IntPtr.Zero;
                    break;
                }

                // Compare the object keys.
                // Create a proxy to the shared config.
                //
                sharedConfig.Buffer = sharedConfigDictionary.Buffer - sharedConfigDictionary.Allocator.OffsetToAllocator + (int)offsetToSharedConfig;

                // Compare key with the proxy.
                //
                bool foundEntry = codegenKey.CodegenTypeIndex() == sharedConfig.Header.CodegenTypeIndex &&
                                  codegenKey.CompareKey(sharedConfig.Config);
                if (foundEntry)
                {
                    break;
                }

                ++probingCount;
            }

            return(sharedConfig);
        }
Example #13
0
        /*
         * Runs dialog about cursed treasure
         */
        static uint e_RunTreasureDialog(IntPtr ptr)
        {
            var     values = new UIntArray(ptr);
            Critter player = Global.GetCritter(values[0]);

            if (player == null)
            {
                return(0);
            }

            Global.RunDialog(player, Dialogs.GhostTreasure, player.HexX, player.HexY, false);

            return(0);
        }
Example #14
0
        public Critter ChooseNextTarget(Critter npc, Critter currentTarget)
        {
            var enemyStack = new UIntArray ();
            npc.GetEnemyStack (enemyStack);

            for (int i = 0; i < enemyStack.Length; i++) {
                if (enemyStack [i] != 0) {
                    var target = npc.GetMap ().GetCritter (enemyStack [i]);
                    if (target != null)
                        return target;
                }
            }

            return null;
        }
Example #15
0
        ShapeData CreateConvexHullShape(ConvexHullShape shape)
        {
            ConvexPolyhedron poly = shape.ConvexPolyhedron;

            if (poly != null)
            {
                throw new NotImplementedException();
            }

            ShapeHull hull = new ShapeHull(shape);

            hull.BuildHull(shape.Margin);

            int          indexCount = hull.NumIndices;
            UIntArray    indices    = hull.Indices;
            Vector3Array points     = hull.Vertices;

            ShapeData shapeData = new ShapeData();

            shapeData.VertexCount = indexCount;

            Vector3[] vertices = new Vector3[indexCount * 2];

            int v = 0, i;

            for (i = 0; i < indexCount; i += 3)
            {
                Vector3 v0 = points[(int)indices[i]];
                Vector3 v1 = points[(int)indices[i + 1]];
                Vector3 v2 = points[(int)indices[i + 2]];

                Vector3 v01    = v0 - v1;
                Vector3 v02    = v0 - v2;
                Vector3 normal = Vector3.Cross(v01, v02);
                normal.Normalize();

                vertices[v++] = v0;
                vertices[v++] = normal;
                vertices[v++] = v1;
                vertices[v++] = normal;
                vertices[v++] = v2;
                vertices[v++] = normal;
            }

            shapeData.SetVertexBuffer(device, vertices);

            return(shapeData);
        }
Example #16
0
        // Событие 1
        static uint e_Announcement(IntPtr values_ptr)
        {
            // Ночью не говорим, ждем до утра.
            if (Global.Hour > 20 || Global.Hour < 8)
            {
                return(Time.GetNearFullSecond(0, 0, 0, 8, (ushort)Global.Random(20, 40), 0) - Global.FullSecond);
            }

            // Зазываем.
            var     values = new UIntArray(values_ptr);
            Critter boy    = Global.GetCritter(values[0]);

            if (boy != null)
            {
                boy.SayMsg(Say.NormOnHead, TextMsg.Text, Str.Radio);
            }
            return(Time.GameMinute((uint)Global.Random(50, 70)));
        }
        public uint[] WeaponComponents(uint weaponHash)
        {
            unsafe
            {
                uint size = 0;
                var  weaponComponentsPtr = IntPtr.Zero;
                Core.Library.Client.LocalPlayer_GetWeaponComponents(PlayerNativePointer, weaponHash, &weaponComponentsPtr, &size);

                var uintArray = new UIntArray
                {
                    data     = weaponComponentsPtr,
                    size     = size,
                    capacity = size
                };

                var result = uintArray.ToArray();

                Core.Library.Shared.FreeUInt32Array(weaponComponentsPtr);
                return(result);
            }
        }
Example #18
0
        //
        // Time Event Handlers
        //

        /*
         * Ressurects ghost
         */
        static uint e_RessurectGhost(IntPtr ptr)
        {
            var     values = new UIntArray(ptr);
            Critter ghost  = Global.GetCritter(values[0]);

            if (ghost == null)
            {
                return(0);
            }

            // try to ressurect ghost
            if (ghost.ToLife())
            {
                return(0);
            }
            else
            {
                // restart event
                return(2 * 60);
            }
        }
 public virtual void SendCombatResult(UIntArray combat_result)
 {
     Crit_SendCombatResult(thisptr, combat_result.ThisPtr);
 }
 public virtual void SetInternalBag(UInt16Array pids, UIntArray min_counts, UIntArray max_counts, IntArray slots)
 {
     Crit_SetInternalBag(thisptr, pids.ThisPtr, min_counts.ThisPtr, max_counts.ThisPtr, slots.ThisPtr);
 }
Example #21
0
 public bool SetTimeEvent(uint id, uint duration, UIntArray values)
 {
     return Global_GetTimeEvent(id, out duration, values.ThisPtr);
 }
Example #22
0
 public ItemsCraftedEventArgs(ItemArray items, UIntArray items_count, ItemArray resources, Critter crafter)
 {
     this.Items = items;
     this.ItemsCount = items_count;
     this.Resources = resources;
     this.Crafter = crafter;
 }
Example #23
0
 public uint CreateTimeEvent(uint begin_second, string func_name, UIntArray values, bool save)
 {
     return Global_CreateTimeEventValues(begin_second, CoreUtils.ParseFuncName(func_name).ThisPtr, values.ThisPtr, save);
 }
Example #24
0
 // Событие 2
 static uint e_AnnouncementMorning(IntPtr values_ptr)
 {
     var values = new UIntArray(values_ptr);
     Critter boy = Global.GetCritter(values[0]);
     if(boy != null)
         boy.SayMsg(Say.NormOnHead, TextMsg.Text, Str.Morning );
     return 24 * 60 * 60;
 }
 public virtual void GetEnemyStack(UIntArray enemy_stack)
 {
     Crit_GetEnemyStack(thisptr, enemy_stack.ThisPtr);
 }
 public virtual uint GetTimeEvents(int identifier, UIntArray indexes, UIntArray durations, UIntArray rates)
 {
     return Crit_GetTimeEvents(thisptr, identifier, (IntPtr)indexes, (IntPtr)durations, (IntPtr)rates);
 }
Example #27
0
 public bool Get(string name, UIntArray data)
 {
     var ss = new ScriptString(name);
     return Global_GetAnyData(ss.ThisPtr, data.ThisPtr);
 }
    /// <summary>
    /// Create Model
    /// </summary>
    /// <param name="f_verts">vertices (normal, uv)</param>
    /// <param name="f_facesIndex">int faces index</param>
    /// <param name="boundingBox">bounding box</param>
    /// <returns>Model</returns>
    public Model CreateModel(float[] f_verts, int[] f_facesIndex, BoundingBox boundingBox)
    {
        uint numVertices = (uint)f_verts.Length;
        uint numFaces    = (uint)f_facesIndex.Length;

        Model        model        = new Model(Context);
        VertexBuffer vertexBuffer = new VertexBuffer(Context);
        IndexBuffer  indexBuffer  = new IndexBuffer(Context);
        Geometry     geometry     = new Geometry(Context);

        VertexElementList vertexElements = new VertexElementList();

        vertexElements.Add(new VertexElement(VertexElementType.TypeVector3, VertexElementSemantic.SemPosition));
        vertexElements.Add(new VertexElement(VertexElementType.TypeVector3, VertexElementSemantic.SemNormal));
        vertexElements.Add(new VertexElement(VertexElementType.TypeVector2, VertexElementSemantic.SemTexcoord));

        int    sizeVB = Marshal.SizeOf(f_verts[0]) * f_verts.Length;
        int    sizeIB = Marshal.SizeOf(f_facesIndex[0]) * f_facesIndex.Length;
        IntPtr pnt_vb = Marshal.AllocHGlobal(sizeVB);
        IntPtr pnt_ib = Marshal.AllocHGlobal(sizeIB);

        try
        {
            Marshal.Copy(f_verts, 0, pnt_vb, f_verts.Length);
            vertexBuffer.SetShadowed(true);
            vertexBuffer.SetSize(numFaces, vertexElements);
            vertexBuffer.SetData(pnt_vb);

            Marshal.Copy(f_facesIndex, 0, pnt_ib, f_facesIndex.Length);
            //IndexBuffer.PackIndexData(indexData, pnt_ib, false, 0, (uint)indexData.Length);
            indexBuffer.SetShadowed(true);
            indexBuffer.SetSize(numFaces, true);
            indexBuffer.SetData(pnt_ib);

            geometry.VertexBuffers.Add(vertexBuffer);
            geometry.IndexBuffer = indexBuffer;
            geometry.SetDrawRange(PrimitiveType.TriangleList, 0, numFaces);
            model.NumGeometries = 1;
            model.SetNumGeometryLodLevels(0, 1);
            model.SetGeometry(0, 0, geometry);
            model.BoundingBox = boundingBox;

            VertexBufferRefList vbRL = new VertexBufferRefList();
            IndexBufferRefList  ibRL = new IndexBufferRefList();
            vbRL.Add(vertexBuffer);
            ibRL.Add(indexBuffer);
            UIntArray morphStart = new UIntArray();
            UIntArray morphCount = new UIntArray();
            morphStart.Add(0);
            morphCount.Add(0);
            model.SetVertexBuffers(vbRL, morphStart, morphCount);
            model.IndexBuffers = ibRL;
        }
        finally
        {
            // Free the unmanaged memory.
            Marshal.FreeHGlobal(pnt_vb);
            Marshal.FreeHGlobal(pnt_ib);
        }

        return(model);
    }
Example #29
0
 public uint GetZoneLocationIds(ushort zx, ushort zy, uint zone_radius, UIntArray location_ids)
 {
     return Global_GetZoneLocationIds(zx, zy, zone_radius, (IntPtr)location_ids);
 }
Example #30
0
 public uint CreateTimeEvent(uint begin_second, Func<IntPtr, uint> func, UIntArray values, bool save)
 {
     var type = func.Method.DeclaringType;
     return Global_CreateTimeEventValues(begin_second, CoreUtils.ParseFuncName(type.FullName + "::" + func.Method.Name).ThisPtr, values.ThisPtr, save);
 }
Example #31
0
 public virtual uint GetEntires(int entire, UIntArray entires, UInt16Array hx, UInt16Array hy)
 {
     return Map_GetEntires(thisptr, entire, (IntPtr)entires, (IntPtr)hx, (IntPtr)hy);
 }
Example #32
0
 public virtual int GetTurnBasedSequence(UIntArray critter_ids)
 {
     return Map_GetTurnBasedSequence(thisptr, critter_ids != null ? critter_ids.ThisPtr : IntPtr.Zero);
 }
 public virtual uint GetTimeEvents(IntArray find_identifiers, IntArray identifiers, UIntArray indexes, UIntArray durations, UIntArray rates)
 {
     return Crit_GetTimeEventsArr(thisptr, (IntPtr)find_identifiers, (IntPtr)identifiers, (IntPtr)indexes, (IntPtr)durations, (IntPtr)rates);
 }
Example #34
0
 public uint GetBagItems(uint bag_id, UInt16Array pids, UIntArray min_counts, UIntArray max_counts, IntArray slots)
 {
     return Global_GetBagItems(bag_id, (IntPtr)pids, (IntPtr)min_counts, (IntPtr)max_counts, (IntPtr)slots);
 }
Example #35
0
        // Событие 1
        static uint e_Announcement(IntPtr values_ptr)
        {
            // Ночью не говорим, ждем до утра.
            if(Global.Hour > 20 || Global.Hour < 8 )
                return Time.GetNearFullSecond(0, 0, 0, 8, (ushort)Global.Random( 20, 40 ), 0 ) - Global.FullSecond;

            // Зазываем.
            var values = new UIntArray(values_ptr);
            Critter boy = Global.GetCritter(values[0]);
            if(boy != null)
                boy.SayMsg(Say.NormOnHead, TextMsg.Text, Str.Radio );
            return Time.GameMinute((uint)Global.Random(50, 70));
        }
Example #36
0
 public ItemsBarterEventArgs(ItemArray sale_items, UIntArray sale_items_count, 
     ItemArray buy_items, UIntArray buy_items_count,
     Critter player, Critter npc)
 {
     this.SaleItems = sale_items;
     this.SaleItemsCount = sale_items_count;
     this.BuyItems = buy_items;
     this.BuyItemsCount = buy_items_count;
     this.Player = player;
     this.Npc = Npc;
 }
Example #37
0
        //
        // Time Event Handlers
        //
        /*
           Ressurects ghost
         */
        static uint e_RessurectGhost(IntPtr ptr)
        {
            var values = new UIntArray(ptr);
            Critter ghost = Global.GetCritter(values[0]);
            if(ghost == null)
            {
                return 0;
            }

            // try to ressurect ghost
            if(ghost.ToLife())
            {
                return 0;
            }
            else
            {
                // restart event
                return 2 * 60;
            }
        }
Example #38
0
        private static Geometry createTesselatedBox2(int nsplit, float size)
        {
            Geometry  geometry = new Geometry();
            Vec3Array vertices = new Vec3Array();
            Vec3Array colors   = new Vec3Array();

            geometry.setVertexArray(vertices);
            geometry.setColorArray(colors, Array.Binding.BIND_PER_VERTEX);

            float step = size / nsplit;
            float s    = 0.5f / 4.0f;

            for (int i = 0; i < nsplit; i++)
            {
                float x = -1.0f + i * step;
                //std.cout << x << std.endl;
                vertices.push_back(new Vec3f(x, s, s));
                vertices.push_back(new Vec3f(x, -s, s));
                vertices.push_back(new Vec3f(x, -s, -s));
                vertices.push_back(new Vec3f(x, s, -s));
                Vec3f c = new Vec3f(0.0f, 0.0f, 0.0f);
                c[i % 3] = 1.0f;
                colors.push_back(c);
                colors.push_back(c);
                colors.push_back(c);
                colors.push_back(c);
            }

            UIntArray array = new UIntArray();

            for (uint i = 0; i < nsplit - 1; i++)
            {
                uint base1 = i * 4;
                array.push_back(base1);
                array.push_back(base1 + 1);
                array.push_back(base1 + 4);
                array.push_back(base1 + 1);
                array.push_back(base1 + 5);
                array.push_back(base1 + 4);

                array.push_back(base1 + 3);
                array.push_back(base1);
                array.push_back(base1 + 4);
                array.push_back(base1 + 7);
                array.push_back(base1 + 3);
                array.push_back(base1 + 4);

                array.push_back(base1 + 5);
                array.push_back(base1 + 1);
                array.push_back(base1 + 2);
                array.push_back(base1 + 2);
                array.push_back(base1 + 6);
                array.push_back(base1 + 5);

                array.push_back(base1 + 2);
                array.push_back(base1 + 3);
                array.push_back(base1 + 7);
                array.push_back(base1 + 6);
                array.push_back(base1 + 2);
                array.push_back(base1 + 7);
            }

            geometry.addPrimitiveSet(new DrawElementsUInt((uint)PrimitiveSet.Mode.TRIANGLES, array.size(), array.frontPtr()));
            geometry.getOrCreateStateSet().setMode(GL.GL_LIGHTING, (uint)false.ToStateAttributeValue());
            geometry.setUseDisplayList(false);
            return(geometry);
        }
Example #39
0
        /*
           Runs dialog about cursed treasure
         */
        static uint e_RunTreasureDialog(IntPtr ptr)
        {
            var values = new UIntArray(ptr);
            Critter player = Global.GetCritter(values[0]);
            if(player == null)
            {
                return 0;
            }

            Global.RunDialog(player, Dialogs.GhostTreasure, player.HexX, player.HexY, false);

            return 0;
        }
 public virtual uint GetInternalBag(UInt16Array pids, UIntArray min_counts, UIntArray max_counts, IntArray slots)
 {
     return Crit_GetInternalBag(thisptr,
         pids != null ? pids.ThisPtr : IntPtr.Zero,
         min_counts != null ? min_counts.ThisPtr : IntPtr.Zero,
         max_counts != null ? max_counts.ThisPtr : IntPtr.Zero,
         slots != null ? slots.ThisPtr : IntPtr.Zero);
 }