Пример #1
0
    public void Awake()
    {
        // See if this player is an AI
        aiLogic = GetComponent <AILogic>();
        if (aiLogic != null)
        {
            isAI = true;
        }
        else // Just in case somehow the initial false set doesn't work
        {
            isAI = false;
        }


        // On awake, set mana to 0 so that when a turn is activated it can increase the mana
        CurrentMana = 0;
        MaxMana     = 0;
        Health      = 40;

        // Set alignment to 0
        CurrentAlignment = 0;

        // Assign players with ID (using find objects as there will only be two player scripts attached)
        players = GameObject.FindObjectsOfType <Player>();
        // Give the players an ID (1 + 2)
        PlayerID = IDCreator.GetUniqueID();
        // set starting health
    }
Пример #2
0
        private CMLReactionScheme CDKReactionSchemeToCMLReactionScheme(IReactionScheme cdkScheme, bool setIDs)
        {
            var reactionScheme = new CMLReactionScheme();

            if (useCMLIDs && setIDs)
            {
                IDCreator.CreateIDs(cdkScheme);
            }
            if (!string.IsNullOrEmpty(cdkScheme.Id))
            {
                reactionScheme.Id = cdkScheme.Id;
            }

            foreach (var reaction in cdkScheme.Reactions)
            {
                reactionScheme.Add(CDKReactionToCMLReaction(reaction));
            }

            foreach (var intScheme in cdkScheme.Schemes)
            {
                reactionScheme.Add(CDKReactionSchemeToCMLReactionScheme(intScheme));
            }

            return(reactionScheme);
        }
Пример #3
0
    public void LoadScene()
    {
        IDCreator.ResetIDs();
        IDHolder.ClearIDHoldersList();
        Command.CommandQueue.Clear();
        Command.CommandExecutionComplete();
        string buttonClicked = EventSystem.current.currentSelectedGameObject.name;

        switch (buttonClicked)
        {
        case "PlayerVsAI":
            GameManager.IsHeadlessMode = false;
            SceneManager.LoadScene("Scene_PlayervsAI");
            break;

        case "AIvsAI":
            GameManager.IsHeadlessMode = true;
            SceneManager.LoadScene("Scene_AIvsAI");
            break;

        case "Quit":
            Application.Quit();
            break;

        case "Menu":
            SceneManager.LoadScene("Scene_Menu");
            break;

        default:
            SceneManager.LoadScene("Scene_Menu");
            break;
        }
    }
Пример #4
0
    // CONSTRUCTOR
    public CreatureLogic(Player owner, CardTemplate ct)
    {
        this.ct    = ct;
        baseHealth = ct.maxHealth;
        Health     = ct.maxHealth;
        baseAttack = ct.attack;
        // if the card has bloodthirst, add 1 to the attacks per turn.
        if (ct.abilityLogic == AbilityLogicList.Bloodthirsty)
        {
            attacksForOneTurn = ct.attacksPerTurn + ct.abilityValue;
        }
        else
        {
            attacksForOneTurn = ct.attacksPerTurn;
        }
        // get alignment
        alignmentValue = ct.alignment;

        // If the card has the Bravery attribute
        if (ct.abilityLogic == AbilityLogicList.Bravery)
        {
            AttacksLeftThisTurn = attacksForOneTurn;
        }
        this.owner       = owner;
        UniqueCreatureID = IDCreator.GetUniqueID();
        CreaturesCreatedThisGame.Add(UniqueCreatureID, this);
    }
Пример #5
0
        private CMLList CDKChemModelToCMLList(IChemModel model, bool setIDs)
        {
            var cmlList = new CMLList {
                Convention = "cdk:model"
            };

            if (useCMLIDs && setIDs)
            {
                IDCreator.CreateIDs(model);
            }
            if (!string.IsNullOrEmpty(model.Id))
            {
                cmlList.Id = model.Id;
            }

            if (model.Crystal != null)
            {
                cmlList.Add(CDKCrystalToCMLMolecule(model.Crystal, false));
            }
            if (model.ReactionSet != null)
            {
                cmlList.Add(CDKReactionSetToCMLReactionList(model.ReactionSet, false));
            }
            if (model.MoleculeSet != null)
            {
                cmlList.Add(CDKAtomContainerSetToCMLList(model.MoleculeSet, false));
            }

            return(cmlList);
        }
Пример #6
0
 // InitID
 void InitID()
 {
     // Pick an ID on the server
     if (GameManager.isServer)
     {
         id = IDCreator.GetNextID();
     }
 }
Пример #7
0
 // Constructor
 public CardLogic(CardTemplate ct)
 {
     // Set the refs
     this.ct = ct;
     // Get unique int ID
     UniqueCardID = IDCreator.GetUniqueID();
     ResetManaCost();
     // Add this card to the dictionary with its ID as key
     CardsCreatedThisGame.Add(UniqueCardID, this);
 }
        public void TestGetAllIDs_IChemSequence()
        {
            Assert.AreEqual(0, ChemSequenceManipulator.GetAllIDs(chemSequence).Count());
            IDCreator.CreateIDs(chemSequence);
            var allIDs = ChemSequenceManipulator.GetAllIDs(chemSequence);

            Assert.AreEqual(18, ChemSequenceManipulator.GetAllIDs(chemSequence).Count());
            var uniq = new HashSet <string>(allIDs);

            Assert.AreEqual(12, uniq.Count);
        }
Пример #9
0
        public void TestGetAllIDs_IChemModel()
        {
            Assert.AreEqual(0, ChemModelManipulator.GetAllIDs(chemModel).Count());
            IDCreator.CreateIDs(chemModel);
            var allIDs = ChemModelManipulator.GetAllIDs(chemModel);

            Assert.AreEqual(16, ChemModelManipulator.GetAllIDs(chemModel).Count());
            var uniq = new HashSet <string>(allIDs);

            Assert.AreEqual(10, uniq.Count);
        }
Пример #10
0
 private void WriteAtomContainer(IAtomContainer molecule)
 {
     writer.Write("{");
     writer.Write('\n');
     writer.Write("  IChemObjectBuilder builder = ");
     writer.Write(builder.Setting);
     writer.Write(".Instance;");
     writer.Write('\n');
     writer.Write("  IAtomContainer mol = builder.NewAtomContainer();");
     writer.Write('\n');
     IDCreator.CreateIDs(molecule);
     WriteAtoms(molecule);
     WriteBonds(molecule);
     writer.Write("}");
     writer.Write('\n');
 }
Пример #11
0
        private CMLReactionList CDKReactionSetToCMLReactionList(IReactionSet reactionSet, bool setIDs)
        {
            var reactionList = new CMLReactionList();

            if (useCMLIDs && setIDs)
            {
                IDCreator.CreateIDs(reactionSet);
            }
            if (!string.IsNullOrEmpty(reactionSet.Id))
            {
                reactionList.Id = reactionSet.Id;
            }

            foreach (var reaction in reactionSet)
            {
                reactionList.Add(CDKReactionToCMLReaction(reaction, false));
            }

            return(reactionList);
        }
Пример #12
0
        private CMLList CDKChemSequenceToCMLList(IChemSequence sequence, bool setIDs)
        {
            var cmlList = new CMLList {
                Convention = "cdk:sequence"
            };

            if (useCMLIDs && setIDs)
            {
                IDCreator.CreateIDs(sequence);
            }
            if (!string.IsNullOrEmpty(sequence.Id))
            {
                cmlList.Id = sequence.Id;
            }

            foreach (var chemModel in sequence)
            {
                cmlList.Add(CDKChemModelToCMLList(chemModel));
            }

            return(cmlList);
        }
Пример #13
0
        private CMLCml CDKChemFileToCMLList(IChemFile file, bool setIDs)
        {
            var cmlList = new CMLCml {
                Convention = "cdk:document"
            };

            if (useCMLIDs && setIDs)
            {
                IDCreator.CreateIDs(file);
            }
            if (!string.IsNullOrEmpty(file.Id))
            {
                cmlList.Id = file.Id;
            }

            foreach (var sequence in file)
            {
                cmlList.Add(CDKChemSequenceToCMLList(sequence));
            }

            return(cmlList);
        }
Пример #14
0
        private CMLMoleculeList CDKAtomContainerSetToCMLList(IEnumerableChemObject <IAtomContainer> moleculeSet, bool setIDs)
        {
            CMLMoleculeList cmlList = new CMLMoleculeList
            {
                Convention = "cdk:moleculeSet"
            };

            if (useCMLIDs && setIDs)
            {
                IDCreator.CreateIDs(moleculeSet);
            }
            if (!string.IsNullOrEmpty(moleculeSet.Id))
            {
                cmlList.Id = moleculeSet.Id;
            }

            foreach (var container in moleculeSet)
            {
                cmlList.Add(CDKAtomContainerToCMLMolecule(container, false, false));
            }
            return(cmlList);
        }
Пример #15
0
        private CMLMolecule CDKCrystalToCMLMolecule(ICrystal crystal, bool setIDs)
        {
            var molecule   = CDKAtomContainerToCMLMolecule(crystal, false, false);
            var cmlCrystal = new CMLCrystal();

            if (useCMLIDs && setIDs)
            {
                IDCreator.CreateIDs(crystal);
            }
            if (!string.IsNullOrEmpty(crystal.Id))
            {
                cmlCrystal.Id = crystal.Id;
            }

            this.CheckPrefix(cmlCrystal);
            cmlCrystal.Z = crystal.Z.Value;
            var params_ = CrystalGeometryTools.CartesianToNotional(crystal.A, crystal.B, crystal.C);

            Debug.WriteLine($"Number of cell params: {params_.Length}");
            cmlCrystal.SetCellParameters(params_);
            molecule.Add(cmlCrystal);
            return(molecule);
        }
Пример #16
0
        public virtual void writeMolecule(IMolecule molecule)
        {
            writer.Write("{\n");
            writer.Write("  Molecule mol = new Molecule();\n");
            IDCreator idCreator = new IDCreator();

            idCreator.createIDs(molecule);
            IAtom[] atoms = molecule.Atoms;
            for (int i = 0; i < atoms.Length; i++)
            {
                IAtom atom = atoms[i];
                writeAtom(atom);
                writer.Write("  mol.addAtom(" + atom.ID + ");\n");
            }
            IBond[] bonds = molecule.Bonds;
            for (int i = 0; i < bonds.Length; i++)
            {
                IBond bond = bonds[i];
                writeBond(bond);
                writer.Write("  mol.addBond(" + bond.ID + ");\n");
            }
            writer.Write("}\n");
        }
Пример #17
0
        private CMLReaction CDKReactionToCMLReaction(IReaction reaction, bool setIDs)
        {
            var cmlReaction = new CMLReaction();

            if (useCMLIDs && setIDs)
            {
                IDCreator.CreateIDs(reaction);
            }
            if (!string.IsNullOrEmpty(reaction.Id))
            {
                cmlReaction.Id = reaction.Id;
            }

            var props = reaction.GetProperties();

            foreach (var key in props.Keys)
            {
                var value = props[key];
                if (value is string)
                {
                    if (!string.Equals(key.ToString(), CDKPropertyName.Title, StringComparison.Ordinal))
                    {
                        var scalar = new CMLScalar();
                        this.CheckPrefix(scalar);
                        scalar.DictRef = "cdk:reactionProperty";
                        scalar.Title   = key.ToString();
                        scalar.SetValue(value.ToString());
                        cmlReaction.Add(scalar);
                    }
                }
            }

            // reactants
            var cmlReactants = new CMLReactantList();

            foreach (var reactant in reaction.Reactants)
            {
                var cmlReactant = new CMLReactant();
                cmlReactant.Add(CDKAtomContainerToCMLMolecule(reactant));
                cmlReactants.Add(cmlReactant);
            }

            // products
            var cmlProducts = new CMLProductList();

            foreach (var product in reaction.Products)
            {
                var cmlProduct = new CMLProduct();
                cmlProduct.Add(CDKAtomContainerToCMLMolecule(product));
                cmlProducts.Add(cmlProduct);
            }

            // substance
            var cmlSubstances = new CMLSubstanceList();

            foreach (var agent in reaction.Agents)
            {
                var cmlSubstance = new CMLSubstance();
                cmlSubstance.Add(CDKAtomContainerToCMLMolecule(agent));
                cmlSubstances.Add(cmlSubstance);
            }
            if (reaction.Id != null)
            {
                cmlReaction.Id = reaction.Id;
            }

            cmlReaction.Add(cmlReactants);
            cmlReaction.Add(cmlProducts);
            cmlReaction.Add(cmlSubstances);
            return(cmlReaction);
        }
Пример #18
0
 public CardController(CardAsset card)
 {
     cardAsset = card ?? throw new ArgumentNullException(nameof(card));
     CardID    = IDCreator.CreateUniqueID();
     CardsCreatedThisGame.Add(CardID, this);
 }
Пример #19
0
        private CMLMolecule CDKAtomContainerToCMLMolecule(IAtomContainer structure, bool setIDs, bool isRef)
        {
            var cmlMolecule = new CMLMolecule();

            if (useCMLIDs && setIDs)
            {
                IDCreator.CreateIDs(structure);
            }

            this.CheckPrefix(cmlMolecule);
            if (!string.IsNullOrEmpty(structure.Id))
            {
                if (!isRef)
                {
                    cmlMolecule.Id = structure.Id;
                }
                else
                {
                    cmlMolecule.Ref = structure.Id;
                }
            }

            if (structure.Title != null)
            {
                cmlMolecule.Title = structure.Title;
            }
            if (structure.GetProperty <string>(CDKPropertyName.InChI) != null)
            {
                var ident = new CMLIdentifier
                {
                    Convention = "iupac:inchi"
                };
                ident.SetAttributeValue(CMLElement.Attribute_value, structure.GetProperty <string>(CDKPropertyName.InChI));
                cmlMolecule.Add(ident);
            }
            if (!isRef)
            {
                for (int i = 0; i < structure.Atoms.Count; i++)
                {
                    var cdkAtom = structure.Atoms[i];
                    var cmlAtom = CDKAtomToCMLAtom(structure, cdkAtom);
                    if (structure.GetConnectedSingleElectrons(cdkAtom).Count() > 0)
                    {
                        cmlAtom.SpinMultiplicity = structure.GetConnectedSingleElectrons(cdkAtom).Count() + 1;
                    }
                    cmlMolecule.Add(cmlAtom);
                }
                for (int i = 0; i < structure.Bonds.Count; i++)
                {
                    var cmlBond = CDKJBondToCMLBond(structure.Bonds[i]);
                    cmlMolecule.Add(cmlBond);
                }
            }

            // ok, output molecular properties, but not TITLE, INCHI, or DictRef's
            var props = structure.GetProperties();

            foreach (var propKey in props.Keys)
            {
                if (propKey is string key)
                {
                    // but only if a string
                    if (!isRef)
                    {
                        object value = props[key];
                        switch (key)
                        {
                        case CDKPropertyName.Title:
                        case CDKPropertyName.InChI:
                            break;

                        default:
                            // ok, should output this
                            var scalar = new CMLScalar();
                            this.CheckPrefix(scalar);
                            scalar.DictRef = "cdk:molecularProperty";
                            scalar.Title   = (string)key;
                            scalar.SetValue(value.ToString());
                            cmlMolecule.Add(scalar);
                            break;
                        }
                    }
                    // FIXME: At the moment the order writing the formula is into properties
                    // but it should be that IMolecularFormula is a extension of IAtomContainer
                    if (!isRef && string.Equals(key, CDKPropertyName.Formula, StringComparison.Ordinal))
                    {
                        switch (props[key])
                        {
                        case IMolecularFormula cdkFormula:
                        {
                            var cmlFormula   = new CMLFormula();
                            var isotopesList = MolecularFormulaManipulator.PutInOrder(MolecularFormulaManipulator.OrderEle, cdkFormula);
                            foreach (var isotope in isotopesList)
                            {
                                cmlFormula.Add(isotope.Symbol, cdkFormula.GetCount(isotope));
                            }
                            cmlMolecule.Add(cmlFormula);
                        }
                        break;

                        case IMolecularFormulaSet cdkFormulaSet:
                            foreach (var cdkFormula in cdkFormulaSet)
                            {
                                var isotopesList = MolecularFormulaManipulator.PutInOrder(MolecularFormulaManipulator.OrderEle, cdkFormula);
                                var cmlFormula   = new CMLFormula {
                                    DictRef = "cdk:possibleMachts"
                                };
                                foreach (var isotope in isotopesList)
                                {
                                    cmlFormula.Add(isotope.Symbol, cdkFormula.GetCount(isotope));
                                }
                                cmlMolecule.Add(cmlFormula);
                            }
                            break;
                        }
                    }
                }
            }

            foreach (var element in customizers.Keys)
            {
                var customizer = customizers[element];
                try
                {
                    customizer.Customize(structure, cmlMolecule);
                }
                catch (Exception exception)
                {
                    Trace.TraceError($"Error while customizing CML output with customizer: {customizer.GetType().Name}");
                    Debug.WriteLine(exception);
                }
            }
            return(cmlMolecule);
        }