Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

mymove() method c#

myMove()
Comment

mymove() method c#


public class Monster
{
    private const int MIN_X = 156;
    private const int MAX_X = 501;
    private int _x;

    //your TL(probably) will tell you to use Enum 
    private bool _toLeft;

    public Monster()
    {
        _toLeft = false;
        _x = MIN_X;
    }

    public void Move()
    {
        if (_toLeft)
        {
            _x--;
        }
        else
        {
            _x++;
        }
        CheckEdges();
    }

    private void CheckEdges()
    {
        if (_x == MAX_X || _x == MIN_X)
            _toLeft = !_toLeft;
    }

}

Comment

PREVIOUS NEXT
Code Example
Csharp :: UnityEngine.Transform.get_position () (at <a0ef933b1aa54b668801ea864e4204fe:0) Gamekit3D.MeleeWeapon.BeginAttack (System.Boolean thowingAttack) 
Csharp :: making beep voice in c# 
Csharp :: Exit string qoutes c# 
Csharp :: unity keep rotating object 
Csharp :: shutdown system c# 
Csharp :: c# list shuffle 
Csharp :: Use tuple to swap values c# 
Csharp :: wpf make both rich Text scroll 
Csharp :: maxheap c# 
Csharp :: c# check if string is directory 
Csharp :: how to change the position of a gameobject in c# unity 
Csharp :: C# define a block as text 
Csharp :: how to draw a rectangle in monogame 
Csharp :: Oculus Unity add haptics 
Csharp :: set decimal point c# 
Csharp :: unity instantiate 
Csharp :: change picturebox image c# 
Csharp :: meta keywords tag mvc .net core 
Csharp :: .net core authorizationhandlercontext 
Csharp :: dictionary c# 
Csharp :: += meaning c# 
Csharp :: c# split string for all blank character 
Csharp :: unity keycode 
Csharp :: C# datetime.now to string only numbers 
Csharp :: unity cast float to int 
Csharp :: best way to compare byte array c# 
Csharp :: reverse for loop unity 
Csharp :: c# datetime to timestamp 
Csharp :: c# restart app 
Csharp :: how to add item to listbox in c# 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =