/// <summary> /// only call from local player /// </summary> /// <param name="collision"></param> public void OnTriggerEnter2D(Collider2D collision) { if (collision.CompareTag("Bullet")) { HitParam hit = collision.GetComponent <Bullet>().hitParam; Rigidbody2D body = rb2d; if (!isLocalPlayer) { body = GetComponent <MySyncPosition>().puppet.GetComponent <Rigidbody2D>(); } if (hit.direction == "right") { body.AddForce(new Vector2(hit.forceBack * 5, 0)); } else { body.AddForce(new Vector2(-hit.forceBack * 5, 0)); } currentStat.hp -= hit.dame; if (currentStat.hp < 0) { playerCommand.Die(); } } }
private void Update() { if (isAttacking && Time.time > nextAttack) { nextAttack = Time.time + weaponStat.attackCountDown; HitParam hit = GetHitParam(); GameObject bullet = GameSystem.LoadPool(weaponStat.bulletName, hit.startPos); bullet.GetComponent <Bullet>().hitParam = hit; bullet.GetComponent <TrailRenderer>().Clear(); float scale = bullet.transform.localScale.x; if (hit.direction == "right") { hit.owner.GetComponent <Rigidbody2D>().AddForce(new Vector2(-weaponStat.forceBack, 0)); bullet.transform.localScale = new Vector3(scale, scale); } else if (hit.direction == "left") { hit.owner.GetComponent <Rigidbody2D>().AddForce(new Vector2(weaponStat.forceBack, 0)); bullet.transform.localScale = new Vector3(-scale, scale); } } }
public void ApplyDame(GameObject target) { HitParam hit = new HitParam(); hit.dame = current.dame; hit.owner = gameObject; hit.ownerTag = gameObject.tag; target.SendMessage("GetHit", hit, SendMessageOptions.DontRequireReceiver); }
public HitParam GetHitParam() { HitParam hit = new HitParam(); hit.dame = 20f; hit.direction = player.direction; hit.owner = player.gameObject; hit.ownerTag = player.tag; hit.targetTags = new List <string>() { "Monster" }; return(hit); }
private void CheckStackList() { if (stackList.Count > 0) { if (base.fromObject == null) { stackList.Clear(); } else { List <HitResult> range = stackList.GetRange(0, stackList.Count); stackList.Clear(); if (base.colliderInterface != null) { base.colliderInterface.SortHitStackList(range); } int i = 0; for (int count = range.Count; i < count; i++) { HitResult hitResult = range[i]; HitParam hitParam = hitResult.target.SelectHitCollider(this, hitResult.hitParams); if (base.colliderInterface == null || base.colliderInterface.CheckHitAttack(attackHitInfo, hitParam.toCollider, hitResult.target)) { if (base.fromObject.CheckHitAttack(attackHitInfo, hitParam.toCollider, hitResult.target)) { base.fromObject.OnHitAttack(attackHitInfo, hitParam); if (base.colliderInterface != null) { base.colliderInterface.OnHitAttack(attackHitInfo, hitParam); if (!base.colliderInterface.IsEnable()) { break; } } } else { Self self = base.fromObject as Self; if (self != null) { self.CancelHit(); } } } } } } }
public void Died(HitParam hitParam) { died = true; executor.enabled = false; gameObject.layer = LayerMask.NameToLayer("OnlyCollisionGround"); GetComponent <MovementExecutor>().enabled = false; GetComponent <Rigidbody2D>().velocity = Vector3.zero; GetComponent <FramesAnimator>().spritesheet = stat.die; if (hitParam.direction == "left") { GetComponent <Rigidbody2D>().AddForce(new Vector2(-700f, 700f)); } else if (hitParam.direction == "right") { GetComponent <Rigidbody2D>().AddForce(new Vector2(700f, 700f)); } Invoke("Disappear", 2f); }
public void SpawnBullet(HitParam hit) { MyDebug.Log("Calling Spawn Bullet"); GameObject bullet = GameSystem.LoadPool(weaponStat.bulletName, hit.startPos); bullet.GetComponent <Bullet>().hitParam = hit; bullet.GetComponent <TrailRenderer>().Clear(); float scale = bullet.transform.localScale.x; if (hit.direction == "right") { hit.owner.GetComponent <Rigidbody2D>().AddForce(new Vector2(-weaponStat.forceBack, 0)); bullet.transform.localScale = new Vector3(scale, scale); } else if (hit.direction == "left") { hit.owner.GetComponent <Rigidbody2D>().AddForce(new Vector2(weaponStat.forceBack, 0)); bullet.transform.localScale = new Vector3(-scale, scale); } }
public virtual void GetHit(HitParam hit) { getHit = true; Debug.Log(current); Debug.Log(current.hp); float dameTake = CalculateDame(hit); GameObject flyingtext = GameSystem.LoadPool("textdame", textName.transform.position); flyingtext.GetComponent <TextMeshPro>().text = Convert.ToInt32(dameTake).ToString(); current.hp -= dameTake; if (current.hp <= 0) { Died(hit); return; } else { StartCoroutine(PauseMovement(0.1f)); } }
public float CalculateDame(HitParam hit) { return(hit.dame); }
private void HitProc(Collider to_collider) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) if ((base.colliderInterface == null || base.colliderInterface.IsEnable()) && !(base.fromCollider == null) && !(base.fromObject == null) && base.fromCollider.get_enabled() && !to_collider.get_isTrigger() && !(to_collider.get_gameObject() == base.fromCollider.get_gameObject())) { StageObject to_object = to_collider.get_gameObject().GetComponentInParent <StageObject>(); if (!(to_object == null) && !(to_object == base.fromObject) && to_object.ignoreHitAttackColliders.IndexOf(to_collider) < 0 && (base.colliderInterface == null || base.colliderInterface.CheckHitAttack(attackHitInfo, to_collider, to_object)) && base.fromObject.CheckHitAttack(attackHitInfo, to_collider, to_object)) { Vector3 crossCheckPoint = base.colliderInterface.GetCrossCheckPoint(base.fromCollider); Vector3 val = Utility.ClosestPointOnCollider(to_collider, crossCheckPoint); Vector3 val2 = val - crossCheckPoint; if (val2 == Vector3.get_zero()) { Bounds bounds = to_collider.get_bounds(); val2 = bounds.get_center() - crossCheckPoint; } Quaternion rot = Quaternion.LookRotation(val2); HitResult hitResult = null; stackList.ForEach(delegate(HitResult o) { if (o.target == to_object) { hitResult = o; } }); if (hitResult == null) { hitResult = new HitResult(); hitResult.target = to_object; stackList.Add(hitResult); } float time = 0f; if (base.colliderInterface != null) { time = base.colliderInterface.GetTime(); } HitParam hitParam = new HitParam(); hitParam.processor = this; hitParam.fromObject = base.fromObject; hitParam.toObject = to_object; hitParam.fromCollider = base.fromCollider; hitParam.toCollider = to_collider; hitParam.point = val; if (m_damageDistanceData != null) { Vector3 val3 = crossCheckPoint; BulletObject bulletObject = base.colliderInterface as BulletObject; if (bulletObject != null) { val3 = bulletObject.startColliderPos; } Vector3 val4 = Utility.ClosestPointOnColliderFix(to_collider, val3); if (val3 == val4) { hitParam.distanceXZ = 0f; } else { Vector2 val5 = val4.ToVector2XZ(); Vector2 val6 = base.fromObject._position.ToVector2XZ(); hitParam.distanceXZ = Vector2.Distance(val5, val6); } } hitParam.exHitPos = base.fromCollider.get_gameObject().get_transform().get_position(); hitParam.rot = rot; hitParam.time = time; hitParam.targetPointList = base.targetPointList; hitParam.crossCheckPoint = crossCheckPoint; hitParam.attackMode = m_attackMode; hitParam.damageDistanceData = m_damageDistanceData; hitResult.hitParams.Add(hitParam); Self self = base.fromObject as Self; if (self != null && !isAlreadyCheckedTask) { BattleCheckerBase.JudgementParam judgementParam = BattleCheckerBase.JudgementParam.Create(base.attackInfo, self); self.taskChecker.OnAttackHit(base.attackInfo.name, judgementParam, 0); isAlreadyCheckedTask = true; } if (base.fromObject is Player && MonoBehaviourSingleton <InGameManager> .IsValid() && !isAlreadyCheckedDeliveryBattleInfo) { MonoBehaviourSingleton <InGameManager> .I.deliveryBattleChecker.AddTotalAttackCount(1); isAlreadyCheckedDeliveryBattleInfo = true; } } } }
public void Attack(HitParam hit) { CmdAttack(hit); }
public void RpcAttack(HitParam hit) { MyDebug.Log("Calling RPC Attack"); SpawnBullet(hit); }
public void CmdAttack(HitParam hit) { MyDebug.Log("Calling CMD Attack"); SpawnBullet(hit); RpcAttack(hit); }