Пример #1
0
        private float CalcRotationY(WorldCoordinatesComponent worldCoordinates, Vector3 dir, float rotationSpeed)
        {
            Quaternion from = new Quaternion(worldCoordinates.rx, worldCoordinates.ry, worldCoordinates.rz, worldCoordinates.rw);
            Quaternion to   = Quaternion.LookRotation(dir, Vector3.up);
            Quaternion res  = Quaternion.RotateTowards(from, to, rotationSpeed * Time.deltaTime);

            return(Mathf.DeltaAngle(from.eulerAngles.y, res.eulerAngles.y));
        }
Пример #2
0
        private Vector3 CalcVector3(WorldCoordinatesComponent attacker, WorldCoordinatesComponent defender)
        {
            Vector3 res = new Vector3(
                defender.x - attacker.x,
                defender.y - attacker.y,
                defender.z - attacker.z
                ).normalized;

            return(res);
        }
Пример #3
0
        private float CalcRotationY(WorldCoordinatesComponent attacker, WorldCoordinatesComponent defender, WeaponComponent weapon, WeaponRotation wr)
        {
            Vector3 dir = CalcVector3(attacker, defender);

            Quaternion from = Quaternion.Euler(0, wr.ry, 0);
            //Quaternion from = new Quaternion(attacker.rx, attacker.ry, attacker.rz, attacker.rw);
            Quaternion to = Quaternion.LookRotation(dir, Vector3.up);

            return(Mathf.DeltaAngle(from.eulerAngles.y, to.eulerAngles.y));
        }
Пример #4
0
        private Vector3 CalcVector3(WorldCoordinatesComponent coord, HexCellBehaviour to)
        {
            Vector3 res = new Vector3(
                to.transform.position.x - coord.x,
                to.transform.position.y - coord.y,
                to.transform.position.z - coord.z
                ).normalized;

            return(res);
        }
Пример #5
0
 private float CalcSqrDistance(WorldCoordinatesComponent coord, HexCellBehaviour to)
 {
     return((new Vector3(coord.x, coord.y, coord.z) - to.transform.position).sqrMagnitude);
 }