public void Magic() { LineOfSight lineOfSight = Player.Instance.GetLineOfSight(); switch (lineOfSight) { case LineOfSight.UP: attackDirection = new Vector2(0.0f, 1.0f); break; case LineOfSight.LEFT: attackDirection = new Vector2(-1.0f, 0.0f); break; case LineOfSight.DOWN: attackDirection = new Vector2(0.0f, -1.0f); break; case LineOfSight.RIGHT: attackDirection = new Vector2(1.0f, 0.0f); break; } RegularMagic(); }
public bool within_arc(Vector2 current_grid_location, Vector2 grid_location) { var los = new LineOfSight(current_grid_location, grid_location, map); if (los.blocked()) { return(false); } var dist = Mathf.Abs(current_grid_location.x - grid_location.x) + Mathf.Abs(current_grid_location.y - grid_location.y); if (dist > range) { return(false); } var distance = grid_location - current_grid_location; if (_direction == UP) { return(distance.y > 0 && Mathf.Abs(distance.x) <= Mathf.Abs(distance.y)); } else if (_direction == DOWN) { return(distance.y < 0 && Mathf.Abs(distance.x) <= Mathf.Abs(distance.y)); } else if (_direction == LEFT) { return(distance.x < 0 && Mathf.Abs(distance.y) <= Mathf.Abs(distance.x)); } else { return(distance.x > 0 && Mathf.Abs(distance.y) <= Mathf.Abs(distance.x)); } }
public override bool TickAction() { if (fgoRequest == null) { if (Time.time > attackFinishTimestamp) { return(false); } return(true); } else { LineOfSight sight = attackAI.gameObject.GetComponentInChildren <LineOfSight> (); if (fgoRequest.DistanceToObject() > sight.radius) { return(false); // abort since the object is too far away } if (fgoRequest.TickAction()) { return(true); } else { fgoRequest = null; StartAttack(); return(true); } } }
private void Awake() { lineOfSightVisual = GetComponent <LineOfSightVisual>(); lineofsight = GetComponent <LineOfSight>(); shooting1 = GetComponent <Shooting1>(); chaseAI = GetComponent <ChaseAI>(); }
public static void Postfix(LineOfSight __instance, ref float __result, AbstractActor source, CombatGameState ___Combat) { if (__instance != null && source != null) { __result = VisualLockHelper.GetSpotterRange(source); } }
public void RayEndPoints() { var min = Vector.Create(5, 5); var max = Vector.Create(7, 7); Func <IEnumerable <Vector>, Vector[]> prepare = vectors => vectors .OrderBy(v => v.X) .ThenBy(v => v.Y) .ToArray(); var expected = prepare( new[] { Vector.Create(5, 5), Vector.Create(5, 6), Vector.Create(5, 7), Vector.Create(7, 5), Vector.Create(7, 6), Vector.Create(7, 7), Vector.Create(6, 5), Vector.Create(6, 7) }); var result = prepare(LineOfSight.RayEndPoints(min, max)); CollectionAssert.AreEqual(expected, result); }
void GatherController() { LineOfSight lineOfSight = GetComponent <LineOfSight>(); if (lineOfSight && lineOfSight.visibleTargets.Count > 0) { //Debug.Log("Resource spotted"); StopCoroutine(Wander()); destination = lineOfSight.visibleTargets[0].position; float disToTarget = Vector3.Distance(agent.destination, transform.position); if (disToTarget <= agent.stoppingDistance) { if (isAnimated) { animator.SetBool("isWalking", false); animator.SetBool("isIdle", false); animator.SetBool("isAttacking", true); return; } //Debug.Log("Reached resource"); Attack(); } } }
// Use this for initialization void Start() { los = GetComponent<LineOfSight>(); player = GameObject.Find("Player"); positionTarget = cameraPosTop; lookTarget = player.transform; }
public void InstanceDeadZone(LineOfSight parEnemyAimingWay) { Vector3 _TempEndPosition = new Vector3(); for (int i = 1; i < 9; i++) { Transform _TempDeadZone = Instantiate(Deadzone.transform, transform.position, Quaternion.identity); _TempEndPosition = new Vector3(); switch (parEnemyAimingWay) { case LineOfSight.down: _TempEndPosition = _TempDeadZone.position; _TempEndPosition.y -= i; _TempDeadZone.position = _TempEndPosition; break; case LineOfSight.left: _TempEndPosition = _TempDeadZone.position; _TempEndPosition.x -= i; _TempDeadZone.position = _TempEndPosition; break; case LineOfSight.up: _TempEndPosition = _TempDeadZone.position; _TempEndPosition.y += i; _TempDeadZone.position = _TempEndPosition; break; case LineOfSight.right: _TempEndPosition = _TempDeadZone.position; _TempEndPosition.x += i; _TempDeadZone.position = _TempEndPosition; break; } RaycastHit2D checkCollision; checkCollision = Physics2D.Linecast(_TempDeadZone.position, _TempDeadZone.position); if (checkCollision.transform != null) { if (checkCollision.transform.tag == "Stone" || checkCollision.transform.tag == "Enemy") { Destroy(_TempDeadZone.gameObject); break; } else if (checkCollision.transform.tag == "DeadZone") { Destroy(_TempDeadZone.gameObject); } else { _TempDeadZone.GetComponent <BoxCollider2D>().enabled = true; } } if (_TempDeadZone != null) { _TempDeadZone.position = _TempEndPosition; _DeadZone.Add(_TempDeadZone); } } }
public Vector2 GetVectorDirection(LineOfSight aimingDirection) { Vector2 direction = new Vector2(); switch (aimingDirection) { case LineOfSight.down: direction = -transform.up; break; case LineOfSight.up: direction = transform.up; break; case LineOfSight.right: direction = transform.right; break; case LineOfSight.left: direction = -transform.right; break; } return(direction); }
public static bool Prefix(LineOfSight __instance, ref VisibilityLevel __result, AbstractActor source, Vector3 sourcePosition, ICombatant target, Vector3 targetPosition, Quaternion targetRotation) { Mod.Log.Trace?.Write($"LOS:GVTTWPAR: source:{CombatantUtils.Label(source)} ==> target:{CombatantUtils.Label(target)}"); // Skip if we aren't ready to process // TODO: Is this necessary anymore? //if (State.TurnDirectorStarted == false || (target as AbstractActor) == null) { return true; } AbstractActor sourceActor = source as AbstractActor; // TODO: Handle buildings here bool sourceHasLineOfSight = VisualLockHelper.CanSpotTarget(sourceActor, sourcePosition, target, targetPosition, targetRotation, __instance); if (sourceHasLineOfSight) { __result = VisibilityLevel.LOSFull; } else { VisibilityLevel sensorsVisibility = VisibilityLevel.None; if (ModState.TurnDirectorStarted) { SensorScanType sensorLock = SensorLockHelper.CalculateSensorLock(sourceActor, sourcePosition, target, targetPosition); sensorsVisibility = sensorLock.Visibility(); } __result = sensorsVisibility; } //Mod.Log.Trace?.Write($"LOS:GVTTWPAR - [{__result}] visibility for source:{CombatantUtils.Label(source)} ==> target:{CombatantUtils.Label(target)}"); return(false); }
void Shield() { LineOfSight lineOfSight = player.GetLineOfSight(); switch (lineOfSight) { case LineOfSight.UP: activeShieldCollider = upCollider; earthShieldCollider = earthUpCollider; attackDirection = new Vector2(0.0f, 1.0f); break; case LineOfSight.LEFT: activeShieldCollider = leftCollider; earthShieldCollider = earthLeftCollider; attackDirection = new Vector2(-1.0f, 0.0f); break; case LineOfSight.DOWN: activeShieldCollider = downCollider; earthShieldCollider = earthDownCollider; attackDirection = new Vector2(0.0f, -1.0f); break; case LineOfSight.RIGHT: activeShieldCollider = rightCollider; earthShieldCollider = earthRightCollider; attackDirection = new Vector2(1.0f, 0.0f); break; } RegularShield(); }
void SwordSwing() { LineOfSight lineOfSight = player.GetLineOfSight(); switch (lineOfSight) { case LineOfSight.UP: attackDirection = new Vector2(0.0f, 1.0f); activeSwordSwingCollider = upCollider; airSwordSwingCollider = airUpCollider; break; case LineOfSight.LEFT: attackDirection = new Vector2(-1.0f, 0.0f); activeSwordSwingCollider = leftCollider; airSwordSwingCollider = airLeftCollider; break; case LineOfSight.DOWN: attackDirection = new Vector2(0.0f, -1.0f); activeSwordSwingCollider = downCollider; airSwordSwingCollider = airDownCollider; break; case LineOfSight.RIGHT: attackDirection = new Vector2(1.0f, 0.0f); activeSwordSwingCollider = rightCollider; airSwordSwingCollider = airRightCollider; break; } RegularSwing(); }
public static void Postfix(LineOfSight __instance, ref float __result, AbstractActor source, ICombatant target) { if (__instance != null && source != null) { __result = VisualLockHelper.GetAdjustedSpotterRange(source, target); } }
public override void OnEnter() { _flocking = (Flocking)((FSMBeetle)this.Fsm).beetleFlocking; _beetle = (BeetleBehaviur)((FSMBeetle)this.Fsm).beetle; _lineOfSight = (LineOfSight)((FSMBeetle)this.Fsm).beetleLineOfSight; _lineOfSight.setExitedBehaviour(); }
public static void Postfix(LineOfSight __instance, ref float __result, AbstractActor source) { if (__instance != null && source != null) { __result = SensorLockHelper.GetSensorsRange(source); } }
// Start is called before the first frame update void Start() { Sequence root = new Sequence(bb); Selector targetSel = new Selector(bb); Help help = new Help(bb); ViewMark mark = new ViewMark(bb); NoDanger noDanger = new NoDanger(bb); Sequence actionSeq = new Sequence(bb); Selector ramSel = new Selector(bb); Sequence ramSeq = new Sequence(bb); LineOfSight los = new LineOfSight(bb); Boost boost = new Boost(bb); NormalizeBoost norm = new NormalizeBoost(bb); Chase chase = new Chase(bb); ramSeq.AddTask(los); ramSeq.AddTask(boost); ramSel.AddTask(ramSeq); ramSel.AddTask(norm); actionSeq.AddTask(ramSel); actionSeq.AddTask(chase); targetSel.AddTask(help); targetSel.AddTask(mark); root.AddTask(targetSel); root.AddTask(noDanger); root.AddTask(actionSeq); this.bt = root; }
public static void Postfix(LineOfSight __instance, AbstractActor source, Vector3 sourcePosition, ICombatant target, ref LineOfFireLevel __result) { if (target is AbstractActor a && a.HasIndirectFireImmunity && __instance.GetVisibilityToTargetWithPositionsAndRotations(source, sourcePosition, a) != VisibilityLevel.LOSFull) { __result = LineOfFireLevel.LOFBlocked; } }
public static void Postfix(LineOfSight __instance, ref float __result, AbstractActor source, AbstractActor target, CombatGameState ___Combat) { if (__instance != null && source != null) { __result = SensorLockHelper.GetAdjustedSensorRange(source, target); } }
public LineOfSight GetLineOfSight() { float verticalMagnitude = animator.GetFloat("VerticalMagnitude"); float horizontalMagnitude = animator.GetFloat("HorizontalMagnitude"); LineOfSight direction = LineOfSight.NONE; if (horizontalMagnitude == 0 && verticalMagnitude == -1) { direction = LineOfSight.DOWN; } else if (horizontalMagnitude == 0 && verticalMagnitude == 1) { direction = LineOfSight.UP; } else if (horizontalMagnitude == -1) { direction = LineOfSight.LEFT; } else if (horizontalMagnitude == 1) { direction = LineOfSight.RIGHT; } return(direction); }
// Use this for initialization new void Start() { base.Start(); type = AIType.Hunter; Bottle.OnBottleShaked += OnBottleShaked; los = GetComponent <LineOfSight>(); tasks.Push(new Task((int)ChasseurTask.Normal)); }
// Use this for initialization new void Start() { base.Start(); type = AIType.Dog; los = GetComponent <LineOfSight>(); AkSoundEngine.PostEvent("dog_idle", gameObject); tasks.Push(new Task((int)DogTask.WanderInFront)); }
private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { LineOfSight LOS = GetComponentInParent <LineOfSight>(); LOS.ShootRaycast(); } }
public static void ForEachVisibleTileInRange(int xPos, int yPos, int vision, System.Action <Tile> func) { ForEachTileInRange(xPos, yPos, vision, t => { if (LineOfSight.Test(xPos, yPos, t.XPos, t.YPos)) { func(t); } }); }
// Use this for initialization void Start() { currentState = State.Normal; originalRotation = transform.rotation; los = GetComponent <LineOfSight> (); los.detectionRange = 45.0f; hero = GameObject.Find("Hero"); disabledSound = GetComponent <AudioSource>(); }
protected virtual void Awake() { DefaultFrequency = Frequency; Motor = transform.parent.GetComponent <EnemyMovementMotor>(); PathFinder = transform.parent.GetComponentInChildren <PathFinder>(); LineOfSight = transform.parent.GetComponentInChildren <LineOfSight>(); AiController = GetComponent <BehaviourController>(); }
void Awake() { _lineOfSight = GetComponent <LineOfSight>(); //_squirrel = (Squirrel3D)FindObjectOfType(typeof(Squirrel3D)); _lineOfSight.Target = _squirrel; _flocking = GetComponent <Flocking>(); _currentState = BeetleStates.Patrolling; _currentWaypoint = startPath; _flocking.Target = _currentWaypoint.transform.position; }
/// <summary> /// This is used to reset and update values that need to reference the actual WoWObject. /// </summary> /// <returns></returns> public virtual bool Update() { if (!IsValid) { return(false); } LineOfSight.Reset(); Collision.Reset(); return(true); }
public GameForm() { InitializeComponent(); size = pictureBox1.Width / 10; snake = new Snake(new Point(0, 0), size); lineOfSight = LineOfSight.Down; rnd = new Random(); timer1.Interval = 1000; score = 0; }
void ElementalShield() { LineOfSight lineOfSight = player.GetLineOfSight(); switch (lineOfSight) { case LineOfSight.UP: activeShieldCollider = upCollider; earthShieldCollider = earthUpCollider; attackDirection = new Vector2(0.0f, 1.0f); break; case LineOfSight.LEFT: activeShieldCollider = leftCollider; earthShieldCollider = earthLeftCollider; attackDirection = new Vector2(-1.0f, 0.0f); break; case LineOfSight.DOWN: activeShieldCollider = downCollider; earthShieldCollider = earthDownCollider; attackDirection = new Vector2(0.0f, -1.0f); break; case LineOfSight.RIGHT: activeShieldCollider = rightCollider; earthShieldCollider = earthRightCollider; attackDirection = new Vector2(1.0f, 0.0f); break; } switch (elementalAttribute) { case ElementalAttribute.NONE: RegularShield(); break; case ElementalAttribute.EARTH: EarthShield(); break; case ElementalAttribute.FIRE: FireShield(); break; case ElementalAttribute.WATER: WaterShield(); break; case ElementalAttribute.AIR: AirShield(); break; } }
private void OnSceneGUI() { LineOfSight fov = (LineOfSight)target; Handles.color = Color.white; Vector3 viewAngleA = fov.DirFromAngle(-fov.viewAngle / 2, false); Vector3 viewAngleB = fov.DirFromAngle(fov.viewAngle / 2, false); Handles.DrawLine(fov.transform.position, fov.transform.position + viewAngleA * fov.viewRadius); Handles.DrawLine(fov.transform.position, fov.transform.position + viewAngleB * fov.viewRadius); }
// Use this for initialization void Start() { charMot = GetComponent<CharacterMotor>(); lineOfSight = GameObject.Find("Main Camera").GetComponent<LineOfSight>(); cameraPos = GameObject.Find("Main Camera").GetComponent<CameraPosition>(); }