Beispiel #1
0
    }//end UpdatePrices

    void Update()
    {
        if (!inside)
        {//if not showing inside
         //this is so that it will stop the player moving, but will still allow rotation
            this.transform.Translate(Vector3.forward * transMult * Time.timeScale);//translate the player

            this.transform.Rotate(Input.GetAxisRaw("Vertical") * rotMult, Input.GetAxisRaw("Horizontal") * rotMult, 0);//rotate the player

            enter = CheckPos();//allowed to enter if close enough to a trade post
        }//end if not in inside

        if (!inside && Input.GetKey(KeyCode.Space)) //if pressing space
            Time.timeScale = 0;//pause
                               //means that it is only possible to pause when is not showing the inside
        else
            Time.timeScale = 1;//else dont pause

        if (nearItem != null)
        {//if not null, then there is something to collect
            double mass = controller.goods[nearItem.groupID].goods[nearItem.itemID].mass * nearItem.number;//the mass of the items in the crate
            if (spaceRemaining >= mass)
            {//if has enough space remaining
                spaceRemaining -= mass;//remove the space remaining
                cargo[nearItem.groupID][nearItem.itemID] += nearItem.number;//add the items to the cargo hold
                pickup = "You collected " + nearItem.number + "\u00D7" + controller.goods[nearItem.groupID].goods[nearItem.itemID].name;
                textshow = Time.timeSinceLevelLoad;//set when the text first shown
                nearItem.Collected();//need to tell the item that it has been collected
            }//end if not enough space
        }//end if item in radar


        if (Time.timeSinceLevelLoad - textshow > 3)//if shown for more than 3 seconds, dont
            pickup = "";//set to blank so that the label doesnt need to be disabled
    }//end Update
Beispiel #2
0
		}//end Update
		
		IEnumerator CollectItem ()
		{//collect the item
				tS.allowGo = false;//stop the trader moving
				yield return new WaitForSeconds (droneTime);//pause for the set time
				tS.allowGo = true;//trader can now continue
		
				if (target != null) {
						CallumP.TradeSys.Item iS = target.GetComponent<CallumP.TradeSys.Item> ();//get the item script
						if(iS != null){//check if null as it may have been collected
						tS.items [iS.groupID].items [iS.itemID].number += iS.number;//increase the number being carreid
						tS.spaceRemaining -= iS.number * controller.goods [iS.groupID].goods [iS.itemID].mass;//decrease the cargo space remaining
						
						iS.Collected ();//IMPORTANT - need to say that the item has been collected so the spawner count can be updated
						}//end if not null
				}//end if target not null
		}//end CollectItem