/// <summary>移动地图角色的方法,改变角色位置并调用charactor里的方法重写字典值,图书馆传送和普通移动都会调用这个方法 /// /// </summary> public virtual void ChangePosition(int step) { if (Charactor.Instance().charactordata.charactorstate == MoveState.MotionLess) { Charactor.Instance().Move(GetComponent <Transform>().position, -step); } else { Debug.Log("角色非静止"); } }
/// <summary>检测被点击的地格是否在角色相邻区域, /// /// </summary> public override void OnClick() { if (Charactor.Instance().aroundlist.ContainsValue(this)) { ChangePosition(1); } else { Debug.Log("这个格子不在角色相邻区域,无法移动"); } }
/// <summary>获取角色实例,并初始化AroundList字典 /// /// </summary> private void Start() { // Charactor.Instance() = GameObject.Find("Charactor").GetComponent<Charactor>(); Charactor.Instance().aroundlist.Add("0,1", null); Charactor.Instance().aroundlist.Add("0,-1", null); Charactor.Instance().aroundlist.Add("1,0", null); Charactor.Instance().aroundlist.Add("-1,0", null); Charactor.Instance().aroundlist.Add("-1,1", null); Charactor.Instance().aroundlist.Add("1,-1", null); Charactor.Instance().CharactorInitalize(); }
public override void OnClick() { if (Charactor.Instance().aroundlist.ContainsValue(this)) { ChangePosition(1); Debug.Log("获取合法"); ///Todo:调用MapManager里的charactor实例的获取道具方法 } else { Debug.Log("不在相邻地格,无法取得道具"); } }