Exemple #1
0
        public override void Construct(Vector3 spawnPosition, float rotation, CampaignSection section)
        {
            base.Construct(spawnPosition, rotation, section);

            this._state = AlienState.ALIVE;
            this._livestate = LiveState.ROAMING;
            this._health = 90;

            this._mesh = new SkinnedMesh();
            this._mesh.Model = AssetLoader.mdl_alien1;

            this._aplayer = new DurationBasedAnimator(_mesh.SkinningData, _mesh.SkinningData.AnimationClips["Take 001"], null);

            this._aplayer.AddAnimationPackage = AssetLoader.ani_alien1;
            this._aplayer.StartClip(Animation_States.moving);

            this.VerticalOffset = new Vector3(0, 0.8f, 0);
            this.ScaleMatrix = Matrix.CreateScale(0.6f);

            UpdateAnimations(0);
            UpdateMajorTransform();

            Globals.gameInstance.sceneGraph.Setup(_mesh);
            this._modelReceipt = Globals.gameInstance.sceneGraph.Add(_mesh);

            _collisionRectangle = new RectangleF(
                _position.X - bBWidth,
                _position.Z - bBWidth, bBWidth * 2, bBWidth * 2);
        }
Exemple #2
0
 public static bool Collide(RectangleF r, Vector3 p)
 {
     if (p.X < r.Left) return false;
     if (p.Z < r.Top) return false;
     if (p.Z > r.Bottom) return false;
     if (p.X > r.Right) return false;
     return true;
 }
Exemple #3
0
 public static bool Collide(RectangleF r1, RectangleF r2)
 {
     if (r1.Right < r2.Left) return false;
     if (r1.Bottom < r2.Top) return false;
     if (r1.Top > r2.Bottom) return false;
     if (r1.Left > r2.Right) return false;
     return true;
 }
Exemple #4
0
        public static bool Collide(CircleF c, RectangleF r)
        {
            // Find the closest point to the circle within the rectangle
            float closestX = MathHelper.Clamp(c.X, r.Left, r.Right);
            float closestY = MathHelper.Clamp(c.Y, r.Top, r.Bottom);

            // Calculate the distance between the circle's center and this closest point
            float distanceX = c.X - closestX;
            float distanceY = c.Y - closestY;

            // If the distance is less than the circle's radius, an intersection occurs
            float distanceSquared = (distanceX * distanceX) + (distanceY * distanceY);
            return distanceSquared < (c.Radius * c.Radius);
        }
Exemple #5
0
 private void UpdatePanelPositions()
 {
     doorLeftMesh.Transform = FLIP90Y * Matrix.CreateTranslation(position + new Vector3(0, 0, openPercent));
     doorRightMesh.Transform = FLIP90Y * FLIP180X * Matrix.CreateTranslation(position + new Vector3(0, 2.5f, -openPercent));
     
     doorLeftBB = new RectangleF(position.X-0.25f, position.Z+openPercent, 0.5f, 2f);
     doorRightBB = new RectangleF(position.X - 0.25f, position.Z - 2f - openPercent, 0.5f, 2f);
 }
        // when checking whether a rectangle collides with a door
        // there are only 2 doors at most: the currently opening one, 
        // and the closed one at the end of the next section
        public bool RectangleCollidesDoor(RectangleF collisionRectangle)
        {
            int ni = (int)(collisionRectangle.Right + collisionRectangle.Left)/2;

            int nearestIndex = (ni - 16) / 32;
            nearestIndex = (int)MathHelper.Clamp(nearestIndex, 0, sections.Count - 1);
            return sections[nearestIndex].RectangleCollidesDoor(collisionRectangle);

        }
 public bool CollideAliens(RectangleF BB)
 {
     for (int i = 0; i < _population.Count; i++)
     {
         BaseAlien ba = _population[i];
         if (Collider.Collide(BB, ba._collisionRectangle))
         {
             return true;
         }
     }
     return false;
 }
Exemple #8
0
        public PlayerObject(PlayerIndex playerIndex, Color color, Vector3 pos, float initialYRot)
        {
            this.playerIndex = playerIndex;
            this.color = color;

            // initial transform
            this._position = pos;
            rotation = initialYRot;

            SetupLights();

            mesh = new SkinnedMesh();
            mesh.Model = AssetLoader.mdl_character;

            //Create a new Animation Player that will take the bone dictionaries as arguments allowing individual animation with upper and lower body
            upPlayer = new DurationBasedAnimator(mesh.SkinningData, mesh.SkinningData.AnimationClips["Take 001"],  Animation_States.upperCharacterBones);
            lowPlayer = new DurationBasedAnimator(mesh.SkinningData, mesh.SkinningData.AnimationClips["Take 001"], Animation_States.lowerCharacterBonesandRoot);
            //Load the animations from the asset loader (these are in an Animation Package)
            upPlayer.AddAnimationPackage = AssetLoader.ani_character;
            upPlayer.StartClip(moving + shooting + weapon);
            lowPlayer.AddAnimationPackage = AssetLoader.ani_character;
            lowPlayer.StartClip(moving+weapon);
            

            UpdateAnimation(0);
            UpdateMajorTransforms(0);

            Globals.gameInstance.sceneGraph.Setup(mesh);
            modelReceipt = Globals.gameInstance.sceneGraph.Add(mesh);
            light1receipt = Globals.gameInstance.sceneGraph.Add(torchlight);
            light2receipt = Globals.gameInstance.sceneGraph.Add(haloemitlight);
            light3receipt = Globals.gameInstance.sceneGraph.Add(halolight);

            SetupWeapons();
            SwitchWeapon(0);

            collisionRectangle = new RectangleF(
                _position.X - boundingBoxSize,
                _position.Y - boundingBoxSize,
                boundingBoxSize * 2,
                boundingBoxSize * 2
            );

        }
Exemple #9
0
        public bool RectangleCollides(RectangleF r)
        {
            // test corners
            if (PointCollides(r.Left, r.Top)) return true;
            if (PointCollides(r.Left, r.Bottom)) return true;
            if (PointCollides(r.Right, r.Top)) return true;
            if (PointCollides(r.Right, r.Bottom)) return true;

            // test int divisors

            for (float y = r.Top; y <= r.Bottom; y+=1)
                for (float x = r.Left; x <= r.Right; x+=1)
                    if (PointCollides(x, y)) return true;

            return false;
        }