Exemple #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);
    }
Exemple #2
0
    /// <summary>
    /// Handles dealing damage to the contact object(enemy)
    /// Also handles pushback and staggering the target.
    /// </summary>
    /// <param name="osh">Target's ObjectStatusHandler</param>
    protected void dealDamange(ObjectStatusHandler osh)
    {
        //inflict damage
        osh.SubtractHealth(_weapon.GetDamage());

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

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



        //drop if hanging
        CharacterMovementHandler cmh = osh.GetComponent <CharacterMovementHandler> ();

//		HangHandler hh = cmh.HangHandler;
        if (cmh && cmh.Hanging)
        {
//			hh.HangToDrop ();
            cmh.HangToDrop();
        }
        else
        {
            //push object back
            //Duke (8/6/2016)
            //BUG : disabled because push direction changes as target rotates. make it absolute direction
            //Log :
            //Duke(8/11/2016) : Code is correct, suspect problem with pre-existing photon view enemies. Instantiating all characters may solve it. Enabled pushback to test it.
            //Duke(8/27/2016) : Problem occured again, there must be something wrong
            //					Seems to be fixed with setting position i nstead of translate
            pushBack(osh, _pushDuration);
            //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 (_pushDuration);
                csh.Stagger(_staggerDuration);
            }
        }
    }