/// チェック public bool Check(GameActorCollManager collMgr, DemoGame.GeometryLine moveMoveLine) { collMgr.StartCollision(); for (int i = 0; i < collMgr.TrgContainer.Num; i++) { GameObjProduct trgObj = collMgr.TrgContainer.GetEntryObj(i); for (int x = 0; x < trgObj.GetCollisionShapeMax(moveType); x++) { GameShapeProduct trgShape = trgObj.GetCollisionShape(moveType, x); /// 衝突 if (calCollPointMove.Check(moveMoveLine, trgShape)) { collMgr.SetCollParam(i, x, calCollPointMove.BestId, calCollPointMove.BestDis); } } } /// 衝突座標をセット setScrapedMovePos(collMgr, moveMoveLine); /// 衝突した return(collMgr.CheckCollHit()); }
/// private メソッド ///--------------------------------------------------------------------------- /// 衝突後の移動座標をセット private void setScrapedMovePos(GameActorCollManager collMgr, DemoGame.GeometryLine moveLine) { /// 衝突あり if (collMgr.CheckCollHit()) { /// ソート collMgr.SortCollisionTrg(); GameObjProduct trgObj = collMgr.TrgContainer.GetEntryObj(0); GameShapeProduct trgShape = trgObj.GetCollisionShape(moveType, collMgr.TrgContainer.GetEntryShapeId(0)); switch (trgShape.GetShapeType()) { /// 三角形 case GameShapeProduct.TypeId.Triangles: setScrapedMovePosTriangle(collMgr, moveLine, (ShapeTriangles)trgShape); break; /// カプセル case GameShapeProduct.TypeId.Capsule: calCollPointMove.Check(moveLine, trgShape); nextPos = calCollPointMove.MovePos; break; } } }
/// 衝突後の移動座標をセット(三角形との衝突) private void setScrapedMovePosTriangle(GameActorCollManager collMgr, DemoGame.GeometryLine moveLine, ShapeTriangles shapeTri) { int primId = collMgr.TrgContainer.GetEntryPrimId(0); /// 衝突点を求める DemoGame.CommonCollision.CheckLineAndTriangle(moveLine, shapeTri.Triangle[primId], ref nextPos); }
/// 破壊対象 public void setBreakTarget(int scrPosX, int scrPosY) { GameActorCollManager useCollMgr = actorDestination.GetMoveCollManager(); Vector3 posStart = new Vector3(0, 0, 0); Vector3 posEnd = new Vector3(0, 0, 0); /// チェックする開始座標と終了座標のセット ctrlResMgr.GraphDev.GetScreenToWorldPos(scrPosX, scrPosY, 0.0f, ref posStart); ctrlResMgr.GraphDev.GetScreenToWorldPos(scrPosX, scrPosY, 1.0f, ref posEnd); DemoGame.GeometryLine moveMoveLine = new DemoGame.GeometryLine(posStart, posEnd); /// 衝突対象の登録 useCollMgr.TrgContainer.Clear(); ctrlResMgr.CtrlHobit.SetDestinationActor(useCollMgr.TrgContainer); ctrlResMgr.CtrlTo.SetDestinationActor(useCollMgr.TrgContainer); ctrlResMgr.CtrlWall.SetDestinationActor(useCollMgr.TrgContainer); /// 衝突判定 calCollLook.SetMoveType(Data.CollTypeId.ChDestination); bool checkBound = calCollLook.Check(useCollMgr, moveMoveLine); if (checkBound) { /// マーカーのセット destinationTrgActor = useCollMgr.TrgContainer.GetEntryObjParent(0); destinationTrgActor.SetDeadFlag(); if (destinationTrgActor.CheckMoveTrgId() == 1) { TouchPostion = destinationTrgActor.BasePos; destinationTrgActor.SetDeadFlag(); } else if (destinationTrgActor.CheckMoveTrgId() == 2) { TouchPostion = destinationTrgActor.BasePos; destinationTrgActor.SetDeadFlag(); } else if (destinationTrgActor.CheckMoveTrgId() == 3) { TouchPostion = destinationTrgActor.BasePos; destinationTrgActor.SetDeadFlag(); } else { TouchPostion = calCollLook.NextPos; } } }
/// ラインとカプセルとの衝突 public bool CheckCapsule(DemoGame.GeometryLine moveLine, ShapeCapsule trgCapsule) { Vector3 collPos = new Vector3(0, 0, 0); calMovePos = moveLine.EndPos; if (DemoGame.CommonCollision.CheckLineAndCapsule(moveLine, trgCapsule.Capsule, ref collPos) == true) { calMovePos = collPos; calBestDis = Common.VectorUtil.Distance(collPos, moveLine.StartPos); calBestId = 0; return(true); } return(false); }
public void findingTower(int scrPosX, int scrPosY) { GameActorCollManager useCollMgr = actorDestination.GetMoveCollManager(); Vector3 posStart = new Vector3(0, 0, 0); Vector3 posEnd = new Vector3(0, 0, 0); /// チェックする開始座標と終了座標のセット ctrlResMgr.GraphDev.GetScreenToWorldPos(scrPosX, scrPosY, 0.0f, ref posStart); ctrlResMgr.GraphDev.GetScreenToWorldPos(scrPosX, scrPosY, 1.0f, ref posEnd); DemoGame.GeometryLine moveMoveLine = new DemoGame.GeometryLine(posStart, posEnd); /// 衝突対象の登録 useCollMgr.TrgContainer.Clear(); ctrlResMgr.CtrlTo.SetDestinationActor(useCollMgr.TrgContainer); /// 衝突判定 calCollLook.SetMoveType(Data.CollTypeId.ChDestination); bool checkBound = calCollLook.Check(useCollMgr, moveMoveLine); if (checkBound) { destinationTrgActor = useCollMgr.TrgContainer.GetEntryObjParent(0); ShapeSphere bndSph = destinationTrgActor.GetBoundingShape(); if (destinationTrgActor.CheckMoveTrgId() == 2) { mode = 2; if (bndSph != null) { TouchPostion = bndSph.Sphre.Pos; } else { TouchPostion = destinationTrgActor.BasePos; } } else { TouchPostion = calCollLook.NextPos; } } }
private float calBestDis; /// 衝突した距離 /// public メソッド ///--------------------------------------------------------------------------- /// ラインとの衝突 public bool Check(DemoGame.GeometryLine moveLine, GameShapeProduct trgShape) { bool hitFlg = false; switch (trgShape.GetShapeType()) { /// 三角形 case GameShapeProduct.TypeId.Triangles: hitFlg = CheckTriangle(moveLine, (ShapeTriangles)trgShape); break; /// カプセル case GameShapeProduct.TypeId.Capsule: hitFlg = CheckCapsule(moveLine, (ShapeCapsule)trgShape); break; } return(hitFlg); }
/// カプセルと三角形との衝突 public bool Check(DemoGame.GeometryLine moveLine, ShapeTriangles trgShape) { Vector3 collPos = StaticDataList.getVectorZero(); calMovePos = moveLine.EndPos; calBestDis = -1.0f; calBestId = -1; float checDis = moveLine.Length + collCheckDis; for (int i = 0; i < trgShape.EntryNum; i++) { float a = (calMovePos.Dot(trgShape.Triangle[i].Plane.Nor) + trgShape.Triangle[i].Plane.D); if (a >= checDis || a <= -checDis) { continue; } if (DemoGame.CommonCollision.CheckLineAndTriangle(moveLine, trgShape.Triangle[i], ref collPos) == true) { float dis = Common.VectorUtil.Distance(collPos, moveLine.StartPos); if (dis < calBestDis || calBestId < 0) { calMovePos = collPos; calBestDis = dis; calBestId = i; } } AppDebug.CollCnt++; } if (calBestId >= 0) { return(true); } return(false); }
/// 敵陣地の拡大 public void setMonument( int scrPosX, int scrPosY ) { GameActorCollManager useCollMgr = actorDestination.GetMoveCollManager(); Vector3 posStart = new Vector3(0,0,0); Vector3 posEnd = new Vector3(0,0,0); /// チェックする開始座標と終了座標のセット ctrlResMgr.GraphDev.GetScreenToWorldPos( scrPosX, scrPosY, 0.0f, ref posStart ); ctrlResMgr.GraphDev.GetScreenToWorldPos( scrPosX, scrPosY, 1.0f, ref posEnd ); DemoGame.GeometryLine moveMoveLine = new DemoGame.GeometryLine( posStart, posEnd ); /// 衝突対象の登録 useCollMgr.TrgContainer.Clear(); useCollMgr.TrgContainer.Add( actorStg, actorStg.GetUseObj(0) ); /// 衝突判定 calCollLook.SetMoveType( Data.CollTypeId.ChDestination ); bool checkBound = calCollLook.Check( useCollMgr, moveMoveLine ); if( checkBound ){ TouchPostion = calCollLook.NextPos; if(ctrlResMgr.CtrlMo.inDistance(TouchPostion) == true){ ctrlResMgr.CtrlMo.EntryAddMonument(1,0,new Vector3(TouchPostion.X,30.0f,TouchPostion.Z)); ctrlResMgr.CtrlPl.Addeffect(towerNowPos); AppSound.GetInstance().PlaySeCamDis( AppSound.SeId.MakeMo, towerNowPos ); //makeEnemyTower if(makeEnemyMonument == 0){ //+-3 ctrlResMgr.CtrlTo.EntryAddTower((int)Data.Tex2dResId.Bosstower,new Vector3((int)Data.SetupValue.EnemyMonumentPosX-3,30.0f,(int)Data.SetupValue.EnemyMonumentPosY-3 )); ctrlResMgr.CtrlTo.EntryAddTower((int)Data.Tex2dResId.Bosstower,new Vector3((int)Data.SetupValue.EnemyMonumentPosX-3,30.0f,(int)Data.SetupValue.EnemyMonumentPosY+3 )); ctrlResMgr.CtrlTo.EntryAddTower((int)Data.Tex2dResId.Bosstower,new Vector3((int)Data.SetupValue.EnemyMonumentPosX+3,30.0f,(int)Data.SetupValue.EnemyMonumentPosY+3 )); ctrlResMgr.CtrlTo.EntryAddTower((int)Data.Tex2dResId.Bosstower,new Vector3((int)Data.SetupValue.EnemyMonumentPosX+3,30.0f,(int)Data.SetupValue.EnemyMonumentPosY-3 )); ctrlResMgr.CtrlWall.EntryAddWall((int)Data.Tex2dResId.BossWall,new Vector3((int)Data.SetupValue.EnemyMonumentPosX-3,30.0f,(int)Data.SetupValue.EnemyMonumentPosY-3),new Vector3((int)Data.SetupValue.EnemyMonumentPosX-3,30.0f,(int)Data.SetupValue.EnemyMonumentPosY+3)); ctrlResMgr.CtrlWall.EntryAddWall((int)Data.Tex2dResId.BossWall,new Vector3((int)Data.SetupValue.EnemyMonumentPosX-3,30.0f,(int)Data.SetupValue.EnemyMonumentPosY+3),new Vector3((int)Data.SetupValue.EnemyMonumentPosX+3,30.0f,(int)Data.SetupValue.EnemyMonumentPosY+3)); ctrlResMgr.CtrlWall.EntryAddWall((int)Data.Tex2dResId.BossWall,new Vector3((int)Data.SetupValue.EnemyMonumentPosX+3,30.0f,(int)Data.SetupValue.EnemyMonumentPosY+3),new Vector3((int)Data.SetupValue.EnemyMonumentPosX+3,30.0f,(int)Data.SetupValue.EnemyMonumentPosY-3)); ctrlResMgr.CtrlWall.EntryAddWall((int)Data.Tex2dResId.BossWall,new Vector3((int)Data.SetupValue.EnemyMonumentPosX+3,30.0f,(int)Data.SetupValue.EnemyMonumentPosY-3),new Vector3((int)Data.SetupValue.EnemyMonumentPosX-3,30.0f,(int)Data.SetupValue.EnemyMonumentPosY-3)); }else if(makeEnemyMonument == 1){ int prePosX = 0,prePosY = 0; int i=-2; int j=-2; for(j=-2; j<=2; j++){ ctrlResMgr.CtrlTo.EntryAddTower((int)Data.Tex2dResId.Bosstower,new Vector3((int)Data.SetupValue.EnemyMonumentPosX+6*i,30.0f,(int)Data.SetupValue.EnemyMonumentPosY+6*j)); if(j!=-2){ ctrlResMgr.CtrlWall.EntryAddWall((int)Data.Tex2dResId.BossWall,new Vector3(prePosX,30.0f,prePosY),new Vector3((int)Data.SetupValue.EnemyMonumentPosX+6*i,30.0f,(int)Data.SetupValue.EnemyMonumentPosY+6*j)); } prePosX = (int)Data.SetupValue.EnemyMonumentPosX+6*i; prePosY = (int)Data.SetupValue.EnemyMonumentPosY+6*j; } i=2; for(j=-2; j<=2; j++){ ctrlResMgr.CtrlTo.EntryAddTower((int)Data.Tex2dResId.Bosstower,new Vector3((int)Data.SetupValue.EnemyMonumentPosX+6*i,30.0f,(int)Data.SetupValue.EnemyMonumentPosY+6*j)); if(j!=-2){ ctrlResMgr.CtrlWall.EntryAddWall((int)Data.Tex2dResId.BossWall,new Vector3(prePosX,30.0f,prePosY),new Vector3((int)Data.SetupValue.EnemyMonumentPosX+6*i,30.0f,(int)Data.SetupValue.EnemyMonumentPosY+6*j)); } prePosX = (int)Data.SetupValue.EnemyMonumentPosX+6*i; prePosY = (int)Data.SetupValue.EnemyMonumentPosY+6*j; } j=-2; for(i=-2; i<=2; i++){ ctrlResMgr.CtrlTo.EntryAddTower((int)Data.Tex2dResId.Bosstower,new Vector3((int)Data.SetupValue.EnemyMonumentPosX+6*i,30.0f,(int)Data.SetupValue.EnemyMonumentPosY+6*j)); if(i!=-2){ ctrlResMgr.CtrlWall.EntryAddWall((int)Data.Tex2dResId.BossWall,new Vector3(prePosX,30.0f,prePosY),new Vector3((int)Data.SetupValue.EnemyMonumentPosX+6*i,30.0f,(int)Data.SetupValue.EnemyMonumentPosY+6*j)); } prePosX = (int)Data.SetupValue.EnemyMonumentPosX+6*i; prePosY = (int)Data.SetupValue.EnemyMonumentPosY+6*j; } j=2; for(i=-2; i<=2; i++){ ctrlResMgr.CtrlTo.EntryAddTower((int)Data.Tex2dResId.Bosstower,new Vector3((int)Data.SetupValue.EnemyMonumentPosX+6*i,30.0f,(int)Data.SetupValue.EnemyMonumentPosY+6*j)); if(i!=-2){ ctrlResMgr.CtrlWall.EntryAddWall((int)Data.Tex2dResId.BossWall,new Vector3(prePosX,30.0f,prePosY),new Vector3((int)Data.SetupValue.EnemyMonumentPosX+6*i,30.0f,(int)Data.SetupValue.EnemyMonumentPosY+6*j)); } prePosX = (int)Data.SetupValue.EnemyMonumentPosX+6*i; prePosY = (int)Data.SetupValue.EnemyMonumentPosY+6*j; } } makeEnemyMonument++; MonumentSetFlag = false; } } }
/// 食べる目標決め public void setEatTarget( int scrPosX, int scrPosY ) { GameActorCollManager useCollMgr = actorDestination.GetMoveCollManager(); Vector3 posStart = new Vector3(0,0,0); Vector3 posEnd = new Vector3(0,0,0); /// チェックする開始座標と終了座標のセット ctrlResMgr.GraphDev.GetScreenToWorldPos( scrPosX, scrPosY, 0.0f, ref posStart ); ctrlResMgr.GraphDev.GetScreenToWorldPos( scrPosX, scrPosY, 1.0f, ref posEnd ); DemoGame.GeometryLine moveMoveLine = new DemoGame.GeometryLine( posStart, posEnd ); /// 衝突対象の登録 useCollMgr.TrgContainer.Clear(); ctrlResMgr.CtrlHobit.SetDestinationActor( useCollMgr.TrgContainer ); ctrlResMgr.CtrlTo.SetDestinationActor( useCollMgr.TrgContainer ); ctrlResMgr.CtrlWall.SetDestinationActor( useCollMgr.TrgContainer ); ctrlResMgr.CtrlHouse.SetDestinationActor( useCollMgr.TrgContainer ); // ctrlResMgr.CtrlTo.SetDestinationActor( useCollMgr.TrgContainer ); // ctrlResMgr.CtrlWall.SetDestinationActor( useCollMgr.TrgContainer ); /// 衝突判定 calCollLook.SetMoveType( Data.CollTypeId.ChDestination ); bool checkBound = calCollLook.Check( useCollMgr, moveMoveLine ); if( checkBound ){ /// マーカーのセット destinationTrgActor = useCollMgr.TrgContainer.GetEntryObjParent(0); ShapeSphere bndSph = destinationTrgActor.GetBoundingShape(); if( destinationTrgActor.CheckMoveTrgId() == 1 ){ if( bndSph != null ){ TouchPostion = bndSph.Sphre.Pos; } else{ TouchPostion = destinationTrgActor.BasePos; } destinationTrgActor.SetEatFlag(); } else if( destinationTrgActor.CheckMoveTrgId() == 2 ){ if( bndSph != null ){ TouchPostion = bndSph.Sphre.Pos; } else{ TouchPostion = destinationTrgActor.BasePos; } destinationTrgActor.SetEatFlag(); } else if( destinationTrgActor.CheckMoveTrgId() == 3 ){ if( bndSph != null ){ TouchPostion = bndSph.Sphre.Pos; } else{ TouchPostion = destinationTrgActor.BasePos; } destinationTrgActor.SetEatFlag(); }else if( destinationTrgActor.CheckMoveTrgId() == 4 ){ if( bndSph != null ){ TouchPostion = bndSph.Sphre.Pos; } else{ TouchPostion = destinationTrgActor.BasePos; } destinationTrgActor.SetEatFlag(); }else{ TouchPostion = calCollLook.NextPos; } } }
/// private メソッド ///--------------------------------------------------------------------------- /// 目的地セット public void setDestination( int scrPosX, int scrPosY ) { GameActorCollManager useCollMgr = actorDestination.GetMoveCollManager(); Vector3 posStart = new Vector3(0,0,0); Vector3 posEnd = new Vector3(0,0,0); /// チェックする開始座標と終了座標のセット ctrlResMgr.GraphDev.GetScreenToWorldPos( scrPosX, scrPosY, 0.0f, ref posStart ); ctrlResMgr.GraphDev.GetScreenToWorldPos( scrPosX, scrPosY, 1.0f, ref posEnd ); DemoGame.GeometryLine moveMoveLine = new DemoGame.GeometryLine( posStart, posEnd ); /// 衝突対象の登録 useCollMgr.TrgContainer.Clear(); ctrlResMgr.CtrlHobit.SetDestinationActor( useCollMgr.TrgContainer ); ctrlResMgr.CtrlTo.SetDestinationActor( useCollMgr.TrgContainer ); ctrlResMgr.CtrlWall.SetDestinationActor( useCollMgr.TrgContainer ); useCollMgr.TrgContainer.Add( actorStg, actorStg.GetUseObj(0) ); /// 衝突判定 calCollLook.SetMoveType( Data.CollTypeId.ChDestination ); bool checkBound = calCollLook.Check( useCollMgr, moveMoveLine ); if( checkBound ){ /// マーカーのセット actorDestination.Start(); Matrix4 mtx = Matrix4.RotationY( 0 ); destinationTrgActor = useCollMgr.TrgContainer.GetEntryObjParent(0); ShapeSphere bndSph = destinationTrgActor.GetBoundingShape(); if( destinationTrgActor.CheckMoveTrgId() == 1 ){ if( bndSph != null ){ destinationPos = bndSph.Sphre.Pos; } else{ destinationPos = destinationTrgActor.BasePos; } actorDestination.SetType( 0 ); } else if( destinationTrgActor.CheckMoveTrgId() == 2 ){ destinationPos = destinationTrgActor.BasePos; if( bndSph != null ){ destinationPos.Y += bndSph.Sphre.R; } actorDestination.SetType( 0 ); } else{ destinationPos = calCollLook.NextPos; destinationPos.Y += 0.02f; actorDestination.SetType( 1 ); } Common.MatrixUtil.SetTranslate( ref mtx, destinationPos ); actorDestination.SetPlace( mtx ); actorDestination.Enable = true; } else{ actorDestination.Enable = false; } }
/// 壁の生成 public void makeWall( int scrPosX, int scrPosY ) { GameActorCollManager useCollMgr = actorDestination.GetMoveCollManager(); Vector3 posStart = new Vector3(0,0,0); Vector3 posEnd = new Vector3(0,0,0); /// チェックする開始座標と終了座標のセット ctrlResMgr.GraphDev.GetScreenToWorldPos( scrPosX, scrPosY, 0.0f, ref posStart ); ctrlResMgr.GraphDev.GetScreenToWorldPos( scrPosX, scrPosY, 1.0f, ref posEnd ); DemoGame.GeometryLine moveMoveLine = new DemoGame.GeometryLine( posStart, posEnd ); /// 衝突対象の登録 useCollMgr.TrgContainer.Clear(); ctrlResMgr.CtrlTo.SetDestinationActor( useCollMgr.TrgContainer ); useCollMgr.TrgContainer.Add( actorStg, actorStg.GetUseObj(0) ); /// 衝突判定 calCollLook.SetMoveType( Data.CollTypeId.ChDestination ); bool checkBound = calCollLook.Check( useCollMgr, moveMoveLine ); if( checkBound ){ /// マーカーのセット // actorDestination.Start(); Matrix4 mtx = Matrix4.RotationY( 0 ); destinationTrgActor = useCollMgr.TrgContainer.GetEntryObjParent(0); ShapeSphere bndSph = destinationTrgActor.GetBoundingShape(); if( destinationTrgActor.CheckMoveTrgId() == 2){ //始点の建物に接触 towerNowPos = destinationTrgActor.BasePos; TouchPostion = destinationTrgActor.BasePos; if(towerPos.X != towerNowPos.X && towerPos.Z != towerNowPos.Z && !(towerPos.X == 0.0f && towerPos.Y == 0.0f && towerPos.Z == 0.0f)){ //最初のタッチ以外もしくは前のタワー以外との接触の場合 if( bndSph != null ){ towerNowPos.Y += bndSph.Sphre.R; } towerNowPos.Y += 0.1f; ctrlResMgr.AddWall = true; ctrlResMgr.AddWallPos1 = towerPos; ctrlResMgr.AddWallPos2 = towerNowPos; makeTowerFlag = false; Console.WriteLine("asdf"); } }else{ Console.WriteLine("fdsa"); towerNowPos = calCollLook.NextPos; TouchPostion = calCollLook.NextPos; towerNowPos.Y += 0.1f; if(towerPos.X == 0.0f && towerPos.Y == 0.0f && towerPos.Z == 0.0f){ towerPos = towerNowPos; effectPos = towerNowPos; //ctrlResMgr.CtrlTo.EntryAddTower( 1, 0.0f, towerNowPos, (int)StaticDataList.getRandom(0,5)); } double dis2 = Common.VectorUtil.Distance( towerPos , towerNowPos ); if(dis2 > newTowerDis){ ctrlResMgr.AddWall = true; ctrlResMgr.AddWallPos1 = towerPos; ctrlResMgr.AddWallPos2 = towerNowPos; ctrlResMgr.AddTower = true; ctrlResMgr.AddTowerPos = towerNowPos; TowerAreaNorth = FMath.Max(TowerAreaNorth , towerNowPos.X); TowerAreaSouth = FMath.Min(TowerAreaSouth , towerNowPos.X); TowerAreaEast = FMath.Max(TowerAreaEast , towerNowPos.Z); TowerAreaWest = FMath.Min(TowerAreaWest , towerNowPos.Z); //AppSound.GetInstance().PlaySeCamDis( AppSound.SeId.MakeMo, towerNowPos ); towerPos = towerNowPos; //sumPos += towerPos; //sumcount++; } dis2 = Common.VectorUtil.Distance( effectPos , towerNowPos ); if(dis2 > newEffectDis){ ctrlResMgr.AddEffectFromEnemy = true; ctrlResMgr.AddEnemyEffectPos = towerNowPos; effectPos = towerNowPos; } } } }
/// 壁の生成 public void makeWall(int scrPosX, int scrPosY) { GameActorCollManager useCollMgr = actorDestination.GetMoveCollManager(); Vector3 posStart = new Vector3(0, 0, 0); Vector3 posEnd = new Vector3(0, 0, 0); /// チェックする開始座標と終了座標のセット ctrlResMgr.GraphDev.GetScreenToWorldPos(scrPosX, scrPosY, 0.0f, ref posStart); ctrlResMgr.GraphDev.GetScreenToWorldPos(scrPosX, scrPosY, 1.0f, ref posEnd); DemoGame.GeometryLine moveMoveLine = new DemoGame.GeometryLine(posStart, posEnd); /// 衝突対象の登録 useCollMgr.TrgContainer.Clear(); ctrlResMgr.CtrlTo.SetDestinationActor(useCollMgr.TrgContainer); useCollMgr.TrgContainer.Add(actorStg, actorStg.GetUseObj(0)); /// 衝突判定 calCollLook.SetMoveType(Data.CollTypeId.ChDestination); bool checkBound = calCollLook.Check(useCollMgr, moveMoveLine); if (checkBound) { /// マーカーのセット // actorDestination.Start(); Matrix4 mtx = Matrix4.RotationY(0); destinationTrgActor = useCollMgr.TrgContainer.GetEntryObjParent(0); ShapeSphere bndSph = destinationTrgActor.GetBoundingShape(); if (destinationTrgActor.CheckMoveTrgId() == 2) //始点の建物に接触 { towerNowPos = destinationTrgActor.BasePos; TouchPostion = destinationTrgActor.BasePos; if (towerPos.X != towerNowPos.X && towerPos.Z != towerNowPos.Z && !(towerPos.X == 0.0f && towerPos.Y == 0.0f && towerPos.Z == 0.0f)) //最初のタッチ以外もしくは前のタワー以外との接触の場合 { if (bndSph != null) { towerNowPos.Y += bndSph.Sphre.R; } towerNowPos.Y += 0.1f; ctrlResMgr.AddWall = true; ctrlResMgr.AddWallPos1 = towerPos; ctrlResMgr.AddWallPos2 = towerNowPos; makeTowerFlag = false; Console.WriteLine("asdf"); } } else { Console.WriteLine("fdsa"); towerNowPos = calCollLook.NextPos; TouchPostion = calCollLook.NextPos; towerNowPos.Y += 0.1f; if (towerPos.X == 0.0f && towerPos.Y == 0.0f && towerPos.Z == 0.0f) { towerPos = towerNowPos; effectPos = towerNowPos; //ctrlResMgr.CtrlTo.EntryAddTower( 1, 0.0f, towerNowPos, (int)StaticDataList.getRandom(0,5)); } double dis2 = Common.VectorUtil.Distance(towerPos, towerNowPos); if (dis2 > newTowerDis) { ctrlResMgr.AddWall = true; ctrlResMgr.AddWallPos1 = towerPos; ctrlResMgr.AddWallPos2 = towerNowPos; ctrlResMgr.AddTower = true; ctrlResMgr.AddTowerPos = towerNowPos; TowerAreaNorth = FMath.Max(TowerAreaNorth, towerNowPos.X); TowerAreaSouth = FMath.Min(TowerAreaSouth, towerNowPos.X); TowerAreaEast = FMath.Max(TowerAreaEast, towerNowPos.Z); TowerAreaWest = FMath.Min(TowerAreaWest, towerNowPos.Z); //AppSound.GetInstance().PlaySeCamDis( AppSound.SeId.MakeMo, towerNowPos ); towerPos = towerNowPos; //sumPos += towerPos; //sumcount++; } dis2 = Common.VectorUtil.Distance(effectPos, towerNowPos); if (dis2 > newEffectDis) { ctrlResMgr.AddEffectFromEnemy = true; ctrlResMgr.AddEnemyEffectPos = towerNowPos; effectPos = towerNowPos; } } } }
/// 敵陣地の拡大 public void setMonument(int scrPosX, int scrPosY) { GameActorCollManager useCollMgr = actorDestination.GetMoveCollManager(); Vector3 posStart = new Vector3(0, 0, 0); Vector3 posEnd = new Vector3(0, 0, 0); /// チェックする開始座標と終了座標のセット ctrlResMgr.GraphDev.GetScreenToWorldPos(scrPosX, scrPosY, 0.0f, ref posStart); ctrlResMgr.GraphDev.GetScreenToWorldPos(scrPosX, scrPosY, 1.0f, ref posEnd); DemoGame.GeometryLine moveMoveLine = new DemoGame.GeometryLine(posStart, posEnd); /// 衝突対象の登録 useCollMgr.TrgContainer.Clear(); useCollMgr.TrgContainer.Add(actorStg, actorStg.GetUseObj(0)); /// 衝突判定 calCollLook.SetMoveType(Data.CollTypeId.ChDestination); bool checkBound = calCollLook.Check(useCollMgr, moveMoveLine); if (checkBound) { TouchPostion = calCollLook.NextPos; if (ctrlResMgr.CtrlMo.inDistance(TouchPostion) == true) { ctrlResMgr.CtrlMo.EntryAddMonument(1, 0, new Vector3(TouchPostion.X, 30.0f, TouchPostion.Z)); ctrlResMgr.CtrlPl.Addeffect(towerNowPos); AppSound.GetInstance().PlaySeCamDis(AppSound.SeId.MakeMo, towerNowPos); //makeEnemyTower if (makeEnemyMonument == 0) { //+-3 ctrlResMgr.CtrlTo.EntryAddTower((int)Data.Tex2dResId.Bosstower, new Vector3((int)Data.SetupValue.EnemyMonumentPosX - 3, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY - 3)); ctrlResMgr.CtrlTo.EntryAddTower((int)Data.Tex2dResId.Bosstower, new Vector3((int)Data.SetupValue.EnemyMonumentPosX - 3, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY + 3)); ctrlResMgr.CtrlTo.EntryAddTower((int)Data.Tex2dResId.Bosstower, new Vector3((int)Data.SetupValue.EnemyMonumentPosX + 3, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY + 3)); ctrlResMgr.CtrlTo.EntryAddTower((int)Data.Tex2dResId.Bosstower, new Vector3((int)Data.SetupValue.EnemyMonumentPosX + 3, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY - 3)); ctrlResMgr.CtrlWall.EntryAddWall((int)Data.Tex2dResId.BossWall, new Vector3((int)Data.SetupValue.EnemyMonumentPosX - 3, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY - 3), new Vector3((int)Data.SetupValue.EnemyMonumentPosX - 3, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY + 3)); ctrlResMgr.CtrlWall.EntryAddWall((int)Data.Tex2dResId.BossWall, new Vector3((int)Data.SetupValue.EnemyMonumentPosX - 3, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY + 3), new Vector3((int)Data.SetupValue.EnemyMonumentPosX + 3, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY + 3)); ctrlResMgr.CtrlWall.EntryAddWall((int)Data.Tex2dResId.BossWall, new Vector3((int)Data.SetupValue.EnemyMonumentPosX + 3, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY + 3), new Vector3((int)Data.SetupValue.EnemyMonumentPosX + 3, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY - 3)); ctrlResMgr.CtrlWall.EntryAddWall((int)Data.Tex2dResId.BossWall, new Vector3((int)Data.SetupValue.EnemyMonumentPosX + 3, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY - 3), new Vector3((int)Data.SetupValue.EnemyMonumentPosX - 3, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY - 3)); } else if (makeEnemyMonument == 1) { int prePosX = 0, prePosY = 0; int i = -2; int j = -2; for (j = -2; j <= 2; j++) { ctrlResMgr.CtrlTo.EntryAddTower((int)Data.Tex2dResId.Bosstower, new Vector3((int)Data.SetupValue.EnemyMonumentPosX + 6 * i, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY + 6 * j)); if (j != -2) { ctrlResMgr.CtrlWall.EntryAddWall((int)Data.Tex2dResId.BossWall, new Vector3(prePosX, 30.0f, prePosY), new Vector3((int)Data.SetupValue.EnemyMonumentPosX + 6 * i, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY + 6 * j)); } prePosX = (int)Data.SetupValue.EnemyMonumentPosX + 6 * i; prePosY = (int)Data.SetupValue.EnemyMonumentPosY + 6 * j; } i = 2; for (j = -2; j <= 2; j++) { ctrlResMgr.CtrlTo.EntryAddTower((int)Data.Tex2dResId.Bosstower, new Vector3((int)Data.SetupValue.EnemyMonumentPosX + 6 * i, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY + 6 * j)); if (j != -2) { ctrlResMgr.CtrlWall.EntryAddWall((int)Data.Tex2dResId.BossWall, new Vector3(prePosX, 30.0f, prePosY), new Vector3((int)Data.SetupValue.EnemyMonumentPosX + 6 * i, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY + 6 * j)); } prePosX = (int)Data.SetupValue.EnemyMonumentPosX + 6 * i; prePosY = (int)Data.SetupValue.EnemyMonumentPosY + 6 * j; } j = -2; for (i = -2; i <= 2; i++) { ctrlResMgr.CtrlTo.EntryAddTower((int)Data.Tex2dResId.Bosstower, new Vector3((int)Data.SetupValue.EnemyMonumentPosX + 6 * i, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY + 6 * j)); if (i != -2) { ctrlResMgr.CtrlWall.EntryAddWall((int)Data.Tex2dResId.BossWall, new Vector3(prePosX, 30.0f, prePosY), new Vector3((int)Data.SetupValue.EnemyMonumentPosX + 6 * i, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY + 6 * j)); } prePosX = (int)Data.SetupValue.EnemyMonumentPosX + 6 * i; prePosY = (int)Data.SetupValue.EnemyMonumentPosY + 6 * j; } j = 2; for (i = -2; i <= 2; i++) { ctrlResMgr.CtrlTo.EntryAddTower((int)Data.Tex2dResId.Bosstower, new Vector3((int)Data.SetupValue.EnemyMonumentPosX + 6 * i, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY + 6 * j)); if (i != -2) { ctrlResMgr.CtrlWall.EntryAddWall((int)Data.Tex2dResId.BossWall, new Vector3(prePosX, 30.0f, prePosY), new Vector3((int)Data.SetupValue.EnemyMonumentPosX + 6 * i, 30.0f, (int)Data.SetupValue.EnemyMonumentPosY + 6 * j)); } prePosX = (int)Data.SetupValue.EnemyMonumentPosX + 6 * i; prePosY = (int)Data.SetupValue.EnemyMonumentPosY + 6 * j; } } makeEnemyMonument++; MonumentSetFlag = false; } } }
/// private メソッド ///--------------------------------------------------------------------------- /// 目的地セット public void setDestination(int scrPosX, int scrPosY) { GameActorCollManager useCollMgr = actorDestination.GetMoveCollManager(); Vector3 posStart = new Vector3(0, 0, 0); Vector3 posEnd = new Vector3(0, 0, 0); /// チェックする開始座標と終了座標のセット ctrlResMgr.GraphDev.GetScreenToWorldPos(scrPosX, scrPosY, 0.0f, ref posStart); ctrlResMgr.GraphDev.GetScreenToWorldPos(scrPosX, scrPosY, 1.0f, ref posEnd); DemoGame.GeometryLine moveMoveLine = new DemoGame.GeometryLine(posStart, posEnd); /// 衝突対象の登録 useCollMgr.TrgContainer.Clear(); ctrlResMgr.CtrlHobit.SetDestinationActor(useCollMgr.TrgContainer); ctrlResMgr.CtrlTo.SetDestinationActor(useCollMgr.TrgContainer); ctrlResMgr.CtrlWall.SetDestinationActor(useCollMgr.TrgContainer); useCollMgr.TrgContainer.Add(actorStg, actorStg.GetUseObj(0)); /// 衝突判定 calCollLook.SetMoveType(Data.CollTypeId.ChDestination); bool checkBound = calCollLook.Check(useCollMgr, moveMoveLine); if (checkBound) { /// マーカーのセット actorDestination.Start(); Matrix4 mtx = Matrix4.RotationY(0); destinationTrgActor = useCollMgr.TrgContainer.GetEntryObjParent(0); ShapeSphere bndSph = destinationTrgActor.GetBoundingShape(); if (destinationTrgActor.CheckMoveTrgId() == 1) { if (bndSph != null) { destinationPos = bndSph.Sphre.Pos; } else { destinationPos = destinationTrgActor.BasePos; } actorDestination.SetType(0); } else if (destinationTrgActor.CheckMoveTrgId() == 2) { destinationPos = destinationTrgActor.BasePos; if (bndSph != null) { destinationPos.Y += bndSph.Sphre.R; } actorDestination.SetType(0); } else { destinationPos = calCollLook.NextPos; destinationPos.Y += 0.02f; actorDestination.SetType(1); } Common.MatrixUtil.SetTranslate(ref mtx, destinationPos); actorDestination.SetPlace(mtx); actorDestination.Enable = true; } else { actorDestination.Enable = false; } }