Ejemplo n.º 1
0
    //dev
    //collider attached to the rig seems to be spinning like hell
    //Thus force-prevent spinning
//	void LateUpdate ()
//	{
//		transform.localPosition = Vector3.zero;
//		transform.localRotation = Quaternion.identity;
//		//		else
//		//			print ("osh : " + _osh.name);
//	}

    //	void OnCollisionStay (Collision collision)
    //	{
    ////		print ("Collided with " + collision.transform.name);
    //		//damagable things discovered
    ////		if (collision.transform.GetComponent<ObjectStatusHandler> () != null) {
    ////			ObjectStatusHandler osh = collision.transform.GetComponent<ObjectStatusHandler> ();
    ////			if (osh.IsWalled) {
    ////				foreach (var po in _pressingObjects) {
    ////					if (po.Timer + _damagingRate < Time.time) {
    ////						dealDamange (osh);
    ////					}
    ////				}
    ////			}
    //////			print (osh.name);
    ////			origin = osh.transform.position;
    ////			origin = new Vector3 (origin.x, transform.position.y, origin.z);
    ////			dir = osh.transform.position - collision.contacts [0].point;
    ////			dir = new Vector3 (dir.x, 0f, dir.z);
    ////			dir.Normalize ();
    ////
    ////			// Physics.SphereCast (레이저를 발사할 위치, 구의 반경, 발사 방향, 충돌 결과, 최대 거리)
    ////			LayerMask lm = (1 << LayerHelper.DEFAULT);
    ////			isHit = false;
    //////			isHit = Physics.SphereCast (origin, radius, dir, out hit, maxDistance, lm);
    ////			isHit = Physics.Raycast (origin, dir, out hit, maxDistance, lm);
    ////			if (isHit) {
    ////				print ("Hit : " + hit.collider.name);
    ////				dealDamange (osh);
    //////				Debug.Break ();
    ////				ParticleController.PC.InstantiateParticle(collision.contacts [0].point);
    ////			}
    ////		}
    //	}

    //	void OnDrawGizmos ()
    //	{
    //		if (isHit) {
    //			Gizmos.color = Color.red;
    //			Gizmos.DrawRay (origin, dir * hit.distance);
    ////			Gizmos.DrawWireSphere (origin + dir * hit.distance, radius);
    //		} else {
    //			Gizmos.DrawRay (origin, dir * maxDistance);
    //		}
    //	}
    /// <summary>
    /// Handles dealing damage to the contact object(enemy)
    /// Also handles pushback and staggering the target.
    /// dev
    /// </summary>
    /// <param name="osh">Target's ObjectStatusHandler</param>
    protected void dealDamange(ObjectStatusHandler osh)
    {
        //inflict damage
        osh.SubtractHealth(_damage);

        //disable hit target's damaging points
        if (true)
        {
            if (osh.GetComponent <CombatHandler> ())
            {
                //				disableDamagingPoints (osh.GetComponent<CombatHandler> ());
                osh.GetComponent <CombatHandler> ().DisableDamagingPoints();
            }
        }

        //add to ultimate guage
        _ch.AddUltimatePoint(_damage / 25);
        //add more if it's a killing blow
        if (osh.GetHealth() - _damage <= 0)
        {
            _ch.AddUltimatePoint(5);
        }

        //if character, stagger it
        //Note : Stagger animation will transit from AnyState for minions and certain character via animator
        //		Player characters at the moment does not have AnyState linked to Stagger, so their action will not get interrupted by getting attack
        CharacterStatusHandler csh = osh.GetComponent <CharacterStatusHandler> ();

        if (csh != null)
        {
            csh.Stagger(_damagingRate / 5f);
        }
        //		if (csh != null)
        //			((CharacterStatusHandler)osh).Stagger (_pushDuration);
    }