Esempio n. 1
0
    void OnCollisionEnter(Collision coll)
    {
        GameObject otherGO = coll.gameObject;

        //Volliding with a wall can also stop walking
        Tile ti = otherGO.GetComponent <Tile>();

        if (ti != null)
        {
            if (ti.height > 0)              //IF ti.height is >0
            //The this ti is a wall, and mage should stop
            {
                StopWalking();
            }
        }
        // See if it's an EnemyBug
        EnemyBug bug = coll.gameObject.GetComponent <EnemyBug>();

        // If otherGO is an EnemyBug, pass bug to CollisionDamage(), which will
        // interpret it as an Enemy
        if (bug != null)
        {
            CollisionDamage(bug);
        }

        // If otherGO is an EnemyBug, pass otherGO to CollisionDamage()
        //if (bug != null) CollisionDamage(otherGO);
    }
Esempio n. 2
0
    private void OnCollisionEnter(Collision collision)
    {
        GameObject otherGO = collision.gameObject;

        // Стык со стенами также останавливает движение
        Tile ti = otherGO.GetComponent <Tile>();

        if (ti != null)
        {
            if (ti.height > 0)
            {
                // Значит это стена и маг должен остановится
                StopWalking();
            }
        }

        // Чекаем врага
        EnemyBug bug = collision.gameObject.GetComponent <EnemyBug>();

        // Если рил павук, зовём помощь
        // Если это паук, передаём его, чтобы он обрабатывался как враг
        if (bug != null)
        {
            CollisionDamage(bug);
        }
        //if (bug != null) CollisionDamage(otherGO);
    }
Esempio n. 3
0
    //EnemyBug的碰撞伤害
    private void OnCollisionEnter(Collision coll)
    {
        GameObject otherGo = coll.gameObject;

        Tile ti = otherGo.GetComponent <Tile>();

        if (ti != null)
        {
            //height>0说明为墙壁,无法穿过
            if (ti.height > 0)
            {
                //Debug.Log("墙壁,无法穿过");
                StopWalking();
            }
        }

        //判断是否为EnemyBug
        EnemyBug bug = coll.gameObject.GetComponent <EnemyBug>();

        //如果otherGO为EnemyBug,则将bug传递给CollisionDamage()
        //if (bug != null)
        //    CollisionDamage(otherGo);

        //如果otherGO为EnemyBug,则将bug传递给CollisionDamage()
        //该方法将bug解释为Enemy:
        if (bug != null)
        {
            CollisionDamage(bug);
        }
    }
Esempio n. 4
0
    void OnTriggerStay(Collider other)
    {
        EnemyBug recipient = other.GetComponent <EnemyBug>();

        if (recipient != null)
        {
            recipient.Damage(damagePerSecond, ElementType.air, true);
        }
    }
Esempio n. 5
0
    private void OnTriggerStay(Collider other)
    {
        EnemyBug recepient = other.GetComponent <EnemyBug>();

        if (recepient)
        {
            recepient.Damage(damagePerSecond, ElementType.fire, true);
        }
    }
Esempio n. 6
0
    void OnTriggerStay(Collider other)
    {
        EnemyBug recipient = other.GetComponent <EnemyBug> ();

        //If there is an enemyBug component, dmage it with fire
        if (recipient != null)
        {
            recipient.Damage(damagePerSecond, ElementType.fire, true);
        }
    }
Esempio n. 7
0
    private void OnTriggerStay(Collider other)
    {
        //获取EnemyBug脚本其他组件的引用
        EnemyBug recipient = other.GetComponent <EnemyBug>();

        //如果有EnemyBug组件,使用火法术消灭它
        if (recipient != null)
        {
            recipient.Damage(damagePreSecond, ElementType.fire, true);
        }
    }
    //Actually damage the other object
    void OnTriggerStay(Collider other)
    {
        //Get a reference to the EnemyBug script component of the other
        EnemyBug recipient = other.GetComponent <EnemyBug>();

        //If there is an EnemyBug component, damage it with fire
        if (recipient != null)
        {
            recipient.Damage(damagePerSecond, ElementType.fire, true);
        }
    }
Esempio n. 9
0
    private void OnTriggerStay(Collider other)
    {
        // Дамажим
        EnemyBug recipient = other.GetComponent <EnemyBug>();

        // Если есть такой скрипт, наносим урон
        if (recipient != null)
        {
            recipient.Damage(damagePerSecond, ElementType.fire, true);
        }
    }
Esempio n. 10
0
    void OnTriggerExit(Collider other)
    {
        // Actually damage the other
        // Get a reference to the EnemyBug script component of the other
        EnemyBug recipient = other.GetComponent <EnemyBug>();

        // If there is an EnemyBug component, dmage it with fire
        if (recipient != null)
        {
            recipient.speed = recipient.saveSpeed;
        }
    }
Esempio n. 11
0
    void OnTriggerStay(Collider other)
    {
        //Actually damage the other
        //Get a refrence to the EnemyBug script component of the other
        EnemyBug recipient = other.GetComponent <EnemyBug> ();

        //If there is an enemyBug component, dmage it with earth
        if (recipient != null)
        {
            recipient.Damage(damagePerSecond, ElementType.earth, true);
        }
    }
Esempio n. 12
0
	}//end of FixedUpdate()

	void OnCollisionEnter(Collision coll){
		GameObject otherGO = coll.gameObject;
		Tile ti = otherGO.GetComponent<Tile>();

		if (ti != null){
			if (ti.height > 0) StopWalking();
			
		}//end of if
			
		EnemyBug bug = coll.gameObject.GetComponent<EnemyBug>();

		if (bug != null) CollisionDamage(bug);
	}//end of OnCollisionEnter(Collision coll)
Esempio n. 13
0
    private void OnTriggerEnter(Collider other)
    {
        //GameObject go = Utils.FindTaggedParent(other.gameObject);

        //if (go == null)
        //    go = other.gameObject;

        //Utils.tr("Flame hit", go.name);

        //获取EnemyBug脚本其他组件的引用
        EnemyBug recipient_bug = other.GetComponent <EnemyBug>();

        //如果有EnemyBug组件,使用水魔法会恢复其生命值
        if (recipient_bug != null)
        {
            //recipient.Damage(damagePreSecond, ElementType.water, true);
            recipient_bug.Recover();
        }
    }
Esempio n. 14
0
    private void OnCollisionEnter(Collision collision)
    {
        GameObject otherGo = collision.gameObject;

        //Collision with wall can also stop walking
        Tile ti = otherGo.GetComponent <Tile>();

        if (ti)
        {
            if (ti.height > 0)
            {
                //Then this ti is a wall and Mage should stop
                StopWalking();
            }
        }

        EnemyBug bug = collision.gameObject.GetComponent <EnemyBug>();

        //if otherGO is an EnemyBug, pass otherGO to collisionDamage()
        if (bug)
        {
            CollisionDamage(bug);
        }
    }
    // Update is called once per frame
    void Update()
    {
        ScoreInfo scoreInfo = EnemyBug.EvaluateScore();

        text.text = initialText + scoreInfo.score + "/" + scoreInfo.maxScore;
    }