Example #1
0
    private IEnumerator OpenAnimation(Action callback)
    {
        GUICameraControll farmCamera = FarmRoot.Instance.Camera.GetComponent <GUICameraControll>();
        Vector3           position   = base.transform.position;

        position.y -= FarmRoot.Instance.gameObject.transform.localPosition.y;
        yield return(base.StartCoroutine(farmCamera.MoveCameraToLookAtPoint(position, 0.2f)));

        bool isEffectEnd = false;
        EffectAnimatorObserver effect = FarmRoot.Instance.GetBuildCompleteEffect(base.transform);

        if (null != effect)
        {
            EffectAnimatorEventTime component = effect.GetComponent <EffectAnimatorEventTime>();
            component.SetEvent(0, delegate
            {
                isEffectEnd = true;
            });
            effect.Play();
        }
        while (!isEffectEnd)
        {
            yield return(null);
        }
        if (callback != null)
        {
            callback();
        }
        yield break;
    }
Example #2
0
    private void Start()
    {
        FarmRoot          instance   = FarmRoot.Instance;
        Camera            component  = base.GetComponent <Camera>();
        GUICameraControll component2 = base.GetComponent <GUICameraControll>();

        component.orthographicSize = component2.CameraOrthographicSizeMax;
        float   z       = 0.1f;
        float   num     = Mathf.Abs(component.ViewportToWorldPoint(new Vector3(0f, 1f, z)).y - instance.transform.position.y);
        float   num2    = Mathf.Abs(component.ViewportToWorldPoint(new Vector3(0f, 0f, z)).y - instance.transform.position.y);
        float   f       = component.transform.localEulerAngles.x * 0.0174532924f;
        float   z2      = Mathf.Abs(num / Mathf.Cos(f));
        Vector3 b       = new Quaternion(component.transform.localRotation.x, 0f, 0f, 1f) * new Vector3(0f, 0f, z2);
        Vector3 vector  = new Vector3(this.drawAreaClip.size.x / 2f, 0f, this.drawAreaClip.size.z / 2f) - b;
        Vector3 vector2 = new Vector3(-this.drawAreaClip.size.x / 2f, 0f, this.drawAreaClip.size.z / 2f) - b;

        z2 = Mathf.Abs(num2 / Mathf.Cos(f));
        b  = new Quaternion(component.transform.localRotation.x, 0f, 0f, 1f) * new Vector3(0f, 0f, z2);
        Vector3 vector3 = new Vector3(-this.drawAreaClip.size.x / 2f, 0f, -this.drawAreaClip.size.z / 2f) - b;

        this.topLeftX    = vector2.x;
        this.topLeftZ    = vector2.z;
        this.topRightX   = vector.x;
        this.bottomLeftZ = vector3.z;
    }
    public bool BuildFarmObject(int facilityID)
    {
        FarmObject farmObject = this.FindFarmObjectByFacilityId(facilityID);
        FarmObject farmObject2;

        if (null == farmObject)
        {
            farmObject2 = this.LoadFarmObject(facilityID);
        }
        else
        {
            farmObject2 = this.DuplicateFarmObject(farmObject);
        }
        if (null == farmObject2)
        {
            return(false);
        }
        farmObject2.facilityID = facilityID;
        FarmObjectSetting component = base.GetComponent <FarmObjectSetting>();
        bool flag = component.SetFarmObject(farmObject2, this.GetScreenCenterPoint());

        if (flag)
        {
            GUICameraControll component2 = FarmRoot.Instance.Camera.GetComponent <GUICameraControll>();
            if (null != component2)
            {
                Vector3 baseGridPosition3D = component.farmObject.GetBaseGridPosition3D();
                base.StartCoroutine(component2.MoveCameraToLookAtPoint(baseGridPosition3D, 0f));
            }
        }
        return(true);
    }
Example #4
0
    private IEnumerator WaitMovedForFarmCamera(GUICameraControll farmCamera, Vector3 position)
    {
        GUIMain.BarrierON(null);
        yield return(AppCoroutine.Start(farmCamera.MoveCameraToLookAtPoint(position, 1f), false));

        GUIMain.BarrierOFF();
        yield break;
    }
	public static Vector3 GetDistanceToGround()
	{
		Vector3 result = Vector3.zero;
		FarmRoot instance = FarmRoot.Instance;
		if (null != instance)
		{
			GUICameraControll component = instance.Camera.GetComponent<GUICameraControll>();
			result = component.distanceToGround;
		}
		return result;
	}
    public void RelocationOfStoreFarmObject(FarmObject farmObject)
    {
        bool flag = this.SetFarmObjectOfEditMode(farmObject, this.GetScreenCenterPoint());

        if (flag)
        {
            GUICameraControll component = FarmRoot.Instance.Camera.GetComponent <GUICameraControll>();
            if (null != component)
            {
                Vector3 baseGridPosition3D = farmObject.GetBaseGridPosition3D();
                base.StartCoroutine(component.MoveCameraToLookAtPoint(baseGridPosition3D, 0f));
            }
        }
    }
    public bool RelocationOfStoreFarmObjectAndDragState(FarmObject farmObject, Vector3 mousePosition)
    {
        bool flag = this.SetFarmObjectOfEditModeAndDragState(farmObject, mousePosition);

        if (flag)
        {
            GUICameraControll component = FarmRoot.Instance.Camera.GetComponent <GUICameraControll>();
            if (null != component)
            {
                Vector3 baseGridPosition3D = farmObject.GetBaseGridPosition3D();
                base.StartCoroutine(component.MoveCameraToLookAtPoint(baseGridPosition3D, 0f));
            }
        }
        return(flag);
    }
    private Vector3 GetExtendBuildPosition(FarmObjectSetting farmObjectSetting, FarmObject prevFarmObject)
    {
        FarmObjectSetting.ExtendBuildPositionSearchResult extendBuildPositionSearchResult = farmObjectSetting.SearchExtendBuildGrid(prevFarmObject);
        FarmGrid grid               = FarmRoot.Instance.Field.Grid;
        int      gridIndex          = grid.GetGridIndex(extendBuildPositionSearchResult.grid);
        Vector3  positionGridCenter = grid.GetPositionGridCenter(gridIndex, true);

        if (!extendBuildPositionSearchResult.isOutsideMap)
        {
            GUICameraControll component = FarmRoot.Instance.Camera.GetComponent <GUICameraControll>();
            if (null != component)
            {
                base.StartCoroutine(component.MoveCameraToLookAtPoint(positionGridCenter, 0f));
            }
        }
        return(positionGridCenter);
    }
Example #9
0
    private void GoToFacility(int facilityID)
    {
        FarmRoot instance = FarmRoot.Instance;

        if (null != instance)
        {
            FarmScenery  scenery = instance.Scenery;
            FarmObject[] array   = scenery.farmObjects.Where((FarmObject x) => x.facilityID == facilityID).ToArray <FarmObject>();
            if (array != null && 0 < array.Length)
            {
                FarmObject        farmObject         = array[0];
                Vector3           baseGridPosition3D = farmObject.GetBaseGridPosition3D();
                GUICameraControll component          = instance.Camera.GetComponent <GUICameraControll>();
                if (null != component)
                {
                    AppCoroutine.Start(this.WaitMovedForFarmCamera(component, baseGridPosition3D), false);
                }
            }
        }
    }