Пример #1
0
    void PrepareForBattle(Dictionary <int, GameObject> tSquadGameObjDic, List <SquadData> tSquadDataList)
    {
        Quaternion mBornQuRed  = Quaternion.LookRotation(Vector3.left, Vector3.up);
        Quaternion mBornQuBlue = Quaternion.LookRotation(Vector3.right, Vector3.up);

        for (int j = 0; j < tSquadDataList.Count; j++)
        {
            GameObject tSquad = Instantiate(mSquadAsset) as GameObject;
            tSquad.transform.position = BattleFunction.SetPosition(tSquadDataList[j].GetBornPosionX(), tSquadDataList[j].GetBornPosionZ());
            if (tSquadDataList[j].GetSquadCamp() == SquadCamp.CampRed)
            {
                tSquad.transform.rotation = mBornQuRed;
            }
            else
            {
                tSquad.transform.rotation = mBornQuBlue;
            }

            GameObject tSquadAim = Instantiate(mAimAsset) as GameObject;
            tSquadAim.transform.position = tSquad.transform.position;

            SquadController tSquadController = tSquad.GetComponent <SquadController>();
            tSquadController.SetmOriginalAim(tSquadAim.transform);
            tSquadController.SetSquadData(tSquadDataList[j]);
            for (int i = 0; i < tSquadDataList[j].GetUnitCount(); i++)
            {
                GameObject tUnit = Instantiate(tSquadDataList[j].UnitAsset) as GameObject;
                tUnit.transform.rotation = tSquad.transform.rotation;

                UnitController tUnitController = tUnit.GetComponent <UnitController>();

                GameObject tUnitAim = Instantiate(mAimAsset) as GameObject;

                tUnitController.GetUnitData().SetInfor(tSquadDataList[j].GetUnitTemplateID());
                tUnitController.SetmOriginalAim(tUnitAim.transform);
                tUnitController.SetmArrowAsset(tSquadDataList[j].UnitArrowAsset);
                tUnitController.SquadTransform = tSquad.transform;

                tSquadController.GetUnitControllerList().Add(tUnit.transform);
            }

            //tSquadController.GetSquadData().SkillAsset = mSkillAsset;
            tSquadGameObjDic.Add(tSquadDataList[j].GetID(), tSquad);

            tSquadController.FormationStrategy();

            for (int i = 0; i < tSquadDataList[j].GetUnitCount(); i++)
            {
                tSquadController.GetUnitControllerList()[i].GetComponent <UnitController>().EmbattingSetPos(tSquad.transform.position);
            }
        }
    }
Пример #2
0
    public void AddEmbateBornList()
    {
        mEmb.MPosCube = mPosAsset;
        if (mCurrentCamp == SquadCamp.CampRed)
        {
            for (int i = 0; i < mBattleSceneConfig.getAttackPosXCount(); i++)
            {
                BornPosInfor tBorPos = new BornPosInfor();
                tBorPos.mBornPos = BattleFunction.SetPosition(mBattleSceneConfig.GetAttackPosXbyIndex(i) * BattleFunction.mDenominator, mBattleSceneConfig.GetAttackPosZbyIndex(i) * BattleFunction.mDenominator);
                foreach (var item in mSquadDataList)
                {
                    if (item.GetSquadCamp() == SquadCamp.CampRed)
                    {
                        if (item.GetBornPosionIndex() == i)
                        {
                            tBorPos.mSquadID = item.GetID();
                            tBorPos.mPosCamp = SquadCamp.CampRed;
//                          tBorPos.mArrangeindex = item.GetBornPosionIndex();
                        }
                    }
                }
                GameObject tCube = Instantiate(mPosAsset, tBorPos.mBornPos, Quaternion.LookRotation(Vector3.forward, Vector3.up)) as GameObject;
                tBorPos.mPosInstance = tCube.transform;
                mEmb.mBornInforList.Add(tBorPos);
            }
        }
        if (mCurrentCamp == SquadCamp.CampBlue)
        {
            for (int i = 0; i < mBattleSceneConfig.getDefencePosXCount(); i++)
            {
                BornPosInfor tBorPos = new BornPosInfor();
                tBorPos.mBornPos = BattleFunction.SetPosition(mBattleSceneConfig.GetDefencePosXbyIndex(i) * BattleFunction.mDenominator, mBattleSceneConfig.GetDefencePosZbyIndex(i) * BattleFunction.mDenominator);
                foreach (var item in mSquadDataList)
                {
                    if (item.GetSquadCamp() == SquadCamp.CampBlue)
                    {
                        if (item.GetBornPosionIndex() == i)
                        {
                            tBorPos.mSquadID = item.GetID();
                            tBorPos.mPosCamp = SquadCamp.CampBlue;
//                          tBorPos.mArrangeindex = item.GetBornPosionIndex();
                        }
                    }
                }
                GameObject tCube = Instantiate(mPosAsset, tBorPos.mBornPos, Quaternion.LookRotation(Vector3.forward, Vector3.up)) as GameObject;
                tBorPos.mPosInstance = tCube.transform;
                mEmb.mBornInforList.Add(tBorPos);
            }
        }
    }
    public void CorretSquadInfor(GC_OBJPOS tObjPosList, SquadController tTargetController = null)
    {
        switch (mStateMachine.GetCurrentState().StateType)
        {
        case StateEnum.Attack:
            break;

        case StateEnum.Idle:
            //
            if ((SquadState)tObjPosList.ObjState == SquadState.AI_COMBAT)
            {
                if (tTargetController != null)
                {
                    SquadAttackPrepare(tTargetController);
                }
            }
            //
            if ((SquadState)tObjPosList.ObjState == SquadState.AI_MARCH)
            {
                UnitMarching(BattleFunction.SetPosition(tObjPosList.PosX, tObjPosList.PosZ));
            }
            break;

        case StateEnum.Prepare:
            break;

        case StateEnum.Walk:
            UnitMarching(BattleFunction.SetPosition(tObjPosList.PosX, tObjPosList.PosZ));
            break;
        }
        //transform.position=SetPosition(tObjPosList.PosX, tObjPosList.PosZ);
        //for (int i = 0; i < mUnitTransformList.Count; i++)
        //{
        //    mUnitTransformList[i].GetComponent<UnitController>().UnitMarching(transform.position, 0f);
        //}
    }