/// <summary> /// Gets the options of the normal cube. /// </summary> /// <value> /// The options of commands of the chosen cube. /// </value> public virtual Command[] GetOptions() { if (transform.forward != Vector3.down && !Level.Singleton.ContainsSensor(new Vector3Int(transform.position).ToVector3)) { setMood(Mood.Happy); } List <Command> options = new List <Command>(); Vector3Int pos; if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.forward, out pos, jumpHeight)) { options.Add(new Move(this, pos)); } if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.back, out pos, jumpHeight)) { options.Add(new Move(this, pos)); } if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.right, out pos, jumpHeight)) { options.Add(new Move(this, pos)); } if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.left, out pos, jumpHeight)) { options.Add(new Move(this, pos)); } return(options.ToArray()); }
public override Command[] GetOptions() { if (transform.forward != Vector3.down && (!Level.Singleton.ContainsElement(transform.position + Vector3.down) || !Level.Singleton.getEntity(transform.position + Vector3.down) is BasicSensor)) { setMood(Mood.Happy); } List <Command> commands = new List <Command>(); if (!stuck || !CubeHelper.IsFree(new Vector3Int(transform.position + Vector3.down))) { commands = CubeHelper.GetListOptions(base.GetOptions()); Vector3Int pos; if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.forward, out pos, GetJumpHeight())) { if (new Vector3Int(transform.position).y - pos.y > 1) { pos = new Vector3Int(transform.position + Vector3.forward); pos.y--; commands.Add(new Move(this, pos)); } } if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.back, out pos, GetJumpHeight())) { if (new Vector3Int(transform.position).y - pos.y > 1) { pos = new Vector3Int(transform.position + Vector3.back); pos.y--; commands.Add(new Move(this, pos)); } } if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.right, out pos, GetJumpHeight())) { if (new Vector3Int(transform.position).y - pos.y > 1) { pos = new Vector3Int(transform.position + Vector3.right); pos.y--; commands.Add(new Move(this, pos)); } } if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.left, out pos, GetJumpHeight())) { if (new Vector3Int(transform.position).y - pos.y > 1) { pos = new Vector3Int(transform.position + Vector3.left); pos.y--; commands.Add(new Move(this, pos)); } } } else { Vector3Int pos; if (CubeHelper.CheckAvailablePosition(transform.position + Vector3.down, out pos, GetJumpHeight())) { commands.Add(new Move(this, pos)); } } return(commands.ToArray()); }
public void MoveTo(Vector3 direction) { Vector3Int pos; if (CubeHelper.CheckAvailablePosition(Position + direction, out pos, 1)) { cc.NotifyMoveTO(new Move(this, pos)); // finished = false; /*Level.Singleton.RemoveEntity(Position); * Debug.Log(pos.ToVector3); * Level.Singleton.AddEntity(this,pos.ToVector3); * transform.position = pos.ToVector3;*/ } else { Debug.Log(direction); moveEvent.Set(); } }