예제 #1
0
파일: Teacup.cs 프로젝트: apolaskey/Inkwell
 public void Initialize(Vector3 startPosition, bool directThrow)
 {
     teacupModel = new BasicModel(Engine.GameContainer, ModelProperties.Opaque, "Models/Levels/Level8/teacup1", startPosition);
     //teacupModel.Link.Texture = Engine.GameContainer.Load<Texture2D>("Textures/");
     thrownSpeed = Engine.Randomize(1.5f, 2.0f);
     DetermineVector();
 }
예제 #2
0
 public override void Initialize(Vector3 enemyPosition)
 {
     base.Initialize(enemyPosition);
     enemyType = EnemyType.JackCard;
     enemyModel = new BasicModel(Engine.GameContainer, ModelProperties.Alpha, Assets.PLANE8, enemyPosition);
     Speed = Engine.Randomize(1.5f, 2.0f);
     PerceptionDistance = 60f;
     Health = 35;
     AttackDamage = 10;
     int suit = Engine.Randomize(0, 4);
     switch (suit)
     {
         case 0:
             String tempCard = mAnimation.Peek.cardTypes[suit];
             enemyModel.Link.Texture = mAnimation.Peek.faceCards[tempCard.ToString() + "JackIdle0".ToString()];
             enemyModel.Link.Type = mAnimation.Peek.cardTypes[suit].ToString() + "Jack".ToString();
             break;
         case 1:
             String tempCard1 = mAnimation.Peek.cardTypes[suit];
             enemyModel.Link.Texture = mAnimation.Peek.faceCards[tempCard1.ToString() + "JackIdle0".ToString()];
             enemyModel.Link.Type = mAnimation.Peek.cardTypes[suit].ToString() + "Jack".ToString();
             break;
         case 2:
             String tempCard2 = mAnimation.Peek.cardTypes[suit];
             enemyModel.Link.Texture = mAnimation.Peek.faceCards[tempCard2.ToString() + "JackIdle0".ToString()];
             enemyModel.Link.Type = mAnimation.Peek.cardTypes[suit].ToString() + "Jack".ToString();
             break;
         case 3:
             String tempCard3 = mAnimation.Peek.cardTypes[suit];
             enemyModel.Link.Texture = mAnimation.Peek.faceCards[tempCard3.ToString() + "JackIdle0".ToString()];
             enemyModel.Link.Type = mAnimation.Peek.cardTypes[suit].ToString() + "Jack".ToString();
             break;
     }
 }
예제 #3
0
        public bool BoolBoxCollision(BasicModel mdl1, BasicModel mdl2)
        {
            gameBox.Min = mdl1.Link.Position + mdl1.Link.BoundingBox.Min;
            gameBox.Max = mdl1.Link.Position + mdl1.Link.BoundingBox.Max;

            newBox.Min = mdl2.Link.Position + mdl2.Link.BoundingBox.Min;
            newBox.Max = mdl2.Link.Position + mdl2.Link.BoundingBox.Max;

            bool temp = false;

            if (gameBox.Intersects(newBox))
            {
                if (mdl2.Link.Display)
                    temp = true;

                #region Collision Debug (Polaskey)
                if (Engine.DebugEnabled)
                {
                    if (temp)
                        dmCollision.Text = "Box Collision has occured with Model" + mdl2.ID;
                    else
                        dmCollision.Text = "Box Collision has not occured with Model" + mdl2.ID;
                }
                #endregion
            }
            return temp;
        }
예제 #4
0
 public override void Initialize(Vector3 enemyPosition)
 {
     base.Initialize(enemyPosition);
     NPC = true;
     enemyType = EnemyType.Caterpillar;
     enemyModel = new BasicModel(Engine.GameContainer, ModelProperties.Alpha, Assets.PLANE6, enemyPosition);
     Speed = 1.0f;
 }
예제 #5
0
 public override void Initialize(Vector3 enemyPosition)
 {
     base.Initialize(enemyPosition);
     NPC = true;
     enemyType = EnemyType.MarchHare;
     enemyModel = new BasicModel(Engine.GameContainer, ModelProperties.Alpha, Assets.PLANE6, enemyPosition);
     enemyModel.Link.Texture = Engine.GameContainer.Load<Texture2D>("Textures\\Enemies\\MarchHare");
     Speed = 1.0f;
 }
예제 #6
0
        public override void Initialize(Vector3 enemyPosition)
        {
            base.Initialize(enemyPosition);
            enemyType = EnemyType.RedCard;
            enemyModel = new BasicModel(Engine.GameContainer, ModelProperties.Alpha, Assets.PLANE8, enemyPosition);
            Speed = Engine.Randomize(0.7f, 1.0f);
            PerceptionDistance = 60f;
            Health = 35;
            AttackDamage = 5;
            int suit = Engine.Randomize(2, 4);
            int number = Engine.Randomize(1, 11);
            switch (number)
            {
                //key ~ suit+number+state
                case 1:
                    enemyModel.Link.Texture = mAnimation.Peek.regCards[mAnimation.Peek.cardTypes[suit].ToString() + number.ToString() + "Idle0".ToString()];
                    enemyModel.Link.Type = mAnimation.Peek.cardTypes[suit].ToString() + number.ToString();
                    break;
                case 2:
                    enemyModel.Link.Texture = mAnimation.Peek.regCards[mAnimation.Peek.cardTypes[suit].ToString() + number.ToString() + "Idle0".ToString()];
                    enemyModel.Link.Type = mAnimation.Peek.cardTypes[suit].ToString() + number.ToString();
                    break;
                case 3:
                    enemyModel.Link.Texture = mAnimation.Peek.regCards[mAnimation.Peek.cardTypes[suit].ToString() + number.ToString() + "Idle0".ToString()];
                    enemyModel.Link.Type = mAnimation.Peek.cardTypes[suit].ToString() + number.ToString();
                    break;
                case 4:
                    enemyModel.Link.Texture = mAnimation.Peek.regCards[mAnimation.Peek.cardTypes[suit].ToString() + number.ToString() + "Idle0".ToString()];
                    enemyModel.Link.Type = mAnimation.Peek.cardTypes[suit].ToString() + number.ToString();
                    break;
                case 5:
                    enemyModel.Link.Texture = mAnimation.Peek.regCards[mAnimation.Peek.cardTypes[suit].ToString() + number.ToString() + "Idle0".ToString()];
                    enemyModel.Link.Type = mAnimation.Peek.cardTypes[suit].ToString() + number.ToString();
                    break;
                case 6:
                    enemyModel.Link.Texture = mAnimation.Peek.regCards[mAnimation.Peek.cardTypes[suit].ToString() + number.ToString() + "Idle0".ToString()];
                    enemyModel.Link.Type = mAnimation.Peek.cardTypes[suit].ToString() + number.ToString();
                    break;
                case 7:
                    enemyModel.Link.Texture = mAnimation.Peek.regCards[mAnimation.Peek.cardTypes[suit].ToString() + number.ToString() + "Idle0".ToString()];
                    enemyModel.Link.Type = mAnimation.Peek.cardTypes[suit].ToString() + number.ToString();
                    break;
                case 8:
                    enemyModel.Link.Texture = mAnimation.Peek.regCards[mAnimation.Peek.cardTypes[suit].ToString() + number.ToString() + "Idle0".ToString()];
                    enemyModel.Link.Type = mAnimation.Peek.cardTypes[suit].ToString() + number.ToString();
                    break;
                case 9:
                    enemyModel.Link.Texture = mAnimation.Peek.regCards[mAnimation.Peek.cardTypes[suit].ToString() + number.ToString() + "Idle0".ToString()];
                    enemyModel.Link.Type = mAnimation.Peek.cardTypes[suit].ToString() + number.ToString();
                    break;
                case 10:
                    enemyModel.Link.Texture = mAnimation.Peek.regCards[mAnimation.Peek.cardTypes[suit].ToString() + number.ToString() + "Idle0".ToString()];
                    enemyModel.Link.Type = mAnimation.Peek.cardTypes[suit].ToString() + number.ToString();
                    break;

            }
        }
예제 #7
0
 public override void Initialize(Vector3 enemyPosition)
 {
     base.Initialize(enemyPosition);
     NPC = true;
     enemyType = EnemyType.WhiteRabbit;
     enemyModel = new BasicModel(Engine.GameContainer, ModelProperties.Alpha, Assets.PLANE6, enemyPosition);
     enemyModel.Link.Texture = Engine.GameContainer.Load<Texture2D>("Textures\\Animations\\WhiteRabbit\\rabbitMove0");
     Speed = 1.0f;
 }
예제 #8
0
 public override void Initialize(Vector3 enemyPosition)
 {
     base.Initialize(enemyPosition);
     enemyType = EnemyType.Hedgehog;
     enemyModel = new BasicModel(Engine.GameContainer, ModelProperties.Alpha, Assets.PLANE6, enemyPosition);
     enemyModel.Link.Texture = Engine.GameContainer.Load<Texture2D>("Textures\\Enemies\\Hedgehog");
     Speed = Engine.Randomize(0.3f, 0.6f);
     PerceptionDistance = 60f;
     DetermineTargetPosition();
     currentState = State.Moving;
 }
예제 #9
0
 public override void Initialize(Vector3 enemyPosition)
 {
     currentSubState = subState.Invisible;
     base.Initialize(enemyPosition);
     NPC = true;
     enemyType = EnemyType.CheshireCat;
     enemyModel = new BasicModel(Engine.GameContainer, ModelProperties.Alpha, Assets.PLANE6, enemyPosition);
     Speed = 1.0f;
     PerceptionDistance = 60f;
     enemyModel.Link.Texture = Engine.GameContainer.Load<Texture2D>("Textures\\Animations\\Cat\\catFadeIn0");
 }
예제 #10
0
 public override void Initialize(Vector3 enemyPosition)
 {
     currentState = State.Moving;
     base.Initialize(enemyPosition);
     NPC = true;
     enemyType = EnemyType.MadHatter;
     enemyModel = new BasicModel(Engine.GameContainer, ModelProperties.Alpha, Assets.PLANE6, enemyPosition);
     enemyModel.Link.Texture = Engine.GameContainer.Load<Texture2D>("Textures\\Enemies\\MadHatter");
     Speed = 1.5f;
     PerceptionDistance = 60f;
 }
예제 #11
0
 public override void Initialize(Vector3 enemyPosition)
 {
     base.Initialize(enemyPosition);
     enemyType = EnemyType.AliceBookworm;
     enemyModel = new BasicModel(Engine.GameContainer, ModelProperties.Alpha, Assets.PLANE6, enemyPosition);
     enemyModel.Link.Texture = Engine.GameContainer.Load<Texture2D>("Textures\\Animations\\Bookworm\\wormMove0");
     Speed = Engine.Randomize(0.1f, 0.4f);
     PerceptionDistance = 60f;
     Health = 25;
     AttackDamage = 2;
 }
예제 #12
0
 public void ThrownInitialize(Vector3 enemyPosition)
 {
     base.Initialize(enemyPosition);
     NPC = true;
     enemyType = EnemyType.Hedgehog;
     enemyModel = new BasicModel(Engine.GameContainer, ModelProperties.Alpha, Assets.PLANE4, enemyPosition);
     enemyModel.Link.Texture = Engine.GameContainer.Load<Texture2D>("Textures\\Enemies\\Hedgehog");
     currentState = State.Moving;
     currentSubState = subState.ThrownByQueen;
     thrownSpeed = Engine.Randomize(1.0f, 1.5f);
     DetermineVector();
 }
예제 #13
0
 public override void Initialize(Vector3 enemyPosition)
 {
     base.Initialize(enemyPosition);
     enemyType = EnemyType.QueenHearts;
     enemyModel = new BasicModel(Engine.GameContainer, ModelProperties.Alpha, Assets.PLANE3, enemyPosition);
     enemyModel.Link.Texture = Engine.GameContainer.Load<Texture2D>("Textures\\Animations\\Queen\\queenIdle0");
     Health = 300;
     Speed = 0.6f;
     PerceptionDistance = 60f;
     AttackDamage = 30;
     targetPosition = Engine.TempVector3(720, 0, 50);
 }
예제 #14
0
        public override void Initialize()
        {
            BloomEffect.Settings = BloomSettings.PresetSettings[1];
            mAudio.Peek.LoadAllSounds();
            mAudio.Peek.PlaySound(mAudio.SoundName.PageTurn1);

            mAvatar.Peek.Load(Engine.TempVector3(10, 1, 55));
            mAvatar.Peek.SetBounds(-20, 720, 0, 200, -12, 117);

            castleCarpet = new BasicModel(Engine.GameContainer, ModelProperties.Opaque, "Models\\Levels\\Level15\\Castle_Carpet", Engine.TempVector3(350, 0, -55));
            castleCarpet.Link.Texture = Engine.GameContainer.Load<Texture2D>("Textures\\Level Textures\\Level15\\RedCarpet");
            castleCarpet.Link.TileAmount.Y = 20f;

            temp = mFile.Peek.XmlReaderLoadLevel("..\\..\\..\\Content\\Level XML\\XmlLevel15.xml");
        }
예제 #15
0
        //int numObstacles = 11;
        public override void Initialize()
        {
            mAudio.Peek.LoadAllSounds();
            mAudio.Peek.PlaySound(mAudio.SoundName.PageTurn2);

            mAvatar.Peek.Load(Engine.TempVector3(-90, 2, 0));
            mAvatar.Peek.SetBounds(-80, 330, -500, 200, -80, 100);

            temp = mFile.Peek.XmlReaderLoadLevel("..\\..\\..\\Content\\Level XML\\XmlLevel7.xml");

            sky = new BasicModel(Engine.GameContainer, ModelProperties.Opaque, "Models\\Levels\\Level 2\\sky", new Vector3(200.0f, 100.0f, 100.0f));
            sky.Link.Texture = Engine.GameContainer.Load<Texture2D>("Textures\\Level Textures\\Level 2\\sky");

            //mAI.Peek.SpawnEnemy(Enemy.EnemyType.WhiteRabbit, Engine.TempVector3(-30, 0, 0));

            Exit.Initialize(320f);
            Exit.LoadTexture("Loading Screens\\ExitLevel");
            Dialogue.Initialize(-40f);
            isStop = true;
            mDialogue.Peek.LoadLevelSeven();
        }
예제 #16
0
        public override void Initialize()
        {
            Foliage = new BasicModel(Engine.GameContainer, ModelProperties.Vegetation, Assets.VEG_LAND, Engine.TempVector3(0.0f, 0.0f, 0.0f));
            mAvatar.Peek.Load(Engine.TempVector3(0.0f, 10.0f, 0.0f));
            Land = new BasicModel(Engine.GameContainer, ModelProperties.Opaque, Assets.LAND, Vector3.Zero);
            Land.Link.Texture = Engine.GameContainer.Load<Texture2D>("Textures\\Environment\\Ground\\Grass1");
            Land.Link.TileAmount.X = 4.0f;
            Land.Link.TileAmount.Y = 4.0f;
            Land.Link.Display = true;
            test2 = new BasicModel(Engine.GameContainer, ModelProperties.Opaque, "Models\\Levels\\Level 2\\flatShroom", Vector3.Zero);
            test2.Link.Texture = Engine.GameContainer.Load<Texture2D>("Textures\\Level Textures\\Level 2\\flatShroom");

            Dust.Initialize(Engine.GameContainer.Load<Texture2D>("Textures\\Environment\\Particles\\Dust"), 1024, 100, Direction.Up, Land.Link.BoundingBox, Color.DarkOliveGreen);
            Rain.Initialize(Engine.GameContainer.Load<Texture2D>("Textures\\Environment\\Particles\\Dust"), 2048, 100, Direction.Up, Land.Link.BoundingBox, Color.CornflowerBlue);

            Exit.Initialize(Land.Link.BoundingBox.Max.X);
            Exit.LoadTexture("Loading Screens\\ExitLevel");

            mAudio.Peek.LoadAllMusic();
            mAudio.Peek.LoadAllSounds();
            base.Initialize();
        }
예제 #17
0
 /****************************************************************************************/
 /// <summary>Tell the ModelManager to flag this model for deletion.</summary>
 public static void Remove(BasicModel Model)
 {
     if (Model._Properties == ModelProperties.Alpha)
     {
         mModel.Peek.AlphaContainer[Model._ID].Disposed = true;
         mModel.Peek.AlphaContainer[Model._ID].Display = false;
     }
     else
     {
         mModel.Peek.OpaqueContainer[Model._ID].Disposed = true;
         mModel.Peek.OpaqueContainer[Model._ID].Display = false;
     }
 }
예제 #18
0
        public void Update(BasicModel[] obstacles)
        {
            this.obstacles = obstacles;
            gravity -= 0.05f;

            if (gravity > 2.0f)
            {
                gravity = 2.0f;
            }

            Top = false;

            for (int i = 0; i < obstacles.Length; i++)
            {
                collide = mPhysics.Peek.BoxCollision(mAvatar.Peek.PlayerModel, obstacles[i]);

                switch (collide)
                {
                    case 1: //underneath
                        mAvatar.Peek.PlayerModel.Link.Position.Y = mAvatar.Peek.PlayerModel.Link.OldPosition.Y;
                        gravity = 0.0f;
                        break;
                    case 2: //on top
                        //mAvatar.Peek.PlayerModel.Link.OldPosition.Y = mAvatar.Peek.PlayerModel.Link.BoundingBox.Min.Y + mAvatar.Peek.PlayerModel.Link.Position.Y;
                        mAvatar.Peek.PlayerModel.Link.OldPosition.Y = obstacles[i].Link.Position.Y + obstacles[i].Link.BoundingBox.Max.Y;
                        mAvatar.Peek.PlayerModel.Link.Position.Y = mAvatar.Peek.PlayerModel.Link.OldPosition.Y;
                        gravity = 0.0f;
                        Top = true;
                        jump = false;
                        break;
                    case 3:
                            mAvatar.Peek.PlayerModel.Link.Position.X = mAvatar.Peek.PlayerModel.Link.OldPosition.X;
                        break;
                    case 4:
                            mAvatar.Peek.PlayerModel.Link.Position.Z = mAvatar.Peek.PlayerModel.Link.OldPosition.Z;
                        break;
                    case 5:
                            mAvatar.Peek.PlayerModel.Link.Position.X = mAvatar.Peek.PlayerModel.Link.OldPosition.X;
                        break;
                    case 6:
                            mAvatar.Peek.PlayerModel.Link.Position.Z = mAvatar.Peek.PlayerModel.Link.OldPosition.Z;
                        break;
                }
            }
            if (!Top)
            {
                jump = true;
            }
            collide = 0;
            collision = 0;
            for (int i = 0; i < obstacles.Length; i++)
            {
                collide = mPhysics.Peek.BoxCollision(mAvatar.Peek.shadowBox, obstacles[i]);

                if (collide > 1)
                {
                    collision++;
                    mAvatar.Peek.shadowBox.Link.Position.Y = obstacles[i].Link.BoundingBox.Max.Y + obstacles[i].Link.Position.Y + 0.5f;
                    mAvatar.Peek.shadowBox.Link.Display = true;
                }
            }
            if ((mAvatar.Peek.shadowBox.Link.Position.Y - 3) > mAvatar.Peek.PlayerModel.Link.Position.Y)
            {
                mAvatar.Peek.shadowBox.Link.Position.Y = mAvatar.Peek.PlayerModel.Link.Position.Y + mAvatar.Peek.PlayerModel.Link.BoundingBox.Min.Y + .5f;
            }
            if (collision == 0)
            {
                mAvatar.Peek.shadowBox.Link.Display = false;
            }
        }
예제 #19
0
        public void PushObject(BasicModel obj, int direction)
        {
            switch (direction)
            {

                case 1:
                    obj.Link.Position.X += mAvatar.Peek.WalkSpeed;
                    break;
                case 2:
                    obj.Link.Position.X -= mAvatar.Peek.WalkSpeed;
                    break;
                case 3:
                    obj.Link.Position.Z += mAvatar.Peek.WalkSpeed;
                    break;
                case 4:
                    obj.Link.Position.Z -= mAvatar.Peek.WalkSpeed;
                    break;
            }
        }
예제 #20
0
 public void Load(BasicModel[] _obstacles)
 {
     collide = 0;
     gravity = 2.0f;
     jump = false;
     collision = 0;
 }
예제 #21
0
        /// <summary>
        /// (BasicModel Version) Determine whether two models are touching each other.
        /// </summary>
        /// <param name="mdl1">First Model</param>
        /// <param name="mdl2">Second Model</param>
        /// <returns>A true or false on whether they have collided.</returns>
        public int BoxCollision(BasicModel mdl1, BasicModel mdl2)
        {
            gameBox.Min = mdl1.Link.Position + mdl1.Link.BoundingBox.Min;
            gameBox.Max = mdl1.Link.Position + mdl1.Link.BoundingBox.Max;

            newBox.Min = mdl2.Link.Position + mdl2.Link.BoundingBox.Min;
            newBox.Max = mdl2.Link.Position + mdl2.Link.BoundingBox.Max;

            int temp = 0;

            if (gameBox.Intersects(newBox))
            {
                /*Under Facing Collision*/
                if ((mdl1.Link.OldPosition.Y + mdl1.Link.BoundingBox.Max.Y) < newBox.Min.Y)
                {
                    if (mdl2.Link.Display)
                        temp = 1;
                    //return 1;
                }
                /*Over Facing Collision*/
                if ((mdl1.Link.OldPosition.Y + mdl1.Link.BoundingBox.Max.Y) > newBox.Max.Y)
                {
                    if (mdl2.Link.Display)
                        temp = 2;
                    //return 2;
                }
                /*Left Facing Collision*/
                if ((mdl1.Link.OldPosition.X + mdl1.Link.BoundingBox.Max.X) < newBox.Min.X)
                {
                    //mdl2.Position += new Vector3(1, 0, 0);
                    if (mdl2.Link.Display)
                        temp = 3;
                    //return 3;
                }
                /*Front Facing Collision*/
                if ((mdl1.Link.OldPosition.Z + mdl1.Link.BoundingBox.Min.Z) > newBox.Max.Z)
                {
                    //mdl2.Position += new Vector3(0, 0, -1);
                    if (mdl2.Link.Display)
                        temp = 4;
                    //return 4;
                }
                /*Right Facing Collision*/
                if ((mdl1.Link.OldPosition.X + mdl1.Link.BoundingBox.Min.X) > newBox.Max.X)
                {
                    //mdl2.Position += new Vector3(-1, 0, 0);
                    if (mdl2.Link.Display)
                        temp = 5;
                    //return 5;
                }
                /*Behind Facing Collision*/
                if ((mdl1.Link.OldPosition.Z + mdl1.Link.BoundingBox.Max.Z) < newBox.Min.Z)
                {
                    //mdl2.Position += new Vector3(0, 0, 1);
                    if (mdl2.Link.Display)
                        temp = 6;
                    //return 6;
                }
                /*Debug Information Hook*/
                if (Engine.DebugEnabled)
                {
                    switch (temp)
                    {
                        case 0: dmCollision2.Text = "Obstacle Collision: Nothing";
                            break;
                        case 1: dmCollision2.Text = "Obstacle Collision: Under Obstacle " + mdl2.ID;
                            break;
                        case 2: dmCollision2.Text = "Obstacle Collision: Over Obstacle " + mdl2.ID;
                            break;
                        case 3: dmCollision2.Text = "Obstacle Collision: Left of Obstacle " + mdl2.ID;
                            break;
                        case 4: dmCollision2.Text = "Obstacle Collision: Front of Obstacle " + mdl2.ID;
                            break;
                        case 5: dmCollision2.Text = "Obstacle Collision: Right of Obstacle " + mdl2.ID;
                            break;
                        case 6: dmCollision2.Text = "Obstacle Collision: Behind Obstacle " + mdl2.ID;
                            break;
                    }
                }
                /*End of Debug Hook*/

                #region push objects

                if (mdl2.Link.IsMovable)
                {
                    switch (temp)
                    {
                        case 3:
                            PushObject(mdl2, 1);
                            break;
                        case 4:
                            PushObject(mdl2, 4);
                            break;
                        case 5:
                            PushObject(mdl2, 2);
                            break;
                        case 6:
                            PushObject(mdl2, 3);
                            break;
                    }
                }

                #endregion
            }
            return temp;
        }
예제 #22
0
 /****************************************************************************************/
 /// <summary>Helps setup the MasterEffect on the Model [INFO: This override the built in BasicEffect with our new effect, could of been done through the Content Pipeline]</summary>
 private static void HelpPrepareMasterEffect(cModel[] Container, BasicModel Model)
 {
     foreach (ModelMesh mesh in Container[Model._ID].Model.Meshes)
     {
         foreach (ModelMeshPart part in mesh.MeshParts)
         {
             part.Effect = mEffect.Peek.MasterEffect();
         }
     }
 }
예제 #23
0
 /****************************************************************************************/
 /// <summary>Sets some Defaults for the Model [TIP: This is generally shared among most models]</summary>
 private static void PrepareModel(ContentManager Content, cModel[] Container, BasicModel Model, string strAssetLocation, Vector3 v3StartingPosition)
 {
     Container[Model._ID].Model = Content.Load<Model>(strAssetLocation);
     Container[Model._ID].Transforms = new Matrix[Container[Model._ID].Model.Bones.Count];
     Container[Model._ID].Position.X = v3StartingPosition.X;
     Container[Model._ID].Position.Y = v3StartingPosition.Y;
     Container[Model._ID].Position.Z = v3StartingPosition.Z == 0.0f ? (0.0f) : (-v3StartingPosition.Z);
     Container[Model._ID].Initialized = true;
 }
예제 #24
0
파일: mFile.cs 프로젝트: apolaskey/Inkwell
        //A lot of this is experimental code. Will be able to test
        //it on the next merge and clean it up afterwards. Needs some cleaning up, will
        //go into different classes.
        public BasicModel[] XmlReaderLoadLevel(string level)
        {
            string newLevel = level;
            XmlTextReader xmlReader;

            this.StaticItems.Clear();

            xmlReader = new XmlTextReader(newLevel);
            while (xmlReader.Read())
            {
                switch (xmlReader.NodeType)
                {
                    case XmlNodeType.Element:
                        {
                            String asset = xmlReader.Name;
                            switch (xmlReader.Name)
                            {
                                case "doodad":
                                    {
                                        /* Example: <doodad position ="0 0 0" rotation="0 0 0" scalar="1"
                                         diffuseEnabled="true" locationModel="Models\" locationTexture="Textures\"
                                         modelProps="Opaque" tileVec="1 1" flipVec="1 1" /> */
                                         pos = xmlReader.GetAttribute("position");
                                         rot = xmlReader.GetAttribute("rotation");
                                         scal = xmlReader.GetAttribute("scalar");
                                         strLocModel = xmlReader.GetAttribute("locationModel");
                                         strLocTexture = xmlReader.GetAttribute("locationTexture");
                                         props = xmlReader.GetAttribute("modelProps");
                                         tile = xmlReader.GetAttribute("tileVec");
                                         flip = xmlReader.GetAttribute("flipVec");
                                         diffEn = xmlReader.GetAttribute("diffuseEnabled");

                                         position = ReadFloat3(pos);
                                         rotation = ReadFloat3(rot);

                                         scalar = ReadFloat(scal);
                                         properties = (ModelProperties)Enum.Parse(typeof(ModelProperties), props);
                                         tileAmount = ReadFloat2(tile);
                                         flipVec = ReadFloat2(flip);
                                         a = new BasicModel(Engine.GameContainer, properties, strLocModel, position);
                                         a.Link.Texture = Engine.GameContainer.Load<Texture2D>(strLocTexture);
                                         a.Link.DiffuseEnabled = Convert.ToBoolean(diffEn);

                                         if (a.Link.DiffuseEnabled)
                                         {
                                             a.Link.DiffuseIntensity = 0.8f;
                                             a.Link.AmbientIntensity = 0.4f;
                                             a.Link.AmbientColor = Color.White.ToVector4();
                                         }

                                        a.Link.TileAmount = tileAmount;
                                        a.Link.RotationMatrix *= Matrix.CreateRotationX(rotation.X);
                                        a.Link.RotationMatrix *= Matrix.CreateRotationY(rotation.Y);
                                        a.Link.RotationMatrix *= Matrix.CreateRotationZ(rotation.Z);
                                        a.Link.ScalerMatrix *= Matrix.CreateScale(scalar);
                                        StaticItems.Add(a);

                                        break;
                                    }
                                case "enemy":
                                    {
                                         ET = xmlReader.GetAttribute("EnemyType");
                                         pos = xmlReader.GetAttribute("position");

                                        EnemyType = (Enemy.EnemyType)Enum.Parse(typeof(Enemy.EnemyType), ET);
                                         position = ReadFloat3(pos);

                                        mAI.Peek.SpawnEnemy(EnemyType, position);

                                        break;
                                    }

                            }
                            break;
                        }
                }
            }
            return StaticItems.ToArray();
        }
예제 #25
0
 private void ThrowTeaCup(Vector3 spawnPosition)
 {
     BasicModel teacup = new BasicModel(Engine.GameContainer, ModelProperties.Alpha, Assets.TEAPOT, enemyModel.Link.Position);
 }
예제 #26
0
        /****************************************************************************************/
        /// <summary>(void) Helper to generate Bounding Boxes.</summary>
        private static void HelpCreateBoundingBox(cModel[] Container, BasicModel Model, Model CopyFromModel)
        {
            /*Create our Bounding Box for this Model*/
            CopyFromModel.CopyAbsoluteBoneTransformsTo(Container[Model._ID].Transforms);

            foreach (ModelMesh mesh in CopyFromModel.Meshes)
            {
                VertexPositionNormalTexture[] vertices =
                new VertexPositionNormalTexture[mesh.VertexBuffer.SizeInBytes / VertexPositionNormalTexture.SizeInBytes];

                mesh.VertexBuffer.GetData<VertexPositionNormalTexture>(vertices);

                Vector3[] vertexs = new Vector3[vertices.Length];

                for (int index = 0; index < vertexs.Length; index++)
                {
                    vertexs[index] = vertices[index].Position;
                }
                Matrix M2 = Container[Model._ID].Transforms[mesh.ParentBone.Index];//<-- Dummy Matrix

                Vector3.Transform(vertexs, ref M2, vertexs);
                Container[Model._ID].BoundingBox = BoundingBox.CreateMerged(Container[Model._ID].BoundingBox, BoundingBox.CreateFromPoints(vertexs));
                Container[Model._ID].PureBoundingBox = Container[Model._ID].BoundingBox;
            }
        }
예제 #27
0
 /// <summary>Load the player's content,put me where you load everything. pass it the position of where the player will start</summary><param name="Position"></param>
 public void Load(Vector3 Position)
 {
     mAnimation.Peek.Load();
     mDamage.Peek.Load();
     State = AvatarState.Standing;
     PlayerHit = false;
     PlayerStop = false;
     PlayerHitTimer = 0;
     FaceingRight = true;
     shadowBox = new BasicModel(Engine.GameContainer, ModelProperties.Alpha, "Models\\Basic Objects\\ShadowPlane", Position - new Vector3(0, 50, 0));
     PlayerModel = new BasicModel(Engine.GameContainer, ModelProperties.Alpha, "Models\\Planes\\Plane6", Position);
     PlayerModel.Link.BoundingBox.Min += Engine.TempVector3(5, 0, -1f);
     PlayerModel.Link.BoundingBox.Max += Engine.TempVector3(-5.5f, -3, 1f);
     AttackBox = new BasicModel(Engine.GameContainer, ModelProperties.Alpha, "Models\\Basic Objects\\box", Vector3.Zero);
     AttackBox.Link.Display = false;
     PlayerModel.Link.Position = Position;
     t2d_AvatarDefend = Engine.GameContainer.Load<Texture2D>("Textures\\Animations\\Character\\heroDefend0");
     t2d_AvatarStun = Engine.GameContainer.Load<Texture2D>("Textures\\Environment\\Ground\\Grass");
     AttackBox.Link.BoundingBox.Max -= Engine.TempVector3(2, 3, -.5f);
     AttackBox.Link.BoundingBox.Min += Engine.TempVector3(3, 3, -.5f);
     shadowBox.Link.BoundingBox = PlayerModel.Link.BoundingBox;
     shadowBox.Link.Texture = Engine.GameContainer.Load<Texture2D>("Textures\\Animations\\Character\\ShadowPlane");
     SetBounds(-1000, 1000, -1000, 1000, -1000, 1000);
 }
예제 #28
0
 /****************************************************************************************/
 /// <summary>(Vegetation) Create's a Axis-Aligned Bounding Box for the Object utilizing the Correct Matrix Transforms.</summary>
 public static void CreateBoundingBox(BasicModel Model, Model ModelToCopyBoxFrom)
 {
     switch (Model._Properties)
     {
         case ModelProperties.Alpha:
             HelpCreateBoundingBox(mModel.Peek.AlphaContainer, Model, ModelToCopyBoxFrom);
             break;
         case ModelProperties.Opaque:
             HelpCreateBoundingBox(mModel.Peek.OpaqueContainer, Model, ModelToCopyBoxFrom);
             break;
         case ModelProperties.Full3D:
             HelpCreateBoundingBox(mModel.Peek.OpaqueContainer, Model, ModelToCopyBoxFrom);
             break;
         case ModelProperties.Vegetation:
             HelpCreateBoundingBox(mModel.Peek.AlphaContainer, Model, ModelToCopyBoxFrom);
             break;
     }
 }