Exemplo n.º 1
0
        // GameObject buildingPrefab;
        //public BuildingPlot buildingPlot;


        public override List <DataObject> Solve(List <DataObject> dataArray)
        {
            // Load a Building
            DataObject dataObjectBuildingBase = BuildingBlockChain.GetLastObjectOfTypeFromDataArray(dataArray, DataObject.ObjectTypes.BuildingBase);//(GetLastObjectOfTypeFromDataArray<GameObject>(dataArray));

            if (dataObjectBuildingBase == null)
            {
                Debug.LogError("BuildBuilding could not be resolved, because it couldnt load a dataObject with BuildingBase as its type");
                return(dataArray);
            }

            // Load a BuildingPlot
            DataObject dataObjectBuildingPlot = BuildingBlockChain.GetLastObjectOfTypeFromDataArray(dataArray, DataObject.ObjectTypes.BuildingPlot);

            if (dataObjectBuildingPlot == null)
            {
                Debug.LogError("BuildBuilding could not be resolved, because it couldnt load a dataObject with BuildingPlot as its type");
                return(dataArray);
            }

            // only do something and alter the dataArray if it is certain this entire action can be resolved!
            BuildingBase buildingBase = (BuildingBase)dataObjectBuildingBase.objectRef;

            Building   nwBuilding   = ((BuildingPlot)dataObjectBuildingPlot.objectRef).BuildBuilding(buildingBase);
            DataObject nwDataObject = new DataObject(DataObject.ObjectTypes.Building, nwBuilding.gameObject.GetComponent <Building>());//new DataObject().Setup(DataObject.ObjectTypes.Building, nwBuilding.GetComponent<Building>());

            // TODO: check if data is correctly formatted!
            // TODO2: Do this in a editor
            Debug.Log("TODO: check if data is correctly formatted!");

            dataArray.Add(nwDataObject); //build the building and add it to the array

            return(base.Solve(dataArray));
        }
Exemplo n.º 2
0
        public override List <DataObject> Solve(List <DataObject> dataArray)
        {
            DataObject dataObjectLastBuilding = BuildingBlockChain.GetLastObjectOfTypeFromDataArray(dataArray, DataObject.ObjectTypes.Building);
            Building   building = (Building)dataObjectLastBuilding.objectRef;

            building.Cit_neutral  += cit_neutral;
            building.Cit_worker   += cit_worker;
            building.Cit_scolar   += cit_scolar;
            building.Cit_military += cit_military;
            building.Cit_merchant += cit_merchant;


            return(dataArray);
        }
Exemplo n.º 3
0
        public override List <DataObject> Solve(List <DataObject> dataArray)
        {
            DataObject dataObjectBaseEvent = BuildingBlockChain.GetLastObjectOfTypeFromDataArray(dataArray, DataObject.ObjectTypes.Event);

            if (dataObjectBaseEvent == null)
            {
                Debug.LogError("FireEvent could not be resolved, because it couldnt load a GameEvent with Event as its type");
                return(dataArray);
            }

            BaseEvent baseEvent = (BaseEvent)dataObjectBaseEvent.objectRef;

            baseEvent.Raise(new List <DataHolder>(), this); //will not send any parameters

            // Add the new event to the list
            DataObject nwDataObject = new DataObject(DataObject.ObjectTypes.Event, baseEvent);

            dataArray.Add(nwDataObject);

            return(base.Solve(dataArray));
        }