private void CenterBoardOn(Transform transform)
        {
            Transform y = this.centeringTarget;

            this.centeringTarget = transform;
            AnimationCurve animationCurve = new AnimationCurve(this.animationKeys);
            float          duration       = 0.75f;
            Quaternion     rotation       = this.locatorGroup.rotation;
            Quaternion     rotationTarget = this.GetRotationTarget(transform);
            float          num            = Mathf.Abs(rotation.eulerAngles.x - rotationTarget.eulerAngles.x);

            if (this.centeringTarget == y)
            {
                return;
            }
            if (num < 0.5f)
            {
                Service.Get <WarBoardBuildingController>().DeselectBuilding();
                this.OnCenterComplete(null);
                return;
            }
            Service.Get <WarBoardBuildingController>().DeselectBuilding();
            if (this.rotateTween != null)
            {
                this.rotateTween.Destroy();
                this.rotateTween = null;
            }
            this.rotateTween = new RotateTween(this.locatorGroup, duration, rotation, rotationTarget, animationCurve, new Action <RotateTween>(this.OnCenterComplete), null);
        }
 public EatResponse OnRelease(int id)
 {
     if (this.anchorFingerId == id)
     {
         this.anchorFingerId = -1;
         this.HandleDrag();
         float num = MathUtils.Sum(this.rotationSamples);
         Array.Clear(this.rotationSamples, 0, this.rotationSamples.Length);
         if (Mathf.Abs(num) > 0.1f)
         {
             if (this.rotateTween != null)
             {
                 this.rotateTween.Destroy();
                 this.rotateTween = null;
             }
             Quaternion rotation    = this.locatorGroup.rotation;
             float      x           = this.locatorGroup.eulerAngles.x;
             float      x2          = x + num * 1.5f;
             Quaternion endRotation = default(Quaternion);
             endRotation.eulerAngles = new Vector3(x2, 0f, 0f);
             float duration = Mathf.Min(Mathf.Abs(num) * 0.3f, 0.4f);
             this.locatorGroup.eulerAngles = new Vector3(this.rotateAmount, 0f, 0f);
             this.rotateTween = new RotateTween(this.locatorGroup, duration, rotation, endRotation, new AnimationCurve(this.easeOutKeys), new Action <RotateTween>(this.OnRotationUpdate), new Action <RotateTween>(this.OnRotationUpdate));
         }
         return(EatResponse.Eaten);
     }
     return(EatResponse.NotEaten);
 }
        private void OnRotationUpdate(RotateTween tween)
        {
            bool  flag             = false;
            float relativeRotation = this.GetRelativeRotation(this.locatorGroup.rotation.eulerAngles.x);

            if (relativeRotation > this.maxRotation)
            {
                flag = true;
                this.locatorGroup.rotation = Quaternion.Euler(new Vector3(this.maxRotation, 0f, 0f));
            }
            else if (relativeRotation < this.minRotation)
            {
                flag = true;
                this.locatorGroup.rotation = Quaternion.Euler(new Vector3(this.minRotation, 0f, 0f));
            }
            if (flag)
            {
                if (this.rotateTween != null)
                {
                    this.rotateTween.Destroy();
                    this.rotateTween = null;
                }
                else if (tween != null)
                {
                    tween.Destroy();
                    tween = null;
                }
            }
            this.UpdateSelections();
        }
    public static void RotateGameObject(GameObject gameObject)
    {
        Init();
        RotateTween tween = new RotateTween(gameObject);

        _activeTweens.Add(tween);
    }
Example #5
0
 private void OnWarBoardLoaded(object asset, object cookie)
 {
     this.warBoard = (GameObject)asset;
     this.warBoardLoadSequenceFinished = true;
     this.maxRotation = 11f;
     this.minRotation = -7f;
     if (this.warBoard != null)
     {
         this.warBoardTransform               = this.warBoard.transform;
         this.warBoardTransform.parent        = this.warboardMasterTransform;
         this.warBoardTransform.localPosition = Vector3.zero;
         this.warBoardTransform.localRotation = Quaternion.identity;
         this.warBoard.SetActive(false);
         this.WarBuildingLocators.Clear();
         this.locatorGroup = this.warBoard.transform.Find("planet_surface");
         if (this.locatorGroup != null)
         {
             SquadController squadController = Service.SquadController;
             SquadWarManager warManager      = squadController.WarManager;
             int             numParticipants = warManager.NumParticipants;
             Transform       transform       = null;
             for (int i = 0; i < numParticipants; i++)
             {
                 string name = "locator" + i.ToString();
                 transform = this.locatorGroup.Find(name);
                 this.WarBuildingLocators.Add(transform);
                 if (i == 1)
                 {
                     this.maxRotation = -transform.localEulerAngles.x + -1.72057f;
                 }
             }
             if (transform != null)
             {
                 this.minRotation = -transform.localEulerAngles.x + -1.72057f;
             }
             AnimationCurve animationCurve = new AnimationCurve(this.animationKeys);
             if (this.rotateTween != null)
             {
                 this.rotateTween.Destroy();
                 this.rotateTween = null;
             }
             this.rotateTween = new RotateTween(this.locatorGroup, 1.5f, Quaternion.Euler(new Vector3(this.minRotation + -1.72057f, 0f, 0f)), Quaternion.Euler(new Vector3(this.maxRotation + -1.72057f, 0f, 0f)), animationCurve, null, null);
             Service.WarBoardBuildingController.ShowBuildings(this.WarBuildingLocators);
             Service.UserInputManager.RegisterObserver(this, UserInputLayer.InternalLowest);
         }
     }
     this.CheckForAllLoadsComplete();
 }
 public EatResponse OnPress(int id, GameObject target, Vector2 screenPosition, Vector3 groundPosition)
 {
     if (this.rotateTween != null)
     {
         this.rotateTween.Destroy();
         this.rotateTween = null;
     }
     if (this.anchorFingerId == -1)
     {
         this.anchorFingerId           = id;
         this.anchorGroundPosition     = groundPosition;
         this.anchorLastGroundPosition = groundPosition;
         this.originalRotation         = this.locatorGroup.eulerAngles.x;
         return(EatResponse.Eaten);
     }
     return(EatResponse.NotEaten);
 }
        public void HideWarBoard()
        {
            UnityEngine.Object.Destroy(this.warBoard);
            this.warBoard          = null;
            this.warBoardTransform = null;
            if (this.warBoardHandle != AssetHandle.Invalid)
            {
                Service.Get <AssetManager>().Unload(this.warBoardHandle);
                this.warBoardHandle = AssetHandle.Invalid;
            }
            UnityEngine.Object.Destroy(this.warboardBackgroundGameObject);
            this.warboardBackgroundGameObject = null;
            if (this.warboardBackground != AssetHandle.Invalid)
            {
                Service.Get <AssetManager>().Unload(this.warboardBackground);
                this.warboardBackground = AssetHandle.Invalid;
            }
            if (this.WarBuildingLocators != null)
            {
                this.WarBuildingLocators.Clear();
                this.WarBuildingLocators = null;
            }
            UnityEngine.Object.Destroy(this.warboardMaster);
            this.warboardMaster          = null;
            this.warboardMasterTransform = null;
            CameraManager cameraManager = Service.Get <CameraManager>();

            cameraManager.WarBoardCamera.Disable();
            cameraManager.MainCamera.Enable();
            Service.Get <UserInputManager>().SetActiveWorldCamera(cameraManager.MainCamera);
            Service.Get <UserInputManager>().UnregisterObserver(this, UserInputLayer.InternalLowest);
            Service.Get <WarBoardBuildingController>().DestroyBuildings();
            EventManager eventManager = Service.Get <EventManager>();

            eventManager.UnregisterObserver(this, EventId.WarBoardParticipantBuildingSelected);
            eventManager.UnregisterObserver(this, EventId.WarBoardBuffBaseBuildingSelected);
            eventManager.UnregisterObserver(this, EventId.WarBoardBuildingDeselected);
            this.flyout.Destroy();
            if (this.rotateTween != null)
            {
                this.rotateTween.Destroy();
                this.rotateTween = null;
            }
            this.anchorFingerId = -1;
            Service.Get <EventManager>().SendEvent(EventId.WarBoardDestroyed, null);
        }
 public void OnCenterComplete(RotateTween tween)
 {
     Service.Get <WarBoardBuildingController>().SelectBuilding(this.centeringTarget.gameObject);
 }
Example #9
0
    public void RotateGameObject(GameObject objectToMove, Vector3 targetPosition, float speed, Func <float, float> EaseMethod)
    {
        var newTween = new RotateTween(objectToMove, targetPosition, speed, EaseMethod);

        _rotationTween.Add(newTween);
    }