Exemplo n.º 1
0
        private void DropRotate()
        {
            // Null check
            if (!CurrentObject)
            {
                return;
            }

            // Detach
            fixedJoint.connectedBody = null;
            // Clear
            CurrentObject.ActiveHand = null;
            CurrentObject            = null;
        }
Exemplo n.º 2
0
        private Interactable2 getNearestInteractable()
        {
            Interactable2 nearest     = null;
            float         minDistance = float.MaxValue;
            float         distance    = 0f;

            foreach (Interactable2 interactable in ContactInteractables)
            {
                distance = (interactable.transform.position - transform.position).sqrMagnitude;

                if (distance < minDistance)
                {
                    minDistance = distance;
                    nearest     = interactable;
                }
            }

            return(nearest);
        }
Exemplo n.º 3
0
        private void DropNormal()
        {
            // Null check
            if (!CurrentObject)
            {
                return;
            }

            //Apply velocity
            Rigidbody targetBody = CurrentObject.GetComponent <Rigidbody>();

            targetBody.velocity        = Pose.GetVelocity();
            targetBody.angularVelocity = Pose.GetAngularVelocity();

            // Detach
            fixedJoint.connectedBody = null;

            // Clear
            CurrentObject.ActiveHand = null;
            CurrentObject            = null;
        }
Exemplo n.º 4
0
        private void PlaceTurret()
        {
            // Null check
            if (!CurrentObject)
            {
                return;
            }
            //Apply velocity
            //Rigidbody targetBody = CurrentObject.GetComponent<Rigidbody>();
            //targetBody.velocity = Pose.GetVelocity();
            //targetBody.angularVelocity = Pose.GetAngularVelocity();
            if (gridPosition.gridActive && gridPosition.canPlace)
            {
                if (MoneyCounter.totalMoneyCounter >= 300)
                {
                    //GameObject newTower = Instantiate(TurretPrefab, gridPosition.GetNearestPointOnGrid(CurrentObject.transform.position),
                    //    gridPosition.transform.rotation);
                    //newTower.transform.SetParent(Table.transform);
                    //MoneyCounter.totalMoneyCounter -= 300;
                    //CurrentObject.transform.position = turretPoint.position;
                    //CurrentObject.transform.rotation = Quaternion.identity;
                    //CurrentObject.transform.parent = RotatingPlane;
                }
                else
                {
                    CurrentObject.transform.position = turretPoint.position;
                    CurrentObject.transform.rotation = Quaternion.identity;
                }
            }
            else
            {
                return;
            }

            // Detach
            fixedJoint.connectedBody = null;
            // Clear
            CurrentObject.ActiveHand = null;
            CurrentObject            = null;
        }
Exemplo n.º 5
0
        private void Pickup()
        {
            // Get nearest
            CurrentObject = getNearestInteractable();
            //null check
            if (!CurrentObject)
            {
                return;
            }

            //check for upgrade menu
            if (CurrentObject.gameObject.CompareTag("Turret"))
            {
                TurretBehaviour turret = CurrentObject.GetComponent <TurretBehaviour>();
                if (turret.UpgradeMenu.activeInHierarchy)
                {
                    turret.UpgradeMenu.SetActive(false);
                }
                else if (!turret.UpgradeMenu.activeInHierarchy)
                {
                    turret.UpgradeMenu.SetActive(true);
                }
                DropRotate();
                return;
            }

            OutlineObject.gameObject.SetActive(true);
            if (CurrentObject.gameObject.CompareTag("CanPickup"))
            {
                PickupNormal();
            }
            else if (CurrentObject.gameObject.CompareTag("CanRotate"))
            {
                Rotate();
            }
        }