Currently finished tasks:
Basic level modeled
Menu Framework in Place
Player Collider Coded
Plan by next week:
Have menu able to modify level states
Startup Menu
Inventory Pickup System
Plan is to have these ready by Andre presentation or Monday, whichever is soonest.
Menu Code past the jump
public class PanelManager : MonoBehaviour
{
void Start()
{
// Create a set of 4 (for this example) state buttons, one empty and a kitchen, oven, and shower button
var filenamesEmpty = new string[] { "empty.png"};
var filenamesKitchen = new string[] { "nullKitchen.png", "undeployed.png", "deploy.png", "rotate.png"};
var filenamesShower = new string[] { "nullShower.png", "off.png", "onCold.png", "onHot.png"};
var filenamesOven = new string[] { "nullOven.png", "off.png", "onWarm.png", "onHot.png"};
var stateEmpty = UIStateButton.create( filenamesEmpty, filenamesEmpty, 0, 0);
var stateKitchenT00 = UIStateButton.create( filenamesKitchen, filenamesKitchen, 0, 0);
stateKitchenT00.onStateChange += onStateChange;
var stateShowerT00 = UIStateButton.create( filenamesShower, filenamesShower, 0, 0);
stateShowerT00.onStateChange += onStateChange;
var stateOvenT00 = UIStateButton.create( filenamesOven, filenamesOven, 0, 0);
stateOvenT00.onStateChange += onStateChange;
// Repeat 14 times for a total of 15 minutes worth of buttons.
var stateKitchenT01 = UIStateButton.create( filenamesKitchen, filenamesKitchen, 0, 0);
stateKitchenT01.onStateChange += onStateChange;
var stateShowerT01 = UIStateButton.create( filenamesShower, filenamesShower, 0, 0);
stateShowerT01.onStateChange += onStateChange;
var stateOvenT01 = UIStateButton.create( filenamesOven, filenamesOven, 0, 0);
stateOvenT01.onStateChange += onStateChange;
var stateKitchenT02 = UIStateButton.create( filenamesKitchen, filenamesKitchen, 0, 0);
stateKitchenT02.onStateChange += onStateChange;
var stateShowerT02 = UIStateButton.create( filenamesShower, filenamesShower, 0, 0);
stateShowerT02.onStateChange += onStateChange;
var stateOvenT02 = UIStateButton.create( filenamesOven, filenamesOven, 0, 0);
stateOvenT02.onStateChange += onStateChange;
var stateKitchenT03 = UIStateButton.create( filenamesKitchen, filenamesKitchen, 0, 0);
stateKitchenT03.onStateChange += onStateChange;
var stateShowerT03 = UIStateButton.create( filenamesShower, filenamesShower, 0, 0);
stateShowerT03.onStateChange += onStateChange;
var stateOvenT03 = UIStateButton.create( filenamesOven, filenamesOven, 0, 0);
stateOvenT03.onStateChange += onStateChange;
var stateKitchenT04 = UIStateButton.create( filenamesKitchen, filenamesKitchen, 0, 0);
stateKitchenT04.onStateChange += onStateChange;
var stateShowerT04 = UIStateButton.create( filenamesShower, filenamesShower, 0, 0);
stateShowerT04.onStateChange += onStateChange;
var stateOvenT04 = UIStateButton.create( filenamesOven, filenamesOven, 0, 0);
stateOvenT04.onStateChange += onStateChange;
var stateKitchenT05 = UIStateButton.create( filenamesKitchen, filenamesKitchen, 0, 0);
stateKitchenT05.onStateChange += onStateChange;
var stateShowerT05 = UIStateButton.create( filenamesShower, filenamesShower, 0, 0);
stateShowerT05.onStateChange += onStateChange;
var stateOvenT05 = UIStateButton.create( filenamesOven, filenamesOven, 0, 0);
stateOvenT05.onStateChange += onStateChange;
var stateKitchenT06 = UIStateButton.create( filenamesKitchen, filenamesKitchen, 0, 0);
stateKitchenT06.onStateChange += onStateChange;
var stateShowerT06 = UIStateButton.create( filenamesShower, filenamesShower, 0, 0);
stateShowerT06.onStateChange += onStateChange;
var stateOvenT06 = UIStateButton.create( filenamesOven, filenamesOven, 0, 0);
stateOvenT06.onStateChange += onStateChange;
var stateKitchenT07 = UIStateButton.create( filenamesKitchen, filenamesKitchen, 0, 0);
stateKitchenT07.onStateChange += onStateChange;
var stateShowerT07 = UIStateButton.create( filenamesShower, filenamesShower, 0, 0);
stateShowerT07.onStateChange += onStateChange;
var stateOvenT07 = UIStateButton.create( filenamesOven, filenamesOven, 0, 0);
stateOvenT07.onStateChange += onStateChange;
var stateKitchenT08 = UIStateButton.create( filenamesKitchen, filenamesKitchen, 0, 0);
stateKitchenT08.onStateChange += onStateChange;
var stateShowerT08 = UIStateButton.create( filenamesShower, filenamesShower, 0, 0);
stateShowerT08.onStateChange += onStateChange;
var stateOvenT08 = UIStateButton.create( filenamesOven, filenamesOven, 0, 0);
stateOvenT08.onStateChange += onStateChange;
var stateKitchenT09 = UIStateButton.create( filenamesKitchen, filenamesKitchen, 0, 0);
stateKitchenT09.onStateChange += onStateChange;
var stateShowerT09 = UIStateButton.create( filenamesShower, filenamesShower, 0, 0);
stateShowerT09.onStateChange += onStateChange;
var stateOvenT09 = UIStateButton.create( filenamesOven, filenamesOven, 0, 0);
stateOvenT09.onStateChange += onStateChange;
var stateKitchenT10 = UIStateButton.create( filenamesKitchen, filenamesKitchen, 0, 0);
stateKitchenT10.onStateChange += onStateChange;
var stateShowerT10 = UIStateButton.create( filenamesShower, filenamesShower, 0, 0);
stateShowerT10.onStateChange += onStateChange;
var stateOvenT10 = UIStateButton.create( filenamesOven, filenamesOven, 0, 0);
stateOvenT10.onStateChange += onStateChange;
var stateKitchenT11 = UIStateButton.create( filenamesKitchen, filenamesKitchen, 0, 0);
stateKitchenT11.onStateChange += onStateChange;
var stateShowerT11 = UIStateButton.create( filenamesShower, filenamesShower, 0, 0);
stateShowerT11.onStateChange += onStateChange;
var stateOvenT11 = UIStateButton.create( filenamesOven, filenamesOven, 0, 0);
stateOvenT11.onStateChange += onStateChange;
var stateKitchenT12 = UIStateButton.create( filenamesKitchen, filenamesKitchen, 0, 0);
stateKitchenT12.onStateChange += onStateChange;
var stateShowerT12 = UIStateButton.create( filenamesShower, filenamesShower, 0, 0);
stateShowerT12.onStateChange += onStateChange;
var stateOvenT12 = UIStateButton.create( filenamesOven, filenamesOven, 0, 0);
stateOvenT12.onStateChange += onStateChange;
var stateKitchenT13 = UIStateButton.create( filenamesKitchen, filenamesKitchen, 0, 0);
stateKitchenT13.onStateChange += onStateChange;
var stateShowerT13 = UIStateButton.create( filenamesShower, filenamesShower, 0, 0);
stateShowerT13.onStateChange += onStateChange;
var stateOvenT13 = UIStateButton.create( filenamesOven, filenamesOven, 0, 0);
stateOvenT13.onStateChange += onStateChange;
var stateKitchenT14 = UIStateButton.create( filenamesKitchen, filenamesKitchen, 0, 0);
stateKitchenT14.onStateChange += onStateChange;
var stateShowerT14 = UIStateButton.create( filenamesShower, filenamesShower, 0, 0);
stateShowerT14.onStateChange += onStateChange;
var stateOvenT14 = UIStateButton.create( filenamesOven, filenamesOven, 0, 0);
stateOvenT14.onStateChange += onStateChange;
// Attach each set to a horizontal pane
var hPaneT00 = new UIHorizontalLayout( 20 );
hPaneT00.addChild( stateEmpty, stateKitchenT00, stateShowerT00, stateOvenT00 );
var hPaneT01 = new UIHorizontalLayout( 20 );
hPaneT01.addChild( stateEmpty, stateKitchenT01, stateShowerT01, stateOvenT01 );
var hPaneT02 = new UIHorizontalLayout( 20 );
hPaneT02.addChild( stateEmpty, stateKitchenT02, stateShowerT02, stateOvenT02 );
var hPaneT03 = new UIHorizontalLayout( 20 );
hPaneT03.addChild( stateEmpty, stateKitchenT03, stateShowerT03, stateOvenT03 );
var hPaneT04 = new UIHorizontalLayout( 20 );
hPaneT04.addChild( stateEmpty, stateKitchenT04, stateShowerT04, stateOvenT04 );
var hPaneT05 = new UIHorizontalLayout( 20 );
hPaneT05.addChild( stateEmpty, stateKitchenT05, stateShowerT05, stateOvenT05 );
var hPaneT06 = new UIHorizontalLayout( 20 );
hPaneT06.addChild( stateEmpty, stateKitchenT06, stateShowerT06, stateOvenT06 );
var hPaneT07 = new UIHorizontalLayout( 20 );
hPaneT07.addChild( stateEmpty, stateKitchenT07, stateShowerT07, stateOvenT07 );
var hPaneT08 = new UIHorizontalLayout( 20 );
hPaneT08.addChild( stateEmpty, stateKitchenT08, stateShowerT08, stateOvenT08 );
var hPaneT09 = new UIHorizontalLayout( 20 );
hPaneT09.addChild( stateEmpty, stateKitchenT09, stateShowerT09, stateOvenT09 );
var hPaneT10 = new UIHorizontalLayout( 20 );
hPaneT10.addChild( stateEmpty, stateKitchenT10, stateShowerT10, stateOvenT10 );
var hPaneT11 = new UIHorizontalLayout( 20 );
hPaneT11.addChild( stateEmpty, stateKitchenT11, stateShowerT11, stateOvenT11 );
var hPaneT12 = new UIHorizontalLayout( 20 );
hPaneT12.addChild( stateEmpty, stateKitchenT12, stateShowerT12, stateOvenT12 );
var hPaneT13 = new UIHorizontalLayout( 20 );
hPaneT13.addChild( stateEmpty, stateKitchenT13, stateShowerT13, stateOvenT13 );
var hPaneT14 = new UIHorizontalLayout( 20 );
hPaneT14.addChild( stateEmpty, stateKitchenT14, stateShowerT14, stateOvenT14 );
// Parent each horizontal pane along with a non functional button displaying time info (30 items total) to a scrollable
var scrollable = new UIScrollableVerticalLayout( 10 );
scrollable.position = new Vector3( Screen.width/4, -(Screen.height)/6, 0 );
scrollable.setSize( Screen.width/2, Screen.height * 2 / 3 );
var untouchable = UIButton.create( "infoT00", "infoT00", 0, 0 );
scrollable.addChild( untouchable );
scrollable.addChild( hPaneT00);
untouchable = UIButton.create( "infoT01", "infoT01", 0, 0 );
scrollable.addChild( untouchable );
scrollable.addChild( hPaneT01);
untouchable = UIButton.create( "infoT02", "infoT02", 0, 0 );
scrollable.addChild( untouchable );
scrollable.addChild( hPaneT02);
untouchable = UIButton.create( "infoT03", "infoT03", 0, 0 );
scrollable.addChild( untouchable );
scrollable.addChild( hPaneT03);
untouchable = UIButton.create( "infoT04", "infoT04", 0, 0 );
scrollable.addChild( untouchable );
scrollable.addChild( hPaneT04);
untouchable = UIButton.create( "infoT05", "infoT05", 0, 0 );
scrollable.addChild( untouchable );
scrollable.addChild( hPaneT05);
untouchable = UIButton.create( "infoT06", "infoT06", 0, 0 );
scrollable.addChild( untouchable );
scrollable.addChild( hPaneT06);
untouchable = UIButton.create( "infoT07", "infoT07", 0, 0 );
scrollable.addChild( untouchable );
scrollable.addChild( hPaneT07);
untouchable = UIButton.create( "infoT08", "infoT08", 0, 0 );
scrollable.addChild( untouchable );
scrollable.addChild( hPaneT08);
untouchable = UIButton.create( "infoT09", "infoT09", 0, 0 );
scrollable.addChild( untouchable );
scrollable.addChild( hPaneT09);
untouchable = UIButton.create( "infoT10", "infoT10", 0, 0 );
scrollable.addChild( untouchable );
scrollable.addChild( hPaneT10);
untouchable = UIButton.create( "infoT11", "infoT11", 0, 0 );
scrollable.addChild( untouchable );
scrollable.addChild( hPaneT11);
untouchable = UIButton.create( "infoT12", "infoT12", 0, 0 );
scrollable.addChild( untouchable );
scrollable.addChild( hPaneT12);
untouchable = UIButton.create( "infoT13", "infoT13", 0, 0 );
scrollable.addChild( untouchable );
scrollable.addChild( hPaneT13);
untouchable = UIButton.create( "infoT14", "infoT14", 0, 0 );
scrollable.addChild( untouchable );
scrollable.addChild( hPaneT14);
// Return: This script now contains data for the state of 45 different buttons, to be used by the event handler. It also creates the visuals for the menu.
return;
}
}
Code for player collider past the break
#pragma strict
// this script pushes all rigidbodies that the character touches
var pushPower = 2.0;
function OnControllerColliderHit (hit : ControllerColliderHit) {
var body : Rigidbody = hit.collider.attachedRigidbody;
// no rigidbody
if (body == null || body.isKinematic)
return;
// We dont want to push objects below us
if (hit.moveDirection.y < -0.3)
return;
// Calculate push direction from move direction,
// we only push objects to the sides never up and down
var pushDir : Vector3 = Vector3 (hit.moveDirection.x, 0, hit.moveDirection.z);
// If you know how fast your character is trying to move,
// then you can also multiply the push velocity by that.
// Apply the push
body.velocity = pushDir * pushPower;
}
No comments:
Post a Comment