Beispiel #1
0
    public void AddUnit <T>(int unitTypeId) where T : BaseUnit
    {
        Type unitType = typeof(T);

        if (unitDict.ContainsKey(unitType))
        {
            Debug.LogError($"[GlobalUnion] AddUnit [{unitType.Name}] Fail. Has Record");
            return;
        }

        int             unitId          = idDistributionChunk.Pop();
        OperationObject operationObject = globalUnionPollingOperation.AddOperationObject(unitId, unitTypeId);

        if (operationObject != null)
        {
            BaseUnit unit = operationObject as BaseUnit;
            unitDict.Add(unitType, unit);

            InitUnit(unit);
        }
        if (!unitTypeDict.ContainsKey(unitType))
        {
            unitTypeDict.Add(unitType, unitTypeId);
        }
    }
Beispiel #2
0
    public GlobalUnion CreateGlobalUnion()
    {
        int             globalId        = idDistributionChunk.Pop();
        OperationObject operationObject = globalUnionPollingOperation.AddOperationObject(globalId, (int)GlobalDefine.GlobalUnionType.Global);

        if (operationObject != null)
        {
            GlobalUnion globalUnion = operationObject as GlobalUnion;
            InitGlobalUnion(globalUnion, globalId);

            globalUnionDict.Add(globalId, globalUnion);
            return(globalUnion);
        }
        return(null);
    }