备份CatanBuilding瘦身独立工程
This commit is contained in:
56
Assets/Scripts/EventWashing/Tools/BrushPointerTouch.cs
Normal file
56
Assets/Scripts/EventWashing/Tools/BrushPointerTouch.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using CW.Common;
|
||||
using PaintCore;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace game
|
||||
{
|
||||
[RequireComponent(typeof(CwHitPointers))]
|
||||
public class BrushPointerTouch : CwPointer
|
||||
{
|
||||
/// <summary>If you want the paint to appear above the finger, then you can set this number to something positive.</summary>
|
||||
public Vector2 Offset { set { offset = value; } get { return offset; } }
|
||||
[SerializeField] private Vector2 offset = Vector2.zero;
|
||||
|
||||
protected virtual void Update()
|
||||
{
|
||||
CwInputManager.Finger finger;
|
||||
|
||||
bool isFollowing = false;
|
||||
Vector2 screenPosition = Vector2.zero;
|
||||
|
||||
for (var i = 0; i < CwInput.GetTouchCount(); i++)
|
||||
{
|
||||
int index;
|
||||
Vector2 position;
|
||||
float pressure;
|
||||
bool set;
|
||||
|
||||
if (EventSystem.current == null) return;
|
||||
|
||||
if (EventSystem.current.IsPointerOverGameObject()) return;
|
||||
|
||||
CwInput.GetTouch(i, out index, out position, out pressure, out set);
|
||||
|
||||
position += offset * CwInputManager.ScaleFactor;
|
||||
|
||||
var down = GetFinger(index, position, pressure, set, out finger);
|
||||
|
||||
cachedHitPointers.HandleFingerUpdate(finger, down, set == false);
|
||||
|
||||
screenPosition = position;
|
||||
isFollowing = true;
|
||||
|
||||
if (set == false)
|
||||
{
|
||||
TryNullFinger(index);
|
||||
}
|
||||
}
|
||||
|
||||
if (isFollowing) FishingYachtAct.Publish<EventWashingGestureFollowPositionData>(new EventWashingGestureFollowPositionData(screenPosition, true));
|
||||
else FishingYachtAct.Publish<EventWashingGestureFollowPositionData>(new EventWashingGestureFollowPositionData(screenPosition, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user