protected new Vector2 GetDirectionToTargetForMovement() { Vector2 direction = base.GetDirectionToTargetForMovement(); WatchmanController wc = playerController as WatchmanController; if (wc != null && wc.lantern != null && !wc.holdingLantern) { if (IsNewTargetCloser(wc.lantern.gameObject, ref direction, ignoreLightLayerMask, lanternDistanceOffset)) { targetIsPlayer = false; direction.Normalize(); direction += GetDirectionAwayFromObstacles(direction) * weightDirectionAwayFromObstacles; } } //Debug.Log(direction + " + " + GetDirectionAwayFromObstacles(direction) + " = "+(direction + GetDirectionAwayFromObstacles(direction))); return(direction); }
protected override void Update() { if (playerController == null) { return; } WatchmanController wc = playerController as WatchmanController; if (wc == null) { return; } finalDirection = GetDirectionToTargetForMovement(); if (canSeeTarget && targetIsPlayer) { if (distanceToTargetSquared <= wc.hitRange && wc.primaryCooldown.done) { wc.AIUsePrimary(); } else if (distanceToTargetSquared < wc.lanternInitialSpeed * wc.lanternInitialSpeed && wc.holdingLantern && wc.secondaryCooldown.done) { wc.AIUseSecondary(); } } if (!wc.holdingLantern && targetIsPlayer && wc.secondaryCooldown.done) { wc.AIUseSecondary(); } if (finalDirection.sqrMagnitude > 0.01f) { wc.AIMove(finalDirection); } }