public static Quaternion GetBearingRotation(this TileVector tv) { Vector3 facing = tv.ToVector3(); float angle = Vector3.Angle(North, tv.ToVector3()); if (angle == 180) { return(Quaternion.AngleAxis(angle, Up)); } else { return(Quaternion.FromToRotation(North, tv.ToVector3())); } }
public void SetPositionAndOrientation(TileVector tv, CardinalDirection dir) { Position = tv.ToVector3(); Rotation = dir.GetBearingRotation(); TilePos = tv; _facing = dir; }
public MoveAnimation(Unit unit, TileVector origin, TileVector destination, CardinalDirection direction, int energyCost) { _avatar = unit.Avatar; _targetPos = destination.ToVector3(); _targetRot = direction.GetBearingRotation(); // TODO: implement energycost, advanced bar animation _targetEnergy = unit.Energy; _isStep = origin != destination; moveSound = _avatar.moveSound; }
void MakeTile(TileVector pos) { var newObj = Instantiate(TileObjects[_rng.Next(TileObjects.Length)]); // position and scale newObj.transform.position = pos.ToVector3(); newObj.transform.localScale = new Vector3(_scaleFactor, _scaleFactor, _scaleFactor); // rotate, to break up repetition newObj.transform.rotation = RandomDirection().GetBearingRotation(); // apply jitter (if enabled) if (JitterFactor > 0) { newObj.transform.position += GetJitter(pos); } // finally, add to our set of tile vectors _map.Add(pos); }
public MoveAnimation(Mech unit, TileVector from, TileVector to) { _targetRot = (to - from).GetBearingRotation(); _targetPos = to.ToVector3(); _unit = unit; }