public void SetupTest() { webDriver = GetWebDriver(); loginComponent = new LoginComponent(webDriver); navigationComponent = new NavigationComponent(webDriver); }
/// <summary> /// Called when the script is first initialized /// </summary> public override void Start() { base.Start(); // Get the navigation component on the same entity as this script navigation = Entity.Get <NavigationComponent>(); // Will search for an CharacterComponent within the same entity as this script character = Entity.Get <CharacterComponent>(); if (character == null) { throw new ArgumentException("Please add a CharacterComponent to the entity containing PlayerController!"); } if (PunchCollision == null) { throw new ArgumentException("Please add a RigidbodyComponent as a PunchCollision to the entity containing PlayerController!"); } modelChildEntity = Entity.GetChild(0); moveDestination = Entity.Transform.WorldMatrix.TranslationVector; PunchCollision.Enabled = false; }
/// <summary> /// Called when the script is first initialized /// </summary> public override void Start() { base.Start(); // Get the navigation component on the same entity as this script Navigation = Entity.Get <NavigationComponent>(); // Will search for an CharacterComponent within the same entity as this script Character = Entity.Get <CharacterComponent>(); if (Character == null) { throw new ArgumentException("Please add a CharacterComponent to the entity containing PlayerController!"); } //if (PunchCollision == null) throw // new ArgumentException("Please add a RigidbodyComponent as a PunchCollision to the entity containing PlayerController!"); ModelChildEntity = Entity.GetChild(0); MoveToDestination = Entity.Transform.WorldMatrix.TranslationVector; //PunchCollision.Enabled = false; Entity atimerE = new Entity { new Core.Timer() }; SceneSystem.SceneInstance.RootScene.Entities.Add(atimerE); AttackTimer = atimerE.Get <Core.Timer>(); }
/// <summary> /// Called when the script is first initialized /// </summary> public override void Start() { base.Start(); navigation = Entity.Get <NavigationComponent>(); character = Entity.Get <CharacterComponent>(); if (character == null) { throw new ArgumentException("Please add a CharacterComponent to the entity containing PlayerController!"); } if (PunchCollision == null) { throw new ArgumentException("Please add a RigidbodyComponent as a PunchCollision to the entity containing PlayerController!"); } modelChildEntity = Entity.GetChild(0); moveDestination = Entity.Transform.WorldMatrix.TranslationVector; PunchCollision.Enabled = false; beepSoundInstance = BeepEffect?.CreateInstance(); beepSoundInstance.Stop(); commandInterpreter.moveHandler = RemoteMove; commandInterpreter.moveCurrentHandler = RemoteMoveCurrentDirection; commandInterpreter.canMoveHandler = RemoteCanMove; commandInterpreter.turnHandler = RemoteTurn; commandInterpreter.haltHandler = HaltMovement; commandInterpreter.beepHandler = PlayBeep; commandInterpreter.signalHandler = Signal; commandInterpreter.markerHandler = MarkerUpDown; }
void Start() { damage = 4; range = 1.5f; maxCooldown = 30; resetCooldown(); navigationComponent = gameObject.GetComponent <NavigationComponent>(); }
void Start() { detectionComponent = GetComponent <DetectionComponent>(); navigationComponent = GetComponent <NavigationComponent>(); gunComponent = GetComponent <Gun>(); healthComponent = GetComponent <HealthComponent>(); healthComponent.RestoreHealth(100); }
/// <summary> /// Tries to move towards the target position using the attached NavigationComponent asynchronously /// </summary> /// <param name="targetPosition"></param> /// <returns></returns> protected IEnumerator <Vector3> Move(Vector3 targetPosition) { NavigationComponent navigationComponent = Entity.Get <NavigationComponent>(); List <Vector3> pathPoints = new List <Vector3>(); if (navigationComponent == null || navigationComponent.NavigationMesh == null) { pathPoints = new List <Vector3> { Entity.Transform.WorldMatrix.TranslationVector, targetPosition }; } else { if (!navigationComponent.TryFindPath(targetPosition, pathPoints)) { yield break; } } Path navigationPath = new Path(pathPoints.ToArray()); Waypoint nextWaypoint = navigationPath.Waypoints[0]; while (nextWaypoint != null) { Vector3 targetSpeed = Vector3.Zero; if (!Drone.Stunned) { // Move towards target when having a waypoint Vector3 dir = nextWaypoint.Position - Entity.Transform.WorldMatrix.TranslationVector; dir.Y = 0; var dist = dir.Length(); if (dist < MoveThreshold) { nextWaypoint = nextWaypoint.Next; continue; } dir.Normalize(); Drone.UpdateBodyRotation(dir); targetSpeed = dir * Drone.MaximumSpeed; float dt = (float)Game.UpdateTime.Elapsed.TotalSeconds; var estimatedDist = targetSpeed.Length() * dt; if (estimatedDist > dist) { targetSpeed = dir * (dist / dt); } } Drone.SetMovement(targetSpeed); yield return(nextWaypoint.Position); } // Stop when done moving Drone.SetMovement(Vector3.Zero); }
public virtual void Start() { navComponent = GetComponent <NavigationComponent>(); foreach (var component in _components) { component.Start(); } }
public void SwitchTo() { if (chosenComponent != null) { chosenComponent.Deactivate(); } button.interactable = false; panel.transform.position = activePos; chosenComponent = this; //Handheld.Vibrate(); }
/// <inheritdoc/> public void NavigateTo(string uri, bool forceLoad = false) { if (NavigationComponent is null) { throw new InvalidOperationException($"Material.Blazor: you have registered a {Utilities.GetTypeName(typeof(IMBAnimatedNavigationManager))} but have not placed a {Utilities.GetTypeName(typeof(MBAnimatedNavigation))} component around your markup in either App.razor or MainLayout.razor"); } if (!Configuration.ApplyAnimation) { NavigationManager.NavigateTo(uri, forceLoad); } else { NavigationComponent.NavigateTo(uri, forceLoad); } }
public override void Start() { base.Start(); // Get the navigation component on the same entity as this script Navigation = Entity.Get <NavigationComponent>(); // Will search for an CharacterComponent within the same entity as this script Character = Entity.Get <CharacterComponent>(); Entity charEntity = Entity.Scene.Entities.FirstOrDefault(x => string.Equals(x.Name, "PlayerCharacter")); PlayerRef = charEntity.Get <Player.PlayerController>(); Entity atimerE = new Entity { new Core.Timer() }; SceneSystem.SceneInstance.RootScene.Entities.Add(atimerE); AttackTimer = atimerE.Get <Core.Timer>(); // Get the navigation component on the same entity as this script Navigation = Entity.Get <NavigationComponent>(); MoveDestination = Entity.Transform.WorldMatrix.TranslationVector; }
void Awake() { agent = GetComponent<NavMeshAgent>(); GameObject healthBarObject = (GameObject) Instantiate(healthBar, new Vector3(), new Quaternion()); healthBarObject.transform.SetParent(transform); healthBarObject.transform.localPosition = new Vector3(0, 3.0f, 0); Image image = healthBarObject.GetComponentInChildren<Image>(); healthComponent.HealthBar = new HealthBarScript(mainCamera, healthBarObject, image); attackComponent = new AttackComponent(animator); experienceComponent = new ExperienceComponent(healthComponent, attackComponent); navComponent = new NavigationComponent(agent, animator); healthComponent.MaxHealth = 100; healthComponent.CurrentHealth = 100; maxMana = 50; currentMana = 50; characterName = "Hattori"; className = "Ninja"; picture = Resources.Load<Sprite>("Icons/ninjaHead"); buttons = null; selectedCircle = transform.FindChild("SelectedCircle").gameObject; }
// Use this for initialization public void Start() { Animator animator = GetComponent<Animator>(); attackComponent = new AttackComponent(animator); NavMeshAgent agent = GetComponent<NavMeshAgent>(); navigationComponent = new NavigationComponent(agent, animator); experienceComponent = new ExperienceComponent(healthComponent, attackComponent); maxMana = 0; currentMana = 0; characterName = "Orc"; className = "Warrior"; experienceComponent.CurrentLevel = 1; experienceComponent.MaxLevel = 1; experienceComponent.CurrentExp = 0; experienceComponent.MaxExp = 100; attackCircle = gameObject.transform.FindChild("AttackCircle").gameObject; selectedCircle = gameObject.transform.FindChild("SelectedCircle").gameObject; picture = Resources.Load<Sprite>("Icons/orc"); }
public override void Process(Entity entity) { NavigationComponent nc = entity.GetComponent <NavigationComponent>(); if (nc.TargetLocation.HasValue) { PositionComponent pc = entity.GetComponent <PositionComponent>(); float deltaX = pc.Position.X - nc.TargetLocation.Value.X; float deltaY = pc.Position.Y - nc.TargetLocation.Value.Y; float distanceToTarget = (float)Math.Sqrt((deltaX * deltaX) + (deltaY * deltaY)); if (distanceToTarget < 15) { nc.TargetLocation = null; entity.GetComponent <ThrustComponent>().ForwardThrust = false; entity.GetComponent <ThrustComponent>().BackwardThrust = true; return; } float angle = (float)Math.Atan2((nc.TargetLocation.Value.Y - pc.Position.Y), (nc.TargetLocation.Value.X - pc.Position.X)) + MathHelper.PiOver2; float angleDegrees = MathHelper.ToDegrees(angle); if (angleDegrees < 0) { angleDegrees += 360; } RotationComponent rc = entity.GetComponent <RotationComponent>(); float angleDiff = angleDegrees - rc.Angle; if (angleDiff > 180) { angleDiff -= 360; } if (angleDiff < -180) { angleDiff += 360; } if (angleDiff < -rc.RotationSpeed) { entity.GetComponent <ThrustComponent>().ForwardThrust = false; entity.GetComponent <ThrustComponent>().BackwardThrust = true; rc.Angle -= rc.RotationSpeed; if (rc.Angle < 0) { rc.Angle += 360; } } else if (angleDiff > rc.RotationSpeed) { entity.GetComponent <ThrustComponent>().ForwardThrust = false; entity.GetComponent <ThrustComponent>().BackwardThrust = true; rc.Angle += rc.RotationSpeed; if (rc.Angle > 360) { rc.Angle -= 360; } } else { ThrustComponent tc = entity.GetComponent <ThrustComponent>(); InertiaComponent ic = entity.GetComponent <InertiaComponent>(); float ticksToTarget = distanceToTarget / ic.Inertia.Length(); float ticksToStop = (float)Math.Log(ic.Inertia.Length() / tc.Deceleration) / tc.Deceleration; if (ticksToTarget > ticksToStop + 15) { tc.ForwardThrust = true; tc.BackwardThrust = false; } else { tc.ForwardThrust = false; tc.BackwardThrust = true; } } } else { if (entity.GetComponent <InertiaComponent>().Inertia.Length() == 0) { entity.GetComponent <ThrustComponent>().ForwardThrust = false; entity.GetComponent <ThrustComponent>().BackwardThrust = false; } } }
/// <summary> /// Calls <see cref="NavigationManager"/> indicating that a navigation interaction has been initiated /// </summary> /// <param name="gameObject"><see cref="GameObject"/> of the <see cref="View"/> making the call</param> /// <param name="component"><see cref="NavigationComponent"/> used to initiate the interaction</param> public virtual void NavigationInteraction(GameObject gameObject, NavigationComponent component) { NavigationManager.Instance.Navigate(gameObject, component.Direction); }
/// <summary> /// Pass a navigation interaction with a reference to a <see cref="NavigationComponent"/> initiating the interaction /// </summary> /// <param name="button"><see cref="NavigationComponent"/> initiating the interaction</param> public void NavigationInteraction(NavigationComponent button) { presenter.NavigationInteraction(gameObject, button); }