Пример #1
0
        void OnDrawGizmosSelected()
        {
            var iso_world = isoWorld;

            if (iso_world && iso_world.isShowDepends)
            {
                for (int i = 0, e = Internal.SelfDepends.Count; i < e; ++i)
                {
                    IsoUtils.DrawLine(
                        Internal.QTBounds.center,
                        Internal.SelfDepends[i].Internal.QTBounds.center,
                        Color.yellow,
                        Color.cyan,
                        0.25f);
                }
                for (int i = 0, e = Internal.TheirDepends.Count; i < e; ++i)
                {
                    IsoUtils.DrawLine(
                        Internal.QTBounds.center,
                        Internal.TheirDepends[i].Internal.QTBounds.center,
                        Color.yellow,
                        Color.cyan,
                        0.75f);
                }
            }
        }
Пример #2
0
        void OnDrawGizmosSelected()
        {
            var iso_object = GetComponent <IsoObject>();

            if (iso_object && iso_object.isoWorld)
            {
                if (radius * 2 < height)
                {
                    IsoUtils.DrawIsoCube(
                        iso_object.isoWorld,
                        iso_object.position + offset,
                        new Vector3(radius * 2.0f, radius * 2.0f, height - radius),
                        Color.green);
                    IsoUtils.DrawIsoSphere(
                        iso_object.isoWorld,
                        iso_object.position + offset - IsoUtils.Vec3FromZ(height * 0.5f - radius),
                        radius,
                        Color.green);
                    IsoUtils.DrawIsoSphere(
                        iso_object.isoWorld,
                        iso_object.position + offset + IsoUtils.Vec3FromZ(height * 0.5f - radius),
                        radius,
                        Color.green);
                }
                else
                {
                    IsoUtils.DrawIsoSphere(
                        iso_object.isoWorld,
                        iso_object.position + offset,
                        radius,
                        Color.green);
                }
            }
        }
Пример #3
0
		public IsoCollision(Collision collision) {
			collider         = IsoUtils.IsoConvertCollider(collision.collider);
			contacts         = IsoUtils.IsoConvertContactPoints(collision.contacts);
			gameObject       = IsoUtils.IsoConvertGameObject(collision.gameObject);
			relativeVelocity = collision.relativeVelocity;
			rigidbody        = IsoUtils.IsoConvertRigidbody(collision.rigidbody);
		}
 public IItem AddItem(IsoRect bounds, T content)
 {
     if (bounds.x.size > 0.0f && bounds.y.size > 0.0f)
     {
         if (_rootNode == null)
         {
             var initial_side = IsoUtils.Vec2From(
                 IsoUtils.Vec2MaxF(bounds.size));
             var initial_bounds = new IsoRect(
                 bounds.center - initial_side * 2.0f,
                 bounds.center + initial_side * 2.0f);
             _rootNode = _nodePool.Take().Init(null, initial_bounds);
         }
         Item item;
         while (!_rootNode.AddItem(bounds, content, out item, _nodePool, _itemPool))
         {
             GrowUp(
                 bounds.center.x < _rootNode.SelfBounds.center.x,
                 bounds.center.y < _rootNode.SelfBounds.center.y);
         }
         return(item);
     }
     else
     {
         return(_itemPool.Take().Init(null, bounds, content));
     }
 }
Пример #5
0
		protected override void Reset() {
			base.Reset();
			var iso_object = GetComponent<IsoObject>();
			radius = iso_object ? IsoUtils.Vec3MinF(iso_object.size) * 0.5f : 0.0f;
			offset = iso_object ? iso_object.size * 0.5f : Vector3.zero;
			EditorUtility.SetDirty(this);
		}
Пример #6
0
 public IsoRaycastHit(RaycastHit hit_info) : this()
 {
     collider  = IsoUtils.IsoConvertCollider(hit_info.collider);
     distance  = hit_info.distance;
     normal    = hit_info.normal;
     point     = hit_info.point;
     rigidbody = IsoUtils.IsoConvertRigidbody(hit_info.rigidbody);
 }
Пример #7
0
		void Awake() {
			IsoUtils.GetOrCreateComponent<IsoFakeRigidbody>(fakeObject).Init(this);
			_realRigidbody                        = IsoUtils.GetOrCreateComponent<Rigidbody>(fakeObject);
			_realRigidbody.freezeRotation         = true;
			_realRigidbody.isKinematic            = isKinematic;
			_realRigidbody.interpolation          = interpolation;
			_realRigidbody.collisionDetectionMode = collisionDetectionMode;
		}
Пример #8
0
		void SetupSectorSize() {
			_sectorsSize = 0.0f;
			var visibles_iter = _visibles.GetEnumerator();
			while ( visibles_iter.MoveNext() ) {
				_sectorsSize += IsoUtils.Vec2MaxF(visibles_iter.Current.Internal.ScreenRect.size);
			}
			var min_sector_size = IsoToScreen(IsoUtils.vec3OneX).x - IsoToScreen(Vector3.zero).x;
			_sectorsSize = Mathf.Round(Mathf.Max(min_sector_size, _sectorsSize / _visibles.Count));
		}
Пример #9
0
    // Update is called once per frame
    void Update()
    {
        float forwardX = Target.position.x + Lead;

        float targetX = Mathf.Max((forwardX * 2 + IsoUtils.ScreenToIso(Input.mousePosition).x) / 3, forwardX);

        transform.position = Vector3.Lerp(transform.position,
                                          new Vector3(targetX, transform.position.y, transform.position.z), Time.deltaTime * MaxSpeed);
    }
Пример #10
0
		void FixScreenRect() {
			if ( isoWorld ) {
				var l = isoWorld.IsoToScreen(position + IsoUtils.Vec3FromY(size.y)).x;
				var r = isoWorld.IsoToScreen(position + IsoUtils.Vec3FromX(size.x)).x;
				var b = isoWorld.IsoToScreen(position).y;
				var t = isoWorld.IsoToScreen(position + size).y;
				Internal.ScreenRect = new Rect(l, b, r - l, t - b);
			}
		}
Пример #11
0
		void OnDrawGizmosSelected() {
			var iso_object = GetComponent<IsoObject>();
			if ( iso_object && iso_object.isoWorld ) {
				IsoUtils.DrawCube(
					iso_object.isoWorld,
					iso_object.position + offset,
					size,
					Color.green, Vector3.zero);
			}
		}
Пример #12
0
		void OnDrawGizmosSelected() {
			var iso_object = GetComponent<IsoObject>();
			if ( iso_object && iso_object.isoWorld ) {
				IsoUtils.DrawCube(
					iso_object.isoWorld,
					iso_object.position + offset,
					size,
					Color.blue, incline);
			}
		}
Пример #13
0
		void OnDrawGizmosSelected() {
			var iso_object = GetComponent<IsoObject>();
			if ( iso_object && iso_object.isoWorld ) {
				IsoUtils.DrawSphere(
					iso_object.isoWorld,
					iso_object.position + offset,
					radius,
					Color.green);
			}
		}
Пример #14
0
		void Update() {
			if ( !IsoUtils.Vec3Approximately(_lastSize, _size) ) {
				size = _size;
			}
			if ( !IsoUtils.Vec3Approximately(_lastPosition, _position) ) {
				position = _position;
			}
			if ( !IsoUtils.Vec2Approximately(_lastTransPos, transform.position) ) {
				FixIsoPosition();
			}
		}
Пример #15
0
		void SetupObjectsSectors() {
			_sectorsMinNumPos = IsoUtils.Vec2From(float.MaxValue);
			_sectorsMaxNumPos = IsoUtils.Vec2From(float.MinValue);
			var visibles_iter = _visibles.GetEnumerator();
			while ( visibles_iter.MoveNext() ) {
				var iso_internal = visibles_iter.Current.Internal;
				iso_internal.MinSector = IsoUtils.Vec3DivFloor(iso_internal.ScreenRect.min, _sectorsSize);
				iso_internal.MaxSector = IsoUtils.Vec3DivCeil (iso_internal.ScreenRect.max, _sectorsSize);
				_sectorsMinNumPos = IsoUtils.Vec3Min(_sectorsMinNumPos, iso_internal.MinSector);
				_sectorsMaxNumPos = IsoUtils.Vec3Max(_sectorsMaxNumPos, iso_internal.MaxSector);
			}
			_sectorsNumPosCount = _sectorsMaxNumPos - _sectorsMinNumPos;
		}
Пример #16
0
        // ---------------------------------------------------------------------
        //
        // Public
        //
        // ---------------------------------------------------------------------

        public void FixTransform()
        {
            var iso_world        = isoWorld;
            var cached_transform = FixCachedTransform();

            if (iso_world && cached_transform)
            {
                cached_transform.position = IsoUtils.Vec3ChangeZ(
                    iso_world.IsoToScreen(position),
                    cached_transform.position.z);
                FixScreenBounds();
                MartDirtyIsoWorld();
            }
        }
Пример #17
0
		public void FixTransform() {
		#if UNITY_EDITOR
			if ( !Application.isPlaying && isAlignment ) {
				_position = tilePosition;
			}
		#endif
			if ( isoWorld ) {
				transform.position = IsoUtils.Vec3ChangeZ(
					isoWorld.IsoToScreen(position),
					transform.position.z);
				FixScreenRect();
			}
			FixLastProperties();
			MartDirtyIsoWorld();
		}
Пример #18
0
        // ---------------------------------------------------------------------
        //
        // Private
        //
        // ---------------------------------------------------------------------

        void FixScreenBounds()
        {
            var iso_world = isoWorld;

            if (iso_world)
            {
                var l = iso_world.IsoToScreen(position + IsoUtils.Vec3FromY(size.y)).x;
                var r = iso_world.IsoToScreen(position + IsoUtils.Vec3FromX(size.x)).x;
                var b = iso_world.IsoToScreen(position).y;
                var t = iso_world.IsoToScreen(position + size).y;
                Internal.QTBounds.Set(l, b, r, t);
            }
            else
            {
                Internal.QTBounds.Set(0.0f, 0.0f, 0.0f, 0.0f);
            }
        }
Пример #19
0
		bool IsIsoObjectDepends(Vector3 a_min, Vector3 a_size, Vector3 b_min, Vector3 b_size) {
			var a_max = a_min + a_size;
			var b_max = b_min + b_size;
			var a_yesno = a_max.x > b_min.x && a_max.y > b_min.y && b_max.z > a_min.z;
			var b_yesno = b_max.x > a_min.x && b_max.y > a_min.y && a_max.z > b_min.z;
			if ( a_yesno && b_yesno ) {
				var da_p = new Vector3(a_max.x - b_min.x, a_max.y - b_min.y, b_max.z - a_min.z);
				var db_p = new Vector3(b_max.x - a_min.x, b_max.y - a_min.y, a_max.z - b_min.z);
				var dp_p = a_size + b_size - IsoUtils.Vec3Abs(da_p - db_p);
				if ( dp_p.x <= dp_p.y && dp_p.x <= dp_p.z ) {
					return da_p.x > db_p.x;
				} else if ( dp_p.y <= dp_p.x && dp_p.y <= dp_p.z ) {
					return da_p.y > db_p.y;
				} else {
					return da_p.z > db_p.z;
				}
			}
			return a_yesno;
		}
Пример #20
0
        void OnDrawGizmos()
        {
            var iso_world = isoWorld;

            if (iso_world)
            {
                if (iso_world.isShowIsoBounds)
                {
                    IsoUtils.DrawIsoCube(
                        iso_world,
                        position + size * 0.5f,
                        size,
                        Color.red);
                }
                if (iso_world.isShowScreenBounds)
                {
                    IsoUtils.DrawRect(
                        Internal.QTBounds,
                        Color.green);
                }
            }
        }
Пример #21
0
		public IsoContactPoint(ContactPoint contact_point) : this() {
			normal        = contact_point.normal;
			otherCollider = IsoUtils.IsoConvertCollider(contact_point.otherCollider);
			point         = contact_point.point;
			thisCollider  = IsoUtils.IsoConvertCollider(contact_point.thisCollider);
		}
Пример #22
0
 public Vector3 MouseIsoTilePosition(Camera camera, float iso_z)
 {
     return(IsoUtils.Vec3Floor(MouseIsoPosition(camera, iso_z)));
 }
Пример #23
0
 public Vector3 MouseIsoTilePosition(Camera camera)
 {
     return(IsoUtils.Vec3Floor(MouseIsoPosition(camera)));
 }
Пример #24
0
 public Vector3 MouseIsoTilePosition(float iso_z)
 {
     return(IsoUtils.Vec3Floor(MouseIsoPosition(iso_z)));
 }
Пример #25
0
        // ---------------------------------------------------------------------
        //
        // MouseIsoTilePosition
        //
        // ---------------------------------------------------------------------

        public Vector3 MouseIsoTilePosition()
        {
            return(IsoUtils.Vec3Floor(MouseIsoPosition()));
        }
Пример #26
0
 public Vector3 TouchIsoTilePosition(int finger_id, Camera camera, float iso_z)
 {
     return(IsoUtils.Vec3Floor(TouchIsoPosition(finger_id, camera, iso_z)));
 }
Пример #27
0
        // ---------------------------------------------------------------------
        //
        // TouchIsoTilePosition
        //
        // ---------------------------------------------------------------------

        public Vector3 TouchIsoTilePosition(int finger_id)
        {
            return(IsoUtils.Vec3Floor(TouchIsoPosition(finger_id)));
        }
Пример #28
0
 public Vector3 ScreenToIso(Vector2 pos, float iso_z)
 {
     return(IsoUtils.Vec3ChangeZ(
                ScreenToIso(new Vector2(pos.x, pos.y - iso_z * tileHeight)),
                iso_z));
 }
Пример #29
0
		void PlaceIsoObject(IsoObject iso_object, float depth) {
			var trans = iso_object.transform;
			trans.position = IsoUtils.Vec3ChangeZ(trans.position, depth);
		}
Пример #30
0
		void OnDrawGizmos() {
			if ( isShowBounds && isoWorld ) {
				IsoUtils.DrawCube(isoWorld, position + size * 0.5f, size, Color.red, Vector3.zero);
			}
		}