コード例 #1
0
ファイル: PressurePoint.cs プロジェクト: LonelyElf/Devout
    //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);
    }
コード例 #2
0
 // Use this for initializationv
 protected override void Start()
 {
     base.Start();
     //continuesly update and search for target
     InvokeRepeating("updateTarget", 0.5f, 1.0f);
     _osh = GetComponent <ObjectStatusHandler> ();
     _ch  = GetComponent <CombatHandler> ();
 }
コード例 #3
0
    //replacing

    /// <summary>
    /// Disables the target's damaging points
    /// Used when target is hit, so that hit target doesn't hurt attackers accidentally
    /// </summary>
    /// <param name="ch">CombatHandler of the target</param>
    //	protected void disableDamagingPoints (CombatHandler targetCH)
    //	{
    //		foreach (var abil in targetCH.GetAbilities()) {
    //			abil.GetWeapon ().DisableDamagingPoints ();
    //			foreach (var dp in abil.GetWeapon().GetDamagingPoints()) {
    //				dp.SetIsActive (false);
    //			}
    //		}
    //	}

    /// <summary>
    /// Pushes the target backwards
    /// </summary>
    /// <param name="osh">Target's ObjectStatusHandler</param>
    /// <param name="duration">Duration of push</param>
    void pushBack(ObjectStatusHandler osh, float duration)
    {
        Vector3 relativeDirection = CombatHelper.getRelativeDirection(_weapon.GetOwner().transform.position, osh.transform.position, PUSHBACK_DIRECTION.OUTWARD);

//		print (relativeDirection.ToString ());
        //
        Debug.DrawLine(_weapon.GetOwner().transform.position, _weapon.GetOwner().transform.position + relativeDirection, Color.yellow);
        osh.PushBurst(relativeDirection * _weapon.GetPushbackForce(), duration);
    }
コード例 #4
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);
            }
        }
    }
コード例 #5
0
    void updatePlayerList()
    {
//		_playerList.Clear ();
        foreach (var go in GameObject.FindGameObjectsWithTag(TagHelper.PLAYER))
        {
            ObjectStatusHandler osh = go.GetComponent <ObjectStatusHandler> ();
//			if (osh.Alive ())
//				_playerList.Add (go.GetComponent<CharacterStatusHandler>());
        }
    }
コード例 #6
0
    protected override void OnCollisionEnter(Collision collision)
    {
        if (_isActive)
        {
            //When hitting hitbox
            if (collision.collider.GetComponent <Hitbox> () != null)
            {
                Hitbox hb = collision.collider.GetComponent <Hitbox> ();
                foreach (var l in _damagableLayers)
                {
                    if (collision.gameObject.layer == l)
                    {
                        //When hitting blocking point
                        if (hb is BlockingPoint)
                        {
//							//disable this character's damaging points
////							disableDamagingPoints(_weapon.GetOwner());
//							_weapon.GetOwner().DisableDamagingPoints();
//
//							//stagger this character
//							//Note : need a way to stagger player characters as it's controlled by minion's animator for now
//							CharacterStatusHandler csh = _weapon.GetOwner().GetComponent<CharacterStatusHandler>();
//
//							//delay blocked staggering for fine-tuning
                            float staggerDelay = 0.2f;
//							if (csh != null)
//								csh.Stagger (((BlockingPoint)hb).GetStaggerDuration (), staggerDelay);

                            if (IsMine)
                            {
                                //instantiate particles
                                //need to change to different particle to differentiate blocking vs damaging
                                ParticleController.PC.InstantiateParticle(ParticleController.PARTICLE_TYPE.HIT, collision.contacts [0].point, staggerDelay);

                                //play sound
                                SoundManager.SINGLETON.PlayHitSound(Weapon.TYPE.SWORD, SoundManager.HitResult.Blocked, collision.contacts [0].point);
                            }
                        }                        //if not a blocking point, then it means a hitpoint, deal damage
                        else
                        {
                            ObjectStatusHandler osh = collision.collider.GetComponent <Hitbox> ().GetOSH();
                            if (!_OSHList.Contains(osh))
                            {
                                if (IsMine)
                                {
                                    dealDamange(osh);
                                    hitEffect(collision.contacts [0].point);
                                    _OSHList.Add(osh);
                                }
                            }
                            else if (!_isOneTimeDamage)
                            {
                                if (IsMine)
                                {
                                    dealDamange(osh);
                                    hitEffect(collision.contacts [0].point);
                                }
                            }

                            //play sound
                            SoundManager.SINGLETON.PlayHitSound(Weapon.TYPE.SWORD, SoundManager.HitResult.Hit, collision.contacts [0].point);
                        }
                        stick(collision);
                        return;
                    }
                }
            }

            //when hit default layer, this may need to change when structures and stuff are in different layer
//			if (collision.gameObject.layer == LayerHelper.DEFAULT && !collision.gameObject.CompareTag (TagHelper.RAGDOLL)) {
            if (collision.gameObject.layer == LayerHelper.WALL || collision.gameObject.layer == LayerHelper.FLOOR || collision.gameObject.layer == LayerHelper.NEAUTRAL)
            {
//				print ("hit " + collision.collider.name);
                stick(collision);
                ParticleController.PC.InstantiateParticle(ParticleController.PARTICLE_TYPE.HIT, collision.contacts [0].point);
            }
//			else
//				print (collision.gameObject.ToString ());
        }
    }
コード例 #7
0
    /// <summary>
    /// Raises the collision enter event.
    /// </summary>
    /// <param name="collision">Collision.</param>
    protected virtual void OnCollisionEnter(Collision collision)
    {
//		print ("hit : " + collision.collider.name);
        if (_isActive)
        {
            //When hitting hitbox
            if (collision.collider.GetComponent <Hitbox> () != null)
            {
                Hitbox hb = collision.collider.GetComponent <Hitbox> ();
                foreach (var l in _damagableLayers)
                {
//					print ("hit : " + collision.collider.name);
                    if (collision.gameObject.layer == l)
                    {
                        print(l.ToString() + ", " + LayerHelper.HITBOX_TEAM_5.ToString());
                        //When hitting blocking point
                        if (hb is BlockingPoint)
                        {
//
//							//disable this character's damaging points
//							_weapon.GetOwner ().DisableDamagingPoints ();
////							_collider.enabled = false;
////							Debug.Break ();
//							//stagger this character
//							//Note : need a way to stagger player characters as it's controlled by minion's animator for now
//							CharacterStatusHandler csh = _weapon.GetOwner ().GetComponent<CharacterStatusHandler> ();
//
//							//delay blocked staggering for fine-tuning
//							float staggerDelay = 0.1f;
//							if (csh != null)
//								csh.Stagger (((BlockingPoint)hb).GetStaggerDuration (), staggerDelay);
//							//instantiate particles
//							//need to change to different particle to differentiate blocking vs damaging
//							ParticleController.PC.InstantiateParticle (ParticleController.PARTICLE_TYPE.HIT, collision.contacts [0].point, staggerDelay);
//							//play sound
//							SoundManager.SINGLETON.PlayHitSound (_weapon.Type, SoundManager.HitResult.Blocked, collision.contacts [0].point);
////							Debug.Break ();
                        }                        //if not a blocking point, then it means a hitpoint, deal damage
                        else
                        {
                            ObjectStatusHandler osh = collision.collider.GetComponent <Hitbox> ().GetOSH();
                            if (!_OSHList.Contains(osh))
                            {
                                dealDamange(osh);
                                hitEffect(collision.contacts [0].point);
                                ParticleController.PC.InstantiateParticle(ParticleController.PARTICLE_TYPE.HIT, collision.contacts [0].point);
                                _OSHList.Add(osh);
                            }
                            else if (!_isOneTimeDamage)
                            {
                                dealDamange(osh);
                                hitEffect(collision.contacts [0].point);
                                ParticleController.PC.InstantiateParticle(ParticleController.PARTICLE_TYPE.HIT, collision.contacts [0].point);
                            }
                            //play sound
                            SoundManager.SINGLETON.PlayHitSound(_weapon.Type, SoundManager.HitResult.Hit, collision.contacts [0].point);
                        }
                    }
                }
            }
        }
    }
コード例 #8
0
    protected virtual void OnTriggerEnter(Collider collider)
    {
        if (_isActive)
        {
//			print (collider.name);
            //When hitting hitbox
            if (collider.GetComponent <Hitbox> () != null)
            {
                Hitbox hb = collider.GetComponent <Hitbox> ();
                foreach (var l in _damagableLayers)
                {
//					print (l.ToString () + ", " + LayerHelper.HITBOX_TEAM_5.ToString () + ", " + collider.name);
                    if (collider.gameObject.layer == l)
                    {
                        ObjectStatusHandler osh = collider.GetComponent <Hitbox> ().GetOSH();
                        //When hitting blocking point
                        if (hb is BlockingPoint)
                        {
//							print ("BLOCK");
                            //disable this character's damaging points
                            _weapon.GetOwner().DisableDamagingPoints();
                            //							_collider.enabled = false;
                            //							Debug.Break ();
                            //stagger this character
                            //Note : need a way to stagger player characters as it's controlled by minion's animator for now
                            CharacterStatusHandler csh = _weapon.GetOwner().GetComponent <CharacterStatusHandler> ();

                            //delay blocked staggering for fine-tuning
                            float staggerDelay = 0.1f;
                            if (csh != null)
                            {
                                csh.Stagger(((BlockingPoint)hb).GetStaggerDuration(), staggerDelay);
                            }
                            //instantiate particles
                            //need to change to different particle to differentiate blocking vs damaging
                            ParticleController.PC.InstantiateParticle(ParticleController.PARTICLE_TYPE.HIT, collider.transform.position, staggerDelay);
                            //play sound
                            SoundManager.SINGLETON.PlayHitSound(_weapon.Type, SoundManager.HitResult.Blocked, collider.transform.position);
                            //							Debug.Break ();
                        }
                        else if (osh)
                        {
                            if (osh is BridgeStatusHandler && RoomLevelHelper.PLAYER_CLASS != CHARACTER_CLASS.TANK)
                            {
                                return;
                            }
//							print ("hit : " + osh.name);
                            if (!_OSHList.Contains(osh))
                            {
                                dealDamange(osh);
                                hitEffect(collider.transform.position);
                                ParticleController.PC.InstantiateParticle(ParticleController.PARTICLE_TYPE.HIT, collider.transform.position);
                                _OSHList.Add(osh);
                            }
                            else if (!_isOneTimeDamage)
                            {
                                dealDamange(osh);
                                hitEffect(collider.transform.position);
                                ParticleController.PC.InstantiateParticle(ParticleController.PARTICLE_TYPE.HIT, collider.transform.position);
                            }
                        }
                        else
                        {
                            print(collider.name);
                        }
                        //play sound
                        SoundManager.SINGLETON.PlayHitSound(_weapon.Type, SoundManager.HitResult.Hit, collider.transform.position);
                    }
                }
            }
        }
    }
コード例 #9
0
ファイル: Hitbox.cs プロジェクト: LonelyElf/Devout
 /// <summary>
 /// Set ObjectStatusHandler
 /// </summary>
 /// <param name="osh">Osh.</param>
 public void SetOSH(ObjectStatusHandler osh)
 {
     _osh = osh;
 }