Пример #1
0
    int mAutoFight = 1;//the value 1 is AutoFight
    void Awake()
    {
        GameObject tbattleRoot = GameObjectCreater.CreateGo("BattleRoot");

        mEmb = transform.GetComponent <Embattling>();
        GameObjectPool.GetInstance().root = tbattleRoot;

        mSquadDataList    = new List <SquadData>();
        mSquadGameObjDict = new Dictionary <int, GameObject>();

        mBattleSceneConfig = TableManager.GetSceneClassByID(1)[0];
        StartCoroutine(AssetLoadManager.LoadFromResource(mPosPath, GeneratePos));

        //EventManager.GetInstance().AddEventListener(EventId.LoadSquad, LoadSquad);
        EventManager.GetInstance().AddEventListener(EventId.StartBattle, StartBattle);
        //EventManager.GetInstance().AddEventListener(EventId.StartFight, StartFight);
        //EventManager.GetInstance().AddEventListener(EventId.ReceiveFight, ReceiveFight);
        //EventManager.GetInstance().AddEventListener(EventId.SendMarch, SendMerch);
        EventManager.GetInstance().AddEventListener(EventId.UseSkill, UseSkill);
        EventManager.GetInstance().AddEventListener(EventId.AutoFight, AutoFight);


        EventManager.GetInstance().AddEventListener(EventId.ReceiveBattleInfor, ReceiveBattleInfor);
        EventManager.GetInstance().AddEventListener(EventId.ReceiveSquadPosInfor, ReceivePosList);
        EventManager.GetInstance().AddEventListener(EventId.ReceiveCommandPursue, ReceiveCommandPursue);
        EventManager.GetInstance().AddEventListener(EventId.ReceivePrepareForAttack, ReceivePrepareForAttack);
        EventManager.GetInstance().AddEventListener(EventId.ReceiveObjGetHurt, ReceiveObjGetHurt);
        EventManager.GetInstance().AddEventListener(EventId.ReceiveSkill, ReceiveSkill);
        EventManager.GetInstance().AddEventListener(EventId.ReceiveBattleEnd, ReceiveBattleEnd);
        //EventManager.GetInstance().AddEventListener(EventId.ReceiveUpdateMarchMsg, ReceiveSendMarch);

        LoadSquad(null);
        //GetBattlerInfor();
    }
    public void AddEmbateBornList()
    {
        Embattling tEmb = transform.GetComponent <Embattling>();

        tEmb.MPosCube = mPosAsset;
        for (int i = 0; i < mBattleSceneConfig.getAttackPosXCount(); i++)
        {
            BornPosInfor tBorPos = new BornPosInfor();
            tBorPos.mBornPos = SetPosition(mBattleSceneConfig.GetAttackPosXbyIndex(i), mBattleSceneConfig.GetAttackPosZbyIndex(i));
            if (i < mCampRedSquadList.Count)
            {
                tBorPos.mSquadID = mCampRedSquadList[i].GetComponent <SquadController>().GetSquadData().GetID();
            }
            GameObject tCube = Instantiate(mPosAsset, tBorPos.mBornPos, Quaternion.LookRotation(Vector3.forward, Vector3.up)) as GameObject;
            tBorPos.mPosInstance = tCube.transform;
            tEmb.mBornInforList.Add(tBorPos);
        }

        //for (int i = 0; i < mBattleSceneConfig.getDefencePosXCount(); i++)
        //{
        //    tBorPos.mBornPos = SetPosition(mBattleSceneConfig.GetDefencePosXbyIndex(i), mBattleSceneConfig.GetDefencePosZbyIndex(i));
        //    if (i < mCampBlueSquadList.Count)
        //    {
        //        tBorPos.mSquadID = mCampBlueSquadList[i].GetComponent<SquadController>().GetSquadData().GetID();
        //    }
        //    tEmb.AddBornList(tBorPos);
        //}
    }