Beispiel #1
0
/// private メソッド
///---------------------------------------------------------------------------

        /// 衝突後の移動座標をセット
        public void setScrapedMovePos(GameActorCollManager collMgr, Vector3 movePos)
        {
            /// 衝突あり
            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, movePos, (ShapeTriangles)trgShape);
                    break;
                }
            }

            /// 衝突無し
            else
            {
                nextPos = movePos;
                ResetGroudParam();
            }

            /// Y軸はマイナスまで行かない
            if (nextPos.Y < 0.0f)
            {
                nextPos.Y = 0.0f;
            }
        }
/// private メソッド
///---------------------------------------------------------------------------

        /// 衝突後の移動座標をセット
        private void setScrapedMovePos(GameActorCollManager collMgr, Vector3 movePos)
        {
            /// 衝突あり
            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, movePos, (ShapeTriangles)trgShape);
                    break;

                /// カプセル
                case GameShapeProduct.TypeId.Capsule:
                    calCollSphMove.Check(moveMoveCap, (ShapeCapsule)trgShape);
                    nextPos = calCollSphMove.MovePos;
                    break;
                }
            }

            /// 衝突無し
            else
            {
                nextPos = movePos;
            }
        }
        /// 破棄
        public override void Term()
        {
            DoTerm();

            if (moveCollMgr != null)
            {
                moveCollMgr.Term();
            }
            if (calCollMove != null)
            {
                calCollMove.Term();
            }
            if (interfereCntr != null)
            {
                interfereCntr.Term();
            }
            if (EventCntr != null)
            {
                EventCntr.Clear();
                EventCntr.Term();
            }

            interfereCntr = null;
            EventCntr     = null;
            moveCollMgr   = null;
            calCollMove   = null;
        }
        /// 移動先のセット

        /**
         * 坂道でも平面と同じ移動が出来るように踏んでいる地面の角度に合わせて移動先の座標に変換をかける
         * upVec  : 地面の法線
         * trgPos : 移動候補のオフセット位置
         */
        public void GetMovePos(GameActorCollManager collMgr, Vector3 upVec, Vector3 trgPos, ref Vector3 movePos)
        {
            ShapeSphere moveSph = (ShapeSphere)collMgr.MoveShape;
            Vector3     leftVec = new Vector3(1.0f, 0.0f, 0.0f);
            Matrix4     world   = new Matrix4();

            // Z軸のセット
            Vector3 calVecX = Common.VectorUtil.Cross2(leftVec, upVec);

            calVecX   = calVecX.Normalize();
            world.M31 = calVecX.X;
            world.M32 = calVecX.Y;
            world.M33 = calVecX.Z;
            world.M34 = 0;

            // X軸のセット
            world.M11 = leftVec.X;
            world.M12 = leftVec.Y;
            world.M13 = leftVec.Z;
            world.M14 = 0;

            // Y軸のセット
            world.M21 = upVec.X;
            world.M22 = upVec.Y;
            world.M23 = upVec.Z;
            world.M24 = 0;

            /// 移動先のセット
            movePos  = Common.VectorUtil.Mult(ref trgPos, world);
            movePos += moveSph.Sphre.Pos;
        }
        /// チェック
        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();
        }
Beispiel #6
0
        /// チェック
        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());
        }
Beispiel #7
0
        /// 衝突後の移動座標をセット(三角形との衝突)
        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);
        }
Beispiel #8
0
        /// 破棄
        public override void Term()
        {
            DoTerm();

            if (moveCollMgr != null)
            {
                moveCollMgr.Term();
            }
            if (unitCmnPlay != null)
            {
                unitCmnPlay.Term();
            }
            if (EventCntr != null)
            {
                EventCntr.Clear();
                EventCntr.Term();
            }
            if (interfereCntr != null)
            {
                interfereCntr.Term();
            }

            interfereCntr = null;
            EventCntr     = null;
            moveCollMgr   = null;
            unitCmnPlay   = null;
            dmgTrgObj     = null;
        }
Beispiel #9
0
/// 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;
                }
            }
        }
Beispiel #10
0
 /// クリア
 public void End()
 {
     playId           = 0;
     useActor         = null;
     useInterfereCntr = null;
     useCollMgr       = null;
 }
        /// シーンの初期化
        public bool Init(DemoGame.SceneManager sceneMgr)
        {
            useSceneMgr = sceneMgr;

            calCollGrav = new ActorUnitCollGravity();
            calCollGrav.Init();

            moveCollMgr = new GameActorCollManager();
            moveCollMgr.Init();

            shapeMove = new ShapeSphere();
            shapeMove.Init(1);
            shapeMove.Set(0, StaticDataList.getVectorZero(), 0.001f);

            renderSph = new DemoGame.RenderGeometry();
            renderSph.MakeSphere();
///        trgObj        = null;

            /// 移動する自身のOBJを登録
            moveCollMgr.SetMoveShape(shapeMove);


            trgObjMoveSpd = 1.0f;
            setPlaceTypeParam(trgObjType);

            nowTaskId = debugMenuTaskId.SelectObj;
            changeTask(debugMenuTaskId.SelectObj);
            return(true);
        }
Beispiel #12
0
        /// 移動先のセット
        public void GetMovePos(GameActorCollManager collMgr, ref Vector3 movePos)
        {
            ShapeSphere moveSph = (ShapeSphere)collMgr.MoveShape;

            movePos    = moveSph.Sphre.Pos;
            movePos.Y -= 0.5f;
        }
        /// シーンの破棄
        public void Term()
        {
            if (calCollGrav != null)
            {
                calCollGrav.Term();
            }
            if (moveCollMgr != null)
            {
                moveCollMgr.Term();
            }
            if (shapeMove != null)
            {
                shapeMove.Term();
            }
            if (renderSph != null)
            {
                renderSph.Dispose();
            }

///        trgObj            = null;
            renderSph   = null;
            shapeMove   = null;
            moveCollMgr = null;
            calCollGrav = null;
            useSceneMgr = null;
        }
        /// 継承メソッド
        ///---------------------------------------------------------------------------
        /// 初期化
        public override bool Init()
        {
            objMark = new ObjDestinationMark();
            objMark.Init();

            moveCollMgr = new GameActorCollManager();
            moveCollMgr.Init();
            return true;
        }
/// 継承メソッド
///---------------------------------------------------------------------------

        /// 初期化
        public override bool Init()
        {
            objMark = new ObjDestinationMark();
            objMark.Init();

            moveCollMgr = new GameActorCollManager();
            moveCollMgr.Init();
            return(true);
        }
Beispiel #16
0
/// private メソッド
///---------------------------------------------------------------------------

        /// 移動衝突対象OBJの登録
        private void setMoveCollTrgObj(ActorBulletBase actor)
        {
            GameCtrlManager      ctrlResMgr = GameCtrlManager.GetInstance();
            GameActorCollManager useCollMgr = actor.GetMoveCollManager();

            /// 移動する自身のOBJを登録
            useCollMgr.SetMoveShape(actor.GetUseObj(0).GetMoveShape());

            /// 対象を登録
            ctrlResMgr.SetCollisionActor(useCollMgr.TrgContainer, actor.BasePos);
        }
        /// 破棄
        public override void Term()
        {
            if (moveCollMgr != null)
            {
                moveCollMgr.Term();
            }
            objMark.Term();

            moveCollMgr = null;
            objMark     = null;
        }
Beispiel #18
0
        /// 破壊対象
        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;
                }
            }
        }
Beispiel #19
0
        /// フレーム処理
        public bool Frame()
        {
            GameCtrlManager ctrlResMgr = GameCtrlManager.GetInstance();

            for (int i = 0; i < actorChList.Count; i++)
            {
                if (actorChList[i].ActiveFlg == true)
                {
                    GameActorCollManager useCollMgr = actorChList[i].GetMoveCollManager();

                    /// 他アクタからのイベントをチェック
                    ///-------------------------------------
                    if (actorChList[i].EventCntr.Num > 0)
                    {
                        ctrlResMgr.CtrlEvent.Play(actorChList[i], actorChList[i].EventCntr);
                    }

                    /// フレーム処理
                    ///-------------------------------------

                    if (actorChList[i].GetStateId() != ActorChBase.StateId.Dead && actorChList[i].GetStateId() != ActorChBase.StateId.Eat)
                    {
                        frameMove(actorChList[i]);
                    }

                    if (actorChList[i].firstFlag == true)
                    {
                        useCollMgr.SetMoveShape(GetUseActorBaseObj(i).GetMoveShape());
                        ctrlResMgr.SetCollisionActorEn(useCollMgr.TrgContainer, actorChList[i].BasePos);
                    }

                    actorChList[i].Frame();

                    /*
                     * if(actorChList[i].eatFlag == true){
                     *      ctrlResMgr.CtrlDestinationMark.EntryAddDestinationMark(actorChList[i].GetBodyPos());
                     * }
                     */

                    /// 自身発生のイベントをチェック
                    ///-------------------------------------
                    if (actorChList[i].EventCntr.Num > 0)
                    {
                        ctrlResMgr.CtrlEvent.Play(actorChList[i], actorChList[i].EventCntr);
                    }
                }
            }

            return(true);
        }
        /// チェック
        public bool Check(GameActorCollManager collMgr, Vector3 movePos)
        {
            ShapeSphere moveSph = (ShapeSphere)collMgr.MoveShape;

            moveMoveCap.Set(moveSph.Sphre.Pos, movePos, moveSph.Sphre.R);

            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);

                    bool hitFlg = false;

                    switch (trgShape.GetShapeType())
                    {
                    /// 三角形
                    case GameShapeProduct.TypeId.Triangles:
                        hitFlg = calCollSphMove.Check(moveMoveCap, (ShapeTriangles)trgShape);
                        break;

                    /// カプセル
                    case GameShapeProduct.TypeId.Capsule:
                        hitFlg = calCollSphMove.Check(moveMoveCap, (ShapeCapsule)trgShape);
                        break;
                    }

                    /// 衝突
                    if (hitFlg)
                    {
                        collMgr.SetCollParam(i, x, calCollSphMove.BestId, calCollSphMove.BestDis);
                        if (moveType == Data.CollTypeId.ChMove)
                        {
                            trgObj.deadFlag = true;
                        }
                    }
                }
            }

            /// 衝突後の移動座標をセット
            setScrapedMovePos(collMgr, movePos);

            /// 衝突した
            return(collMgr.CheckCollHit());
        }
Beispiel #21
0
        /// 開始
        public void Start(GameActorProduct useActor, GameActorContainer useInterfereCntr, GameActorCollManager useCollMgr)
        {
            basePos = new Vector3(0.0f, 0.0f, 0.0f);
            baseRot = new Vector3(0.0f, 0.0f, 0.0f);

            setMtxRotateEulerXYZ(baseRot);

            Common.MatrixUtil.SetTranslate(ref baseMtx, basePos);

            playId = 0;

            this.useActor         = useActor;
            this.useInterfereCntr = useInterfereCntr;
            this.useCollMgr       = useCollMgr;
        }
Beispiel #22
0
 /// 破棄
 public void Term()
 {
     if (calCollMove != null)
     {
         calCollMove.Term();
     }
     if (calCollGrav != null)
     {
         calCollGrav.Term();
     }
     calCollGrav      = null;
     calCollMove      = null;
     useCollMgr       = null;
     useActor         = null;
     useInterfereCntr = null;
 }
/// 継承メソッド
///---------------------------------------------------------------------------

        /// 初期化
        public override bool Init()
        {
            moveCollMgr = new GameActorCollManager();
            moveCollMgr.Init();

            interfereCntr = new GameActorContainer();
            interfereCntr.Init();

            calCollMove = new ActorUnitCollMove();
            calCollMove.Init();

            EventCntr = new GameActorEventContainer();
            EventCntr.Init();

            return(DoInit());
        }
Beispiel #24
0
/// 継承メソッド
///---------------------------------------------------------------------------

        /// 初期化
        public override bool Init()
        {
            unitCmnPlay = new ActorUnitCommon();
            unitCmnPlay.Init();

            moveCollMgr = new GameActorCollManager();
            moveCollMgr.Init();

            interfereCntr = new GameActorContainer();
            interfereCntr.Init();

            EventCntr = new GameActorEventContainer();
            EventCntr.Init();

            return(DoInit());
        }
        /// 衝突後の移動座標をセット(三角形との衝突)
        private void setScrapedMovePosTriangle(GameActorCollManager collMgr, Vector3 movePos, ShapeTriangles shapeTri)
        {
            ShapeSphere moveSph = (ShapeSphere)collMgr.MoveShape;
            int         primId  = collMgr.TrgContainer.GetEntryPrimId(0);

            Vector3 collPos    = StaticDataList.getVectorZero();
            float   scrapedPow = (moveSph.Sphre.R + 0.001f);

            /// 点と面上の最近接点を求める
            DemoGame.CommonCollision.GetClosestPtPosPlane(movePos, shapeTri.Triangle[primId].Plane, ref collPos);

            /// 移動候補座標更新
            nextPos.X = collPos.X + (scrapedPow * (shapeTri.Triangle[primId].Plane.Nor.X));
            nextPos.Y = collPos.Y + (scrapedPow * (shapeTri.Triangle[primId].Plane.Nor.Y));
            nextPos.Z = collPos.Z + (scrapedPow * (shapeTri.Triangle[primId].Plane.Nor.Z));
        }
        /// チェック
        public bool Check( GameActorCollManager collMgr, Vector3 movePos )
        {
            ShapeSphere moveSph = (ShapeSphere)collMgr.MoveShape;

            moveMoveCap.Set( moveSph.Sphre.Pos, movePos, moveSph.Sphre.R );

            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 );

                bool hitFlg = false;

                switch( trgShape.GetShapeType() ){

                /// 三角形
                case GameShapeProduct.TypeId.Triangles:
                    hitFlg = calCollSphMove.Check( moveMoveCap, (ShapeTriangles)trgShape );
                    break;

                /// カプセル
                case GameShapeProduct.TypeId.Capsule:
                    hitFlg = calCollSphMove.Check( moveMoveCap, (ShapeCapsule)trgShape );
                    break;
                }

                /// 衝突
                if( hitFlg ){
                    collMgr.SetCollParam( i, x, calCollSphMove.BestId, calCollSphMove.BestDis );
                    if(moveType == Data.CollTypeId.ChMove){
                        trgObj.deadFlag = true;
                    }
                }
            }
            }

            /// 衝突後の移動座標をセット
            setScrapedMovePos( collMgr, movePos );

            /// 衝突した
            return collMgr.CheckCollHit();
        }
Beispiel #27
0
        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;
                }
            }
        }
Beispiel #28
0
        /// フレーム処理
        public bool Frame()
        {
            for (int i = 0; i < actorChList.Count; i++)
            {
                if (actorChList[i].ActiveFlg == true)
                {
                    GameActorCollManager useCollMgr = actorChList[i].GetMoveCollManager();
                    /// 他アクタからのイベントをチェック
                    ///-------------------------------------
                    if (actorChList[i].EventCntr.Num > 0)
                    {
                        ctrlResMgr.CtrlEvent.Play(actorChList[i], actorChList[i].EventCntr);
                    }

                    /// フレーム処理
                    ///-------------------------------------
                    if (actorChList[i].GetStateId() != ActorChBase.StateId.Dead && actorChList[i].GetStateId() != ActorChBase.StateId.Eat)
                    {
                        frameMove(actorChList[i]);
                    }

                    if (actorChList[i].firstFlag == true)
                    {
                        useCollMgr.SetMoveShape(GetUseActorBaseObj(i).GetMoveShape());
                        ctrlResMgr.SetCollisionActorEn(useCollMgr.TrgContainer, actorChList[i].BasePos);
                    }

                    actorChList[i].Frame();

//				actorChList[i].ActiveDisPlace = Common.VectorUtil.DistanceXZ(actorChList[i].GetBodyPos(), CtrlRandom.getRandom.CtrlPl.GetPos());

                    /// 自身発生のイベントをチェック
                    ///-------------------------------------
                    if (actorChList[i].EventCntr.Num > 0)
                    {
                        ctrlResMgr.CtrlEvent.Play(actorChList[i], actorChList[i].EventCntr);
                    }
                }
            }


            return(true);
        }
Beispiel #29
0
        /// 衝突後の移動座標をセット(三角形との衝突)
        public void setScrapedMovePosTriangle(GameActorCollManager collMgr, Vector3 movePos, ShapeTriangles shapeTri)
        {
            ShapeSphere moveSph = (ShapeSphere)collMgr.MoveShape;
            int         primId  = collMgr.TrgContainer.GetEntryPrimId(0);

            Vector3 collPos    = StaticDataList.getVectorZero();
            float   scrapedPow = (moveSph.Sphre.R + 0.001f);

            /// 弾く力の算出
            moveMoveCap.Set(moveSph.Sphre.Pos, movePos, moveSph.Sphre.R);
            DemoGame.CommonCollision.CheckSphereAndTriangle(moveMoveCap, shapeTri.Triangle[primId], ref collPos);

            /// 移動候補座標更新
            nextPos.X = moveSph.Sphre.Pos.X;
            nextPos.Y = collPos.Y + (scrapedPow * (shapeTri.Triangle[primId].Plane.Nor.Y));
            nextPos.Z = moveSph.Sphre.Pos.Z;

            touchGroundType = shapeTri.CollisionType;
            touchGroundFlg  = true;

            treadVec = shapeTri.Triangle[primId].Plane.Nor;
        }
        /// 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 );
        }
Beispiel #32
0
        /// 敵陣地の拡大
        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;
                }
            }
        }
Beispiel #33
0
        /// 壁の生成
        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;
                    }
                }
            }
        }
        /// private メソッド
        ///---------------------------------------------------------------------------
        /// 衝突後の移動座標をセット
        public void setScrapedMovePos( GameActorCollManager collMgr, Vector3 movePos )
        {
            /// 衝突あり
            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, movePos, (ShapeTriangles)trgShape );
                break;
            }
            }

            /// 衝突無し
            else{
            nextPos            = movePos;
            ResetGroudParam();
            }

            /// Y軸はマイナスまで行かない
            if( nextPos.Y < 0.0f ){
            nextPos.Y = 0.0f;
            }
        }
 /// 破棄
 public void Term()
 {
     if( calCollMove != null ){
     calCollMove.Term();
     }
     if( calCollGrav != null ){
     calCollGrav.Term();
     }
     calCollGrav         = null;
     calCollMove         = null;
     useCollMgr          = null;
     useActor            = null;
     useInterfereCntr    = null;
 }
 /// クリア
 public void End()
 {
     playId              = 0;
     useActor            = null;
     useInterfereCntr    = null;
     useCollMgr          = null;
 }
Beispiel #37
0
        /// フレーム処理
        public bool Frame()
        {
            //Console.WriteLine(actorChList.Count);

//		if(stateId == CtrlStateId.Move && ZonbiList.Count == 0){		//戦闘開始まで数える
            if (ctrlResMgr.countTime == (int)Data.SetupValue.EnemyAppearTime)
            {
                EnemyDispearFlag = false;
                SetCtrlStateId(CtrlStateId.BattleMove);
                ctrlResMgr.battleStartFlag = true;
            }
            else if (ctrlResMgr.countTime == (int)Data.SetupValue.EnemyAppearTime + (int)Data.SetupValue.EnemyAppearingTime)
            {
                if (stateId != CtrlStateId.Move)
                {
                    SetCtrlStateId(CtrlStateId.Move);
                }
            }
            else if (ctrlResMgr.countTime > (int)Data.SetupValue.EnemyAppearTime + (int)Data.SetupValue.EnemyAppearingTime && EnemyDispearFlag == false)
            {
                float dis = Common.VectorUtil.DistanceXZ(EnemyCenterPos, ctrlResMgr.EnemyMoPos);
                if (dis < (int)Data.SetupValue.ToBattleMode * 3)
                {
                    EnemyDispearFlag       = true;
                    ctrlResMgr.ZonbiNumber = ZonbiList.Count;
                }
            }

            makeList();
            changeState();
            for (int i = 0; i < actorChList.Count; i++)
            {
                GameActorCollManager useCollMgr = actorChList[i].GetMoveCollManager();
                /// 他アクタからのイベントをチェック
                ///-------------------------------------
                if (actorChList[i].MovedFlag == true)
                {
                    Vector3 tempVector3 = actorChList[i].GetBodyPos() - new Vector3(ctrlResMgr.CtrlCam.GetCamPos().X, ctrlResMgr.CtrlPl.GetPos().Y, ctrlResMgr.CtrlCam.GetCamPos().X);
                    if (tempVector3.Cross(new Vector3(actorChList[i].BaseMtx.M31, actorChList[i].BaseMtx.M33, actorChList[i].BaseMtx.M33)).Y > 0)
                    {
                        actorChList[i].moveAngle = true;
                    }
                    else
                    {
                        actorChList[i].moveAngle = false;
                    }
                    actorChList[i].MovedFlag = false;
                }

                /// フレーム処理
                ///-------------------------------------
                if (actorChList[i].GetStateId() != ActorChBase.StateId.Dead && actorChList[i].GetStateId() != ActorChBase.StateId.Eat)
                {
                    switch (stateId)
                    {
                    case CtrlStateId.Move:                          frameMove(actorChList[i]);                      break;

                    case CtrlStateId.BattleMove:            frameBattleMove(actorChList[i]);      break;

                    case CtrlStateId.Battle:                        frameBattle(actorChList[i]);          break;

                    case CtrlStateId.MurderMove:            frameMurderMove(actorChList[i]);      break;

                    case CtrlStateId.Murder:                        frameMurder(actorChList[i]);          break;

                    case CtrlStateId.BreakTowerAndWall:     frameBreakTower(actorChList[i]);      break;

                    case CtrlStateId.Eat:                           frameEat(actorChList[i]);                       break;
                    }
                }
                useCollMgr.SetMoveShape(GetUseActorBaseObj(i).GetMoveShape());
                ctrlResMgr.SetCollisionActorEn(useCollMgr.TrgContainer, actorChList[i].BasePos);
                actorChList[i].Frame();
            }
            return(true);
        }
        /// 継承メソッド
        ///---------------------------------------------------------------------------
        /// 初期化
        public override bool Init()
        {
            moveCollMgr = new GameActorCollManager();
            moveCollMgr.Init();

            interfereCntr = new GameActorContainer();
            interfereCntr.Init();

            calCollMove    = new ActorUnitCollMove();
            calCollMove.Init();

            EventCntr = new GameActorEventContainer();
            EventCntr.Init();

            return( DoInit() );
        }
        /// 破棄
        public override void Term()
        {
            DoTerm();

            if( moveCollMgr != null ){
            moveCollMgr.Term();
            }
            if( calCollMove != null ){
            calCollMove.Term();
            }
            if( interfereCntr != null ){
            interfereCntr.Term();
            }
            if( EventCntr != null ){
            EventCntr.Clear();
            EventCntr.Term();
            }

            interfereCntr    = null;
            EventCntr        = null;
            moveCollMgr      = null;
            calCollMove      = null;
        }
        /// 破棄
        public override void Term()
        {
            if( moveCollMgr != null ){
            moveCollMgr.Term();
            }
            objMark.Term();

            moveCollMgr   = null;
            objMark       = null;
        }
Beispiel #41
0
/// 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 setScrapedMovePosTriangle( GameActorCollManager collMgr, Vector3 movePos, ShapeTriangles shapeTri )
        {
            ShapeSphere        moveSph    = (ShapeSphere)collMgr.MoveShape;
            int                primId     = collMgr.TrgContainer.GetEntryPrimId( 0 );

            Vector3            collPos = StaticDataList.getVectorZero();
            float              scrapedPow = (moveSph.Sphre.R+0.001f);

            /// 弾く力の算出
            moveMoveCap.Set( moveSph.Sphre.Pos, movePos, moveSph.Sphre.R );
            DemoGame.CommonCollision.CheckSphereAndTriangle( moveMoveCap, shapeTri.Triangle[primId], ref collPos );

            /// 移動候補座標更新
            nextPos.X = moveSph.Sphre.Pos.X;
            nextPos.Y = collPos.Y + ( scrapedPow * (shapeTri.Triangle[primId].Plane.Nor.Y) );
            nextPos.Z = moveSph.Sphre.Pos.Z;

            touchGroundType   = shapeTri.CollisionType;
            touchGroundFlg    = true;

            treadVec = shapeTri.Triangle[primId].Plane.Nor;
        }
 /// 移動先のセット
 public void GetMovePos( GameActorCollManager collMgr, ref Vector3 movePos )
 {
     ShapeSphere moveSph = (ShapeSphere)collMgr.MoveShape;
     movePos       = moveSph.Sphre.Pos;
     movePos.Y    -= 0.5f;
 }
        /// 開始
        public void Start( GameActorProduct useActor, GameActorContainer useInterfereCntr, GameActorCollManager useCollMgr )
        {
            basePos        = new Vector3( 0.0f, 0.0f, 0.0f );
            baseRot        = new Vector3( 0.0f, 0.0f, 0.0f );

            setMtxRotateEulerXYZ( baseRot );

            Common.MatrixUtil.SetTranslate( ref baseMtx, basePos );

            playId        = 0;

            this.useActor            = useActor;
            this.useInterfereCntr    = useInterfereCntr;
            this.useCollMgr          = useCollMgr;
        }
        /// シーンの初期化
        public bool Init( DemoGame.SceneManager sceneMgr )
        {
            useSceneMgr = sceneMgr;

            calCollGrav    = new ActorUnitCollGravity();
            calCollGrav.Init();

            moveCollMgr = new GameActorCollManager();
            moveCollMgr.Init();

            shapeMove = new ShapeSphere();
            shapeMove.Init(1);
            shapeMove.Set( 0, StaticDataList.getVectorZero(), 0.001f );

            renderSph = new DemoGame.RenderGeometry();
            renderSph.MakeSphere();
            ///        trgObj        = null;

            /// 移動する自身のOBJを登録
            moveCollMgr.SetMoveShape( shapeMove );

            trgObjMoveSpd = 1.0f;
            setPlaceTypeParam( trgObjType );

            nowTaskId    = debugMenuTaskId.SelectObj;
            changeTask( debugMenuTaskId.SelectObj );
            return true;
        }
        /// シーンの破棄
        public void Term()
        {
            if( calCollGrav != null ){
            calCollGrav.Term();
            }
            if( moveCollMgr != null ){
            moveCollMgr.Term();
            }
            if( shapeMove != null ){
            shapeMove.Term();
            }
            if( renderSph != null ){
            renderSph.Dispose();
            }

            ///        trgObj            = null;
            renderSph        = null;
            shapeMove        = null;
            moveCollMgr        = null;
            calCollGrav        = null;
            useSceneMgr        = null;
        }
        /// private メソッド
        ///---------------------------------------------------------------------------
        /// 衝突後の移動座標をセット
        private void setScrapedMovePos( GameActorCollManager collMgr, Vector3 movePos )
        {
            /// 衝突あり
            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, movePos, (ShapeTriangles)trgShape );
                break;

            /// カプセル
            case GameShapeProduct.TypeId.Capsule:
                calCollSphMove.Check( moveMoveCap, (ShapeCapsule)trgShape );
                nextPos = calCollSphMove.MovePos;
                break;
            }
            }

            /// 衝突無し
            else{
            nextPos = movePos;
            }
        }
        /// 衝突後の移動座標をセット(三角形との衝突)
        private void setScrapedMovePosTriangle( GameActorCollManager collMgr, Vector3 movePos, ShapeTriangles shapeTri )
        {
            ShapeSphere      moveSph    = (ShapeSphere)collMgr.MoveShape;
            int              primId     = collMgr.TrgContainer.GetEntryPrimId( 0 );

            Vector3          collPos = StaticDataList.getVectorZero();
            float            scrapedPow = (moveSph.Sphre.R+0.001f);

            /// 点と面上の最近接点を求める
            DemoGame.CommonCollision.GetClosestPtPosPlane( movePos, shapeTri.Triangle[primId].Plane, ref collPos );

            /// 移動候補座標更新
            nextPos.X = collPos.X + ( scrapedPow * (shapeTri.Triangle[primId].Plane.Nor.X) );
            nextPos.Y = collPos.Y + ( scrapedPow * (shapeTri.Triangle[primId].Plane.Nor.Y) );
            nextPos.Z = collPos.Z + ( scrapedPow * (shapeTri.Triangle[primId].Plane.Nor.Z) );
        }
Beispiel #49
0
        /// 継承メソッド
        ///---------------------------------------------------------------------------
        /// 初期化
        public override bool Init()
        {
            unitCmnPlay = new ActorUnitCommon();
            unitCmnPlay.Init();

            moveCollMgr = new GameActorCollManager();
            moveCollMgr.Init();

            interfereCntr = new GameActorContainer();
            interfereCntr.Init();

            EventCntr = new GameActorEventContainer();
            EventCntr.Init();

            return( DoInit() );
        }
        /// 移動先のセット
        /**
         * 坂道でも平面と同じ移動が出来るように踏んでいる地面の角度に合わせて移動先の座標に変換をかける
         * upVec  : 地面の法線
         * trgPos : 移動候補のオフセット位置
         */
        public void GetMovePos( GameActorCollManager collMgr, Vector3 upVec, Vector3 trgPos, ref Vector3 movePos )
        {
            ShapeSphere moveSph = (ShapeSphere)collMgr.MoveShape;
            Vector3 leftVec     = new Vector3( 1.0f, 0.0f, 0.0f );
            Matrix4 world       = new Matrix4();

            // Z軸のセット
            Vector3 calVecX = Common.VectorUtil.Cross2( leftVec, upVec );
            calVecX      = calVecX.Normalize();
            world.M31    = calVecX.X;
            world.M32    = calVecX.Y;
            world.M33    = calVecX.Z;
            world.M34    = 0;

            // X軸のセット
            world.M11    = leftVec.X;
            world.M12    = leftVec.Y;
            world.M13    = leftVec.Z;
            world.M14    = 0;

            // Y軸のセット
            world.M21    = upVec.X;
            world.M22    = upVec.Y;
            world.M23    = upVec.Z;
            world.M24    = 0;

            /// 移動先のセット
            movePos = Common.VectorUtil.Mult( ref trgPos, world );
            movePos += moveSph.Sphre.Pos;
        }
Beispiel #51
0
        /// 破棄
        public override void Term()
        {
            DoTerm();

            if( moveCollMgr != null ){
            moveCollMgr.Term();
            }
            if( unitCmnPlay != null ){
            unitCmnPlay.Term();
            }
            if( EventCntr != null ){
            EventCntr.Clear();
            EventCntr.Term();
            }
            if( interfereCntr != null ){
            interfereCntr.Term();
            }

            interfereCntr = null;
            EventCntr     = null;
            moveCollMgr   = null;
            unitCmnPlay   = null;
            dmgTrgObj     = null;
        }