Show
Ignore:
Timestamp:
02/21/2012 11:50:14 AM (2 years ago)
Author:
acarter
Message:

Fractional traffic now works

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • Code/oMaE/oMaE/Overworld/Objects/Door.cs

    r44 r57  
    1313namespace oMaE.Overworld.Objects 
    1414{ 
     15    using MiniGames; 
    1516    /// <summary> 
    1617    /// A 3D door. 
     
    1819    public class Door : Collidable 
    1920    { 
    20         private GameObject doorLock; 
     21        private Vector2 otherSide; 
     22        private MiniGame doorLock; 
    2123        private Tile door, wall; 
    2224        private bool elephantNear; 
     25        private String nearText; 
     26        private Color completed; 
     27        private Door partner = null; 
     28        /// <summary> 
     29        /// The text to be displayed for being near the door. 
     30        /// </summary> 
     31        public override string NearText { get { return nearText; }} 
    2332        /// <summary> 
    2433        /// Creates a new door. 
    2534        /// </summary> 
    2635        /// <param name="doorColor">The color of the door.</param> 
     36        /// <param name="doorColor2">The color of the door when completed.</param> 
    2737        /// <param name="wallColor">The color of the wall above the door.</param> 
    2838        /// <param name="left">The left side of the door.</param> 
     
    3040        /// <param name="doorHeight">The height of the door.</param> 
    3141        /// <param name="wallHeight">The width of the door.</param> 
    32         public Door(Color doorColor, Color wallColor, 
     42        /// <param name="nearText">The text of the door when nearby.</param> 
     43        public Door(Color doorColor, Color doorColor2, Color wallColor, 
    3344                    Vector2 left, Vector2 right, 
    34                     float doorHeight = 8.0f, float wallHeight = 10.0f) 
     45                    float doorHeight = 8.0f, float wallHeight = 10.0f, String nearText = "Press the space button to open the door.") 
    3546        { 
    3647            right -= left; 
     48            Vector2 normal = new Vector2(right.Y, -right.X); 
     49            normal.Normalize(); 
     50            otherSide = left + 0.5f * right - 5.0f * normal; 
    3751            wallHeight -= doorHeight; 
     52            completed = doorColor2; 
    3853            door = new Tile(doorColor, new Vector3(left.X, 0, left.Y), new Vector3(0, doorHeight, 0), new Vector3(right.X, 0, right.Y)); 
    3954            wall = new Tile(wallColor, new Vector3(left.X, doorHeight, left.Y), new Vector3(0, wallHeight, 0), new Vector3(right.X, 0, right.Y)); 
     55            this.nearText = nearText; 
     56        } 
     57        public Door(Color doorColor, Color doorColor2, Color wallColor, 
     58                    Vector2 left, Vector2 right, Door partner, 
     59                    float doorHeight = 8.0f, float wallHeight = 10.0f, String nearText = "Press the space button to open the door.") 
     60        { 
     61            this.partner = partner; 
     62            partner.partner = this; 
     63            right -= left; 
     64            Vector2 normal = new Vector2(right.Y, -right.X); 
     65            normal.Normalize(); 
     66            otherSide = left + 0.5f * right - 5.0f * normal; 
     67            wallHeight -= doorHeight; 
     68            completed = doorColor2; 
     69            door = new Tile(doorColor, new Vector3(left.X, 0, left.Y), new Vector3(0, doorHeight, 0), new Vector3(right.X, 0, right.Y)); 
     70            wall = new Tile(wallColor, new Vector3(left.X, doorHeight, left.Y), new Vector3(0, wallHeight, 0), new Vector3(right.X, 0, right.Y)); 
     71            this.nearText = nearText; 
    4072        } 
    4173        /// <summary> 
     
    4678            children.Add(door); 
    4779            children.Add(wall); 
    48             doorLock = driver.GetMinigame(); 
     80            // FIXME 
     81            if (partner == null || partner.doorLock == null) 
     82                doorLock = driver.GetMinigame(); 
     83            else 
     84                doorLock = partner.doorLock; 
    4985            base.Initialize(); 
    5086        } 
     
    80116        { 
    81117            if (elephantNear && gameState.Down(Keys.Space)) 
    82                 driver.Play2DGame(doorLock); 
     118                driver.Play2DGame(doorLock, otherSide); 
     119            if (doorLock.Completed) 
     120                door.Color = completed; 
    83121            base.Update(gameState); 
    84122        }