Example #1
0
    void OnCiderTaken() {
		if (!isServer)
			return;

		prevSpawnedCider = null;
		RpcPlayCiderTakenAudio ();
    }
Example #2
0
	public void OnStealItem() {
		if (!isServer)
    		return;

		Debug.Log("BreweryBehavior OnStealItem");
		RpcPlayCiderTakenAudio ();
		// Stealing does not remove Item since collision was not used, so we remove the item manually.
		Debug.Log("ItemBehavior destroy");
		Destroy(prevSpawnedCider.gameObject);
		prevSpawnedCider = null;
	}
Example #3
0
 // Add an item to the inventory. Return 'true' if successful or 'false' otherwise.
 public static bool addItem(ItemBehaviour itemBehaviour)
 {
     for (int i = 0; i < Inventory.Length; i++) {
         if (Inventory[i] == null) {
             Inventory[i] = new Item(itemBehaviour.itemName,
                                     itemBehaviour.icon,
                                     itemBehaviour.description,
                                     itemBehaviour.itemHandler);
             return true;
         }
     }
     return false;
 }
	// Returns true if taken, false otherwise.
	public bool TakeItem(ItemBehaviour itemBehavior) {
		if (!isServer)
			return false;

		if (IsCarryingItem())
			return false;

		// start carrying the item;
		float spriteOffset = G.get().CARRY_OVERHEAD_OFFSET_Y + 
			gameObject.GetComponent<Collider2D>().bounds.size.y / 2.0f;
		m_carryingItem = (GameObject) Instantiate(itemBehavior.itemIconPrefab);
		NetworkServer.Spawn(m_carryingItem);
		RpcCarryingItemInit(m_carryingItem, this.gameObject, spriteOffset);

		carryingItemType = itemBehavior.itemType;

		return true;
	}
Example #5
0
    void Update() {
    	if (!isServer)
    		return;

		if (HasItem()) {
    		// do nothing
    	} else {
	    	produceTimeElapsed -= Time.deltaTime;
	    	if (produceTimeElapsed <= 0) {
				GameObject spawned = (GameObject) Instantiate(
					ciderPrefab, produceSpawnPosition, Quaternion.identity);
				var spawnedCider = spawned.GetComponent<ItemBehaviour>();
				spawnedCider.OnTaken += OnCiderTaken;
				NetworkServer.Spawn(spawned);
				produceTimeElapsed = G.get().CIDER_PRODUCE_DELAY;
				prevSpawnedCider = spawnedCider;
			}
		}
    }
Example #6
0
	//per turn
	public void updateItem(){
	 
		for (int i = 0; i < itemBehaviourGameObject.transform.childCount; i++) {
			itemBehaviour = itemBehaviourGameObject.transform.GetChild (i).GetComponent<ItemBehaviour> ();		 
		 
		 
		 
			if(m_x == itemBehaviour.m_x+1 && m_y==itemBehaviour.m_y){
		 
				if (String.Compare (itemBehaviour.name, "SWITCH", false) == 0) {
					itemBehaviour.updateSwitch(enemieBehaviourGameObject);
				 
				}
		 
				if (String.Compare (itemBehaviour.name, "SEQUENTIAL_SWITCH", false) == 0) {
					itemBehaviour.updateSequentialSwitch();
					 
				}
 
			
			}

			 	 
			if(m_x == itemBehaviour.m_x-1 && m_y==itemBehaviour.m_y){
				 
				if (String.Compare (itemBehaviour.name, "SWITCH", false) == 0) {
					itemBehaviour.updateSwitch(enemieBehaviourGameObject);
					 
				}
				 
				if (String.Compare (itemBehaviour.name, "SEQUENTIAL_SWITCH", false) == 0) {
					itemBehaviour.updateSequentialSwitch();
					 
				}
			 
			}
		 
			if(m_x == itemBehaviour.m_x && m_y==itemBehaviour.m_y+1){
			 
				if (String.Compare (itemBehaviour.name, "SWITCH", false) == 0) {
					itemBehaviour.updateSwitch(enemieBehaviourGameObject);
				 
				}
				 
				if (String.Compare (itemBehaviour.name, "SEQUENTIAL_SWITCH", false) == 0) {
					itemBehaviour.updateSequentialSwitch();
					 
				}
			 
				 
			}
			 
			if(m_x == itemBehaviour.m_x && m_y==itemBehaviour.m_y-1){
			 
				if (String.Compare (itemBehaviour.name, "SWITCH", false) == 0) {
					itemBehaviour.updateSwitch(enemieBehaviourGameObject);
				 
				}
			 
				if (String.Compare (itemBehaviour.name, "SEQUENTIAL_SWITCH", false) == 0) {
					itemBehaviour.updateSequentialSwitch();
				 
				}
				 
				 
			}

		}
	
	}
Example #7
0
	// real time
	public void updateItemRealTime(){
			for (int i = 0; i < itemBehaviourGameObject.transform.childCount; i++) {
			itemBehaviour = itemBehaviourGameObject.transform.GetChild (i).GetComponent<ItemBehaviour> ();		 
					
			if (m_x == itemBehaviour.m_x && m_y == itemBehaviour.m_y) {
				if (String.Compare (itemBehaviour.name, "TRAP", false) == 0) {

					finishPosition = new Vector3(itemBehaviour.m_x, itemBehaviour.m_y+1,1);
					AudioSource.PlayClipAtPoint(attackSoundC, transform.position);	
					itemBehaviour.trap ();
					itemBehaviour.remove ();
					inTrap=true;	
					anim.SetBool ("move", false); 
					up = down = right = left = false;
			 
						
				}
			}
			if (m_x == itemBehaviour.m_x && m_y == itemBehaviour.m_y) {
				if(String.Compare (itemBehaviour.name, "GEM", false) == 0){
					//not get if is caught
					if(!itemBehaviour.isCaught){
						AudioSource.PlayClipAtPoint(gemCollectedSound, transform.position);	
						gem++;				 
						itemBehaviour.isCaught=true;				
						itemBehaviour.transform.Search ("CFXM2_ShinyItem Cyan").GetComponent<Renderer> ().enabled = false;
						itemBehaviour.transform.Search ("CFXM2_ShinyItem Cyan").GetComponent<ParticleSystem>().enableEmission = false;
						itemBehaviour.transform.Search ("CFXM2_ShinyItem Cyan").GetComponent<ParticleSystem>().Stop ();
						itemBehaviour.GetComponent<Renderer> ().enabled = false;
					}else{
						itemBehaviour.transform.Search ("CFXM2_ShinyItem").GetComponent<ParticleSystem>().loop = true;
						if(itemBehaviour.isFinish){
							finishMap();
						}
					}


					
				}
				
				if(String.Compare (itemBehaviour.name, "KEY", false) == 0){
					//not get if is caught
					if(!itemBehaviour.isCaught){
						AudioSource.PlayClipAtPoint(keyCollectedSound, transform.position);	
						haveKey = true;	
						itemBehaviour.isCaught=true;			
						objKey.GetComponent<key>().setVisible(true);
						itemBehaviour.transform.Search ("CFXM2_ShinyItem").GetComponent<Renderer> ().enabled = false; 
						itemBehaviour.transform.Search ("CFXM2_ShinyItem").GetComponent<ParticleSystem>().enableEmission = false;
						itemBehaviour.transform.Search ("CFXM2_ShinyItem").GetComponent<ParticleSystem>().Stop ();
						itemBehaviour.GetComponent<Renderer> ().enabled = false;
					}else{
						itemBehaviour.transform.Search ("CFXM2_ShinyItem").GetComponent<ParticleSystem>().loop = true;
						if(itemBehaviour.isFinish){
							finishMap();
						}
					}
				}
			}

		
		}
	}
Example #8
0
	public void updateDoor(int direction){
		for (int i = 0; i < itemBehaviourGameObject.transform.childCount; i++) {
			itemBehaviour = itemBehaviourGameObject.transform.GetChild (i).GetComponent<ItemBehaviour> ();		 
	
			if(direction==4)
			if(m_x == itemBehaviour.m_x+1 && m_y==itemBehaviour.m_y){
				if (String.Compare (itemBehaviour.name, "KEY_RECQUIRING_DOOR", false) == 0) {
					itemBehaviour.updateKeyRecquiringDoor(haveKey, enemieBehaviourGameObject);

				}

				if (String.Compare (itemBehaviour.name, "ALWAYS_OPEN_DOOR", false) == 0) {

						isFinish = itemBehaviour.isFinish; 
						to_board = itemBehaviour.to_board;
						to_spawner = itemBehaviour.to_spawner;
					 
				}
				
			}
			
			if(direction==2)		 
			if(m_x == itemBehaviour.m_x-1 && m_y==itemBehaviour.m_y){
			

				if (String.Compare (itemBehaviour.name, "KEY_RECQUIRING_DOOR", false) == 0) {
					itemBehaviour.updateKeyRecquiringDoor(haveKey, enemieBehaviourGameObject);
				}

				if (String.Compare (itemBehaviour.name, "ALWAYS_OPEN_DOOR", false) == 0) {
						isFinish = itemBehaviour.isFinish; 
						to_board = itemBehaviour.to_board;
						to_spawner = itemBehaviour.to_spawner;
					 
				}
			}
			if(direction==3)
			if(m_x == itemBehaviour.m_x && m_y==itemBehaviour.m_y+1){
		
			
				if (String.Compare (itemBehaviour.name, "KEY_RECQUIRING_DOOR", false) == 0) {
					itemBehaviour.updateKeyRecquiringDoor(haveKey, enemieBehaviourGameObject);
				}

				if (String.Compare (itemBehaviour.name, "ALWAYS_OPEN_DOOR", false) == 0) {
						isFinish = itemBehaviour.isFinish; 
						to_board = itemBehaviour.to_board;
						to_spawner = itemBehaviour.to_spawner;
					 
				}
				
			}
			if(direction==1)
			if(m_x == itemBehaviour.m_x && m_y==itemBehaviour.m_y-1){		 
		 
				if (String.Compare (itemBehaviour.name, "KEY_RECQUIRING_DOOR", false) == 0) {
					itemBehaviour.updateKeyRecquiringDoor(haveKey, enemieBehaviourGameObject);
					
				}
			 
				if (String.Compare (itemBehaviour.name, "ALWAYS_OPEN_DOOR", false) == 0) {

						to_board = itemBehaviour.to_board;
						to_spawner = itemBehaviour.to_spawner;
						isFinish = itemBehaviour.isFinish; 
					 						
				 
				}
				
			}
			
		}
	}
Example #9
0
	//makes port update when changing status
	private void updadeDoor(){
	
		for (int i = 0; i < itemBehaviourGameObject.transform.childCount; i++) {
			itemBehaviour = itemBehaviourGameObject.transform.GetChild (i).GetComponent<ItemBehaviour> ();			 
			itemBehaviour.updateDoor ("LOCALLY_CLOSED_DOOR");

		}
	}
Example #10
0
	public override void OnStartServer()
    {
		prevSpawnedCider = null;
		produceTimeElapsed = 0;
		produceSpawnPosition = gameObject.transform.FindChild("CiderSpawnPoint").position;
    }
Example #11
0
	public override void CopyFromControl (ItemBehaviour control)
	{
		this.Ammo = ((ItemRanged)control).Ammo;
	}
Example #12
0
	public virtual void CopyFromControl (ItemBehaviour control) {}