GetComponentInChildren() public method

public GetComponentInChildren ( Type type ) : Component
type System.Type
return Component
 private void Awake()
 {
     titleControls = GameObject.Find ("Canvas");
     btnStart = titleControls.GetComponentInChildren<Button> ();
     btnStart.onClick.AddListener (() => btnOnclick ());
     inputField = titleControls.GetComponentInChildren<InputField> ();
 }
Example #2
0
    public void SetMaster(GameObject mas)
    {
        master = mas;
        healthGUI = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Enemies/healthObj"));
        Image health = healthGUI.GetComponentInChildren<Image>();
        Text healthtext = healthGUI.GetComponentInChildren<Text>();
        if (gameObject.transform.position.x < 0)
        {
            health.transform.localPosition = new Vector3(-40, (Screen.height / Screen.dpi) + 80, gameObject.transform.localPosition.z);
            healthtext.transform.localPosition = new Vector3(-25, (Screen.height / Screen.dpi) + 75, gameObject.transform.localPosition.z);
        }
        else
        {
            health.transform.localPosition = new Vector3(45, (Screen.height / Screen.dpi) + 80, gameObject.transform.localPosition.z);
            healthtext.transform.localPosition = new Vector3(66, (Screen.height / Screen.dpi) + 75, gameObject.transform.localPosition.z);
        }

        //health.transform.localPosition = new Vector3(gameObject.transform.localPosition.x * 13 + 11f, (Screen.height/Screen.dpi) +80, gameObject.transform.localPosition.z);
        //healthtext.transform.localPosition = new Vector3(gameObject.transform.localPosition.x *12 + 14, (Screen.height / Screen.dpi) + 75, gameObject.transform.localPosition.z);

        healthtxt = healthtext;
        healthbar = health;

        //if the forgottone
        if(gameObject.name== "Forgotten(Clone)0")
        {
            spinner1 = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Enemies/Forgottonspinner1"));
            spinner2 = (GameObject)GameObject.Instantiate(Resources.Load("Prefabs/Enemies/ForgottonSpinner2"));
            spinner1.transform.localScale = new Vector3 (1.4f,1.3f,1);
            spinner2.transform.localScale = new Vector3 (1.4f,1.3f,1);
        }
    }
Example #3
0
    // Use this for initialization
    void Start()
    {
        if (GetComponent<Identity>().unitType.isBuilding())
        {
            //GetComponent<Health>().setHealth(50);
            //GetComponent<Health>().setMaxHealth(50);
            //GetComponent<Health>().setAuxHealth(50);
            auxMaxHealth = GetComponent<BuildingConstruction>().timer;
            maxHealth = MapValues(auxMaxHealth, 0, auxMaxHealth, GetComponent<Health>().getMaxHealth() / 10, GetComponent<Health>().getMaxHealth());
            curHealth = MapValues(auxMaxHealth - GetComponent<BuildingConstruction>().timer, 0, auxMaxHealth, GetComponent<Health>().getMaxHealth() / 10, GetComponent<Health>().getMaxHealth());
        }
        else
        {
            maxHealth = GetComponent<Health>().getMaxHealth();
            curHealth = GetComponent<Health>().getHealth();
        }

        g = Instantiate(prefab);
        g.transform.SetParent(GameController.Instance.healthBarsParent.transform);

        g.transform.GetChild(0).transform.position = Camera.main.WorldToScreenPoint(GetComponentInChildren<auxHealth>().gameObject.transform.position);
        g1 = g.GetComponentInChildren<auxHealth>().gameObject;

        visualHealth = g.GetComponentInChildren<auxHealth>().i;

        unitLOSEntity = gameObject.GetComponent<LOSEntity>();
    }
    public void OnBeginDrag(PointerEventData eventData)
    {
        newParent = this.transform.parent;
        oldParent = this.transform.parent;
        this.transform.SetParent (this.transform.parent.parent.parent.parent.parent);
        Debug.Log ("OLD PARENT IS: " + oldParent);

        GetComponent<CanvasGroup>().blocksRaycasts = false;

        UI_Container = GameObject.FindGameObjectWithTag ("UI Container");

        //YAY GLOW
        if (oldParent.gameObject.transform.name.ToString () == "Scrollable List") {
            for (int i = 0; i < UI_Container.GetComponentInChildren<SquadSelectionScript>().MemberList.Length; i++) {
                Color glowColour = Color.Lerp (oldValue, newValue, Mathf.PingPong (Time.time, 8));
                UI_Container.GetComponentInChildren<SquadSelectionScript>().MemberList[i].GetComponent<Image>().color = glowColour;
            }
        }

        //YAY WEAPONS GLOW
        if (oldParent.gameObject.transform.name.ToString () == "Scrollable Weapons List") {
            for (int i = 0; i < UI_Container.GetComponentInChildren<SquadSelectionScript>().WeaponList.Length; i++) {
                Color glowColour = Color.Lerp (oldValue, newValue, Mathf.PingPong (Time.time, 8));
                UI_Container.GetComponentInChildren<SquadSelectionScript>().WeaponList[i].GetComponent<Image>().color = glowColour;
            }
        }
    }
	public void Selected(GameObject card) {
		card.transform.SetSiblingIndex (9);
        card.GetComponent<RectTransform>().sizeDelta = new Vector2(m_CardWidth * 0.9f, m_CardHeight * 0.9f);
        m_Servant = card.tag;
        if (card.GetComponentInChildren<Text>())
        {
            m_IntroText.GetComponent<Text>().text = card.GetComponentInChildren<Text>().text;
        }
        int i = 1;
        bool bigger = false;
		foreach (var item in m_Cards) {
            if (card == item)
            {
                bigger = true;
                i = 6;
            }
            else
            {
                if (bigger)
                    item.transform.SetSiblingIndex(i--);
                else
                    item.transform.SetSiblingIndex(i++);
                item.GetComponent<RectTransform>().sizeDelta = new Vector2(m_CardWidth * 0.8f, m_CardHeight * 0.8f);
            }
        }
	}
Example #6
0
    public void Swap(GameObject from, GameObject to)
    {
        Transform thisposition = from.transform;
        Vector2 temp_position = thisposition.position;
        GameObject temp_parent = thisposition.parent.gameObject;

        Transform targetposition = to.transform;

        from.transform.SetParent(targetposition.parent,false);
        from.transform.position = targetposition.position;

        to.transform.SetParent(temp_parent.transform,false);
        to.transform.position = temp_position;

        if(from.transform.parent.name.Contains("Substitution")){
            from.GetComponentInChildren<PlayerDragScript>().enabled = false;
        }
        else{
            from.GetComponentInChildren<PlayerDragScript>().enabled = true;
        }
        if(to.transform.parent.name.Contains("Substitution")){
            to.GetComponentInChildren<PlayerDragScript>().enabled = false;
        }
        else{
            to.GetComponentInChildren<PlayerDragScript>().enabled = true;
        }

        from.GetComponent<PlayerAttribute>().updateNameView();
        to.GetComponent<PlayerAttribute>().updateNameView();
    }
 private void SpawnMyPlayer()
 {
     myPlayer = PhotonNetwork.Instantiate("Character", Vector3.zero, Quaternion.identity, 0);
     myPlayer.GetComponentInChildren<PlayerMovement>().enabled = true;
     myPlayer.GetComponentInChildren<CameraScript>().enabled = true;
     myPlayer.GetComponentInChildren<Camera>().enabled = true;
 }
    public void DisplaySettingsFile(GameObject clickedButton)
    {
        // we need to clear out the children in the list before we generate new ones
        for (int i = 0; i < fieldsList.transform.childCount; i ++)
        {
            fieldsList.transform.GetChild(i).gameObject.SetActive(false);
            Debug.Log("destroying: " + fieldsList.transform.GetChild(i).name);
            Destroy(fieldsList.transform.GetChild(i).gameObject);

        }

        string file = settingsFileFolderPath + "/" + clickedButton.GetComponentInChildren<Text> ().text;

        string tmpFile = clickedButton.GetComponentInChildren<Text> ().text.Substring(0, clickedButton.GetComponentInChildren<Text> ().text.Length - 5);
        Type fileType = System.Type.GetType(tmpFile);
        activeSettingsFileType = fileType;

        WidgetSettings displayedFile = XmlIO.Load (file, fileType) as WidgetSettings;

        object[] displayedValues = displayedFile.GetValues ();

        FieldInfo[] fieldsArray = fileType.GetFields ();

        for (int i = 0; i < fieldsArray.Length; i++)
        {
            GameObject fieldUI = Instantiate (Resources.Load ("WidgetSettings/" + fieldsArray [i].FieldType.Name + "_UI")) as GameObject;
            fieldUI.transform.SetParent (fieldsList.transform);
            fieldUI.transform.FindChild("Title").GetComponent<Text>().text = fieldsArray[i].Name;
            fieldUI.GetComponent<FieldUIs>().SetFieldValue(displayedValues[i]);

        }
    }
Example #9
0
    void OnParticleCollision(GameObject other)
    {
        print("burn!!!!");
		if (other.CompareTag("Torch"))
		{
			ParticleSystem fire = other.GetComponentInChildren<ParticleSystem>();
			fire.Play();
		}
		if (other.CompareTag("Rubble"))
		{
			Debug.Log("boom");
            Rigidbody[] pieces = other.gameObject.GetComponentsInChildren<Rigidbody>();
            foreach (Rigidbody piece in pieces)
            {
                piece.isKinematic = false;
                piece.AddExplosionForce(500, other.gameObject.transform.position, 5);
            }
            BoxCollider goocollider = other.GetComponent<BoxCollider>();
            goocollider.enabled = false;
            ParticleSystem bakahatsu = other.GetComponentInChildren<ParticleSystem>();
            bakahatsu.Play();
            GameObject goo = other.transform.FindChild("Goo").gameObject;
            Destroy(goo);

		}
    }
    //Called by CreateNewUser
    public void ClickedUser(GameObject userObject)
    {
        //Changes userName in SaveLoad class to the text in the first Username slot
        saveLoad.userName = userObject.GetComponentInChildren<Text>().text;
        //Deletes and then saves the Users after deltetion
        saveLoad.Delete();
        foreach(User user in createUser.listOfTypeUSERS)
        {

            if(userObject.GetComponentInChildren<Text>().text == user.getPlayerName())
            {
                Debug.Log("Deleting "+userObject.GetComponentInChildren<Text>().text);
                index = createUser.listOfUsers.IndexOf(userObject);
                createUser.listOfUsers.Remove(userObject);
                createUser.listOfTypeUSERS.Remove(user);
                Destroy (userObject);
                if(createUser.usernameNumb != 0)
                    createUser.usernameNumb--;
                else
                    createUser.usernameNumb = 4;
                createUser.userNumbTracker--;
                break;
            }

        }
        DeletionOver();
    }
    /// <summary>
    /// In the Tiled layer add a custom property called 'physicsMaterial2D' to be used in the handler
    /// The value of the property must be a valid PhysicsMaterial2D located in the Assets/Materials/PhysicsMaterial/
    /// </summary>
    public void HandleCustomProperties(GameObject gameObject,
        IDictionary<string, string> props)
    {
        //Se não existir o custom property já saimos
        if (!props.ContainsKey("physicsMaterial2D"))
        {
            return;
        }

        string materialName = props["physicsMaterial2D"] + ".physicsMaterial2D";
        string materialPath = "Assets/Materials/PhysicsMaterial/" + materialName;


        // Verificamos se o material existe, se não existir disparamos o erro e retornamos
        PhysicsMaterial2D material = AssetDatabase.LoadAssetAtPath(materialPath, typeof(PhysicsMaterial2D)) as PhysicsMaterial2D;
        if (material == null)
        {
            Debug.LogError(String.Format("Could not find material: {0}", materialName));
            return;
        }
        
        //O tiled2unity sempre exporta o collider como PolygonCollider, se mudar temos que refazer essa parte
        if (gameObject.GetComponentInChildren<PolygonCollider2D>() != null)
        {
            gameObject.GetComponentInChildren<PolygonCollider2D>().sharedMaterial = material;
        }

        
    }
	private void PopulateMap(GameObject mapObject)
	{
		int levelIndex = Random.Range(0, MainMenuManager.Levels.Count);
		MainMenuManager.LevelPackage level = MainMenuManager.Levels[levelIndex];
		mapObject.GetComponentInChildren<Image>().sprite = level.Thumbnail;
		mapObject.GetComponentInChildren<Text>().text = level.Name;
		m_ShownMap.Add(new ExposedMap() { Name = level.Name, GameObject = mapObject });
	}
	public void selectMonth(GameObject opcion){
		btnMonth.GetComponentInChildren<Text> ().text = opcion.GetComponentInChildren<Text> ().text;
		Debug.Log (opcion.GetComponentInChildren<Text> ().text);

		GMS.userData.format_month (opcion.GetComponentInChildren<Text> ().text);

		DDMonth.SetActive (false);
	}
Example #14
0
 public CTTestInputDisplay(GameObject attchedGameObject)
 {
     gameObject = attchedGameObject;
     line = gameObject.GetComponentInChildren<LineRenderer>();
     text = gameObject.GetComponentInChildren<GUIText>();
     _trailVerts = new List<Vector3>();
     GameMessenger.Reg("newTestInputRecording", this, Message_newTestInputRecording);
     GameMessenger.Reg("touch", this, Message_touch);
 }
Example #15
0
 void Start()
 {
     manaBar = GameObject.FindGameObjectWithTag("ManaBar");
     spellBar = GameObject.FindGameObjectWithTag("SpellBar");
     deathScreen = GameObject.FindGameObjectWithTag("DeathScreen");
     generator = GameObject.FindGameObjectWithTag("Generator").GetComponent<GenerateScript>();
     manaBar.GetComponentInChildren<Image>().fillMethod = Image.FillMethod.Radial360;
     manaBar.GetComponentInChildren<Image>().type = Image.Type.Filled;
 }
Example #16
0
    public bool addNewMissile(GameObject missile, missileType mType)
    {
        switch (mType) {
        case(missileType.Homing):
            if (homingMissileObject != null) {
                return false;
            }

            homingMissileObject = missile;
            navPoint homingNav = homingMissileObject.GetComponentInChildren<navPoint> ();
            homingNav.playerColor = playerColor;
            homingNav.nameTag = nameTag;
            homingNav.refresh();
            mC = homingMissileObject.GetComponentInChildren<homingMissileScript> ();
            mC.tLC = this;
            return true;
        case(missileType.Controlled):
            if (controlledMissileOjbect != null) {
                return false;
            }

            controlledMissileOjbect = missile;
            navPoint contNav = controlledMissileOjbect.GetComponentInChildren<navPoint> ();
            contNav.playerColor = playerColor;
            contNav.nameTag = nameTag;
            contNav.refresh ();
            contMisScript = missile.GetComponentInChildren<ControlledMissile> ();
            contMisScript.tLC = this;
            return true;
        case(missileType.Collector):
            Debug.Log("Received fire command");
            if(ResourceMissile != null) {
                return false;
            }
            Debug.Log("Setting up AI missile");
            ResourceMissile = missile;
            navPoint rescontNav = ResourceMissile.GetComponentInChildren<navPoint>();
            rescontNav.playerColor = playerColor;
            rescontNav.nameTag = nameTag;
            rescontNav.refresh();
            resourceMissileScript = missile.GetComponentInChildren<resourceRobot>();
            resourceMissileScript.tLC = this;
            Debug.Log("Returning true");
            return true;
        case(missileType.DefenseSystem):
            if(DefenseSystem != null){
                return false;
            }
            DefenseSystem = missile;
            DefenseSystemScript = missile.GetComponentInChildren<defensesystem>();
            DefenseSystemScript.tLC = this;
            return true;
        default:
            return false;
        }
    }
    void Awake()
    {
        speech = transform.FindChild("SpeechBubble").gameObject;

        speechBubble = speech.GetComponentInChildren<tk2dSlicedSprite>();
        textMesh = speech.GetComponentInChildren<tk2dTextMesh>();

        speech.SetActive(false);
        UpdateTexts(text);
    }
	private void OnSpiderHidden(GameObject spider)
	{
		if (spider.tag == "enemy")
		{
				Canvas canvas = spider.GetComponentInChildren<Canvas>();
				if (canvas)
				spider.GetComponentInChildren<Canvas>().enabled = false;
				spider.GetComponent<EnemyScript>().anim.enabled = false;

		}
	}
 public void ForceTouch(GameObject obj)
 {
     if (obj.GetComponent<Collider>())
     {
         OnTriggerStay(obj.GetComponent<Collider>());
     }
     else if (obj.GetComponentInChildren<Collider>())
     {
         OnTriggerStay(obj.GetComponentInChildren<Collider>());
     }
 }
Example #20
0
 void OnHexRedisplay(Tile tile_data, GameObject tile_current)
 {
     if (tile_data.Type == Tile.TileType.Empty) {
         tile_current.GetComponentInChildren<MeshRenderer> ().enabled = false;
     } else if (tile_data.Type == Tile.TileType.Terrian) {
         // Just do this right now as we only have 1 type of terrian. Later on we could add more types of terrian tiles, and
         // change the MeshRender depending on the type of terrian that is presented.
         tile_current.GetComponentInChildren<MeshRenderer> ().enabled = true;
     }
     else
         Debug.Log("There is an error in the tile type");
 }
	private void OnSpiderVisible(GameObject spider)
	{
		if (spider.tag == "enemy" && hiss != null)
		{
			hiss.Stop();
			hiss.Play();
			Canvas canvas = spider.GetComponentInChildren<Canvas>();
			if (canvas)
			spider.GetComponentInChildren<Canvas>().enabled = true;
			spider.GetComponent<EnemyScript>().anim.enabled = true;
		}
	}
Example #22
0
 //FIXME_VAR_TYPE transform;
 //void Start()
 //{
 //    //GameObject lOwner  = transform.parent.gameObject;
 //    if (!owner)
 //        return;
 //    if (Network.peerType != NetworkPeerType.Disconnected && networkView.isMine)
 //    {
 //        networkView.RPC("RPCSetOwner", RPCMode.Others, owner.networkView.viewID);
 //        networkView.enabled = true;
 //    }
 //}
 public void setOwner(GameObject pOwner)
 {
     gameObject.name = "NS";
     transform.parent = pOwner.transform;
     transform.localPosition = Vector3.zero;
     owner = pOwner;
     hero = owner.GetComponentInChildren<Hero>();
     character = hero.getCharacter();
     actionCommandControl = owner.GetComponentInChildren<ActionCommandControl>();
     life = owner.GetComponent<Life>();
     soldierModelSmoothMove = owner.GetComponent<SoldierModelSmoothMove>();
 }
 private void ToggleInteractableObject(GameObject interactable, bool toggle)
 {
     if (interactable.transform.parent.GetComponent<Chest>()) {
         interactable.transform.parent.GetComponent<Chest>().enabled = toggle;
     }
     if (interactable.GetComponent<InteractableObject>()) {
         interactable.GetComponent<InteractableObject>().enabled = toggle;
     }
     else if (interactable.GetComponentInChildren<InteractableObject>()) {
         interactable.GetComponentInChildren<InteractableObject>().enabled = toggle;
     }
 }
 public void Spawn(int bonusId, Color color)
 {
     Vector3 position = new Vector3 (
         Random.Range (-playbox.transform.localScale.x / 2, playbox.transform.localScale.x / 2),
         playbox.transform.localScale.y / 2 + transform.localScale.y * 2,
         0);
     capsule = Instantiate (capsulePrefab, position, Quaternion.identity) as GameObject;
     capsule.GetComponentInChildren<MeshRenderer> ().material.color = color;
     capsule.GetComponentInChildren<CapsuleController> ().bonusId = bonusId;
     capsule.transform.GetChild (1).GetComponent<MeshRenderer> ().material.color = color;
     capsule.transform.parent = transform;
 }
    void initHealthBar()
    {
        healthPanel = Instantiate(healthPrefab);
        healthPanel.transform.SetParent(canvas.transform, false);
        healthPanel.name = this.name;

        healthPanel.GetComponentInChildren<Text>().text = enemy.name;

        healthBar = healthPanel.GetComponentInChildren<Image>();
        healthBar.name = this.name;

        damagePopup = healthPanel.gameObject.GetComponentsInChildren<Text>(true)[1];
    }
Example #26
0
    public void Content(GameObject btn)
    {
        string crdCode = btn.GetComponentInChildren<Text> ().text;

        if (crdCode[0] == 'C') {
            float r = returnToColor(crdCode.Substring(1,2));
            float g = returnToColor(crdCode.Substring(3,2));
            float b = returnToColor(crdCode.Substring(5,2));

            if((int)btn.transform.localEulerAngles.y >= 90){
                //Mostrar
                btn.GetComponent<Image>().color = new Color(r,g,b,1);
                btn.GetComponent<Image>().sprite = ctnImg;

                //Mostrar Color Carta no InputField
                input.GetComponent<Image>().color = new Color(r,g,b,1);
            }

            if((int)btn.transform.localEulerAngles.y >= 270){
                //Nao Mostrar
                btn.GetComponent<Image>().color = new Color(1,1,1,1);
                btn.GetComponent<Image>().sprite = cardImg;

                //Nao Mostrar Color Carta no InputField
                input.GetComponent<Image>().color = new Color(0,0,0,1);
            }

        } else if (crdCode[0] == '#') {
            if((int)btn.transform.localEulerAngles.y >= 90){
                //Mostrar
                btn.GetComponentInChildren<Text>().enabled = true;
                btn.GetComponent<Button>().enabled = false;
                btn.GetComponent<Image>().sprite = ctnImg;
                btn.GetComponent<Image>().color = new Color(0,0,0,1);

                //Mostrar Hex Carta no InputField
                input.GetComponentInChildren<Text>().text = crdCode;
            }

            if((int)btn.transform.localEulerAngles.y >= 270){
                //Nao Mostrar
                btn.GetComponentInChildren<Text>().enabled = false;
                btn.GetComponent<Button>().enabled = true;
                btn.GetComponent<Image>().sprite = cardImg;
                btn.GetComponent<Image>().color = new Color(1,1,1,1);

                //Nao Mostrar Hex Carta no InputField
                input.GetComponentInChildren<Text>().text = "";
            }
        }
    }
 //Includes ADS code.
 public void FireThisWeapon(Camera camera, GameObject currentWep)
 {
     if (Input.GetMouseButton(1) && !isReloading)
     {
         if (currentWep.GetComponent<GunMovement>().isFiring && currentWep.GetComponentInChildren<GunMechanics>().CurrentRate >= currentWep.GetComponentInChildren<GunMechanics>().RateOfFire && !isReloading)
         {
             currentWep.GetComponent<GunMovement>().Recoil();
             currentWep.GetComponentInChildren<GunMechanics>().ShootBullet();
         }
         else
         {
             if (!isReloading)
             {
                 currentWep.GetComponent<GunMovement>().ADS();
             }
             currentWep.GetComponentInChildren<GunMechanics>().CurrentRate += 1f * Time.deltaTime;
             currentWep.GetComponentInChildren<GunMechanics>().Muzzle.GetComponent<SpriteRenderer>().enabled = false;
             currentWep.GetComponentInChildren<GunMechanics>().AimDownSights(camera);
         }
     }
     else if (currentWep.GetComponent<GunMovement>().isFiring && currentWep.GetComponentInChildren<GunMechanics>().CurrentRate >= currentWep.GetComponentInChildren<GunMechanics>().RateOfFire && !isReloading)
     {
         currentWep.GetComponent<GunMovement>().Recoil();
         currentWep.GetComponentInChildren<GunMechanics>().ShootBullet();
     }
     else
     {
         currentWep.GetComponentInChildren<GunMechanics>().CurrentRate += 1f * Time.deltaTime;
         currentWep.GetComponentInChildren<GunMechanics>().Muzzle.GetComponent<SpriteRenderer>().enabled = false;
         currentWep.GetComponent<GunMovement>().Still();
         currentWep.GetComponentInChildren<GunMechanics>().ReturnFromSights(camera);
     }
 }
Example #28
0
 void Awake()
 {
     player = GameObject.FindGameObjectWithTag(Tags.player);
     if(player != null)
     {
         playerViewport = player.GetComponentInChildren<Camera>();
         viewportBlur = player.GetComponentInChildren<Blur>();
         playerInput = player.GetComponent<Player_Input>();
     }
     contextMessage.text = "";
     
     if (SceneManager.GetActiveScene().buildIndex == 2)
         levelController = GameObject.FindGameObjectWithTag(Tags.levelController).GetComponent<MainLevelController>();
 }
Example #29
0
    public override void OnHit( GameObject other )
    {
        if ( inmuneTimer > 0 )
            return;

        if ( state == State.DYING )
            return;

        hearts--;

        if ( other.GetComponentInChildren<Pottery>() != null )
            hearts -= 2;

        hitFeedbackTimer = 0.2f;
        //inmuneTimer = 0.3f;

        Player p = other.GetComponentInChildren<Player>();

        if ( p != null )//&& playerKnockbackHitFactor > 0 )
        {
            p.velocity *= -playerKnockbackHitFactor;
            p.frictionCoef = 0.999f;
            velocity = p.direction * 0.03f;
        }

        if ( hearts <= 0 )
        {
            gravity.y = -0.05f;
            Die();
            state = State.DYING;
            animator.PlayAnim( "Death" );
            collisionEnabled = false;
        }
        else
        {

            animator.renderer.material.SetColor ( "_AddColor", Color.black );
            jumpAttacking = false;
            state = State.WALKING;
        }

        gravityEnabled = true;

        if ( SFXDeath.Length > 0 )
        {
            AudioSource sfxdeath = SFXDeath[ Random.Range(0, SFXDeath.Length) ];
            sfxdeath.pitch = Random.Range (0.9f, 1.1f);
            sfxdeath.Play();
        }
    }
Example #30
0
	// Use this for initialization
	void Start () 
	{	
		// Instantiate tile for hover
		hoverTile = (GameObject) Instantiate(hoverTile);
		hoverTile.GetComponentInChildren<MeshRenderer>().enabled = false;
		
		// Create a mesh renderer component
		hoverTileRenderer = hoverTile.GetComponentInChildren<MeshRenderer>();
		
		// Initialize other variables
		selectedRoomType = RoomType.None;
		selectedCell = new Vector2(-1,-1);
		rooms = new List<Room>();
	}