Ejemplo n.º 1
0
        public void FollowObject(Object o, XYZ_d target, double speed)
        {
            XYZ_d vector = new XYZ_d(target).Sub(o.Position);

            vector.Div(vector.Length()).Mul(speed);
            MoveObject(o, vector);
        }
Ejemplo n.º 2
0
        protected override void DoSomething()
        {
            delta.Set(target).Sub(obj.Position);
            direction.Add(delta).Div(4);
            delta.Set(direction).Div(direction.Length()).Mul(speed);
            delta.z = (target.z - obj.Position.z - 20) / 20;

            modifier.MoveObject(obj, delta);
            Thread.Sleep(1);
        }
Ejemplo n.º 3
0
        public void Falling()
        {
            Vector.z += 4;
            if (!Check_Wall(Vector))
            {
                Position.Add(Vector);
                world.ConvertToInfinity(Position);
            }
            else if (Vector.Length() != 0)
            {
                XYZ index = new XYZ();
                world.GetFrameIndex(new XYZ_d(Position).Add(Vector), index);

                double vLength = Vector.Length();
                if (vLength > 90)
                {
                    // if(world.IsInFrame(index))
                    //   CrushFrame((int)(vLength / 4));
                    Vector.Div(4);
                    return;
                }
                else
                {
                    isJumpable = true;
                }

                world.ConvertIndexToPosition(index);
                if (Vector.z > 0)
                {
                    Position.z = index.z - world.frameLength / 2 - 1;
                }
                else
                {
                    Position.z = index.z + world.frameLength / 2 + 4;
                    isJumpable = false;
                }
                Vector.Set(0);
            }
        }
Ejemplo n.º 4
0
        public void MakeCone(XYZ_d pos, int radius, int height)
        {
            XYZ    frameIndex = new XYZ();
            XYZ_d  temp       = new XYZ_d();
            XYZ_d  temp2      = new XYZ_d();
            XYZ_d  temp3      = new XYZ_d();
            double distance   = 0;

            pos.z += height;
            XYZ_b color  = new XYZ_b(1, 1, 1);
            XYZ_b color2 = new XYZ_b(color).Mul(30);

            double degreeX = 30 * -Math.PI / 180d;
            double degreeY = 0 * Math.PI / 180d;
            double sinX    = Math.Sin(degreeX);
            double sinY    = Math.Sin(degreeY);
            double cosX    = Math.Cos(degreeX);
            double cosY    = Math.Cos(degreeY);
            XYZ_d  basisX  = new XYZ_d(cosY, -sinY, 0);
            XYZ_d  basisY  = new XYZ_d(cosX * sinY, cosX * cosY, -sinX);
            XYZ_d  basisZ  = new XYZ_d(sinX * sinY, sinX * cosY, cosX);

            for (int i = -radius - 1; i < radius + 1; i++)
            {
                for (int j = -radius - 1; j < radius + 1; j++)
                {
                    for (int k = -height - 1; k < -height / 2 + 1; k++)
                    {
                        temp.Set(pos).Add(i, j, k);
                        frameIndex = temp.ToXYZ();
                        ConvertToInfinity(frameIndex);
                        SetBlock(frameIndex, true);
                        SetColor(frameIndex, 0, 0, 0);
                        SetRender(frameIndex, renderer_block);
                        //SetColor(frameIndex,1,0,0);
                    }
                }
            }

            for (int i = -radius; i < radius; i++)
            {
                for (int j = -radius; j < radius; j++)
                {
                    for (int k = -height; k < -height / 2; k++)
                    {
                        temp.Set(pos).Add(i, j, k);
                        frameIndex = temp.ToXYZ();
                        ConvertToInfinity(frameIndex);
                        SetBlock(frameIndex, false);
                        SetRender(frameIndex, renderer_air);
                        //SetColor(frameIndex,1,0,0);
                    }
                }
            }
            //frameIndex = pos.ToXYZ();
            //ConvertToInfinity(frameIndex);
            //frameIndex.z -= height - 10;

            temp.Set(pos).Sub(0, 10, height - 10);
            for (int i = -2; i <= 2; i++)
            {
                for (int j = -2; j <= 2; j++)
                {
                    for (int k = -2; k <= 2; k++)
                    {
                        temp2.Set(temp).Add(i, j, k);
                        frameIndex = temp2.ToXYZ();
                        ConvertToInfinity(frameIndex);
                        SetBlock(frameIndex, true);
                        SetRender(frameIndex, renderer_block);
                    }
                }
            }

            for (int i = -radius; i < radius; i++)
            {
                for (int j = -radius; j < radius; j++)
                {
                    temp.Set(pos).Add(i, j, 0);
                    distance = pos.Distance(temp);
                    if (distance < radius)
                    {
                        frameIndex = temp.ToXYZ();
                        ConvertToInfinity(frameIndex);
                        //SetColor(frameIndex,color);

                        temp2.Set(temp).Sub(pos).Add(0, 0, height).Div(height);
                        temp2.Set(basisX.x * temp2.x + basisY.x * temp2.y + basisZ.x * temp2.z,
                                  basisX.y * temp2.x + basisY.y * temp2.y + basisZ.y * temp2.z,
                                  basisX.z * temp2.x + basisY.z * temp2.y + basisZ.z * temp2.z);
                        temp2.Div(temp2.Length());
                        //temp2.Set(temp3);
                        temp.Set(pos).Add(0, 0, -height);

                        /*******************************************************************************/

                        /*  frameIndex = temp.ToXYZ();
                         * XYZ deltaSign = new XYZ(Math.Sign(temp2.x),Math.Sign(temp2.y),Math.Sign(temp2.z));
                         * int nextDir = 0;
                         * XYZ_d maxNumOfDelta = new XYZ_d(frameLength).Mul(deltaSign).Div(temp2);
                         * XYZ_d target = new XYZ_d(halfFrameLength);
                         * target.Mul(deltaSign);//delta벡터 방향으로 이동시 접촉가능한 경계면들 구하기.
                         * target.Div(temp2);
                         */
                        //XYZ gap = new XYZ(frameIndex);

                        //color.Set(2,2,2);
                        //byte code = 0;
                        for (int k = 0; k < height * 1.5f; k++)
                        {
                            temp.Add(temp2);
                            frameIndex = temp.ToXYZ();

                            /* if (target.x < target.y)
                             *      if(target.x < target.z) nextDir = 0;
                             *      else nextDir = 2;
                             * else
                             *      if(target.y < target.z) nextDir = 1;
                             *      else nextDir = 2; */

                            //target.element[nextDir] += maxNumOfDelta.element[nextDir];
                            //frameIndex.element[nextDir] += deltaSign.element[nextDir];
                            ConvertToInfinity(frameIndex);
                            if (isFrameEnabled(frameIndex))
                            {
                                AddColor(frameIndex, color2);
                                break;
                            }
                            else
                            {
                                AddColor(frameIndex, color);
                            }
                            //SetBlock(frameIndex,code);

                            //gap.Set(frameIndex);

                            //Console.WriteLine(nextDir);
                        }
                    }
                }
            }
        }