Basicly the title says everything this issue is repeted in lines: 32,70/47,24/53,36/55,36/85,39
File where the issue is linked to
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseController : MonoBehaviour {
public GameObject CircularCursor;
Vector3 lastFramePosition;
Vector3 dragStartPosition;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Vector3 currentFramePosition = Camera.main.ScreenToWorldPoint (Input.mousePosition);
currentFramePosition.z = 0;
UpdateCursor();
UpdateDragging();
UpdateCameraMovement();
lastFramePosition = Camera.main.ScreenToWorldPoint( Input.mousePosition );
lastFramePosition.z = 0;
}
void UpdateCursor() {
// Update the circle cursor position
Tile tileUnderMouse = WorldController.Instance.GetTileAtWorldCoord(currentFramePosition);
if(tileUnderMouse != null) {
CircularCursor.SetActive(true);
Vector3 cursorPosition = new Vector3(tileUnderMouse.X, tileUnderMouse.Y, 0);
CircularCursor.transform.position = cursorPosition;
}
else {
// Mouse is outside of the valid tile space, so hide the cursor.
CircularCursor.SetActive(false);
}
}
void UpdateDragging() {
// Start Drag
if( Input.GetMouseButtonDown(0) ) {
dragStartPosition = currentFramePosition;
}
// End Drag
if( Input.GetMouseButtonUp(0) ) {
int start_x = Mathf.FloorToInt( dragStartPosition.x );
int end_x = Mathf.FloorToInt( currentFramePosition.x );
int start_y = Mathf.FloorToInt( dragStartPosition.y );
int end_y = Mathf.FloorToInt( currentFramePosition.y );
// We may be dragging in the "wrong" direction, so flip things if needed.
if(end_x < start_x) {
int tmp = end_x;
end_x = start_x;
start_x = tmp;
}
if(end_y < start_y) {
int tmp = end_y;
end_y = start_y;
start_y = tmp;
}
// Loop through all the tiles
for (int x = start_x; x <= end_x; x++) {
for (int y = start_y; y <= end_y; y++) {
Tile t = WorldController.Instance.world.GetTileAt(x, y);
if(t != null) {
t.Type = Tile.TileType.Grass;
}
}
}
}
}
void UpdateCameraMovement() {
// Handle screen panning
if( Input.GetMouseButton(1) || Input.GetMouseButton(2) ) { // Right or Middle Mouse Button
Vector3 diff = lastFramePosition - currentFramePosition;
Camera.main.transform.Translate( diff );
}
}
}
Thanks in advanced