本文整理汇总了C#中WorldObject.damage方法的典型用法代码示例。如果您正苦于以下问题:C# WorldObject.damage方法的具体用法?C# WorldObject.damage怎么用?C# WorldObject.damage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorldObject
的用法示例。
在下文中一共展示了WorldObject.damage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
void Update()
{
if (monster.input.jumpPressed && !inAir) {
startJumpTime = Time.time;
startJump = true;
lr.enabled = true;
lr.SetColors(jumpTrailColorStart, jumpTrailColorEnd);
}
if (startJump) {
var deltaTime = Mathf.Clamp(Time.time - startJumpTime, 0f, monster.maxJumpTime);
jumpForce = deltaTime * monster.maxJumpForce / monster.maxJumpTime;
var targetBloodTake = (monster.move.jumpForce / monster.maxJumpForce) * monster.maxBloodPerJump;
monster.bloodTaken = monster.bloodManager.reserveBlood(targetBloodTake);
}
//
if (checkGround()) {
if (inAir) {
velocity = Vector3.zero;
inAir = false;
monster.sounder.playSound(monster.landingSound);
transform.position = hit.point + hit.normal * monster.size.y;
var angle = Mathf.Atan2(hit.normal.y, hit.normal.x) * Mathf.Rad2Deg - 90f;
transform.rotation = Quaternion.Euler(0f, 0f, angle);
}
previousObject = null;
}
else if (checkWorldObject()) {
if (hit.collider.GetComponent<WorldObject>() != previousObject) {
velocity = Vector3.zero;
inAir = false;
monster.sounder.playSound(monster.landingSound);
transform.position = (Vector3)hit.point
+ Vector3.up * hit.normal.y * monster.size.y
+ Vector3.right * hit.normal.x * monster.size.x;
var angle = Mathf.Atan2(hit.normal.y, hit.normal.x) * Mathf.Rad2Deg - 90f;
transform.rotation = Quaternion.Euler(0f, 0f, angle);
sittingOnObject = hit.collider.GetComponent<WorldObject>();
if (!sittingOnObject.canThrow && sittingOnObject.canBlood) {
sittingOnObject.damage(monster.damageValue);
sittingOnObject = null;
}
else {
transform.SetParent(sittingOnObject.transform);
transform.localScale = Vector3.one;
}
}
}
else if (checkSkyscraper()) {
if (targetSkyscraper == null) {
if (hit.collider.GetComponent<Skyscraper>() != currentSkyscraper) {
velocity = Vector3.zero;
currentSkyscraper = hit.collider.GetComponent<Skyscraper>();
targetSkyscraper = null;
inAir = false;
monster.sounder.playSound(monster.landingSound);
var angle = Mathf.Atan2(hit.normal.y, hit.normal.x) * Mathf.Rad2Deg - 90f;
transform.rotation = Quaternion.Euler(0f, 0f, angle);
}
}
else {
var targetDistance = (transform.position - targetPoint).magnitude;
if (targetDistance < minTargetDistance) {
minTargetDistance = targetDistance;
}
else {
velocity = Vector3.zero;
currentSkyscraper = targetSkyscraper;
targetSkyscraper = null;
inAir = false;
monster.sounder.playSound(monster.landingSound);
}
}
previousObject = null;
}
if (monster.input.jumpReleased && !inAir) {
var dir = (monster.input.clickPos - transform.position).normalized;
monster.bloodManager.getBlood(monster.bloodTaken);
jumpForce = monster.bloodTaken / monster.maxBloodPerJump * monster.maxJumpForce;
velocity = dir * jumpForce;
targetPoint = monster.input.clickPos;
minTargetDistance = Mathf.Infinity;
var col = Physics2D.OverlapCircle(monster.input.clickPos, 0.1f, Game.instance.skyscraperLayer);
if (col != null) {
targetSkyscraper = col.GetComponent<Skyscraper>();
}
else
targetSkyscraper = null;
sittingOnObject = null;
transform.SetParent(null);
transform.localScale = Vector3.one;
inAir = true;
startJump = false;
lr.enabled = false;
monster.bloodTaken = 0f;
monster.sounder.playSound(monster.jumpSound);
}
//.........这里部分代码省略.........