예제 #1
0
파일: Enemy.cs 프로젝트: Creator13/MathGame
    public Enemy(Vector2 position)
    {
        visual = Resources.Load <Texture2D>("pacman");

        Circle        = new Circle();
        Circle.Radius = visual.width * .5f;

        Position = position;
    }
예제 #2
0
    public Projectile(Vector2 position, Vector2 direction, float startVelocity, float acceleration)
    {
        visual = Resources.Load <Texture2D>("pacman");

        Circle = new Circle {
            Position = position,
            Radius   = visual.width * .5f * SCALE
        };

        velocity = startVelocity;
        accelerationPerSecond = acceleration;

        Direction = direction;
    }
예제 #3
0
    public Player()
    {
        visual = Resources.Load <Texture2D>("pacman");

        Circle        = new Circle();
        Circle.Radius = visual.width * .5f;

        pixel = new Texture2D(1, 1, TextureFormat.RGBA32, false);
        pixel.SetPixel(0, 0, Color.white);
        pixel.Apply();

        Position = new Vector2(Screen.width * .5f - visual.width * .5f, Screen.height * .5f - visual.height * .5f);

        rigidbody = new Rigidbody {
            mass            = 1.0f,
            force           = 150.0f,
            dragCoefficient = .47f
        };
    }
예제 #4
0
파일: Player.cs 프로젝트: Pheraone/MathGame
    public Player()
    {
        visual = Resources.Load <Texture2D>("pacman");

        Circle        = new DevMath.Circle();
        Circle.Radius = visual.width * .5f;

        pixel = new Texture2D(1, 1, TextureFormat.RGBA32, false);
        pixel.SetPixel(0, 0, Color.white);
        pixel.Apply();

        Position = new DevMath.Vector2(Screen.width * .5f - visual.width * .5f, Screen.height * .5f - visual.height * .5f);

        rigidbody = new DevMath.Rigidbody()
        {
            mass = 1.0f,
            frictionCoefficient = .4f,
            normalForce         = 9.81f
        };
    }
예제 #5
0
    public void Update()
    {
        UpdatePhysics();

        var mousePos = new DevMath.Vector2(Input.mousePosition.x, Screen.height - Input.mousePosition.y);
        var mouseDir = (mousePos - Position).Normalized;

        Rotation = DevMath.DevMath.RadToDeg(DevMath.Vector2.Angle(new DevMath.Vector2(.0f, .0f), mouseDir));

        if (Input.GetMouseButton(0))
        {
            chargeTime += Time.deltaTime;
        }
        else if (Input.GetMouseButtonUp(0))
        {
            float p = DevMath.DevMath.Clamp(chargeTime, .0f, MAX_CHARGE_TIME) / MAX_CHARGE_TIME;

            Game.Instance.CreateProjectile(Position, Direction, DevMath.DevMath.Lerp(MIN_PROJECTILE_START_VELOCITY, MAX_PROJECTILE_START_VELOCITY, p), DevMath.DevMath.Lerp(MIN_PROJECTILE_START_ACCELERATION, MAX_PROJECTILE_START_ACCELERATION, p));

            chargeTime = .0f;
        }
    }
예제 #6
0
 public static Vector2 ToUnity(this DevMath.Vector2 v)
 {
     return(new Vector2(v.x, v.y));
 }
예제 #7
0
 public void CreateProjectile(DevMath.Vector2 position, DevMath.Vector2 direction, float startVelocity, float acceleration)
 {
     projectiles.Add(new Projectile(position, direction, startVelocity, acceleration));
 }