Ejemplo n.º 1
0
        public static IEnumerator TrapLine(Entity player, Emplacement place, OptionEffect options)
        {
            /// TODO: recoder ca avec rift
            Vector3i offsetSurface = new Vector3i(0, options.OptionShape.offsetSurface, 0);

            Vector3i pos = place.ipos;
            // size = E/W=largeur, hauteur, N/S profondeur (portee)
            Vector3i size           = options.OptionShape.shape;
            Vector3  base_direction = Emplacement.Truncate(place.direction, true, true);

            float pace = 0.1f;                               // TODO pace in option
            Block air  = Block.GetBlockByName("air", false); // The air instance could prolly be shared ...
            // Block blk = options.OptionBlock.block;

            int portee = 100;

            BlockSetter setter    = new BlockSetter(options.OptionBlock);
            BlockSetter setterAir = new BlockSetter(options.OptionBlock.Copy());

            setterAir.options.block = air;

            Vector3 posf = Vectors.ToFloat(pos + offsetSurface);
            // string[] random_blocks = new string[]{"trapSpikesWoodDmg0", "trapSpikesWoodDmg1", "trapSpikesWoodDmg2"};
            // Block[] random_blocks = options.OptionBlock.blocks;
            Vector3i start = Geo3D.Surface(place.ipos);

            for (int k = 0; k < 10; k++)
            {
                Vector3 direction = base_direction + Vectors.Float.Randomize(GameManager.Instance.World.GetGameRandom(), 0.1f);
                direction.y = 0;
                direction   = direction.normalized;
                // IntLine traj = new IntLine(start, direction); //east
                IEnumerable <Vector3i> segment = IntLine.Segment(Vectors.ToFloat(start), direction, 1, 10); // skip 0 intersecting with the previous
                foreach (Vector3i where in segment)
                {
                    Vector3i Swhere = Geo3D.Surface(where);
                    // randomisation : "trapSpikesWoodDmg0-2"
                    // string rdm = random_blocks[(int) Math.Floor(GameManager.Instance.World.GetGameRandom().RandomFloat*3)];
                    // setter.options.block = Block.GetBlockByName(rdm, false);
                    // Block rdm =

                    setter.Apply(Swhere + Vectors.Up);
                    setter.Push();
                    start = Swhere;
                    yield return(new WaitForEndOfFrame());
                }
                yield return(new WaitForSeconds(0.5f));
            }
        }
Ejemplo n.º 2
0
        /*
         *
         * Options:
         * - ground (water, traps)
         * - recursion
         * - size / depth (puis avant)
         * - other content : Z, animal, torch, lights ...
         *
         */


        public static IEnumerator Rift(EntityPlayer player, Emplacement place, OptionEffect options)
        {
            /*
             * Laisse des blocks tomber au dessus ? just changed  erase="yes"
             * (longueur 1, hauteur (profonfeur), replicats)
             */
            EntityPlayerLocal epl = player as EntityPlayerLocal;

            epl.cameraTransform.SendMessage("ShakeBig");
            yield return(new WaitForSeconds(1f));

            BlockSetter setter    = new BlockSetter(options.OptionBlock);
            Vector3     direction = Vectors.Copy(place.direction);

            direction.y = 0;
            direction   = direction.normalized;

            Vector3i start = Geo3D.Surface(place.ipos);

            for (int k = 0; k < options.OptionShape.shape.z; k++)
            {
                Vector3 kdirection = direction + Vectors.Float.Randomize(GameManager.Instance.World.GetGameRandom(), 0.2f);
                // IntLine traj = new IntLine(start, direction); //east
                IEnumerable <Vector3i> segment = IntLine.Segment(Vectors.ToFloat(start), kdirection, 0, options.OptionShape.shape.x);
                Vector3i prev    = new Vector3i();
                bool     hasprev = false;
                foreach (Vector3i where in segment)
                {
                    Vector3i Swhere = Geo3D.Surface(where);
                    setter.Apply(Swhere);
                    if (hasprev)
                    {
                        for (int creuse = 1; creuse < options.OptionShape.shape.y; creuse++)
                        {
                            setter.Apply(prev + creuse * Vectors.Down);
                        }
                    }
                    setter.Push();
                    start = Swhere;
                    yield return(new WaitForEndOfFrame());

                    hasprev = true; prev = Swhere;
                }
                yield return(new WaitForSeconds(1f));
            }
        }
Ejemplo n.º 3
0
        public static IEnumerator Rift(EntityPlayer player, Emplacement place, OptionEffect options)
        {
            /*
             * Laisse des blocks tomber au dessus ? just changed  erase="yes"
             */
            Vector3i offsetSurface = new Vector3i(0, options.OptionShape.offsetSurface, 0);

            EntityPlayerLocal epl = player as EntityPlayerLocal;

            epl.cameraTransform.SendMessage("ShakeBig");
            yield return(new WaitForSeconds(1f));

            // Vector3i shape = options.OptionShape.shape; /// (longueur, hauteur, largeur)
            BlockSetter setter = new BlockSetter(options.OptionBlock);
            Vector3i    start  = Geo3D.Surface(place.ipos);

            for (int k = 0; k < 3; k++)
            {
                // Vector3 direction = Vectors.Float.UnitX + Vectors.Float.Randomize(GameManager.Instance.World.GetGameRandom(), 0.1f);
                Vector3 direction = place.direction + Vectors.Float.Randomize(GameManager.Instance.World.GetGameRandom(), 0.1f);
                direction.y = 0;
                direction   = direction.normalized;
                // IntLine traj = new IntLine(start, direction); //east
                IEnumerable <Vector3i> segment = IntLine.Segment(Vectors.ToFloat(start), direction, 1, 5); // skip 0 intersecting with the previous
                foreach (Vector3i where in segment)
                {
                    Vector3i Swhere = Geo3D.Surface(where) + offsetSurface;
                    setter.Apply(Swhere);
                    setter.Apply(Swhere + Vectors.Up);
                    setter.Apply(Swhere + 2 * Vectors.Up);
                    setter.Push();
                    start = Swhere;
                    yield return(new WaitForEndOfFrame());
                }
                yield return(new WaitForSeconds(1f));
            }
        }