예제 #1
0
    public PUGameObject(
			cRect bounds,
			cVector3 rotation,
			bool hidden,
			float lastY,
			float lastX,
			int renderQueueOffset,
			bool clipDepth,
			bool clipStencil )
        : this()
    {
        this.bounds = bounds;
        this.boundsExists = true;

        this.rotation = rotation;
        this.rotationExists = true;

        this.hidden = hidden;
        this.hiddenExists = true;

        this.lastY = lastY;
        this.lastYExists = true;

        this.lastX = lastX;
        this.lastXExists = true;

        this.renderQueueOffset = renderQueueOffset;
        this.renderQueueOffsetExists = true;

        this.clipDepth = clipDepth;
        this.clipDepthExists = true;

        this.clipStencil = clipStencil;
        this.clipStencilExists = true;
    }
예제 #2
0
    public PUSprite(
			string resourcePath,
			cVector3 position,
			float scale,
			cRect bounds )
        : this()
    {
        this.resourcePath = resourcePath;
        this.resourcePathExists = true;

        this.position = position;
        this.positionExists = true;

        this.scale = scale;
        this.scaleExists = true;

        this.bounds = bounds;
        this.boundsExists = true;
    }
예제 #3
0
    public PUImageButton(
			string normalResourcePath,
			string highlightedResourcePath,
			cColor touchColor,
			cVector2 touchSize,
			string onTouchUp,
			string onTouchDown,
			string resourcePath,
			string shader,
			cVector2 anchor,
			cColor color,
			cRect bounds,
			cVector3 rotation,
			bool hidden,
			float lastY,
			float lastX,
			int renderQueueOffset,
			bool clipDepth,
			bool clipStencil,
			string title,
			string tag,
			string tag1,
			string tag2,
			string tag3,
			string tag4,
			string tag5,
			string tag6 )
        : this()
    {
        this.normalResourcePath = normalResourcePath;
        this.normalResourcePathExists = true;

        this.highlightedResourcePath = highlightedResourcePath;
        this.highlightedResourcePathExists = true;

        this.touchColor = touchColor;
        this.touchColorExists = true;

        this.touchSize = touchSize;
        this.touchSizeExists = true;

        this.onTouchUp = onTouchUp;
        this.onTouchUpExists = true;

        this.onTouchDown = onTouchDown;
        this.onTouchDownExists = true;

        this.resourcePath = resourcePath;
        this.resourcePathExists = true;

        this.shader = shader;
        this.shaderExists = true;

        this.anchor = anchor;
        this.anchorExists = true;

        this.color = color;
        this.colorExists = true;

        this.bounds = bounds;
        this.boundsExists = true;

        this.rotation = rotation;
        this.rotationExists = true;

        this.hidden = hidden;
        this.hiddenExists = true;

        this.lastY = lastY;
        this.lastYExists = true;

        this.lastX = lastX;
        this.lastXExists = true;

        this.renderQueueOffset = renderQueueOffset;
        this.renderQueueOffsetExists = true;

        this.clipDepth = clipDepth;
        this.clipDepthExists = true;

        this.clipStencil = clipStencil;
        this.clipStencilExists = true;

        this.title = title;
        this.titleExists = true;

        this.tag = tag;
        this.tagExists = true;

        this.tag1 = tag1;
        this.tag1Exists = true;

        this.tag2 = tag2;
        this.tag2Exists = true;

        this.tag3 = tag3;
        this.tag3Exists = true;

        this.tag4 = tag4;
        this.tag4Exists = true;

        this.tag5 = tag5;
        this.tag5Exists = true;

        this.tag6 = tag6;
        this.tag6Exists = true;
    }
예제 #4
0
 protected int outcode(cVector3 globalpos)
 {
     return outcodeLocal(globalToLocalPosition(globalpos));
 }
예제 #5
0
        /* Overload this so as not to change
            velocity as I normally want my walls to be stable and not drift after being dragged. */

        /// <summary>
        /// There's a collision if pcritter has crossed the wall or if the radius of pcritter is more than
        /// the pcritter's distance to the wall.  Has code to prevent the pcritter from going through the wall.
        /// Returns true if a collision was detected and false otherwise.
        /// </summary>
        /// <param name="pcritter">The critter to test for a collision with the wall.</param>
        /// <returns></returns>
        public override bool collide(cCritter pcritter)
        {
            cVector3 oldlocalpos, newlocalpos;
            float newdistance;
            int oldoutcode, newoutcode;
            bool crossedwall;

            oldlocalpos = globalToLocalPosition(pcritter.OldPosition);
            oldoutcode = _pskeleton.outcode(oldlocalpos);
            newlocalpos = globalToLocalPosition(pcritter.Position);
            newdistance = _pskeleton.distanceToOutcode(newlocalpos,
                out newoutcode); //Sets the newoutcode as well.
            crossedwall = crossed(oldoutcode, newoutcode);

            if (newdistance >= pcritter.Radius && !crossedwall) //No collision 
                return false; /*See if there's a collision at all. We
		say there's a collision if crossedwall or if the
		cCritterWall.distance is less than radius.  Remember that
		cCritterWall.distance measures the distance to the OUTSIDE 
		PERIMETER of the box, not the distance to the box's center. */

            /* I collided, so I need to move back further into the last good
            zone I was in outside the wall.  I want to set newlocalpos so 
            the rim of its critter is touching the wall. The idea is to back
            up in the direction of oldlocalpos.  To allow the possibility
            of skidding along the wall, we plan to back up from the
            the face (or edge or corner) facing oldlocalpos.  This works
            only if oldlocalpos was a good one, not inside the box.  In 
            principle this should always be true, but some rare weird circumstance
            (like a triple collsion) might mess this up, so we check for the
            bad case before starting. */

            if (oldoutcode == cRealBox3.BOX_INSIDE) //Note that this almost never happens.
            {
                cVector3 insidepos = new cVector3();
                insidepos.copy(oldlocalpos);
                oldlocalpos.subassign(pcritter.Tangent.mult(_pskeleton.MaxSize));
                //Do a brutally large backup to get out of the box for sure.
                oldoutcode = _pskeleton.outcode(oldlocalpos);
                //Recalculate outcode at this new position.
                oldlocalpos = _pskeleton.closestSurfacePoint(oldlocalpos, oldoutcode,
                    insidepos, cRealBox3.BOX_INSIDE, false);
                //Go to the closest surface point from there.
                oldoutcode = _pskeleton.outcode(oldlocalpos);
                //Recalculate outcode one more time to be safe.
                crossedwall = crossed(oldoutcode, newoutcode);
                //Recalculate crossedwall 
            }
            /* I find that with this code, the mouse can drag things through walls,
        so I do a kludge to block it by setting crossedwall to TRUE, this
        affects the action of cRealBox.closestSurfacePoint, as modified
        in build 34_4. */
            if (pcritter.Listener.IsKindOf("cListenerCursor"))
                crossedwall = true; //Don't trust the mouse listener.
            newlocalpos = _pskeleton.closestSurfacePoint(oldlocalpos, oldoutcode,
                newlocalpos, newoutcode, crossedwall);
            /* This call to closestSurfacePoint will move the newlocal pos
        from the far new side (or inside, or overlapping) of the box back to 
        the surface, usually on the old near side, edge, or corner given by
        oldoutcode. This prevents going through the	wall.
            If oldoutcode is a corner position and you are in fact heading
        towards a face near the corner, we used to bounce off the corner
        even though visually you can see you should bounce off the
        face.  This had the effect of making a scooter player get hung up on
        a corner sometimes. As of build 34_3, I'm moving the 
        newlocalpos to the newoutocode side in the case where oldlocalpos
        is an edge or a corner, and where crossedwall isn't TRUE.  I
        have to force in a TRUE for the cCursorLIstener case.  The USEJIGGLE
        code below also helps keep non-player critters from getting stuck
        on corners. */
            //Now back away from the box.
            newoutcode = _pskeleton.outcode(newlocalpos);
            cVector3 avoidbox = _pskeleton.escapeVector(newlocalpos, newoutcode);
            newlocalpos.addassign(avoidbox.mult(pcritter.Radius));
            newoutcode = _pskeleton.outcode(newlocalpos);
            pcritter.moveTo(localToGlobalPosition(newlocalpos), true);
            //TRUE means continuous motion, means adjust tangent etc.
            //Done with position, now change the velocity 
            cVector3 localvelocity = globalToLocalDirection(pcritter.Velocity);
            cVector3 oldlocalvelocity = new cVector3();
            oldlocalvelocity.copy(localvelocity);
            _pskeleton.reflect(localvelocity, newoutcode);
            /* I rewrote the reflect code on Feb 22, 2004 for VErsion 34_3, changing
        it so that when you reflect off an edge or corner, you only bounce
        the smallest of your three velocity components. Balls stll seem to
        get hung up on the corner once is awhile. */
            /* Now decide, depending on the pcritter's absorberflag and bounciness,
        how much you want to use the new localvelocity vs. the 
        oldlocalvelocity. We decompose the new localvelocity into the
        tangentvelocity parallel to the wall and the normalvelocity
        away from the wall. Some pencil and paper drawings convince
        me that the tangent is half the sum of the oldlocalvelocity
        and the reflected new localvelocity. */
            cVector3 tangentvelocity = localvelocity.add(oldlocalvelocity).mult(0.5f);
            cVector3 normalvelocity = localvelocity.sub(tangentvelocity);
            float bouncefactor = 1.0f;
            if (pcritter.AbsorberFlag)
                bouncefactor = 0.0f;
            else
                bouncefactor = pcritter.Bounciness;
            localvelocity = tangentvelocity.add(normalvelocity.mult(bouncefactor));
            /* Maybe the rotation should depend on the kind of edge or corner.
            Right now let's just use critter's binormal. Don't to it 
            to the player or viewer as it's confusing.  */
            if (!(cRealBox3.isFaceOutcode(newoutcode)) && //edge or corner 
                !(pcritter.IsKindOf("cCritterViewer")) && //not viewer 
                !(pcritter.IsKindOf("cCritterArmedPlayer")))
            //Not player.  Note that cPlayer inherits from cCritterArmedPlayer, 
            //so don't use cCritterPlayer as the base class here.
            {
                localvelocity.rotate(new cSpin(
                    Framework.randomOb.randomReal(
                        -cCritterWall.CORNERJIGGLETURN,
                        cCritterWall.CORNERJIGGLETURN), //A random turn 
                        pcritter.Binormal)); //Around the critter's binormal 
                localvelocity.multassign(cCritterWall.CORNERJIGGLEKICK); //Goose it a little 
            }
            pcritter.Velocity = localToGlobalDirection(localvelocity);
            return true;
        }
 public cCritterDoor(cVector3 enda, cVector3 endb, float thickness, float height, cGame pownergame)
     : base(enda, endb, thickness, height, pownergame)
 {
 }
예제 #7
0
 public cSpriteTextureBox(cVector3 locorner)
 {
     _pskeleton = new cRealBox3(locorner, new cVector3(1.0f, 1.0f, 1.0f));
     _initialize();
 }
예제 #8
0
 public void SetRotation(cVector3 v)
 {
     rotation = v; rotationExists = true;
 }
예제 #9
0
    public virtual void gaxb_load(XmlReader reader, object _parent, Hashtable args)
    {
        if(reader == null && _parent == null)
            return;

        parent = _parent;

        if(this.GetType() == typeof( LDGEquipment ))
        {
            gaxb_addToParent();
        }

        xmlns = reader.GetAttribute("xmlns");

        string attr;
        attr = reader.GetAttribute("dmgStructure");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { dmgStructure = float.Parse(attr); dmgStructureExists = true; }

        attr = reader.GetAttribute("dmgShields");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { dmgShields = float.Parse(attr); dmgShieldsExists = true; }

        attr = reader.GetAttribute("dmgArmor");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { dmgArmor = float.Parse(attr); dmgArmorExists = true; }

        attr = reader.GetAttribute("dmgPlanet");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { dmgPlanet = float.Parse(attr); dmgPlanetExists = true; }

        attr = reader.GetAttribute("range");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { range = float.Parse(attr); rangeExists = true; }

        attr = reader.GetAttribute("spread");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { spread = float.Parse(attr); spreadExists = true; }

        attr = reader.GetAttribute("reload");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr == null) { attr = "1"; }
        if(attr != null) { reload = float.Parse(attr); reloadExists = true; }

        attr = reader.GetAttribute("reloadCounter");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { reloadCounter = float.Parse(attr); reloadCounterExists = true; }

        attr = reader.GetAttribute("armor");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { armor = float.Parse(attr); armorExists = true; }

        attr = reader.GetAttribute("structure");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { structure = float.Parse(attr); structureExists = true; }

        attr = reader.GetAttribute("shields");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { shields = float.Parse(attr); shieldsExists = true; }

        attr = reader.GetAttribute("speed");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { speed = float.Parse(attr); speedExists = true; }

        attr = reader.GetAttribute("turning");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { turning = float.Parse(attr); turningExists = true; }

        attr = reader.GetAttribute("special");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { special = int.Parse(attr); specialExists = true; }

        attr = reader.GetAttribute("name");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { name = attr; nameExists = true; }

        attr = reader.GetAttribute("icon");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { icon = int.Parse(attr); iconExists = true; }

        attr = reader.GetAttribute("time");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { time = int.Parse(attr); timeExists = true; }

        attr = reader.GetAttribute("position");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { position = attr; positionExists = true; }

        attr = reader.GetAttribute("velocity");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { velocity = attr; velocityExists = true; }

        attr = reader.GetAttribute("rotation");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { rotation = attr; rotationExists = true; }

        attr = reader.GetAttribute("beingDragged");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { beingDragged = bool.Parse(attr); beingDraggedExists = true; }
    }
예제 #10
0
 public cForceGravity(float gravity = 25.0f)
 {
     _pulldirection = new cVector3(0.0f, -1.0f, 0.0f);
     _intensity     = gravity;
 }
예제 #11
0
 public cForceGravity(float gravity, cVector3 pulldirection)
 {
     _pulldirection = new cVector3();
     _pulldirection.copy(pulldirection);
     _intensity = gravity;
 }
예제 #12
0
        /* Overload to rule out possibliity of 
            all/wall collision,	even if they aren't fixed. */

        /// <summary>
        /// Finds and returns the distance from the wall to a point.
        /// </summary>
        /// <param name="vpoint">The point from which the distance to the wall will be measured.</param>
        /// <returns></returns>
        public new float distanceTo(cVector3 vpoint)
        {
            return _pskeleton.distanceTo(globalToLocalPosition(vpoint));
        }
예제 #13
0
 /// <summary>
 /// Returns true if a line from start to end passes through the wall.  Othersize, returns false.
 /// </summary>
 /// <param name="start">The starting point for the line.</param>
 /// <param name="end">The ending point for the line.</param>
 /// <returns></returns>
 public virtual bool blocks(cVector3 start, cVector3 end)
 {
     return crossed(outcode(start), outcode(end));
 }
 public cVector3 getCorrectionPercents(int modelIndex)
 {
     cVector3 cp = new cVector3();
     cp.Z = minfo[modelIndex].offset;
     return cp;
 }
 public cCritterInvisibleWall(cVector3 enda, cVector3 endb, float thickness = THICKNESS,
                              float height = WALLPRISMDZ, cGame pownergame = null) : base(enda, endb, thickness,
                                                                                          height, pownergame)
 {
     Sprite = new cSpriteComposite();
 }
예제 #16
0
        public cCritterBossMog(cGame3D pownergame, cVector3 position, cCritterBullet bullet, float firerate = 4.0f, int health = 20, int model = 5)
            : base(pownergame, position, model, bullet, firerate, health)
        {

        }
예제 #17
0
    public PUTable(
			cVector2 contentSize,
			bool bounces,
			bool pagingEnabled,
			bool scrollEnabled,
			PlanetUnity.ScrollDirection scrollDirection,
			bool directionalLockEnabled,
			cRect bounds,
			cVector3 rotation,
			bool hidden,
			float lastY,
			float lastX,
			int renderQueueOffset,
			bool clipDepth,
			bool clipStencil,
			string title,
			string tag,
			string tag1,
			string tag2,
			string tag3,
			string tag4,
			string tag5,
			string tag6 )
        : this()
    {
        this.contentSize = contentSize;
        this.contentSizeExists = true;

        this.bounces = bounces;
        this.bouncesExists = true;

        this.pagingEnabled = pagingEnabled;
        this.pagingEnabledExists = true;

        this.scrollEnabled = scrollEnabled;
        this.scrollEnabledExists = true;

        this.scrollDirection = scrollDirection;
        this.scrollDirectionExists = true;

        this.directionalLockEnabled = directionalLockEnabled;
        this.directionalLockEnabledExists = true;

        this.bounds = bounds;
        this.boundsExists = true;

        this.rotation = rotation;
        this.rotationExists = true;

        this.hidden = hidden;
        this.hiddenExists = true;

        this.lastY = lastY;
        this.lastYExists = true;

        this.lastX = lastX;
        this.lastXExists = true;

        this.renderQueueOffset = renderQueueOffset;
        this.renderQueueOffsetExists = true;

        this.clipDepth = clipDepth;
        this.clipDepthExists = true;

        this.clipStencil = clipStencil;
        this.clipStencilExists = true;

        this.title = title;
        this.titleExists = true;

        this.tag = tag;
        this.tagExists = true;

        this.tag1 = tag1;
        this.tag1Exists = true;

        this.tag2 = tag2;
        this.tag2Exists = true;

        this.tag3 = tag3;
        this.tag3Exists = true;

        this.tag4 = tag4;
        this.tag4Exists = true;

        this.tag5 = tag5;
        this.tag5Exists = true;

        this.tag6 = tag6;
        this.tag6Exists = true;
    }
예제 #18
0
        protected float _spiralangle;    /* Angle that the vortex force makes with the vector from _eyeposition
                                          * to a critter position.  Positive means counterclockwise, negative is clockwise,
                                          * -0.5 to 0.5 PI is outward, 0.5 to 1.5 PI is inward. +- 0.5 PI is neither. */

        public cForceVortex(float friction = 0.5f)
            : base(friction)
        {
            _eyeposition = new cVector3(0.0f, 0.0f, 0.0f);
            _spiralangle = 0.6f * (float)Math.PI;
        }
예제 #19
0
        /* Uses _foveaproportion which lies between 0.0 and 1.0. We say something is visible if it
         *  appears on the inner _foveaproportion central box of the viewer's image screen,
         *  which is what you see in the view window. */
        //overloads

        //Use _pownerview to get the CpopDoc and get the cGame from that.

        public override void update(ACView pactiveview, float dt)
        {
            base.update(pactiveview, dt);
            ZClipPlanes = Game.Border.outerBox(cSprite.MAXPRISMDZ);
            if (_trackplayer &&
                !((Listener != null) && Listener.RuntimeClass == "cListenerViewerRide"))

            /* The meaning of the visibleplayer() condition is that it doesn't make sense
             * to track the player if it's not an onscreen player. The reason for the
             * listener condition is that you don't want to stare at the player when
             * riding it. */
            /*  I should  explain that the goal here is to not bother turning when the player
             * is  moving around in the middle of the veiw area, and only to turn when he's near
             * the edge, but to have the turning when he's near the edge be smoooth.
             * The use of the 0.85 foveaproportion parameter means that you react before the player
             * gets right up to the edge.  The reactproportion factor in lookAtProportional and
             * moveToProportional is delicate and should probably be adjusted according to the
             * current player speed relative to the visible window.  The issue is that (a) if I make
             * reactproportion too small, like 0.01, then the viewer doesn't turn (or move) fast
             * enough to catch up with the player and keep it in view, but (b) if I make reactpropotion
             * too big, like 0.5, then the turning or moving is such an abrupt jump that the visual
             * effect is jerky.  The goal is to do turns that are just big enough to not look jerky,
             * but to have the turns be big enough so you aren't turning more often than you really
             * have to.  Another downside of a toosmall reactproportion, by the way, is that it can be
             * computationally expensive to react.
             * The way we finally solved this is to do a while loop to turn just
             * far enough, moving just a little at a time so as to not overshoot. */
            {
                if (isVisible(Game.Player.Position)) // Uses _foveaproportion
                {
                    _lastgoodplayeroffset = Position.sub(Game.Player.Position);
                }

                /*I'm not sure about constantly changing _lastgoodplayeroffset.  On the
                 * one hand, the offset I set in setViewpoint was a standard good one, so why
                 * not keep it.  On the other, if I want to move my viewpoint around then I
                 * do want to be able to get a new value here. It seems ok for now.*/
                else //not visible, so do somehting about it.
                {
                    int loopcount      = 0; /* Never have a while loop without a loopcount
                                             * to make sure you don't spin inside the while forever under some
                                             * unexpected situation like at startup. */
                    cVector3 lookat    = Game.Player.Position;
                    cVector3 viewerpos = lookat.add(_lastgoodplayeroffset);
                    if (Game.worldShape() == cGame.SHAPE_XSCROLLER)
                    {
                        lookat = new cVector3(Game.Player.Position.X,
                                              Game.Border.Midy, Game.Player.Position.Z);
                        viewerpos = new cVector3(lookat.X, Position.Y, Position.Z);
                    }
                    if (Game.worldShape() == cGame.SHAPE_YSCROLLER)
                    {
                        lookat = new cVector3(Game.Border.Midx,
                                              Game.Player.Position.Y, Game.Player.Position.Z);
                        viewerpos = new cVector3(Position.X, lookat.Y, Position.Z);
                    }
                    if (_perspective)
                    {
                        while (!isVisible(lookat) && loopcount < 100) // Uses _foveaproportion
                        {
                            moveToProportional(viewerpos, cCritterViewer.TURNPROPORTION);
                            loopcount++;
                        }
                    }
                    else //ortho case
                    {
                        while (!isVisible(lookat) && loopcount < 100) // Uses _foveaproportion
                        {
                            moveToProportional(lookat.add(Game.Player.Binormal.mult(10.0f)),
                                               cCritterViewer.TURNPROPORTION);
                            loopcount++;
                        }
                    }
                }
            }
            //Possibly ride the player.
            if (Listener.IsKindOf("cListenerViewerRide"))
            {
                cCritter pplayer = Game.Player;
                cVector3 offset  = ((cListenerViewerRide)Listener).Offset;
                moveTo(pplayer.Position.add(
                           pplayer.AttitudeTangent.mult(offset.X).add(
                               pplayer.AttitudeNormal.mult(offset.Y).add(
                                   pplayer.AttitudeBinormal.mult(offset.Z)))));
                cRealBox3 skeleton = pplayer.MoveBox;
                if (skeleton.ZSize < 0.5f)
                {
                    skeleton.setZRange(0.0f, offset.Z);
                }
                if (skeleton.YSize < 0.5f)
                {
                    skeleton.setYRange(0.0f, offset.Z);
                }
                skeleton.clamp(_position);
                for (int i = 0; i < Game.Biota.count(); i++)
                {
                    cCritter pother = Game.Biota.GetAt(i);
                    if (pother.IsKindOf("cCritterWall"))
                    {
                        pother.collide(this);
                    }
                }

                /* colliding with the wall may have twisted the viwer's orientation,
                 * so align it once again. */
                Attitude = pplayer.Attitude; /* Before we call lookAt,
                                              * make sure your attitude matches the player.  For one thing,
                                              * you may have gotten twisted around in the COLLIDEVIEWER code. */
                lookAt(pplayer.Position.add(
                           pplayer.AttitudeTangent.mult(cListenerViewerRide.PLAYERLOOKAHEAD * pplayer.Radius))
                       );

                /* This has the effect that as offset gets large you change your
                 * looking direction see right in front of the player. The multiplier
                 * cCritterViewer.PLAYERLOOKAHEAD is tweaked to work well
                 * with the default cCritterViewer.OFFSET. */
            }
        }
예제 #20
0
 public cForceVortex(float friction, float spiralangle)
     : base(friction)
 {
     _eyeposition = new cVector3(0.0f, 0.0f, 0.0f);
     _spiralangle = spiralangle;
 }
예제 #21
0
        //function to be passed into the thread that walls are spawned in
        //this allows us to wait a few seconds before spawning walls in order to maintain a gap between them.
        public void spawnWall(cVector3 enda, cVector3 endb, float thickness, float height, cGame pownergame, cCritterSlideWall.TYPE wallType, cVector3 moveAxisAndDirection, bool bounce, cVector3 startPos, cVector3 endPos)
        {
            int   numWalls = 3;
            float spawnPos = 10; //position the ith wall must reach before the (i + 1)th wall spawns

            //spawn the first wall
            cCritterSlideWall wall      = new cCritterSlideWall(enda, endb, thickness, height, pownergame, wallType, moveAxisAndDirection, bounce, startPos, endPos);
            cSpriteTextureBox spriteBox = new cSpriteTextureBox(wall.Skeleton, BitmapRes.Wood2, 16);

            wall.Sprite = spriteBox;

            //spawn the remaining walls
            for (int i = 0; i < numWalls - 1; i++)
            {
                //wait until the previous wall reaches the spawn position
                while (wall.Position.Z > spawnPos)
                {
                    ;
                }
                //spawn the wall and add textures.
                wall        = new cCritterSlideWall(enda, endb, thickness, height, pownergame, wallType, moveAxisAndDirection, bounce, startPos, endPos);
                spriteBox   = new cSpriteTextureBox(wall.Skeleton, BitmapRes.Wood2, 16);
                wall.Sprite = spriteBox;
            }
        }
예제 #22
0
        protected cVector3 _windvector; /* The effective rest direction for this force.  Default is
                                         * the zero vector.  */

        public cForceDrag(float friction = 0.5f)
        {
            _windvector = new cVector3();
            _intensity  = friction;
        }
예제 #23
0
 public void SetVelocity(cVector3 v)
 {
     velocity = v; velocityExists = true;
 }
예제 #24
0
 public cForceDrag(float friction, cVector3 windvector)
 {
     _windvector = new cVector3();
     _windvector.copy(windvector);
     _intensity = friction;
 }
 public DamagingWall(cVector3 enda, cVector3 endb, float thickness, float height, cGame pownergame)
     : base(enda, endb, thickness, height, pownergame)
 {
 }
예제 #26
0
 public virtual void vectorToPixel(cVector3 position, out int xpix, out int ypix, out float zbuff)
 {
     xpix  = ypix = 1;
     zbuff = 1.0f;
 }
예제 #27
0
 public cSpriteTextureBox(cVector3 locorner, cVector3 hicorner, Color color)
 {
     _pskeleton = new cRealBox3(locorner, hicorner);
     _initialize();
     setSideColors(color);
 }
예제 #28
0
 public virtual Color sniff(cVector3 sniffpoint)
 {
     return(Color.FromArgb(0));
 }
예제 #29
0
        protected int outcodeLocal(cVector3 localpos)
        { 		/* This tells you which of the 27 possible positions a 
			localpos has relative to the pskeleton box */
            return _pskeleton.outcode(localpos);
        }
예제 #30
0
 public virtual void drawline(cVector3 posa, cVector3 posb,
                              cColorStyle pcolorstyle)
 {
 }                               //reallinewidth 0 means 1 pixel wide.
예제 #31
0
    public PULabel(
			string shader,
			string font,
			int fontSize,
			PlanetUnity.LabelAlignment alignment,
			cColor textColor,
			string value,
			cVector2 shadowOffset,
			cColor shadowColor,
			cRect bounds,
			cVector3 rotation,
			bool hidden,
			float lastY,
			float lastX,
			int renderQueueOffset,
			bool clipDepth,
			bool clipStencil,
			string title,
			string tag,
			string tag1,
			string tag2,
			string tag3,
			string tag4,
			string tag5,
			string tag6 )
        : this()
    {
        this.shader = shader;
        this.shaderExists = true;

        this.font = font;
        this.fontExists = true;

        this.fontSize = fontSize;
        this.fontSizeExists = true;

        this.alignment = alignment;
        this.alignmentExists = true;

        this.textColor = textColor;
        this.textColorExists = true;

        this.value = value;
        this.valueExists = true;

        this.shadowOffset = shadowOffset;
        this.shadowOffsetExists = true;

        this.shadowColor = shadowColor;
        this.shadowColorExists = true;

        this.bounds = bounds;
        this.boundsExists = true;

        this.rotation = rotation;
        this.rotationExists = true;

        this.hidden = hidden;
        this.hiddenExists = true;

        this.lastY = lastY;
        this.lastYExists = true;

        this.lastX = lastX;
        this.lastXExists = true;

        this.renderQueueOffset = renderQueueOffset;
        this.renderQueueOffsetExists = true;

        this.clipDepth = clipDepth;
        this.clipDepthExists = true;

        this.clipStencil = clipStencil;
        this.clipStencilExists = true;

        this.title = title;
        this.titleExists = true;

        this.tag = tag;
        this.tagExists = true;

        this.tag1 = tag1;
        this.tag1Exists = true;

        this.tag2 = tag2;
        this.tag2Exists = true;

        this.tag3 = tag3;
        this.tag3Exists = true;

        this.tag4 = tag4;
        this.tag4Exists = true;

        this.tag5 = tag5;
        this.tag5Exists = true;

        this.tag6 = tag6;
        this.tag6Exists = true;
    }
예제 #32
0
    public override void gaxb_load(XmlReader reader, object _parent, Hashtable args)
    {
        base.gaxb_load(reader, _parent, args);

        if(reader == null && _parent == null)
            return;

        parent = _parent;

        if(this.GetType() == typeof( PUSprite ))
        {
            gaxb_addToParent();
        }

        xmlns = reader.GetAttribute("xmlns");

        string attr;
        attr = reader.GetAttribute("resourcePath");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { resourcePath = attr; resourcePathExists = true; }

        attr = reader.GetAttribute("position");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { position = attr; positionExists = true; }

        attr = reader.GetAttribute("scale");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { scale = float.Parse(attr); scaleExists = true; }
    }
예제 #33
0
    public PUMovie(
			bool hasAlpha,
			bool looping,
			string resourcePath,
			string shader,
			cVector2 anchor,
			cColor color,
			cRect bounds,
			cVector3 rotation,
			bool hidden,
			float lastY,
			float lastX,
			int renderQueueOffset,
			bool clipDepth,
			bool clipStencil,
			string title,
			string tag,
			string tag1,
			string tag2,
			string tag3,
			string tag4,
			string tag5,
			string tag6 )
        : this()
    {
        this.hasAlpha = hasAlpha;
        this.hasAlphaExists = true;

        this.looping = looping;
        this.loopingExists = true;

        this.resourcePath = resourcePath;
        this.resourcePathExists = true;

        this.shader = shader;
        this.shaderExists = true;

        this.anchor = anchor;
        this.anchorExists = true;

        this.color = color;
        this.colorExists = true;

        this.bounds = bounds;
        this.boundsExists = true;

        this.rotation = rotation;
        this.rotationExists = true;

        this.hidden = hidden;
        this.hiddenExists = true;

        this.lastY = lastY;
        this.lastYExists = true;

        this.lastX = lastX;
        this.lastXExists = true;

        this.renderQueueOffset = renderQueueOffset;
        this.renderQueueOffsetExists = true;

        this.clipDepth = clipDepth;
        this.clipDepthExists = true;

        this.clipStencil = clipStencil;
        this.clipStencilExists = true;

        this.title = title;
        this.titleExists = true;

        this.tag = tag;
        this.tagExists = true;

        this.tag1 = tag1;
        this.tag1Exists = true;

        this.tag2 = tag2;
        this.tag2Exists = true;

        this.tag3 = tag3;
        this.tag3Exists = true;

        this.tag4 = tag4;
        this.tag4Exists = true;

        this.tag5 = tag5;
        this.tag5Exists = true;

        this.tag6 = tag6;
        this.tag6Exists = true;
    }
예제 #34
0
    public override void gaxb_load(XmlReader reader, object _parent, Hashtable args)
    {
        base.gaxb_load(reader, _parent, args);

        if(reader == null && _parent == null)
            return;

        parent = _parent;

        if(this.GetType() == typeof( PUGameObject ))
        {
            gaxb_addToParent();
        }

        xmlns = reader.GetAttribute("xmlns");

        string attr;
        attr = reader.GetAttribute("bounds");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { bounds = attr; boundsExists = true; }

        attr = reader.GetAttribute("rotation");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { rotation = attr; rotationExists = true; }

        attr = reader.GetAttribute("hidden");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { hidden = bool.Parse(attr); hiddenExists = true; }

        attr = reader.GetAttribute("lastY");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { lastY = float.Parse(attr); lastYExists = true; }

        attr = reader.GetAttribute("lastX");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { lastX = float.Parse(attr); lastXExists = true; }

        attr = reader.GetAttribute("renderQueueOffset");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr != null) { renderQueueOffset = int.Parse(attr); renderQueueOffsetExists = true; }

        attr = reader.GetAttribute("clipDepth");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr == null) { attr = "false"; }
        if(attr != null) { clipDepth = bool.Parse(attr); clipDepthExists = true; }

        attr = reader.GetAttribute("clipStencil");
        if(attr != null && planetOverride != null) { attr = processStringMethod.Invoke(null, new [] {_parent, attr}).ToString(); }
        if(attr == null) { attr = "false"; }
        if(attr != null) { clipStencil = bool.Parse(attr); clipStencilExists = true; }
    }
예제 #35
0
        /* Turns the 2 points into 4 and calls the virtual
         *      drawrectangle method that uses four corners.  The 2 corner call assumes
         *      the rectangle has its z values averaged between
         *      cornerlo and cornerhi and traverses the 4 corners starting out heading from
         *      cornerlo.x() to cornerhi.x(). */

        public virtual void drawrectangle(cVector3 corner0, cVector3 corner1,
                                          cVector3 corner2, cVector3 corner3, cColorStyle pcolorstyle,
                                          int drawflags)
        {
        }                     //Defined in indivdiual graphics files.
예제 #36
0
        public void setViewpoint(cVector3 toViewer, cVector3 lookatPoint,
                                 bool trytoseewholeworld = true)
        {
            //First do some default setup stuff
            cVector3 toviewer = new cVector3();

            toviewer.copy(toViewer);
            cVector3 lookatpoint = new cVector3();

            lookatpoint.copy(lookatPoint);
            _fieldofviewangle = cCritterViewer.STARTFIELDOFVIEWANGLE;
            Speed             = 0.0f;
            _attitude         = new cMatrix3(new cVector3(0.0f, 0.0f, -1.0f),
                                             new cVector3(-1.0f, 0.0f, 0.0f), new cVector3(0.0f, 1.0f, 0.0f),
                                             new cVector3(0.0f, 0.0f, 0.0f));

            /* To get a reasonable default orientation, we arrange the viewer axes so that:
             * viewer x axis = world -z axis, viewer y axis = world -x axis, viewer z axis = world y axis.
             * We pick this orientation so that if the viewer moves "forward" (along its tangent vector)
             * it moves towards the world.  (We correct the mismatch between the coordinate systems in the
             * cCritterViewer.loadViewMatrix method, which has a long comment about this.)
             * Note that we will adjust _position (fourth column) later in this  call
             * with a moveTo, also we may rotate the _attitude a bit. */
            if (!_perspective)                                                                               //Ortho view, simply move up.
            {
                _proportionofworldtoshow = 1.0f;                                                             //Show all of a flat world.
                moveTo(lookatpoint.add((new cVector3(0.0f, 0.0f, 1.0f)).mult(cCritterViewer.ORTHOZOFFSET))); // Get above the world
                _maxspeed = _maxspeedstandard = 0.5f * cCritterViewer.ORTHOZOFFSET;                          //Mimic perspective case.
            }
            else //_perspective
            {
                if (toviewer.IsPracticallyZero)                    //Not usable, so pick a real direction.
                {
                    toviewer.copy(new cVector3(0.0f, 0.0f, 1.0f)); //Default is straight up.
                }
                if (trytoseewholeworld)                            /* Treat toviewer as a direction, and back off in that direction
                                                                    * enough to see the whole world */
                {
                    toviewer.normalize();                          //Make it a unit vector.
                    _proportionofworldtoshow = cCritterViewer.PROPORTIONOFWORLDTOSHOW;
                    //Trying to show all of a world when flying around it, often leaves too big a space around it.
                    float furthestcornerdistance = Game.Border.maxDistanceToCorner(lookatpoint);
                    float tanangle = (float)Math.Tan(_fieldofviewangle / 2.0f); /* We work with half the fov in this calculation,
                                                                                *  the tanangle will be the ratio of visible distance to distance above the world,
                                                                                *  that is, tanangle = dr/dz, where
                                                                                *  Our dr is _proportionofworldtoshow * furthestcornerdistance, and
                                                                                *  our dz is the unknown seeallz height we need to back off to.
                                                                                *  Swap tangangle and dz to get the next formula. */
                    float seeallz  = _proportionofworldtoshow * furthestcornerdistance / tanangle;
                    moveTo(lookatpoint.add(toviewer.mult(seeallz)));
                }
                else /*Not trytoseewholeworld.  In this case we don't normalize toviewer, instead
                      *         we treat it as a displacment from the lookatpoint. */
                {
                    moveTo(lookatpoint.add(toviewer));
                }
                lookAt(lookatpoint);
                _maxspeed = _maxspeedstandard = 0.5f * (Position.sub(lookatpoint)).Magnitude;

                /* Define the speed like this so it typically takes two seconds (1/0.5)
                 * to fly in to lookatpoint. */
                _lastgoodplayeroffset = Position.sub(Game.Player.Position);
            }
        }
예제 #37
0
 public void SetPosition(cVector3 v)
 {
     position = v; positionExists = true;
 }
예제 #38
0
        }                     //Defined in indivdiual graphics files.

        public virtual void drawcircle(cVector3 center, float radius,
                                       cColorStyle pcolorstyle, int drawflags)
        {
        }
예제 #39
0
 public virtual void translate(cVector3 translation)
 {
 }
예제 #40
0
    public LDGEquipment(
			float dmgStructure,
			float dmgShields,
			float dmgArmor,
			float dmgPlanet,
			float range,
			float spread,
			float reload,
			float reloadCounter,
			float armor,
			float structure,
			float shields,
			float speed,
			float turning,
			int special,
			string name,
			int icon,
			int time,
			cVector3 position,
			cVector3 velocity,
			cVector3 rotation,
			bool beingDragged )
        : this()
    {
        this.dmgStructure = dmgStructure;
        this.dmgStructureExists = true;

        this.dmgShields = dmgShields;
        this.dmgShieldsExists = true;

        this.dmgArmor = dmgArmor;
        this.dmgArmorExists = true;

        this.dmgPlanet = dmgPlanet;
        this.dmgPlanetExists = true;

        this.range = range;
        this.rangeExists = true;

        this.spread = spread;
        this.spreadExists = true;

        this.reload = reload;
        this.reloadExists = true;

        this.reloadCounter = reloadCounter;
        this.reloadCounterExists = true;

        this.armor = armor;
        this.armorExists = true;

        this.structure = structure;
        this.structureExists = true;

        this.shields = shields;
        this.shieldsExists = true;

        this.speed = speed;
        this.speedExists = true;

        this.turning = turning;
        this.turningExists = true;

        this.special = special;
        this.specialExists = true;

        this.name = name;
        this.nameExists = true;

        this.icon = icon;
        this.iconExists = true;

        this.time = time;
        this.timeExists = true;

        this.position = position;
        this.positionExists = true;

        this.velocity = velocity;
        this.velocityExists = true;

        this.rotation = rotation;
        this.rotationExists = true;

        this.beingDragged = beingDragged;
        this.beingDraggedExists = true;
    }
예제 #41
0
    public PUGameObject(
			cRect bounds,
			cVector3 rotation,
			bool hidden,
			float lastY,
			float lastX,
			int renderQueueOffset,
			bool clipDepth,
			bool clipStencil,
			string title,
			string tag,
			string tag1,
			string tag2,
			string tag3,
			string tag4,
			string tag5,
			string tag6 )
        : this()
    {
        this.bounds = bounds;
        this.boundsExists = true;

        this.rotation = rotation;
        this.rotationExists = true;

        this.hidden = hidden;
        this.hiddenExists = true;

        this.lastY = lastY;
        this.lastYExists = true;

        this.lastX = lastX;
        this.lastXExists = true;

        this.renderQueueOffset = renderQueueOffset;
        this.renderQueueOffsetExists = true;

        this.clipDepth = clipDepth;
        this.clipDepthExists = true;

        this.clipStencil = clipStencil;
        this.clipStencilExists = true;

        this.title = title;
        this.titleExists = true;

        this.tag = tag;
        this.tagExists = true;

        this.tag1 = tag1;
        this.tag1Exists = true;

        this.tag2 = tag2;
        this.tag2Exists = true;

        this.tag3 = tag3;
        this.tag3Exists = true;

        this.tag4 = tag4;
        this.tag4Exists = true;

        this.tag5 = tag5;
        this.tag5Exists = true;

        this.tag6 = tag6;
        this.tag6Exists = true;
    }
예제 #42
0
        public void setRoom2()
        {
            Biota.purgeCritters("cCritterWall");
            Biota.purgeCritters("cCritter3Dcharacter");
            Biota.purgeCritters("cCritterBoss");
            setBorder(50.0f, 40.0f, 50.0f);
            cRealBox3 skeleton = new cRealBox3();

            skeleton.copy(_border);
            setSkyBox(skeleton);
            SkyBox.setAllSidesTexture(BitmapRes.Graphics1, 2);
            SkyBox.setSideTexture(cRealBox3.LOY, BitmapRes.Concrete);
            SkyBox.setSideSolidColor(cRealBox3.HIY, Color.Blue);
            _seedcount = 0;
            Player.setMoveBox(new cRealBox3(50.0f, 40.0f, 50.0f));
            wentThrough  = true;
            startNewRoom = Age;

            //add door
            cCritterDoor      pdwall      = new cCritterDoor(new cVector3(_border.Midx, _border.Loy + 4, _border.Loz), new cVector3(_border.Midx, _border.Loy + 10, _border.Loz), 2.0f, 3.0f, this);
            cSpriteTextureBox pspritedoor = new cSpriteTextureBox(pdwall.Skeleton, BitmapRes.Door);

            pdwall.Sprite = pspritedoor;

            float wallThickness = 5.0f, wallHeight = 10.0f;
            //starting block
            cVector3          enda          = new cVector3(Border.Midx, Border.Loy + 1, Border.Hiz);
            cVector3          endb          = new cVector3(Border.Midx, Border.Loy + 1, Border.Hiz - 5);
            cCritterWall      startingBlock = new cCritterWall(enda, endb, wallThickness, wallHeight, this);
            cSpriteTextureBox pspritebox    =
                new cSpriteTextureBox(startingBlock.Skeleton, BitmapRes.Wood2, 16); //Sets all sides

            startingBlock.Sprite = pspritebox;
            //ending block
            cVector3          enda2       = new cVector3(Border.Midx, Border.Loy + 1, Border.Loz + 7);
            cVector3          endb2       = new cVector3(Border.Midx, Border.Loy + 1, Border.Loz);
            cCritterWall      endBlock    = new cCritterWall(enda2, endb2, wallThickness, 8.0f, this);
            cSpriteTextureBox pspritebox2 =
                new cSpriteTextureBox(endBlock.Skeleton, BitmapRes.Wood2, 16); //Sets all sides

            endBlock.Sprite = pspritebox2;
            //floor
            cVector3     enda3 = new cVector3(Border.Midx, Border.Loy, Border.Loz);
            cVector3     endb3 = new cVector3(Border.Midx, Border.Loy, Border.Hiz);
            DamagingWall floor = new DamagingWall(enda3, endb3, 0.5f, 0.5f, this);

            //med pack
            _ptreasure = new cCritterMedpack(this, new cVector3(Border.Midx, Border.Loy + 7, Border.Hiz - 4));

            //sliding walls (spawned based on pos of starting block)
            cVector3 leftEnd = new cVector3();

            leftEnd.addassign(startingBlock.Position.add(new cVector3(0, 4.0f, -0.5f)));
            cVector3 rightEnd = new cVector3();

            rightEnd.copy(leftEnd);
            rightEnd.addassign(new cVector3(0, 0, -5.0f));
            float    thickness = 0.1f, height = 0.3f;
            cVector3 moveAxisandDirection = new cVector3(0, 0, -0.005f);
            cVector3 startPos             = new cVector3();

            startPos.copy(rightEnd);
            cVector3 endPos = new cVector3();

            endPos.copy(startPos);
            endPos.Z = Border.Loz + 9.5f;

            //spawn sliding walls in a separate thread
            new Thread(() =>
                       spawnWall(leftEnd, rightEnd, thickness, height, this, cCritterSlideWall.TYPE.PLATFORM, moveAxisandDirection, false, startPos, endPos)).Start();

            seedCritters();
            Player.moveTo(startingBlock.Position.add(new cVector3(0, 10.0f, 0)));
            new cCritterBossDrFreak(this, endBlock.Position.add(new cVector3(0, 10.0f, 0)), new KnockbackBullet(), 5);
        }