public void Move() { if (CanMove.CanMove()) { Vector3 direction = (player.transform.position - transform.position).normalized; direction.x *= 0.5f; direction.y *= 1.8f; transform.position += direction * speed * Time.deltaTime; } }
public override void WriteXml(System.Xml.XmlWriter writer) { base.WriteXml(writer); if (!string.IsNullOrWhiteSpace(this.Description)) { writer.WriteAttributeString("Description", this.Description); } if (!CanMove) { writer.WriteAttributeString("CanMove", CanMove.ToString()); } }
protected override void OnUpdate() { var group = World.GetExistingSystem <ServerSimulationSystemGroup>(); var tick = group.ServerTick; var deltaTime = Time.DeltaTime; Entities.ForEach((ref Dash dash, ref Usable usable, ref OwningPlayer player, ref Cooldown cooldown) => { if (usable.inuse) { if (cooldown.timer == cooldown.duration) { // just used ability DestinationComponent dest = EntityManager.GetComponentData <DestinationComponent>(player.Value); CanMove canmove = EntityManager.GetComponentData <CanMove>(player.Value); dest.Valid = false; canmove.Value = false; EntityManager.SetComponentData <DestinationComponent>(player.Value, dest); EntityManager.SetComponentData <CanMove>(player.Value, canmove); } Debug.Log("DashSystem inuse is true"); GamePosition pos = EntityManager.GetComponentData <GamePosition>(player.Value); Rotation rot = EntityManager.GetComponentData <Rotation>(player.Value); float3 direction = math.rotate(rot.Value, dash.dir); pos.Value += direction.xz * dash.speed * deltaTime; dash.distance_traveled += dash.speed * deltaTime; EntityManager.SetComponentData <GamePosition>(player.Value, pos); if (dash.distance_traveled >= dash.max_distance) { usable.inuse = false; EntityManager.SetComponentData <CanMove>(player.Value, new CanMove { Value = true }); if (cooldown.timer < 0) { usable.canuse = true; } dash.distance_traveled = 0; } } }); }
private void Start() { rd2 = GetComponent <Rigidbody2D>(); isSet = false; init = true; Gctrl = GameObject.Find("GameCtrl").GetComponent <GameCtrl>(); CM = GameObject.Find("Pos").GetComponent <CanMove>(); gameObject.GetComponent <SpriteRenderer>().sortingOrder = Gctrl.layer; Bctrl = GameObject.Find("BackGroundCtrl").GetComponent <BackGroundCtrl>(); Uctrl = GameObject.Find("EventSystem").GetComponent <UICtrl>(); if (Gctrl.isFeverTime == true) { StartCoroutine(FeverCoroutine()); } }
// Start is called before the first frame update void Start() { tan = FirstSpeed; // 画面の縦横の半分 screenSizeHalf.x = Screen.width / 2f; screenSizeHalf.y = Screen.height / 2f; // マウスの初期位置 mPos = new Vector2(0.0f, 0.0f); /*mPos = Input.mousePosition - screenSizeHalf; * previousRad = Mathf.Atan2(mPos.x, mPos.y);*/ canmove = kogane_wait.GetComponent <CanMove>(); MotiWind = MotiSound.GetComponent <CriAtomSource>(); }
void Start() { isTouchAva = true; isStarted = false; feverTime = 5; canCountForBack = 0; isRandInit = false; isFeverOver = false; tmpCount = 0; CanCount = 0; isFeverTime = false; isTouch = true; level = 1; UserTouch = true; layer = 0; Score = 0; CM = GameObject.Find("Pos").GetComponent <CanMove>(); Uctrl = GameObject.Find("EventSystem").GetComponent <UICtrl>(); }
private void Awake() { moveComponent = GetComponent<CanMove>(); }
void Start() { canMoove = GetComponent<CanMove>(); canTakeDamage = GetComponent<CanTakeDamage>(); canTakeDamage.healthChanged += GoFasterIfHealthIsLow; }
void Start() { Vector3 pos = transform.position; healthBar = Instantiate(healthBarSPrite,new Vector3(pos.x - 0.15f, pos.y + 0.15f, 0f), transform.rotation) as GameObject; healthBar.transform.parent = gameObject.transform; healthBar.gameObject.transform.localScale = new Vector3(0,1,1); playerMoney = PlayerMoney.instance; canMove = GetComponent<CanMove>(); ionShield = GetComponent<IonShield>(); flash = GetComponent<Flash>(); }
public void SetMoveFunctions(CanMove <T1, T2> canMove0, GameMove <T1, T2> doMove0, GameMove <T1, T2> undoMove0) { canMove = canMove0; doMove = doMove0; undoMove = undoMove0; }
protected virtual void Awake() { moveComponent = GetComponent<CanMove>(); animator = GetComponent<Animator>(); }
private void Awake() { moveComponent = GetComponent <CanMove>(); }
/// <summary> /// 输入 起始点,最远距离,返回点集合,可以使用的点的集合,之后再使用BFS走到对应点上 /// </summary> public List <Pos> ShowAera(Pos start, int distanse, CanMove canMoveFunc) { int y = blocks.GetLength(1);//获取指定维度中的元素个数,这里也就是列数了。 int x = blocks.GetUpperBound(0) + 1; bfs = new int[x, y]; //初始化 for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { bfs[i, j] = short.MaxValue; } } List <Pos> queue = new List <Pos>(); List <Pos> avaliablePos = new List <Pos>(); bfs[start.x, start.y] = 0; queue.Add(start); Pos p = start; bool flag = true; //c# 7.0才支持的本地方法....这个 Func func = (int ox, int oy) => { if (isInMap(p + new Pos(ox, oy)) && canMoveFunc(p + new Pos(ox, oy)) && bfs[p.x + ox, p.y + oy] == short.MaxValue) { if (bfs[p.x, p.y] + 1 > distanse) { //queue.Remove(p); flag = false; return(false); } bfs[p.x + ox, p.y + oy] = bfs[p.x, p.y] + 1; //m.blocks[p.x + ox, p.y + oy].isArea = true; Pos np = new Pos(p.x + ox, p.y + oy); queue.Add(np); avaliablePos.Add(new Pos(p.x + ox, p.y + oy)); } return(true); }; while (flag) { if (queue.Count == 0) { avaliablePos.Add(start); return(avaliablePos); } else { if (debugMode) { Show(); } //取第一个点,值最小的点 p = queue[0]; //右边 如果右面为撞墙则返回np func(1, 0); func(-1, 0); func(0, 1); func(0, -1); //去掉这个点 queue.Remove(p); } } avaliablePos.Add(start); return(avaliablePos); }
/// <summary> /// 基于距离判定的优化DFS算法 起点终点,返回路径点列表 /// </summary> public List <Pos> BFS(Pos start, Pos stop, CanMove canMoveFunc) { int x = blocks.GetLength(0); //获取维数,这里指行数 int y = blocks.GetLength(1); //获取指定维度中的元素个数,这里也就是列数了。 //int x = blocks.GetUpperBound(0) + 1; bfs = new int[x, y]; for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { bfs[i, j] = short.MaxValue; } } List <Pos> queue = new List <Pos>(); bfs[start.x, start.y] = 0; queue.Add(start); Pos p = start; bool flag = true; Func func = (int ox, int oy) => { if (canMoveFunc(p + new Pos(ox, oy)) && isInMap(p + new Pos(ox, oy)) && bfs[p.x + ox, p.y + oy] == short.MaxValue) { bfs[p.x + ox, p.y + oy] = bfs[p.x, p.y] + 1; if (debugMode) { blocks[p.x + ox, p.y + oy].BackColor = ConsoleColor.Blue; } Pos np = new Pos(p.x + ox, p.y + oy); if (np == stop) { flag = false; } else if (np.Distanse(stop) <= p.Distanse(stop)) { queue.Insert(0, np); } else { queue.Add(np); } } else if ((p + new Pos(ox, oy)) == stop) { flag = false; } return(true); }; while (flag) { if (queue.Count == 0) { return(new List <Pos>() { stop }); } else { if (debugMode) { Show(); } //初始化当前这个点 //取第一个点,值最小的点 p = queue[0]; //取最后一个点 深度优先 //p = queue.Last(); func(1, 0); func(-1, 0); func(0, 1); func(0, -1); //去掉这个点 queue.Remove(p); } } if (debugMode) { Show(); Console.ReadKey(); } //搜寻路径 List <Pos> path = new List <Pos>(); path.Add(stop); flag = true; while (flag) { if (debugMode) { Show(); } p = path.First(); if (p == start) { return(path); } List <Pos> min = new List <Pos>(); min.Add(p); //左面 if (bfs[p.x - 1, p.y] < bfs[min.Last().x, min.Last().y]) { min.Add(new Pos(p.x - 1, p.y)); } if (bfs[p.x + 1, p.y] < bfs[min.Last().x, min.Last().y]) { min.Add(new Pos(p.x + 1, p.y)); } if (bfs[p.x, p.y - 1] < bfs[min.Last().x, min.Last().y]) { min.Add(new Pos(p.x, p.y - 1)); } if (bfs[p.x, p.y + 1] < bfs[min.Last().x, min.Last().y]) { min.Add(new Pos(p.x, p.y + 1)); } if (debugMode) { blocks[min.Last().x, min.Last().y].BackColor = ConsoleColor.Red; } path.Insert(0, new Pos(min.Last().x, min.Last().y)); } return(path); }
protected virtual void Awake() { moveComponent = GetComponent <CanMove>(); animator = GetComponent <Animator>(); }