void ReadCSV() { txt = (TextAsset)Resources.Load("ikea2", typeof(TextAsset)); string[] line = txt.text.Split('\n'); for (int i = 1; i < line.Length -1; ++i) { FurnitureTemplate furniture = new FurnitureTemplate(); string[] values = line[i].Split(','); for ( int j = 0; j < values.Length; ++j ) { if ( j == 0 ) furniture.SetTexture( values[ j ] ); if ( j == 1 ) furniture.Description = values[ j ]; if ( j == 2 ) furniture.Name = ( values[ j ] ); if ( j == 3 ) furniture.SetDepartment( values[ j ] ); if ( j == 4 ) furniture.Price = float.Parse( values[ j ] ); if ( j == 5 ) furniture.AllanKeys = int.Parse( values[ j ] ); if ( j == 6 ) furniture.SetZone( values[ j ] ); } furnitureMap[ furniture.Department ].Add( furniture ); } }
public void OnFurnitureCollected( FurnitureTemplate Template ) { DeductCash( Template.Price ); AllanKeys += Template.AllanKeys; }
public void OnFurnitureCollected( FurnitureTemplate Template ) { PointBurst burst = (Instantiate( PointBurst, Vector3.zero, Quaternion.identity ) as GameObject).GetComponent<PointBurst>(); PointBursts.Enqueue( burst ); burst.SetUpForFurniture( new Vector2( 0, 0 ), Template.Price, Template.AllanKeys ); dataObject.CollectedFurniture.Add( Template ); if ( Player.HasDiscount ) { switch ( Player.DiscountType ) { case GiftCard.Discount.DIS_25: burst.SetUpForFurniture( new Vector2( 0, 0 ), Template.Price * 0.75f, Template.AllanKeys ); break; case GiftCard.Discount.DIS_50: burst.SetUpForFurniture( new Vector2( 0, 0 ), Template.Price * 0.50f, Template.AllanKeys ); break; case GiftCard.Discount.DIS_75: burst.SetUpForFurniture( new Vector2( 0, 0 ), Template.Price * 0.25f, Template.AllanKeys ); break; } } ap.PlayClip( Audiopocalypse.Sounds.Pickup_Furniture ); if ( Player.Cash < 0 && State == Gamestate.NONE ) Lose(); }
void Start() { dataobject = GameObject.FindObjectOfType<Data>(); if ( dataobject == null ) { GameObject go = new GameObject(); Data d = go.AddComponent<Data>(); d.CollectedFurniture = new List<FurnitureTemplate>(); int NumFurniture = 100;//Random.Range(10, 21); for ( int i = 0; i < NumFurniture; i++ ) { FurnitureTemplate temp = new FurnitureTemplate(); temp.AllanKeys = Random.Range( 1, 4 ); int temp2 = System.Enum.GetNames(typeof(DepartmentType)).Length; temp.Department = (DepartmentType)Random.Range( 0, temp2 - 1); temp.Description = "Description: " + temp.Department.ToString(); temp.Name = "Name: " + temp.Department.ToString(); temp.Price = Random.Range( 0.0f, 1000.0f ); temp.Sprite = null; d.CollectedFurniture.Add( temp ); } d.didWin = false; d.ElapsedTime = new System.TimeSpan( 0, Random.Range( 0, 60 ), Random.Range( 0, 60 ) ); d.RemainingMoney = 0; dataobject = d; } alphaTweenStarted = false; numItems = 0; numCompletedTweens = 0; itemRects = new List<FurnitureListElement>(); foreach( FurnitureTemplate template in dataobject.CollectedFurniture ) { numItems++; // Total the number of Allen keys and amount spent SpentMoney += template.Price; AllenKeyTotal += template.AllanKeys; Rect priceRect, nameRect; FurnitureListElement pair = new FurnitureListElement(); // Shopping cart item name field nameRect = new Rect( 520f, 0f - 2f * numItems * itemSpacing, 280f, 30f ); priceRect = new Rect( 800f, 0f - 2f * numItems * itemSpacing, 100f, 30f ); pair.NameRect = nameRect; pair.PriceRect = priceRect; pair.Template = template; float itemTargetHeight = 670f - itemSpacing * numItems; itemRects.Add(pair); if (numItems <= SHOWN_ITEMS) StartCoroutine( TweenTextFields( itemRects.Count - 1, itemTargetHeight ) ); } }
public ShoppingListPair( FurnitureTemplate Template ) { this.Template = Template; HasBeenCollected = false; }