/// <summary> /// Casts the ray and does whatever the action is. (Template Method pattern) /// </summary> /// <returns> /// The ray and do. /// </returns> /// <param name='action'> /// If set to <c>true</c> action. /// </param> public bool CastRayAndDo( OnHit action ) { RaycastHit hit; Ray cast = getRayCast(); int mask = 1 << LayerMask.NameToLayer("Catwalk"); if ( Physics.Raycast( cast, out hit, CastTestDist, mask ) ) { var blockSpawner = Projectile.GetComponent<BlockSpawner>(); if ( blockSpawner != null && hit.collider.gameObject.IsProjectile() == false ) { var worldObj = GameObject.FindGameObjectWithTag("World"); var World = worldObj.GetComponent<GenerateWorld>(); //var createAt = cast.origin + (cast.direction * (hit.distance - 0.1f)); var createAt = hit.point + (hit.normal *(0.5f)); var playerPos = getRayCast().origin; var futureIndex = World.getIndexOfPoint( ref createAt); var playerIndexTop = World.getIndexOfPoint( ref playerPos); var playerIndexBottom = new BlockIndex(playerIndexTop.x, playerIndexTop.y-1, playerIndexTop.z); //Don't create on top of ourselves: if ( (playerIndexTop != futureIndex) && (playerIndexBottom != futureIndex) ) { Vector3 currentDirection = getRayCast().direction.normalized; action(World, blockSpawner, hit, currentDirection, createAt, futureIndex); } } return true; } return false; }
private void OnTriggerEnter2D(Collider2D other) { OnHit currentNote = other.GetComponentInParent <OnHit>(); currentNote.GetKilled(); }
private void NotifyHit(int hitPoints, string objectThatHitName) { OnHit?.Invoke(hitPoints, objectThatHitName); }
public static void Hit(int damage) { OnHit?.Invoke(damage); }
public override void Register() { BeforeCast.Add(new CastHandler(ClearSpikeImmunities)); OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(CountTargets, 0, Targets.UnitDestAreaEnemy)); OnHit.Add(new HitHandler(SplitDamage)); }
public Bullet(int Damage, OnHit OnHit) { this.Damage = Damage; this.onHitMethod = OnHit; }
private void Awake() { _onHit = GetComponentInParent <OnHit>(); }
public void Init(OnHit onHit, GetParentBlock getParentBlock) { OnHitDelegate = onHit; GetParentBlockDelegate = getParentBlock; }
public void SetOnHit(OnHit on_hit) { this.on_hit = on_hit; }
public void DeregisterOnHit(OnHit effect) { on_hit_list.Remove(effect); }
public void RegisterOnHit(OnHit effect) { on_hit_list.Add(effect); }
public override void Hit(int damage, int force) { ApplyDamage(damage + (force / 2)); OnHit.Raise(this, damage, force); }
public override void Register() { OnHit.Add(new HitHandler(InitializeVisualStalker)); }
public void Init(OnHit on_hit) { this.on_hit = on_hit; }
private bool Collision(Fixture chara, Fixture obj, Contact list) { bool returnValue = false; if (model.state == CharacterState.attacking && (obj.CollisionCategories != Category.Cat20 || !((MoveModel)obj.Body.UserData).PlayerIndexes.Contains(model.playerIndex)) && currentMove.Stats.Type == MoveType.Body && (currentMove.Stats.StopAtHit || obj.CollisionCategories != Category.Cat11) && currentMove.attackTimeLeft <= currentMove.Stats.Duration - currentMove.Stats.BodyStart) { moves.EndMove(currentMove); moves.RemoveMove(currentMove); view.Rotation = 0; view.BoundBox.Rotation = 0; model.attackMode = false; if ((obj.CollisionCategories == Category.Cat9 || obj.CollisionCategories == Category.Cat10) && chara.Body.Position.Y + view.size.Y / 2 <= obj.Body.Position.Y - (float)obj.Body.UserData / 2) { model.inAir = false; if (obj.CollisionCategories == Category.Cat10) { model.onSoftBox = true; } model.jumpsLeft = 3; } NaturalState(); returnValue = true; } else if ((obj.CollisionCategories == Category.Cat9 || obj.CollisionCategories == Category.Cat10) && (chara.Body.Position.Y + view.size.Y / 2 <= obj.Body.Position.Y - (float)obj.Body.UserData / 2 && view.VelocityY >= -0.001)) { model.inAir = false; if (obj.CollisionCategories == Category.Cat10) { model.onSoftBox = true; } NaturalState(); model.jumpsLeft = 3; returnValue = true; } else if (obj.CollisionCategories == Category.Cat9) { returnValue = true; } else if (obj.CollisionCategories == Category.Cat20) { MoveModel move = (MoveModel)obj.Body.UserData; if (!move.PlayerIndexes.Contains(model.playerIndex) && !model.invounerable) { move.PlayerIndexes.Add(model.playerIndex); MoveStats stats = move.Stats; float ratio = 0; if (stats.Type == MoveType.Charge && move.chargeTime < stats.MaxWait) { ratio = move.chargeTime / stats.MaxWait; } else { ratio = 1; } Vector2 power = ratio * stats.Power; int damage = (int)ratio * stats.Damage; view.Velocity = move.Xdirection * power * (1 + model.damagePoints / 100) * (100 / model.weight); if (Math.Abs(view.VelocityY) == 0) { view.VelocityY = -1; } model.damagePoints += damage; model.setState(CharacterState.takingHit); if (OnHit != null) { OnHit.Invoke(ConvertUnits.ToDisplayUnits(obj.Body.Position), damage, model.damagePoints, move.PlayerIndexes.First(), model.playerIndex, stats.hitSound); } //if (move.Adjustable && ((AdjustableMove)move).StopAtHit) move.attackTimeLeft = 0; } } else if (obj.CollisionCategories == Category.Cat7 || obj.CollisionCategories == Category.Cat8) { OnCharacterDeath.Invoke(this, obj.CollisionCategories == Category.Cat7); } return(returnValue); }
protected void RaiseOnHit(AttackPackage attack, AttackResult result) { OnHit?.Invoke(attack, result); _onHit.Invoke(); }
public void AddEventListener(OnHit del) { _del = del; }
public void Hit(Hit type, Vector2 direction) { OnHit?.Invoke(type, direction); }
public void ClearEventListener() { _del = null; }
public void EventHit() { OnHit?.Invoke(); }
private void OnTriggerEnter2D(Collider2D collider2D) { OscarRigidbody2D.bodyType = RigidbodyType2D.Static; SoundManager.PlaySound(SoundManager.Sound.Whine); OnHit?.Invoke(this, EventArgs.Empty); }
private RayManager() { onHitDegelate += (obj, hit) => { }; }
private void Hit() { setPosition(startPosition); OnHit.Invoke(); }
public override void Register() { OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 0, Targets.UnitSrcAreaEnemy)); OnObjectAreaTargetSelect.Add(new ObjectAreaTargetSelectHandler(FilterTargets, 1, Targets.UnitSrcAreaEnemy)); OnHit.Add(new HitHandler(RecalculateDamage)); }
private void pipeHit() { OnHit.Invoke(); setPosition(startPosition); transform.position = new Vector3(transform.position.x, pipeY + 0.5f, transform.position.z); }
private void Weapon_OnHit(IWeapon arg1, Projectile arg2, Collider arg3, Vector3 arg4, Vector3 arg5) { OnHit?.Invoke(arg1, arg2, arg3, arg4, arg5); }
public void Hit() => OnHit?.Invoke();
public override void Register() { OnHit.Add(new HitHandler(RecalculateDamage)); }
// Start is called before the first frame update void Start() { gameControllerScript = GameObject.Find("Game Controller").GetComponent <disableAllClicks>(); onhitScript = onHitObj.GetComponent <OnHit>(); }
public override void Register() { OnHit.Add(new HitHandler(HandleOnHit)); }
public void GiveDamage(int ammount) { currentHealth -= ammount; OnHit?.Invoke(gameObject.GetComponent <ZombieAI>()); }