Ai
1 Star 0 Fork 3

wayfarer/rongYaoDaLuCode

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
TBSwipe.cs 3.05 KB
一键复制 编辑 原始数据 按行查看 历史
liyonghelpme 提交于 2015-05-19 23:14 +08:00 . rong Yao Da Lu Some Code For Game
using System;
using System.Runtime.CompilerServices;
using UnityEngine;
[AddComponentMenu("FingerGestures/Toolbox/Swipe")]
public class TBSwipe : TBComponent
{
private FingerGestures.SwipeDirection direction;
public float minVelocity;
public bool swipeDown = true;
public TBComponent.Message swipeDownMessage = new TBComponent.Message("OnSwipeDown", false);
public bool swipeLeft = true;
public TBComponent.Message swipeLeftMessage = new TBComponent.Message("OnSwipeLeft", false);
public TBComponent.Message swipeMessage = new TBComponent.Message("OnSwipe");
public bool swipeRight = true;
public TBComponent.Message swipeRightMessage = new TBComponent.Message("OnSwipeRight", false);
public bool swipeUp = true;
public TBComponent.Message swipeUpMessage = new TBComponent.Message("OnSwipeUp", false);
private float velocity;
public event TBComponent.EventHandler<TBSwipe> OnSwipe;
private TBComponent.Message GetMessageForSwipeDirection(FingerGestures.SwipeDirection direction)
{
if (direction == FingerGestures.SwipeDirection.Left)
{
return this.swipeLeftMessage;
}
if (direction == FingerGestures.SwipeDirection.Right)
{
return this.swipeRightMessage;
}
if (direction == FingerGestures.SwipeDirection.Up)
{
return this.swipeUpMessage;
}
return this.swipeDownMessage;
}
public bool IsValid(FingerGestures.SwipeDirection direction)
{
if (direction == FingerGestures.SwipeDirection.Left)
{
return this.swipeLeft;
}
if (direction == FingerGestures.SwipeDirection.Right)
{
return this.swipeRight;
}
if (direction == FingerGestures.SwipeDirection.Up)
{
return this.swipeUp;
}
return ((direction == FingerGestures.SwipeDirection.Down) && this.swipeDown);
}
public bool RaiseSwipe(int fingerIndex, Vector2 fingerPos, FingerGestures.SwipeDirection direction, float velocity)
{
if (velocity < this.minVelocity)
{
return false;
}
if (!this.IsValid(direction))
{
return false;
}
base.FingerIndex = fingerIndex;
base.FingerPos = fingerPos;
this.Direction = direction;
this.Velocity = velocity;
if (this.OnSwipe != null)
{
this.OnSwipe(this);
}
base.Send(this.swipeMessage);
base.Send(this.GetMessageForSwipeDirection(direction));
return true;
}
public FingerGestures.SwipeDirection Direction
{
get
{
return this.direction;
}
protected set
{
this.direction = value;
}
}
public float Velocity
{
get
{
return this.velocity;
}
protected set
{
this.velocity = value;
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wayfarer/rongYaoDaLuCode.git
git@gitee.com:wayfarer/rongYaoDaLuCode.git
wayfarer
rongYaoDaLuCode
rongYaoDaLuCode
master

搜索帮助