/// <summary>
 /// Adds an item to the nearby item list.
 /// </summary>
 /// <param name="itemBehaviour">The item to be added.</param>
 public void AddNearbyItem(ItemBehaviour itemBehaviour)
 {
     if (itemBehaviour != null && !_nearbyItems.Contains(itemBehaviour))
     {
         _nearbyItems.Add(itemBehaviour);
     }
 }
 /// <summary>
 /// Removes an item from the nearby item list.
 /// </summary>
 /// <param name="itemBehaviour">The item to be removed.</param>
 public void RemoveNearbyItem(ItemBehaviour itemBehaviour)
 {
     if (itemBehaviour != null && _nearbyItems.Contains(itemBehaviour))
     {
         _nearbyItems.Remove(itemBehaviour);
     }
 }
        /// <summary>
        /// Drops an item if one is in the slot.
        /// </summary>
        /// <param name="context">The context of the input action.</param>
        /// <param name="swapping">Whether or not the current slot is performing a swap behaviour.</param>
        private void OnDropItem(InputAction.CallbackContext context, bool swapping)
        {
            if (!SceneManager.GetActiveScene().isLoaded)
            {
                return;
            }
            if (!context.performed)
            {
                return;
            }

            ItemBehaviour itemBehaviour = _slots[_currentSlotIndex].DropItem(swapping);

            if (itemBehaviour == null)
            {
                return;
            }

            if (swapping)
            {
                UpdateSlotIndicator();
            }

            itemBehaviour.transform.position = _player.transform.position;
            itemBehaviour.gameObject.SetActive(true);
        }
Ejemplo n.º 4
0
 private void OnItemCollectedEvent(ItemBehaviour item)
 {
     Debug.Log("You got item!!!!!!!!!!");
     // add the score value for the item to the player score
     playerScore += item.scoreValueForItem;
     UpdateScore();
 }
Ejemplo n.º 5
0
    public void Trigger(int i)
    {
        if (item == null)
        {
            return;
        }

        if (player.GetPlayerID() == 1)
        {
            Game.instance.shootControllsEnable1 = true;
        }
        else
        {
            Game.instance.shootControllsEnable2 = true;
        }

        if (Main.mode == Mode.Host)
        {
            Game.instance.network.Write("g " + player.GetPlayerID() + ":" + i);
        }

        ItemEvents.player = player;
        ItemEvents.i      = i;

        item.trigger.Invoke();

        GetComponent <Image>().sprite = startSprite;
        item = null;
    }
Ejemplo n.º 6
0
        public override void InstallBindings()
        {
            // create default bindings
            Container.Bind(x => x.AllInterfaces()
                           .Where(i =>
                                  i != typeof(IGameContext) &&
                                  i != typeof(IGameConfig) &&
                                  i != typeof(IUiConfig) &&
                                  i != typeof(IRandomNumberGenerator) &&
                                  i != typeof(IInputHolder)
                                  )
                           )
            .To(x => x.AllNonAbstractClasses().InNamespaces("Assets.Scripts"))
            .AsSingle();

            Container.Bind <IGameContext>().FromInstance(_gameContext).AsSingle();
            Container.Bind <IGameConfig>().FromInstance(_gameConfig).AsSingle();
            Container.Bind <IUiConfig>().FromInstance(_uiConfig).AsSingle();
            int rngSeed = _gameConfig.RngSeed == 0 ? Random.Range(0, int.MaxValue) : _gameConfig.RngSeed;

            Container.Bind <IRandomNumberGenerator>().FromInstance(new RandomNumberGenerator(rngSeed)).AsSingle();
            Container.Bind <IInputHolder>().To <InputHolder>().AsSingle();

            ItemBehaviour  itemPrefab  = Resources.Load <ItemBehaviour>("Prefabs/Item");
            ActorBehaviour actorPrefab = Resources.Load <ActorBehaviour>("Prefabs/Actor");

            Container.BindFactory <ItemBehaviour, ItemBehaviour.Factory>().FromComponentInNewPrefab(itemPrefab);
            Container.BindFactory <ActorBehaviour, ActorBehaviour.Factory>().FromComponentInNewPrefab(actorPrefab);

            Container.Bind <Material>().FromInstance(Resources.Load <Material>("Materials/Plain"))
            .WhenInjectedInto <PathRenderer>();
        }
    /**
     * <summary>
     * Watch for the item on top of the belt
     * </summary>
     */
    protected override void WatchForItem()
    {
        Bounds  bounds = this.transform.GetComponent <Collider2D>().bounds;
        Vector2 size   = bounds.size;

        Collider2D[] colliders = Physics2D.OverlapBoxAll(this.transform.position, size, 0);
        foreach (Collider2D collider in colliders)
        {
            if (collider.tag == Tags.Item)
            {
                Transform item       = collider.GetComponent <Transform>();
                Bounds    itemBounds = item.GetComponent <Collider2D>().bounds;
                Vector2   itemPoint  = new Vector2(itemBounds.min.x, itemBounds.max.y);

                // Always move when the item is exactly or more on top of the collider
                if (!bounds.Contains(itemPoint))
                {
                    continue;
                }

                ItemBehaviour itemBehaviour = item.GetComponent <ItemBehaviour>();
                itemBehaviour.direction = ItemDirection.Right;
                itemBehaviour.speed     = 5f;
                itemBehaviour.MoveRight();
            }
        }
    }
Ejemplo n.º 8
0
    /// <summary>
    /// The create actor.
    /// </summary>
    /// <param name="game">
    /// The game.
    /// </param>
    /// <param name="actor">
    /// The actor.
    /// </param>
    private void CreateActor(Game game, Item actor)
    {
        GameObject    actorCube      = GameObject.CreatePrimitive(PrimitiveType.Cube);
        ItemBehaviour actorBehaviour = (ItemBehaviour)actorCube.AddComponent(typeof(ItemBehaviour));

        actorBehaviour.Initialize(game, actor, this);
    }
Ejemplo n.º 9
0
        public void ReturnToPool(ItemBehaviour inObject)
        {
            ItemBehaviour item = inObject.GetComponent <ItemBehaviour>();

            if (item == null)
            {
                throw new UnityException(string.Format("GameObject {0} is not recognised as an Item and cannot be returned to a pool!", inObject.name));
            }

            ItemDefinition definition = item.ItemDefinition;

            if (definition == null)
            {
                throw new UnityException(string.Format("Item component on GameObject {0} does not have a valid ItemDefinition!", inObject.name));
            }

            assertKeyExists(definition.itemName);

            // Debug.Log("returned to pool", inObject.gameObject);

            inObject.SetSpriteLayerOrder(0);
            inObject.transform.SetParent(poolRoot);
            inObject.transform.localPosition = Vector3.zero;
            inObject.transform.localRotation = Quaternion.identity;
            inObject.gameObject.SetActive(false);
            objectPools[definition.itemName].Enqueue(inObject);
        }
Ejemplo n.º 10
0
    void OnCiderTaken() {
		if (!isServer)
			return;

		prevSpawnedCider = null;
		RpcPlayCiderTakenAudio ();
    }
Ejemplo n.º 11
0
        /// <summary>
        /// Attempt to drop the item if there is one in the slot.
        /// </summary>
        /// <param name="swapping">Whether or not the current slot is performing a swap behaviour.</param>
        /// <returns>The dropped item (null if empty).</returns>
        public ItemBehaviour DropItem(bool swapping = true)
        {
            if (ItemBehaviour == null)
            {
                return(null);
            }

            bool shouldDrop = ItemBehaviour.OnDropItem(this);

            if (!shouldDrop)
            {
                return(null);
            }

            SetSprite(null, _inventorySlotInitialScale);

            ItemBehaviour itemBehaviour = ItemBehaviour;

            ItemBehaviour = null;

            if (swapping)
            {
                _inventoryBehaviour.UpdateSlotIndicator();
            }

            return(itemBehaviour);
        }
Ejemplo n.º 12
0
    private ItemBehaviour[] GetAvaiableSlots()
    {
        int slotsAvaiable = 0;

        foreach (ItemBehaviour item in grid)
        {
            if (item.value == SymbolName.N)
            {
                slotsAvaiable++;
            }
        }

        ItemBehaviour[] tempItems = new ItemBehaviour [slotsAvaiable];
        int             counter   = 0;

        foreach (ItemBehaviour item in grid)
        {
            if (item.value == SymbolName.N)
            {
                tempItems [counter] = item;
                counter++;
            }
        }

        return(tempItems);
    }
Ejemplo n.º 13
0
    /**
     * <summary>
     * Watch for the item on top of the belt
     * </summary>
     */
    protected override void WatchForItem()
    {
        Bounds  bounds = this.transform.GetComponent <Collider2D>().bounds;
        Vector2 size   = bounds.size;

        Collider2D[] colliders = Physics2D.OverlapBoxAll(this.transform.position, size, 0);
        foreach (Collider2D collider in colliders)
        {
            if (collider.tag == Tags.Item)
            {
                Transform item       = collider.GetComponent <Transform>();
                Bounds    itemBounds = item.GetComponent <Collider2D>().bounds;
                Vector2   itemPoint  = new Vector2(itemBounds.max.x, itemBounds.min.y);

                // Do not move the item if the item point is not on the belt
                if (!bounds.Contains(itemPoint))
                {
                    continue;
                }

                ItemBehaviour itemBehaviour = item.GetComponent <ItemBehaviour>();
                itemBehaviour.speed = 5f;
                itemBehaviour.MoveLeft();
            }
        }
    }
Ejemplo n.º 14
0
    private void OnTriggerExit2D(Collider2D other)
    {
        itemOver    = null;
        gettingItem = false;

        tanamaquina = false;
        maquinaover = null;
    }
Ejemplo n.º 15
0
 void Awake()
 {
     item = transform.parent.gameObject.GetComponent <ItemBehaviour>();
     if (item)
     {
         dontAct = item.DontDisable;
     }
 }
        /// <summary>
        /// Updates the current slot index and spawns correct item
        /// </summary>
        public void UpdateCurrentSlot()
        {
            if (SelectedItem is null && !(currentHeldItem is null))

            {
                currentHeldItem.OnDeselectItem();
                Destroy(currentHeldItem.gameObject);
                currentHeldItem = null;
            }
Ejemplo n.º 17
0
        void SetBehaviour(GameObject g, bool enabled)
        {
            ItemBehaviour hook = g.gameObject.GetComponent <ItemBehaviour>();

            if (hook != null)
            {
                hook.DontDisable = enabled;
            }
        }
Ejemplo n.º 18
0
    public void OnItemTakenFromBox(ItemBehaviour itemLabel)
    {
        Debug.Log("Item taken at " + TimeRemaining);

        _pickedupItems[itemLabel.gameObject] = new CollectedItem()
        {
            pos = itemLabel.OriginCoordinate,
            ts  = maxTimeSeconds - TimeRemaining
        };
    }
 void OnCollisionEnter(Collision other)
 {
     if (other.gameObject.tag == "Underground") {
         Rigidbody rb = this.gameObject.GetComponent <Rigidbody >();
         rb.AddForce(new Vector3(0, 10, 0), ForceMode.Impulse);
     } else if (other.gameObject.tag == "Item") {
         ItemBehaviour ib = other.gameObject.GetComponent <ItemBehaviour >();
         ib.PlayerCollided();
     }
 }
Ejemplo n.º 20
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player" && other.GetComponent <BackPackBehaviour>().Items.Count < other.GetComponent <BackPackBehaviour>().Capacity)
     {
         print("Collision");
         ItemBehaviour b = this.GetComponent <ItemBehaviour>();
         other.gameObject.GetComponent <BackPackBehaviour>().AddItem(b.ItemRuntime);
         Destroy(Prefab);
     }
 }
Ejemplo n.º 21
0
    void Awake()
    {
        Instance = this;

        foreach (ItemTemplate i in itemTemplates)
        {
            itemTable[i.itemName] = i;
        }

        RegisterItemBehaviour(ItemName.HealthPotion, AddPlayerHealth);
    }
Ejemplo n.º 22
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;
	}
Ejemplo n.º 23
0
    private void CreateActor(Item actorItem)
    {
        GameObject    actorGo = (GameObject)Instantiate(this.ActorPrefab);
        ItemBehaviour ib      = actorGo.GetComponent <ItemBehaviour>();

        if (ib == null)
        {
            ib = actorGo.AddComponent(typeof(ItemBehaviour)) as ItemBehaviour;
        }
        ib.Initialize(this.Game, actorItem, this.ItemObjectName(actorItem), null);
    }
Ejemplo n.º 24
0
        private ItemBehaviour instantiateItem(ItemDefinition definition, bool startActive = true)
        {
            ItemBehaviour item = itemFactory.CreateItem(definition);

            if (startActive == false)
            {
                item.transform.parent = poolRoot;
                item.gameObject.SetActive(false);
            }
            return(item);
        }
Ejemplo n.º 25
0
        public ItemBehaviour CreateItem(ItemDefinition itemDefinition)
        {
            GameObject     itemObject     = new GameObject("New " + itemDefinition.itemName, itemComponentTypes);
            ItemBehaviour  itemBehaviour  = itemObject.GetComponent <ItemBehaviour>();
            SpriteRenderer spriteRenderer = itemObject.GetComponent <SpriteRenderer>();

            itemBehaviour.Awake();
            spriteRenderer.sortingLayerName = itemSortingLayer;
            spriteRenderer.sprite           = itemDefinition.texture;
            itemBehaviour.ItemDefinition    = itemDefinition;
            return(itemBehaviour);
        }
Ejemplo n.º 26
0
    /******************************************************
    * MonoBehaviour methods, Awake
    ******************************************************/

    void Awake()
    {
        // load perfab
        if (itemPrefab == null)
        {
            itemPrefab = (GameObject)Resources.Load("itemPrefab");
        }

        GameObject tmp = (GameObject)Instantiate(itemPrefab, transform.position, Quaternion.identity);

        itemBehavior = tmp.GetComponent <ItemBehaviour>();
    }
Ejemplo n.º 27
0
        void buildProjectFromCSV(string path)
        {
            Item[] items = ProjectFactory.buildItemsFromCSV(path);
            int    i     = 0;

            foreach (Item item in items)
            {
                ItemBehaviour itemBehavior = item.Build(new Vector3(Mathf.Sin(i) * 10, i / 5, Mathf.Cos(i) * 10), Vector3.zero);
                itemBehavior.transform.LookAt(Vector3.zero);
                i++;
            }
        }
Ejemplo n.º 28
0
        private Vector3[] BuildVerticesFromItems(ItemBehaviour item, ItemBehaviour other, int vertCount)
        {
            Vector3[] verts = new Vector3[vertCount];
            Vector3   dir   = other.transform.position - item.transform.position;

            for (int i = 0; i < vertCount - 1; i++)
            {
                verts[i] = item.transform.position + (dir * (1f / (float)vertCount) * i);
            }
            verts[vertCount - 1] = other.transform.position;
            return(verts);
        }
Ejemplo n.º 29
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     // if(other.gameObject.CompareTag("TAGferramenta") && InteragirButtonPress()){
     //     Debug.Log("teste");
     // }
     if (other.gameObject.CompareTag("TAGitem"))
     {
         Debug.Log(other.GetComponent <ItemBehaviour>());
         item        = other.GetComponent <ItemBehaviour>();
         gettingItem = true;
     }
 }
Ejemplo n.º 30
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;
 }
Ejemplo n.º 31
0
        public static bool IsInBackpack(ItemBehaviour behaviour)
        {
            if (CarryMore)
            {
                return(behaviour.transform.position.y < -900);
            }
            else if (AdvancedBackpack)
            {
                return(Vector3.Distance(behaviour.transform.position, AdvancedBackpackPosition) < AdvancedBackpackDistance);
            }

            return(false);
        }
Ejemplo n.º 32
0
 public void SpawnFromPool(out ItemBehaviour outObject, string itemName)
 {
     assertKeyExists(itemName);
     if (objectPools[itemName].Count > 0)
     {
         outObject = objectPools[itemName].Dequeue();
         outObject.gameObject.SetActive(true);
     }
     else
     {
         outObject = instantiateItem(registeredItemDefinitions[itemName]);
     }
 }
Ejemplo n.º 33
0
        public void SpawnItem(ItemDefinition item, Vector2Int spawnPosition)
        {
            ItemBehaviour instantiatedItem = _itemBehaviourFactory.Create();

            instantiatedItem.GetComponent <SpriteRenderer>().sprite = item.Sprite;
            instantiatedItem.ItemData.ItemType       = item.ItemType;
            instantiatedItem.ItemData.ItemDefinition = item;

            Vector2Int positionToPlaceItem = GetPositionToPlaceItem(spawnPosition);

            instantiatedItem.ItemData.LogicalPosition = positionToPlaceItem;
            instantiatedItem.RefreshWorldPosition();
        }
Ejemplo n.º 34
0
	// 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;
	}
Ejemplo n.º 35
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;
			}
		}
    }
Ejemplo n.º 36
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();
				 
				}
				 
				 
			}

		}
	
	}
Ejemplo n.º 37
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");

		}
	}
Ejemplo n.º 38
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; 
					 						
				 
				}
				
			}
			
		}
	}
Ejemplo n.º 39
0
	public override void CopyFromControl (ItemBehaviour control)
	{
		this.Ammo = ((ItemRanged)control).Ammo;
	}
Ejemplo n.º 40
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();
						}
					}
				}
			}

		
		}
	}
Ejemplo n.º 41
0
	public override void OnStartServer()
    {
		prevSpawnedCider = null;
		produceTimeElapsed = 0;
		produceSpawnPosition = gameObject.transform.FindChild("CiderSpawnPoint").position;
    }
Ejemplo n.º 42
0
	public virtual void CopyFromControl (ItemBehaviour control) {}