public PointLight(IFollowable target, Color color, float radius, float intensity) { _target = target; _color = color; _radius = radius; _intensity = intensity; }
public static void Add(IFollowable item) { if (item == null) { return; } lock (FollowableCash) { if (FollowableCash.ContainsKey(item.Key)) { var container = FollowableCash[item.Key]; if (!container.Contains(item)) { Update(item); container.Add(item); } } else { var hs = new HashSet <IFollowable> { item }; FollowableCash.Add(item.Key, hs); } } }
public override SteeringOutput GetSteering() { // Create the structure to hold our output SteeringOutput steering = new SteeringOutput(); // Get orientation to the target float rotation = target.transform.eulerAngles.z - character.transform.eulerAngles.z; // Map the result to the (-pi, pi) interval rotation = MapToRange(rotation); float rotationSize = Mathf.Abs(rotation); // Check if we are there, return no steering if (rotationSize < targetRadius) { steering.linear = Vector3.zero; steering.angular = 0f; return(steering); } // This is the orientation that we want to have float targetRotation; // If we are outside the slow radius, the go to max speed if (rotationSize > slowRadius) { targetRotation = maxSpeed; } // Otherwise calculate scaled orientation else { targetRotation = maxSpeed * rotationSize / slowRadius; } // The final target rotation combines speed (already in the variable) and direction targetRotation *= rotation / rotationSize; // Get characters current orientation IFollowable followable = character.GetComponent <IFollowable>(); float characterRotation = followable.GetRotation(); // Acceleration tries to get to the target orientation steering.angular = targetRotation - characterRotation; steering.angular /= timeToTarget; // Check if the acceleration is too fast float angularAcceleration = Mathf.Abs(steering.angular); if (angularAcceleration > maxAcceleration) { steering.angular /= angularAcceleration; steering.angular = steering.angular * maxAcceleration; } // Output the steering steering.linear = Vector3.zero; return(steering); }
Task <bool> ConfirmFollowRemovingAsync(IFollowable item) { return(_dialogService.ShowMessageDialog( content: "ConfirmRemoveFollow_DialogDescWithItemName".Translate(item.GetLabel()), title: "ConfirmRemoveFollow_DialogTitle".Translate(), acceptButtonText: "RemoveFollow".Translate(), cancelButtonText: "Cancel".Translate() )); }
public SimpleFollowCamera(IFollowable target, float distance, float angle) { this.Target = target; this.distance = distance; this.angle = angle; UpdateProjection(); CanyonGame.Instance.GraphicsDevice.DeviceReset += delegate(object s, EventArgs e) { UpdateProjection(); }; this.CreateView(); }
public static string GetLabel(this IFollowable followable) { return(followable switch { IUser user => user.Nickname, Video.ITag tag => tag.Tag, IChannel channel => channel.Name, IMylist mylist => mylist.Name, ICommunity community => community.Name, _ => throw new NotSupportedException(followable?.GetType().Name), });
internal void SetFollowTarget(IFollowable followTarget) { _nowProcessFollow.Value = true; try { _followTarget.Value = followTarget; _isFollowTarget.Value = FollowManager.IsFollowItem(followTarget); } finally { _nowProcessFollow.Value = false; } }
GameObject IFollowable.AddFollower(GameObject Follower) { Debug.Log("Player AddFollower " + Follower.name); if (this.Follower != null) { IFollowable FollowerComponent = this.Follower.GetComponent <Enemy>(); return(FollowerComponent.AddFollower(Follower)); } else { this.Follower = Follower; return(gameObject); } }
public FirstpersonCamera(Game game, IFollowable target=null) : base(game) { this.Target = target; this.start = this.real = null; time = 0; Enabled = false; UpdateProjection(); game.GraphicsDevice.DeviceReset += delegate(object s, EventArgs a) { UpdateProjection(); }; }
public void HardSet(IFollowable target = null) { if (target != null) { start = new Followable(target); real = new Followable(target); this.time = FirstpersonCamera.Delay; this.Enabled = true; } else { time = 0; this.start = this.real = null; this.Enabled = false; } }
void OnCollisionEnter2D(Collision2D col) { if (Following == null) { Debug.Log("Collision " + col.gameObject.name); IFollowable FollowingComponent = col.gameObject.GetComponent <Enemy>(); if (FollowingComponent == null) { FollowingComponent = col.gameObject.GetComponent <Player>(); Main.UpdateScore(1); } if (FollowingComponent != null) { Following = FollowingComponent.AddFollower(gameObject); } } }
public override SteeringOutput GetSteering() { // Create the structure to hold our output SteeringOutput steering = new SteeringOutput(); // Get direction to the target IFollowable followable = character.GetComponent <IFollowable>(); Vector3 characterVelocity = followable.GetVelocity(); Vector3 direction; if (target == null) { direction = characterVelocity.normalized; } else { direction = target.transform.position - character.transform.position; } float distance = direction.magnitude; // Velocity that we want to have Vector3 targetVelocity; // The target velocity combines speed and direction targetVelocity = direction; targetVelocity.Normalize(); targetVelocity *= maxSpeed; // Acceleration tries to get to the target velocity steering.linear = targetVelocity - characterVelocity; steering.linear /= timeToTarget; // Check if the acceleration is too fast if (steering.linear.magnitude > maxAcceleration) { steering.linear.Normalize(); steering.linear = steering.linear * maxAcceleration; } // Output the steering steering.angular = 0; return(steering); }
public static void Remove(IFollowable item) { if (item == null) { return; } lock (FollowableCash) { if (FollowableCash.ContainsKey(item.Key)) { var container = FollowableCash[item.Key]; if (container.Contains(item)) { container.Remove(item); } } } }
public static void Update(IFollowable item) { if (item == null) { return; } lock (FollowableCash) { if (FollowableCash.ContainsKey(item.Key)) { var container = FollowableCash[item.Key]; foreach (var followable in container) { CopyIFollowable(followable, item); } } } }
private static void CopyIFollowable(IFollowable item1, IFollowable item2) { item1.HasFollowed = item2.HasFollowed; }
public Followable(IFollowable followable) { this.Position = followable.Position; this.Orientation = followable.Orientation; }
public SpringChaseCamera(Game game, IFollowable target = null) : base(game) { this.Target = target; }
/// <summary> /// Reset the camera's motion/velocity and set the /// position hard to the desired. /// </summary> public void HardSet(IFollowable target=null) { if (target != null) { IFollowable old = this.Target; this.Target = target; UpdateWorld(); this.Target = old; } else { UpdateWorld(); } this.Velocity = Vector3.Zero; this.Position = this.desiredPosition; viewChanged = true; }
public double CalculatePrice(IFollowable influencer) { return(influencer.Followers * 0.9); }
public double CalculatePricePerPostFor(IFollowable influencer) { return(_providers[influencer.Provider].CalculatePrice(influencer)); }
public void HardSet(IFollowable target=null) { // This is already a hard follow camera. }
/// <summary> /// /// </summary> /// <param name="game">Isntance tridy GhameHost</param> /// <param name="followable">Objekt ke sledovani</param> /// <param name="moveSpeed">Rychlost kamery vuci objektu 0f-1f (nepohybliva-bez zpozdeni)</param> public FollowingCamera(GameScreen game, IFollowable followable, float moveSpeed = 0.03f) : base(game) { MoveSpeed = moveSpeed; _followable = followable; NeedRecalculation = true; }
public override SteeringOutput GetSteering() { // Create the structure to hold our output SteeringOutput steering = new SteeringOutput(); // Get direction to the target Vector3 direction = target.transform.position - character.transform.position; float distance = direction.magnitude; // Check if we are there, return no steering if (distance < targetRadius) { Debug.Log("Piss"); steering.linear = Vector3.zero; steering.angular = 0f; return(steering); } // This is the speed that we want to have float targetSpeed; // If we are outside the slow radius, the go to max speed if (distance > slowRadius) { targetSpeed = maxSpeed; } // Otherwise calculate scaled speed else { //Debug.Log("Pingo " + character.name); targetSpeed = maxSpeed * (distance / slowRadius); } // Velocity that we want to have Vector3 targetVelocity; // The target velocity combines speed and direction targetVelocity = direction; targetVelocity.Normalize(); targetVelocity *= targetSpeed; Vector3 characterVelocity = Vector3.zero; // Get characters current speed IFollowable followable = character.GetComponent <IFollowable>(); characterVelocity = followable.GetVelocity(); /*if (character.GetComponent<AIMovement>() != null) * { * AIMovement aiMovement = character.GetComponent<AIMovement>(); * characterVelocity = aiMovement.GetVelocity(); * } else if (character.GetComponent<FishController>() != null) * { * FishController fishController = character.GetComponent<FishController>(); * characterVelocity = fishController.GetVelocity(); * } else * { * throw new System.Exception("The is no component of the game object " + character.name + " which has a velocity parameter (ie. AIMovement or FishController)"); * }*/ // Acceleration tries to get to the target velocity steering.linear = targetVelocity - characterVelocity; steering.linear /= timeToTarget; // Check if the acceleration is too fast if (steering.linear.magnitude > maxAcceleration) { steering.linear.Normalize(); steering.linear = steering.linear * maxAcceleration; } // Output the steering steering.angular = 0; return(steering); }
void NotifyFollowRemoved(IFollowable item) { _notificationService.ShowLiteInAppNotification_Success("FollowRemovedNotification_WithItemName".Translate(item.GetLabel())); }
public void Follow(IFollowable followable) { Following = followable; }
public void Setup(IFollowable follower) { this.follower = follower; offsetX = follower.GetPositionOffset().x; }
/// <summary> /// /// </summary> void Start() { _target = Target.GetComponent <IFollowable>(); }