Exemplo n.º 1
0
        private void LoadRig(RigData data)
        {
            GameObject obj = rootTransform.Find(data.ObjectName).gameObject;

            if (null != obj)
            {
                GameObject rendererObj = obj.transform.Find(data.meshPath).gameObject;
                if (null != rendererObj)
                {
                    if (rendererObj.TryGetComponent <SkinnedMeshRenderer>(out SkinnedMeshRenderer renderer))
                    {
                        RigController controller = obj.AddComponent <RigController>();
                        controller.SkinMesh   = renderer;
                        controller.RootObject = renderer.rootBone;

                        obj.tag = "PhysicObject";
                        BoxCollider objectCollider = obj.AddComponent <BoxCollider>();
                        objectCollider.center        = renderer.bounds.center;
                        objectCollider.size          = renderer.bounds.size;
                        renderer.updateWhenOffscreen = true;
                        controller.Collider          = objectCollider;

                        GlobalState.GeometryImporter.GenerateImportSkeleton(controller.RootObject, controller);
                    }
                }
            }
        }
Exemplo n.º 2
0
    private void OnEnable()
    {
        rigController            = FindObjectOfType <RigController>();
        itemDatabase             = FindObjectOfType <ItemDatabase>();
        miningControllerInstance = FindObjectOfType <MiningController>();
        mapDelegateHolder        = FindObjectOfType <MapDelegateHolder>();


        rigController.rigUpgradedActions  += UpgradeARig;
        rigController.rackUpgradedActions += UpgradeARackOfRigs;



        // Populating the rig slot list and assigning IDs
        int i = 0;

        foreach (Transform child in rigSlotHolder)
        {
            rigSlots.Add(child);
            child.GetComponent <Rigslot>().myOrderNumber = i;
            i++;
        }

        // Populating the rack slots list and assigning IDs

        foreach (Transform child in rackSlotHolder)
        {
            rackSlots.Add(child);
            child.GetComponent <RackSlot>().myOrderNumber = i;

            child.GetComponent <RackSlot>().racksInThisGroup = 0;
            i++;
        }
    }
Exemplo n.º 3
0
    void onHideEnded()
    {
        currentRig.gameObject.SetActive(false);
        nextRig.gameObject.SetActive(true);
        currentRig = nextRig;
        nextRig    = null;

        OnNewRigSet?.Invoke();
    }
Exemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        rigController    = FindObjectOfType <RigController>();
        miningController = FindObjectOfType <MiningController>();

        mainUIController = GameObject.FindGameObjectWithTag("MainUI").GetComponent <UIController>();

        // I am sending the ID of the rackslot I am referring to
        unfoldButton.onClick.AddListener(() => mainUIController.ShowRacksSideMenu(orderNumber));

        upgradeAllButton.onClick.AddListener(() => UpgradeAllRacksInThisGroup());
    }
Exemplo n.º 5
0
        /// <summary>
        /// Allows the motor to process after the camera and controller have completed
        /// </summary>
        public override void PostRigLateUpdate()
        {
            base.PostRigLateUpdate();

            mStartMotor.PostRigLateUpdate();
            mEndMotor.PostRigLateUpdate();

            if (mTransitionElapsedTime >= _TransitionTime)
            {
                int lNewMotorIndex = (_EndMotorIndexOverride >= 0 && _EndMotorIndex < RigController.Motors.Count ? _EndMotorIndexOverride : _EndMotorIndex);
                RigController.ActivateMotor(lNewMotorIndex);
            }
        }
Exemplo n.º 6
0
 public void SwitchToRevolver()
 {
     if (currentRig != rigWithRevolver)
     {
         if (currentRig != null)
         {
             currentRig.Hide();
             nextRig = rigWithRevolver;
         }
         else
         {
             currentRig = rigWithRevolver;
             currentRig.gameObject.SetActive(true);
             nextRig = null;
             OnNewRigSet?.Invoke();
         }
     }
 }
Exemplo n.º 7
0
 public void SwitchToKatana()
 {
     if (currentRig != rigWithKatana)
     {
         if (currentRig != null)
         {
             currentRig.Hide();
             nextRig = rigWithKatana;
         }
         else
         {
             currentRig = rigWithKatana;
             currentRig.gameObject.SetActive(true);
             nextRig = null;
             OnNewRigSet?.Invoke();
         }
     }
 }
Exemplo n.º 8
0
    // Use this for initialization
    void Start()
    {
        currentMapController = FindObjectOfType <MapController>();
        itemDatabase         = FindObjectOfType <ItemDatabase>();
        rigController        = FindObjectOfType <RigController>();
        miningController     = FindObjectOfType <MiningController>();
        mapDelegateHolder    = FindObjectOfType <MapDelegateHolder>();

        if (controllingRack)
        {   // If this UI element controls a rack, then make the button call upgrade a rack function from the rig controller
            upgradeButton.onClick.AddListener(() => rigController.UpgradeARack(GetComponent <RackID>().myControlID));
            myRackID = GetComponent <RackID>();
        }
        else
        {
            upgradeButton.onClick.AddListener(() => rigController.UpgradeARig(GetComponent <RigID>().myControlID));
            myRigID = GetComponent <RigID>();
            myRig   = FindObjectOfType <ItemDatabase>().rigTypes[0];
        }

        // If the center activate button is ON then give it a function of buying a brand new rig
        if (activateButton && !controllingRack)
        {
            activateButton.onClick.AddListener(() => BuyARigFromScratch());
        }
        else
        {
            activateButton.gameObject.SetActive(false);
        }

        if (!controllingRack)
        {
            mapDelegateHolder.upgradedRigActions += UpdateMyRigUI;
        }
        else
        {
            mapDelegateHolder.upgradedRackActions += UpdateMyRackUI;
        }

        InitizalizeTheUI();
    }
Exemplo n.º 9
0
 public RigData(RigController controller)
 {
     ObjectName = controller.name;
     meshPath   = GetPathToRoot(controller.transform, controller.SkinMesh.transform);
 }
Exemplo n.º 10
0
        /// <summary>
        /// Updates the motor over time. This is called by the controller
        /// every update cycle so movement can be updated.
        /// </summary>
        /// <param name="rDeltaTime">Time since the last frame (or fixed update call)</param>
        /// <param name="rUpdateIndex">Index of the update to help manage dynamic/fixed updates. [0: Invalid update, >=1: Valid update]</param>
        /// <param name="rTiltAngle">Amount of tilting the camera needs to do to match the anchor</param>
        public override CameraTransform RigLateUpdate(float rDeltaTime, int rUpdateIndex, float rTiltAngle = 0f)
        {
            if (mPath == null)
            {
                return(mRigTransform);
            }
            if (RigController == null)
            {
                return(mRigTransform);
            }

            bool lHasArrived = false;

            if (mHasStarted && !mIsPaused)
            {
                float lSpeed = _Speed.Evaluate(DistanceTravelledNormalized);
                mDistanceTravelled += lSpeed * rDeltaTime;
            }

            if (mDistanceTravelled >= mPathLength)
            {
                if (_Loop)
                {
                    mDistanceTravelled -= mPathLength;
                }
                else
                {
                    mDistanceTravelled = mPathLength;
                }

                lHasArrived = true;
            }

            float lPercent = mDistanceTravelled / mPathLength;

            Vector3 lPosition = mPath.GetPoint(lPercent);

            if (mLastPosition == Vector3.zero)
            {
                mLastPosition = lPosition;
            }

            mRigTransform.Position = lPosition;

            if (_RotateToAnchor)
            {
                mRigTransform.Rotation = Quaternion.LookRotation(AnchorPosition - lPosition, Vector3.up);
            }
            else if (_RotateToMovementDirection)
            {
                if ((lPosition - mLastPosition).sqrMagnitude != 0f)
                {
                    mRigTransform.Rotation = Quaternion.LookRotation(lPosition - mLastPosition, Vector3.up);
                }
            }

            mLastPosition = lPosition;

            if (lHasArrived && mHasStarted)
            {
                if (_ActivateMotorOnComplete)
                {
                    if (_EndMotorIndex >= 0 && _EndMotorIndex < RigController.Motors.Count)
                    {
                        RigController.ActivateMotor(_EndMotorIndex);
                    }
                }

                if (RigController.MotorArrived != null)
                {
                    RigController.MotorArrived(this);
                }

                // Send the message
                CameraMessage lMessage = CameraMessage.Allocate();
                lMessage.ID    = 204;
                lMessage.Motor = this;

                if (RigController.ActionTriggeredEvent != null)
                {
                    RigController.ActionTriggeredEvent.Invoke(lMessage);
                }

#if USE_MESSAGE_DISPATCHER || OOTII_MD
                MessageDispatcher.SendMessage(lMessage);
#endif

                CameraMessage.Release(lMessage);

                // Reset the flags
                if (!_Loop)
                {
                    mHasStarted = false;
                }
            }

            return(mRigTransform);
        }
Exemplo n.º 11
0
 private void LoadLogs()
 {
     _controller = File.Exists("logs.gz") ? new RigController(JsonControl.GetSerializedGzipFile <BindingList <RigController.Rig> >("logs.gz")) : new RigController();
 }
Exemplo n.º 12
0
        /// <summary>
        /// Updates the motor over time. This is called by the controller
        /// every update cycle so movement can be updated.
        /// </summary>
        /// <param name="rDeltaTime">Time since the last frame (or fixed update call)</param>
        /// <param name="rUpdateIndex">Index of the update to help manage dynamic/fixed updates. [0: Invalid update, >=1: Valid update]</param>
        /// <param name="rTiltAngle">Amount of tilting the camera needs to do to match the anchor</param>
        public override CameraTransform RigLateUpdate(float rDeltaTime, int rUpdateIndex, float rTiltAngle = 0f)
        {
            if (mPath == null)
            {
                return(mRigTransform);
            }
            if (RigController == null)
            {
                return(mRigTransform);
            }

            bool lHasArrived = false;

            if (mHasStarted && !mIsPaused)
            {
                float lSpeed = _Speed.Evaluate(DistanceTravelledNormalized);
                mDistanceTravelled += lSpeed * rDeltaTime;
            }

            if (mDistanceTravelled >= mPathLength)
            {
                if (_Loop)
                {
                    mDistanceTravelled -= mPathLength;
                }
                else
                {
                    mDistanceTravelled = mPathLength;
                }

                lHasArrived = true;
            }

            float lPercent = mDistanceTravelled / mPathLength;

            Vector3 lPosition = mPath.GetPoint(lPercent);

            if (mLastPosition == Vector3.zero)
            {
                mLastPosition = lPosition;
            }

            mRigTransform.Position = lPosition;

            if (_RotateToAnchor)
            {
                mRigTransform.Rotation = Quaternion.LookRotation(AnchorPosition - lPosition, Vector3.up);
            }
            else if (_RotateToMovementDirection)
            {
                if ((lPosition - mLastPosition).sqrMagnitude != 0f)
                {
                    mRigTransform.Rotation = Quaternion.LookRotation(lPosition - mLastPosition, Vector3.up);
                }
            }

            mLastPosition = lPosition;

            if (lHasArrived && mHasStarted)
            {
                if (_ActivateMotorOnComplete)
                {
                    if (_EndMotorIndex >= 0 && _EndMotorIndex < RigController.Motors.Count)
                    {
                        RigController.ActivateMotor(_EndMotorIndex);
                    }
                }

                if (RigController.MotorArrived != null)
                {
                    RigController.MotorArrived(this);
                }

                if (!_Loop)
                {
                    mHasStarted = false;
                }
            }

            return(mRigTransform);
        }
Exemplo n.º 13
0
 private void Start()
 {
     playerObj = GameObject.FindGameObjectWithTag("Player");
     player    = playerObj.GetComponent <RigController>();
 }
Exemplo n.º 14
0
        private void TraverseScene(Transform root, string parentPath)
        {
            foreach (Transform currentTransform in root)
            {
                if (currentTransform == SceneManager.BoundingBox)
                {
                    continue;
                }

                string path = parentPath;
                path += "/" + currentTransform.name;


                // Depending on its type (which controller we can find on it) create data objects to be serialized
                LightController lightController = currentTransform.GetComponent <LightController>();
                if (null != lightController)
                {
                    LightData lightData = new LightData();
                    SetCommonData(currentTransform, parentPath, path, lightController, lightData);
                    SetLightData(lightController, lightData);
                    SceneData.Current.lights.Add(lightData);
                    continue;
                }

                CameraController cameraController = currentTransform.GetComponent <CameraController>();
                if (null != cameraController)
                {
                    CameraData cameraData = new CameraData();
                    SetCommonData(currentTransform, parentPath, path, cameraController, cameraData);
                    SetCameraData(cameraController, cameraData);
                    SceneData.Current.cameras.Add(cameraData);
                    continue;
                }

                ColimatorController colimatorController = currentTransform.GetComponent <ColimatorController>();
                if (null != colimatorController)
                {
                    // Nothing to do here, ignore the object
                    continue;
                }

                RigController skinController = currentTransform.GetComponent <RigController>();
                if (null != skinController && !skinController.isImported)
                {
                    SceneData.Current.rigs.Add(new RigData(skinController));
                }

                // Do this one at the end, because other controllers inherits from ParametersController
                ParametersController controller = currentTransform.GetComponent <ParametersController>();
                ObjectData           data       = new ObjectData();
                SetCommonData(currentTransform, parentPath, path, controller, data);
                try
                {
                    SetObjectData(currentTransform, controller, data);
                    SceneData.Current.objects.Add(data);
                }
                catch (Exception e)
                {
                    Debug.Log("Failed to set object data: " + e.Message);
                }

                // Serialize children
                if (!data.isImported)
                {
                    TraverseScene(currentTransform, path);
                }
            }
        }