コード例 #1
0
 public override Vector2?FindTarget()
 {
     // move towards the mouse if player is holding and clicking
     if (returningToPlayer || Vector2.Distance(projectile.Center, player.Center) > IdleDistanceMulitplier * ModifiedMaxDistance())
     {
         returningToPlayer = true;
         return(null);                // force back into non-attacking mode if too far from player
     }
     if (player.HeldItem.type == itemType && (usingSpecial || (player.channel && player.altFunctionUse != 2)))
     {
         MousePlayer mPlayer = player.GetModPlayer <MousePlayer>();
         mPlayer.SetMousePosition();
         Vector2?_mouseWorld = mPlayer.GetMousePosition();
         if (_mouseWorld is Vector2 mouseWorld)
         {
             syncedMouseWorld = mouseWorld;
             Vector2 targetFromPlayer = mouseWorld - player.Center;
             if (targetFromPlayer.Length() < ModifiedMaxDistance())
             {
                 return(mouseWorld - projectile.Center);
             }
             targetFromPlayer.Normalize();
             targetFromPlayer *= ModifiedMaxDistance();
             return(player.Center + targetFromPlayer - projectile.Center);
         }
     }
     return(null);
 }
コード例 #2
0
 protected virtual int?GetSpriteDirection()
 {
     if (vectorToTarget is Vector2 target)
     {
         MousePlayer mPlayer     = player.GetModPlayer <MousePlayer>();
         Vector2?    _mouseWorld = mPlayer.GetMousePosition();
         if (_mouseWorld is Vector2 mouseWorld)
         {
             return(Math.Sign((mouseWorld - player.Center).X));
         }
         else
         {
             return(null);
         }
     }
     else if (attackFrame > 0)
     {
         // don't change directions while weapon is still out
     }
     else if (projectile.velocity.X < -1)
     {
         return(-1);
     }
     else if (projectile.velocity.X > 1)
     {
         return(1);
     }
     return(null);
 }
コード例 #3
0
 // Use this for initialization
 void Awake()
 {
     playerTwo = GameObject.Find("MousePlayer");
     secondPlayerScript = playerTwo.GetComponent<MousePlayer>();
     objectsISpawn = secondPlayerScript.yourObjectArray;
     tileID = GridSystem.tileCounter;
     GridSystem.tileCounter++;
 }
コード例 #4
0
 // Use this for initialization
 void Awake()
 {
     playerTwo          = GameObject.Find("MousePlayer");
     secondPlayerScript = playerTwo.GetComponent <MousePlayer>();
     objectsISpawn      = secondPlayerScript.yourObjectArray;
     tileID             = GridSystem.tileCounter;
     GridSystem.tileCounter++;
 }
コード例 #5
0
        protected override void PostReceive(BinaryReader reader, int sender, Player player)
        {
            MousePlayer mousePlayer = player.GetModPlayer <MousePlayer>();

            mousePlayer.ResetTimeout();

            if (Main.netMode == NetmodeID.Server)
            {
                new MouseResetTimeoutPacket(player).Send(from : sender, bcCondition : delegate(Player otherPlayer)
                {
                    //Only send to other player if the mouse would be in visible range
                    Rectangle otherPlayerBounds = Utils.CenteredRectangle(otherPlayer.Center, MousePlayer.MaxRange);

                    if (mousePlayer.TryGetMousePosition(out Vector2 mouseWorld))
                    {
                        Point mousePoint = mouseWorld.ToPoint();
                        return(otherPlayerBounds.Contains(mousePoint));
                    }
                    return(false);
                });
            }
        }
コード例 #6
0
ファイル: Regenerate.cs プロジェクト: SebastiaanBuwalda/Aim3D
 // Use this for initialization
 void Start()
 {
     scriptToEdit = GetComponent<MousePlayer> ();
     StartCoroutine (IntervalCompleter());
 }
コード例 #7
0
 // Use this for initialization
 void Start()
 {
     scriptToEdit = GetComponent <MousePlayer> ();
     StartCoroutine(IntervalCompleter());
 }