コード例 #1
0
ファイル: PointLight.cs プロジェクト: nasdf/Boxel-Engine
 public PointLight(IFollowable target, Color color, float radius, float intensity)
 {
     _target = target;
     _color = color;
     _radius = radius;
     _intensity = intensity;
 }
コード例 #2
0
 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);
         }
     }
 }
コード例 #3
0
ファイル: Align.cs プロジェクト: RawbPower/Fishing-Game
    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);
    }
コード例 #4
0
 Task <bool> ConfirmFollowRemovingAsync(IFollowable item)
 {
     return(_dialogService.ShowMessageDialog(
                content: "ConfirmRemoveFollow_DialogDescWithItemName".Translate(item.GetLabel()),
                title: "ConfirmRemoveFollow_DialogTitle".Translate(),
                acceptButtonText: "RemoveFollow".Translate(),
                cancelButtonText: "Cancel".Translate()
                ));
 }
コード例 #5
0
        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();
        }
コード例 #6
0
 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),
     });
コード例 #7
0
        internal void SetFollowTarget(IFollowable followTarget)
        {
            _nowProcessFollow.Value = true;

            try
            {
                _followTarget.Value   = followTarget;
                _isFollowTarget.Value = FollowManager.IsFollowItem(followTarget);
            }
            finally
            {
                _nowProcessFollow.Value = false;
            }
        }
コード例 #8
0
ファイル: Player.cs プロジェクト: gitvestman/Snabbt
 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);
     }
 }
コード例 #9
0
        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();
            };
        }
コード例 #10
0
 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;
     }
 }
コード例 #11
0
ファイル: Enemy.cs プロジェクト: gitvestman/Snabbt
 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);
         }
     }
 }
コード例 #12
0
ファイル: Stop.cs プロジェクト: RawbPower/Fishing-Game
    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);
    }
コード例 #13
0
        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);
                    }
                }
            }
        }
コード例 #14
0
        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);
                    }
                }
            }
        }
コード例 #15
0
 private static void CopyIFollowable(IFollowable item1, IFollowable item2)
 {
     item1.HasFollowed = item2.HasFollowed;
 }
コード例 #16
0
ファイル: IFollowable.cs プロジェクト: koenbollen/canyon
 public Followable(IFollowable followable)
 {
     this.Position = followable.Position;
     this.Orientation = followable.Orientation;
 }
コード例 #17
0
 public SpringChaseCamera(Game game, IFollowable target = null)
     : base(game)
 {
     this.Target = target;
 }
コード例 #18
0
 /// <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;
 }
コード例 #19
0
ファイル: main.cs プロジェクト: melissa160/oop-in-csharp
 public double CalculatePrice(IFollowable influencer)
 {
     return(influencer.Followers * 0.9);
 }
コード例 #20
0
ファイル: main.cs プロジェクト: melissa160/oop-in-csharp
 public double CalculatePricePerPostFor(IFollowable influencer)
 {
     return(_providers[influencer.Provider].CalculatePrice(influencer));
 }
コード例 #21
0
 public void HardSet(IFollowable target=null)
 {
     // This is already a hard follow camera.
 }
コード例 #22
0
 /// <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;
 }
コード例 #23
0
ファイル: Arrive.cs プロジェクト: RawbPower/Fishing-Game
    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);
    }
コード例 #24
0
 void NotifyFollowRemoved(IFollowable item)
 {
     _notificationService.ShowLiteInAppNotification_Success("FollowRemovedNotification_WithItemName".Translate(item.GetLabel()));
 }
コード例 #25
0
 public void Follow(IFollowable followable)
 {
     Following = followable;
 }
コード例 #26
0
        public void Setup(IFollowable follower)
        {
            this.follower = follower;

            offsetX = follower.GetPositionOffset().x;
        }
コード例 #27
0
 /// <summary>
 ///
 /// </summary>
 void Start()
 {
     _target = Target.GetComponent <IFollowable>();
 }