protected override void LoadContent() { base.LoadContent(); //BackColor = new Color(133, 182, 203); BackColor = new Color(221, 255, 221); BackColor = Color.White; Debugger.Color = Color.Black; GraphicsDevice.BlendState = BlendState.Opaque; GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise; GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap; _graphics.PreferMultiSampling = true; GameObject con = new GameObject("construct"); Instantiate(con); _construct = con.AddComponent <ConstructComponent>(); _construct.Enabled = true; Resources.LoadAll(); InitGUI(); MainCamera.AddComponent <Grid.Framework.Components.Movable2DCamera>(); /* * GameObject test = new GameObject("test"); * test.AddComponent<GeometrytestComponent>(); * test.Enabled = true; * Instantiate(test);*/ }
public void EnemyCommanderShipDead(GameObject commander) { StopAllCoroutines(); Animator animator = MainCamera.AddComponent <Animator>(); animator.runtimeAnimatorController = Resources.Load("Battle/CameraAnimation/Camera_CommanderShipDieCtrl") as RuntimeAnimatorController; MainCamera_.transform.position = commander.transform.position; MainCamera_.transform.eulerAngles = Vector3.zero; MainCamera.transform.localPosition = new Vector3(-17, 16.3f, -42); MainCamera.transform.localEulerAngles = new Vector3(15, 386, 0); animator.SetTrigger("CommanderShipDie"); }
protected override void LoadContent() { base.LoadContent(); GraphicsDevice.BlendState = BlendState.Opaque; GraphicsDevice.DepthStencilState = DepthStencilState.Default; GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise; GraphicsDevice.SamplerStates[0] = SamplerState.LinearWrap; _graphics.PreferMultiSampling = true; GameObject con = new GameObject("construct"); _construct = con.AddComponent <ConstructComponent>(); _construct.Enabled = true; Instantiate(con); Resources.LoadAll(); _compassBtn = new ImageButton(10, 10, 80, 80, LoadContent <Texture2D>("icon\\circle")); _segmentBtn = new ImageButton(100, 10, 80, 80, LoadContent <Texture2D>("icon\\segment")); _vectorBtn = new ImageButton(190, 10, 80, 80, LoadContent <Texture2D>("icon\\vector")); _lineBtn = new ImageButton(280, 10, 80, 80, LoadContent <Texture2D>("icon\\line")); _dotBtn = new ImageButton(370, 10, 80, 80, LoadContent <Texture2D>("icon\\dot")); _clearBtn = new Button(460, 10, 80, 80, "Clear") { BackColor = Color.Azure }; _deleteBtn = new Button(550, 10, 80, 80, "Delete") { BackColor = Color.Honeydew }; _undoBtn = new Button(640, 10, 80, 80, "Undo") { BackColor = Color.Violet }; guiManagerComponent.GUIs.Add(_compassBtn); guiManagerComponent.GUIs.Add(_segmentBtn); guiManagerComponent.GUIs.Add(_vectorBtn); guiManagerComponent.GUIs.Add(_lineBtn); guiManagerComponent.GUIs.Add(_dotBtn); guiManagerComponent.GUIs.Add(_clearBtn); guiManagerComponent.GUIs.Add(_deleteBtn); guiManagerComponent.GUIs.Add(_undoBtn); MainCamera.AddComponent <Grid.Framework.Components.Movable2DCamera>(); GameObject test = new GameObject("test"); test.AddComponent <GeometryTestComponent>(); test.Enabled = false; Instantiate(test); }
/// <summary> /// 布阵相机协程 /// </summary> /// <returns></returns> private IEnumerator DeployCameraThread() { // 相机开始移动 //yield return new WaitForSeconds( 2f ); MainCamera_.transform.position = Vector3.zero; MainCamera_.transform.localEulerAngles = Vector3.zero; // 相机要指向的位置缓存 int firstID = 30000; int secondID = 40000; int thirdID = 60000; Dictionary <int, Vector3> posList = new Dictionary <int, Vector3>(); int shipCount = BattleSys.GetShipCount(false); for (int i = 0; i < shipCount; i++) { ClientShip cs = BattleSys.GetShipByIndex(false, i); if (cs.Reference.id == firstID || cs.Reference.id == secondID || cs.Reference.id == thirdID) { if (!posList.ContainsKey(cs.Reference.id)) { posList.Add(cs.Reference.id, cs.Position); } } } Animator animator = MainCamera.AddComponent <Animator>(); animator.runtimeAnimatorController = Resources.Load("Camera/camera_control") as RuntimeAnimatorController; Vector3 pos; posList.TryGetValue(firstID, out pos); MainCamera_.transform.position = pos; MainCamera.transform.position = new Vector3(29.3f, 19.9f, -40.8f); MainCamera.transform.localEulerAngles = new Vector3(15, 315, 0); animator.SetTrigger("DeployCameraStep01"); yield return(new WaitForSeconds(2.3f)); posList.TryGetValue(secondID, out pos); MainCamera_.transform.position = pos; MainCamera.transform.position = new Vector3(38.3f, 4.3f, 49.7f); MainCamera.transform.localEulerAngles = new Vector3(-2.3f, 238.54f, 0); animator.SetTrigger("DeployCameraStep02"); yield return(new WaitForSeconds(3.51f)); posList.TryGetValue(thirdID, out pos); MainCamera_.transform.position = pos; MainCamera.transform.position = new Vector3(46.8f, 8.1f, -9.7f); MainCamera.transform.localEulerAngles = new Vector3(0, 258, 0); animator.SetTrigger("DeployCameraStep03"); yield return(new WaitForSeconds(3.2f)); // 显示敌人指挥中心信息 StartCoroutine(PlayEffectOfMainEnemy(pos)); yield return(new WaitForSeconds(2.1f)); posList.Clear(); // 得到相机和边线的z值差 proto.BattlefieldReference reference = GlobalConfig.GetBattlefieldReferenceByID(BattleSys.NowMapID); if (reference == null) { yield break; } // 战场长度 float length = reference.basearea_len + reference.deptharea_len + reference.deployarea_len; Vector3 position = new Vector3(DeployOriginPositionX, DeployOriginPositionY, -length - 23.8f); Vector3 angle = new Vector3(DeployOriginRotationX, DeployOriginRotationY, DeployOriginRotationZ); // 初始化基地区域相机属性 CameraInfo info = GetCameraInfo(CameraStatusType.DeployMoveToBase); info.position = position + new Vector3(0, 0, length - reference.basearea_len / 2); info.angles = angle; // 初始化布阵区域相机属性 info = GetCameraInfo(CameraStatusType.DeployMoveToDeploy); info.position = position; info.angles = angle; // 设置相机位置和旋转 MainCamera.transform.position = Vector3.zero; MainCamera.transform.localEulerAngles = Vector3.zero; MainCamera_.transform.position = position; MainCamera_.transform.localEulerAngles = angle; animator.SetTrigger("DeployCameraStep04"); yield return(new WaitForSeconds(2)); Destroy(animator); // 移动完毕,修改模式为可操作模式 SetCameraType(CameraStatusType.Deploy); // 显示布阵界面 UIManager.ShowPanel <DeployPanel>(); UIManager.ShowPanel <DeployCameraControl>(); // 开启相机线程 StartCoroutine(CameraThread(null)); }