コード例 #1
0
    public void SaveMolecule(GameObject molecule, string name)
    {
        HandleTextFile.ClearFile(name + ".txt");
        string text = "M" + molecule.transform.position + "M\n";

        for (int i = 0; i < molecule.transform.childCount; i++)
        {
            Transform child = molecule.transform.GetChild(i);
            if (child.CompareTag("Interactable"))
            {
                string atomType     = child.GetComponent <Atom>().GetAtomType();
                int    allowedBonds = Properties.BONDS[atomType];
                Dictionary <int, int> bondsFormed = child.GetComponent <Atom>().GetBonds();
                int     bondsMade = child.GetComponent <Atom>().GetNumberBondsMade();
                Vector3 pos       = new Vector3(child.position.x, child.position.y, child.position.z);
                text += "N atom: " + atomType + "_" + bondsMade + " _" + pos + "\n";
                foreach (var par in bondsFormed)
                {
                    text += "    _" + par.Key + "_" + par.Value + "\n";
                }
                text += "\n";
            }
        }
        HandleTextFile.SaveFile(name + ".txt", text);
    }
コード例 #2
0
    void DecryptElitizedLastGeneration()
    {
        HandleTextFile.ReadString("aux");
        string[] objects = HandleTextFile.Data.Split(';');
        string[,] characteristics = new string[objects.Length, 18];
        //Debug.Log("Objectslenght "+objects.Length);
        for (int j = 0; j < objects.Length - 1; j++)
        {
            string[] temp = objects[j].Split('_');
            //Debug.Log("temp "+temp.Length);
            for (int i = 0; i < 18; i++)
            {
                //Debug.Log("char " + j + "," + i);
                characteristics[j, i] = temp[i];
            }
        }
        for (int j = 0; j < objects.Length - 1; j++)
        {
            CreatureAI c = new CreatureAI();
            c.myId         = int.Parse(characteristics[j, 1]);
            c.Genoma[0]    = float.Parse(characteristics[j, 3]);
            c.Genoma[1]    = float.Parse(characteristics[j, 4]);
            c.Genoma[2]    = float.Parse(characteristics[j, 5]);
            c.Genoma[3]    = float.Parse(characteristics[j, 6]);
            c.AmIAPredator = int.Parse(characteristics[j, 8]);
            c.FinalFitness = float.Parse(characteristics[j, 14]);

            //creaturesGlobalHeritance.creature.Add(c);
            LastElitizedCreatures.Add(c);
        }
    }
コード例 #3
0
 void WriteDetails()
 {
     if (IterationPupulation == "1")
     {
         HandleTextFile.WriteString("Experiment Nº: " + dataPath + ", Crossover: " + Crossover + ", Mutation: " + Mutation + ", EvolutionPression: " + EvolutionPression + ", numGenerations: " + numGenerations + ", MinMax = [0f-2f], Food: " + maxFoodRange + ", Number Creatures: " + maxCreaRange + ", Predators?: " + Predators + ", Predators%: " + PredatorsPercentage, IterationPupulation.ToString(), true);
     }
 }
コード例 #4
0
 //clears drop zones between stages
 //allies remain from stage to stage
 // pass in a 1 it clears everything, pass in 0 it only clears equipment
 public void ClearDropZones(int Mode)
 {
     for (int i = 0; i < dzones.Count; i++)
     {
         if (Mode == 1)
         {
             foreach (AmourCard AC in dzones[i].SpecificUseCards)
             {
                 AC.GetComponent <Dragable>().returnParent = Discard.transform;
                 AC.transform.SetParent(Discard.transform);
                 AC.gameObject.GetComponent <Image>().sprite = AC.GetComponent <AdventureCard>().cardBack;
                 Discard.cards.Add(AC);
             }
             dzones[i].SpecificUseCards.Clear();
         }
         foreach (EquipmentCard EC in dzones[i].Equipment)
         {
             EC.GetComponent <Dragable>().returnParent = Discard.transform;
             EC.transform.SetParent(Discard.transform);
             EC.gameObject.GetComponent <Image>().sprite = EC.GetComponent <AdventureCard>().cardBack;
             Discard.cards.Add(EC);
         }
         dzones[i].Equipment.Clear();
         HandleTextFile.WriteLog((Controler.LogLine += 1) + " Clearing cards from Dropzone of player" + (i + 1) + " #BNF-19", Controler.SName);
     }
 }
コード例 #5
0
 public override void EndTurn()
 {
     HandleTextFile.WriteLog("Action Log: Tournament Turn End ", GameControler.SName);
     FlipDropzone(dzones[turn], true);
     if (hands[turn].cards.Count > 12)
     {
         if (PhotonNetwork.player.ID == turn + 1)
         {
             pop.ActivateDiscard(hands[turn].cards.Count - 12);
         }
     }
     else
     {
         int next = playerWhoDrewTheCard;
         if (playerWhoDrewTheCard + 1 > 3)
         {
             next = 0;
         }
         if (turnsPassed == joinedPlayers)
         {
             pop.EnableTournamentBlockScreen(players[next], (next));
             EndTournament();
         }
         else
         {
             glows[turn].SetActive(false);
             glows[turn + 1].SetActive(true);
             GetNext();
         }
     }
 }
コード例 #6
0
    static public Predecessors.Predecessor ReadPredecessor(string path)
    {
        string jsonText   = HandleTextFile.ReadString(path);
        var    parsedJson = JSON.Parse(jsonText);

        if (parsedJson["type"] == "single")
        {
            Predecessors.SinglePredecessor single = ScriptableObject.CreateInstance <Predecessors.SinglePredecessor>();
            single.name = parsedJson["name"];
            single.SetPredecessor(parsedJson["predecessor"].Value[0]);
            return(single);
        }
        else if (parsedJson["type"] == "context")
        {
            Predecessors.ContextSensitivePredecessor context = ScriptableObject.CreateInstance <Predecessors.ContextSensitivePredecessor>();
            context.name = parsedJson["name"];
            //These are supposed to be stored as chars, taking the first value from the string gives us that
            context.SetPredecessor(parsedJson["predecessor"].Value[0]);
            context.SetLetters(parsedJson["preLetter"].Value, parsedJson["postLetter"].Value);

            Debug.Log(context);
            return(context);
        }
        Debug.Log("The JSON was badly formed");
        return(null);
    }
コード例 #7
0
    void Start()
    {
        listFonts    = GameObject.FindGameObjectsWithTag("LifePoint").ToList();
        listSpawns   = GameObject.FindGameObjectsWithTag("Spawner").ToList();
        player       = GameObject.FindGameObjectWithTag("Player");
        game         = GameObject.FindGameObjectWithTag("Game");
        nextLevelObj = GameObject.FindGameObjectWithTag("NextLevel");
        healthBar    = player.GetComponent <HealthBarPlayer>();

        sceneLoader = game.GetComponent <SceneLoader>();
        nextLevel   = nextLevelObj.GetComponent <NextLevel>();

        playerCmd = player.GetComponent <PlayerComand>();

        for (int i = 0; i < listFonts.Count; i++)
        {
            lifeFountain = listFonts[i].GetComponent <LifeFountain>();
        }
        for (int j = 0; j < listSpawns.Count; j++)
        {
            handleText = listSpawns[j].GetComponent <HandleTextFile>();
            spawnInt.Add(0);
        }
        for (int k = 0; k < listTotens.Count; k++)
        {
            ctrlMaterial = listTotens[k].GetComponent <ControllMaterial>();
        }
    }
コード例 #8
0
    public void Init()
    {
        spritePreview.gameObject.SetActive(isCreateMode ? true : false);
        var json = HandleTextFile.ReadString();
        //var cleanJson = json.Replace('\\',' ');

        var myObjects = JsonConvert.DeserializeObject <List <DTGridData> >(json);

        if (myObjects == null)
        {
            Debug.Log("null map data");
            return;
        }
        foreach (var g in myObjects)
        {
            var grid = g;
            if (grid.posX > Columns || grid.posX < 0 ||
                grid.posY > Horizontal || grid.posY < 0)
            {
                continue;
            }
            _curTileType = (TileType)grid.value;
            SpawnTile(grid.posX, grid.posY, grid.value);
        }
    }
コード例 #9
0
 static void ReadFile(HandleTextFile htf)
 {
     // string path = "Assets/Resources/sat00.txt";
     Debug.Log(htf.input_file);
     try
     {
         // Create an instance of StreamReader to read from a file.
         // The using statement also closes the StreamReader.
         using (StreamReader sr = new StreamReader(htf.input_file.ToString()))
         {
             int    count = 0;
             string line;
             while ((line = sr.ReadLine()) != null)
             {
                 string[] split_line = line.Split(' ');
                 htf.file_col_count = split_line.Length;
                 count++;
             }
             htf.file_row_count = count;
         }
     }
     catch (Exception e)
     {
         // Let the user know what went wrong.
         Debug.Log("The file could not be read:");
         Debug.Log(e.Message);
     }
 }
コード例 #10
0
    public override void join(bool choice)
    {
        joined[turn] = choice;
        if (PhotonNetwork.player.ID != turn + 1)
        {
            pop.EnableJoinBlockScreen(turn, choice);
        }
        else
        {
            pop.EnableWaitScreen();
        }
        HandleTextFile.WriteLog((GameControler.LogLine += 1) + " Player " + (turn + 1) + "'s choice has been shown to other players, #BNF-30", GameControler.SName);
        turnsPassed++;
        TurnOrder();
        SetGlow(turn);
        pop.EnableTournamentBlockScreen(players[turn], turn);
        if (choice == true)
        {
            joinedPlayers++;
        }
        HandleTextFile.WriteLog((GameControler.LogLine += 1) + " Action Log: Player " + (turn + 1) + " Joins the Tournament : " + choice + ", #BNF-30", GameControler.SName);

        if (turnsPassed > 3)
        {
            Start();
        }
        //AI Logic
        if (players[turn].GetComponent <AiPlayer>() != null)
        {
            AiPlayer temp = players[turn].GetComponent <AiPlayer>();
            temp.JoinTournament(players, Reward, this);
        }
    }
コード例 #11
0
 public void init()
 {
     player         = GameObject.FindGameObjectWithTag("Player");
     spawm          = GameObject.FindGameObjectWithTag("Spawner");
     sphereCast     = player.GetComponent <SphereCast>();
     handleTextFile = spawm.GetComponent <HandleTextFile>();
 }
コード例 #12
0
    // Use this for initialization
    void Start()
    {
        MM        = GetComponent <MoleculeManager>();
        LM        = GetComponent <LevelManager>();
        manager   = GetComponent <Manager>();
        BBManager = GameObject.FindGameObjectWithTag("Board").GetComponent <BlackBoardManager>();
        IM        = GameObject.Find("Info").GetComponent <InformationManager>();

        PS = GetComponent <PointSystem>();
        if (levelsFile != "")
        {
            levels = HandleTextFile.ReadLevels(levelsFile);
        }
        //APMultiple = GameObject.Find("ControlPanelAnswers").GetComponent<AnswerPanel>();
        //APSingle = GameObject.Find("ControlPanelAnswer").GetComponent<AnswerPanel>();
        levelComplete    = false;
        newLevel         = true;
        getAnswer        = false;
        correctMolLoaded = false;
        partialCreated   = false;
        canCreateNew     = true;
        restore          = false;
        level            = 1;
        string[] info = new string[2] {
            "1", "multiple choice"
        };
        Logs.BeginFile(fileName, info);
        SoundEffectsManager.SetUp();
    }
コード例 #13
0
ファイル: Dragable.cs プロジェクト: LukasMcClelland/Quest
 public void OnBeginDrag(PointerEventData eventData)
 {
     HandleTextFile.WriteLog("UI log: Grab Dragable Object", GameControler.SName);
     returnParent = transform.parent;
     transform.SetParent(transform.parent.parent);
     GetComponent<CanvasGroup>().blocksRaycasts = false;
 }
コード例 #14
0
    private void Start()
    {
        string spellsText  = HandleTextFile.ReadString(spellBookLocation1);
        string spellsText2 = HandleTextFile.ReadString(spellBookLocation2);

        spell1Settings = JsonUtility.FromJson <SpellJson>(spellsText);

        if (creature != null)
        {
            creature.spell1Settings = spell1Settings;
        }
        if (spell1 != null && spell1.isOn)
        {
            codeSetter.text = (spell1Settings.code);
        }
        spell2Settings = JsonUtility.FromJson <SpellJson>(spellsText2);

        if (creature != null)
        {
            creature.spell2Settings = spell2Settings;
        }
        if (spell1 != null && spell2 != null)
        {
            spell1.onValueChanged.AddListener(delegate {
                OnToggleChangedSpell1();
            });
            spell2.onValueChanged.AddListener(delegate {
                OnToggleChangedSpell1();
            });
        }
    }
コード例 #15
0
 // Use this for initialization
 void Start()
 {
     _currentLevel   = 0;
     _handleTextFile = GetComponent <HandleTextFile>();
     levels          = _handleTextFile.ReadString("Assets/levels/levels.txt").Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);
     SetLevel(_currentLevel);
 }
コード例 #16
0
    public void WindowsAppLauncher()
    {
#if UNITY_STANDALONE_WIN
        //if (appDownloader.StartDownloadWindows(WindowAppID) == true)
        //{
        //}
        if (isFaceDetectSetting == true)
        {
            HandleTextFile fileRead2 = new HandleTextFile();
            fileRead2.SetFileVariable("FaceDetectSetting", "0");
        }

        GameObject.Find("TextDebug").GetComponent <Text>().text = "Start Window App: " + WindowAppID;
        string m_Path = Application.dataPath;
        if (File.Exists(m_Path + "/../Library/" + WindowAppID + "/" + WindowAppID + ".exe") == true)
        {
            GameLuncher gl = new GameLuncher();
            gl.LunchNow(WindowAppID);

            HandleTextFile fileRead = new HandleTextFile();
            fileRead.SetFileVariable("GameName", WindowAppID);
        }
        else
        {
            downloadInstall.StartDownload();
        }
#endif
    }
コード例 #17
0
    public void ExportLevel()
    {
        levelStr  = "";
        levelStr += boardSize + "-"; // <= 6
        levelStr += moves + "-";     // <= 8

        for (int h = 0; h < goalCenterTiles.Length; ++h)
        {
            levelStr += goalCenterTiles[h] + "-";
        }

        for (int i = 0; i < previewColors.Length; ++i)
        {
            levelStr += previewColors[i] + "-";
        }

        string boardStr = "";

        for (int c = 0; c < Services.LevelManager.numCols; ++c)
        {
            for (int r = 0; r < Services.LevelManager.numRows; ++r)
            {
                boardStr += "[-" + c + "-,-" + r + "-]-";
                foreach (Tile tile in Services.LevelManager.board[c, r].tileStack)
                {
                    boardStr += tile.color + "-";
                }
            }
        }

        levelStr += boardStr;
        levelStr += ".";

        HandleTextFile.WriteString(inputString, levelStr);
    }
コード例 #18
0
    public void EnableI(int DZIndex)
    {
        HandleTextFile.WriteLog("UI Log: Enable Players" + (DZIndex + 1) + " Dropzone", GameControler.SName);
        Dropable temp = (Dropable)dzones[DZIndex].GetComponent <Dropable>();

        temp.enabled = true;
    }
コード例 #19
0
 public void ToggleBoard(int id, int State)
 {
     if (State == 0)
     {
         HandleTextFile.WriteLog((LogLine += 1) + " Action Log: Disable Board Objects", SName);
         for (int i = 0; i < 4; i++)
         {
             dzones[i].GetComponent <Dropable>().enabled = false;
             hands[i].gameObject.SetActive(false);
             Dragable[] temphand = hands[i].GetComponentsInChildren <Dragable>();
             foreach (Dragable d in temphand)
             {
                 d.enabled = false;
             }
         }
         hands[id].gameObject.SetActive(true);
     }
     else
     {
         HandleTextFile.WriteLog((LogLine += 1) + " Action Log: Enable Board Objects", SName);
         for (int i = 0; i < 4; i++)
         {
             dzones[i].GetComponent <Dropable>().enabled = true;
             hands[i].gameObject.SetActive(true);
             Dragable[] temphand = hands[i].GetComponentsInChildren <Dragable>();
             foreach (Dragable d in temphand)
             {
                 d.enabled = true;
             }
         }
     }
 }
コード例 #20
0
    //checks sponsor's quest setup, returns true if valid
    public bool CheckSponsorQuestZones()
    {
        int last = 0;
        int tempBP;

        for (int i = 0; i < questCard.numberOfStages; i++)
        {
            tempBP = qzones[i].UpdateBP(questCard.specialFoeId);
            if (tempBP > last)
            {
                last = tempBP;
            }
            else
            {
                this.gameObject.GetComponent <PhotonView>().RPC("ResetSponsorQzones", PhotonTargets.All);
                return(false);
            }

            if (qzones[i].ControledFoes.Count == 0)
            {
                this.gameObject.GetComponent <PhotonView>().RPC("ResetSponsorQzones", PhotonTargets.All);
                return(false);
            }
        }
        pop.EnableSponsorBlockScreen(turn, true);
        HandleTextFile.WriteLog((Controler.LogLine += 1) + " Sponsor has played cards in zones. Quest Valid. Quest Start " + "#BNF-5", Controler.SName);
        return(true);
    }
コード例 #21
0
    private bool IsMoleculeComplete(string description)
    {
        //with two names describing the molecule, the first has to be the name and the second the class (it only really needs the name)
        if (description.Contains("&"))
        {
            string[] info  = description.Split('&');
            string   name  = info[1];
            string   text1 = HandleTextFile.ReadString(name + "Bonds.txt");
            return(MM.CompareMoleculesString(text1, false));
        }

        //with no upper case letters, it could be used just the name or the class.
        //for the class, it is called CheckMoleculesClass, and for the name just read the text file
        if (!description.Any(char.IsUpper))
        {
            if (MM.CheckMoleculesClass(description))
            {
                return(true);
            }
            else
            {
                string text1 = HandleTextFile.ReadString(description + "Bonds.txt");
                return(MM.CompareMoleculesString(text1, false));
            }
        }

        //with upper case letters and no spaces, it means it is the formule of the molecule (Ex. CH4)
        if (description.Split(' ').Length <= 1)
        {
            string text1 = HandleTextFile.ReadString(description + "Bonds.txt");
            return(MM.CompareMoleculesString(text1, false));
        }
        return(false);
    }
コード例 #22
0
ファイル: Engine.cs プロジェクト: jotaate/Crowd-Simulation
 void Awake()
 {
     Instance        = this;
     spatialDatabase = new LQProximityDatabase(Vector3.zero, new Vector3(500, 0, 500), new Vector3(10, 0, 10));
     results         = FindObjectOfType <HandleTextFile>();
     CreateAgents();
 }
コード例 #23
0
 public void DealHands()
 {
     HandleTextFile.WriteLog((LogLine += 1) + " Action Log: Player Deal", SName);
     for (int i = 0; i < hands.Count; i++)
     {
         hands[i].dealHand(ADeck);
     }
 }
コード例 #24
0
 public void Draw(Deck InputDeck)
 {
     HandleTextFile.WriteLog((GameControler.LogLine += 1) + " Action log: Draw Card " + InputDeck.cards[0].name, GameControler.SName);
     InputDeck.cards[0].gameObject.GetComponent <Dragable>().returnParent = this.transform;
     Instantiate(InputDeck.cards[0]).transform.SetParent(this.transform);
     this.cards.Add(InputDeck.cards[0]);
     InputDeck.cards.RemoveAt(0);
 }
コード例 #25
0
    void LoadProgress()
    {
        string text = HandleTextFile.ReadString();

        string[] word = text.Split(' ');
        totalPoint    = float.Parse(word[0]);
        totalDistance = float.Parse(word[1]);
    }
コード例 #26
0
 private void Awake()
 {
     LobbyLineNumber = 0;
     LName           = "Build";
     PhotonNetwork.ConnectUsingSettings(versionNumber);
     PhotonNetwork.automaticallySyncScene = true;
     HandleTextFile.WriteLog((LobbyLineNumber += 1) + " Network Log: Initializing Server: " + "#SNG1", LName);
 }
コード例 #27
0
 public void EndTournament()
 {
     HandleTextFile.WriteLog("Action Log: Tournament Turn End ", GameControler.SName);
     CalculateWinner();
     boardUI.SetActive(false);
     gameState = false;
     InatiatedBy.ReturnControl(ADeck, Discard, hands, dzones, playerWhoDrewTheCard);
 }
    void Start()
    {
        objRend   = new List <Renderer>();
        enemyList = new List <GameObject>();

        sphereCast = new SphereCast();



        player     = GameObject.FindGameObjectWithTag("Player");
        spawns     = GameObject.FindGameObjectsWithTag("Spawner").ToList();
        sphereCast = player.GetComponent <SphereCast>();
        //enemyRender = GameObject.FindGameObjectWithTag("Inimigo");


        //objMesh = GameObject.FindGameObjectWithTag("HideObj");
        //objRend = objMesh.GetComponent<Renderer>();

        //obsList = GameObject.FindGameObjectsWithTag("Toten").ToList();
        enemyList = GameObject.FindGameObjectsWithTag("Inimigo").ToList();

        totenRend = GetComponent <Renderer>();
        totenRend.material.shader = Shader.Find("Toon/Lit Dissolve DoubleTex");


        shaderController = player.GetComponent <ShaderController>();

        for (int i = 0; i < spawns.Count; i++)
        {
            handText = spawns[i].GetComponent <HandleTextFile>();
        }


        //if (SaveLoadGame.instance.deuLoad == true)
        //{
        //    obsList[tottenAtual].GetComponent<Renderer>().material = material[1];
        //}

        //for (int j = 0; j < enemyList.Count; j++)
        //{
        //    matEnemy = enemyList[j].GetComponent<EnemyMatCtrl>();
        //}

        //for (int j = 0; j < obsList.Count; j++)
        //{
        //    obsList[j].GetComponent<Renderer>().sharedMaterial = material[0];
        //}

        //for (int j = 0; j < enemyList.Count; i++)
        //{
        //    enemyRender = enemyList[j]
        //}
        //rendEnemy = GetComponent<Renderer>();
        //rendEnemy.material.shader = Shader.Find("Toon/Lit Dissolve");

        //rend = GetComponent<Renderer>();
        //rend.material.shader = Shader.Find("Toon/Lit Dissolve Appear");
    }
コード例 #29
0
    public Card DrawStoryCard()
    {
        Card TempCard = SDeck.cards[0].GetComponent <Card>();

        HandleTextFile.WriteLog((LogLine += 1) + " Action Log: Story Card " + TempCard.name + " has Been Drawn " + "#BNF-1", SName);
        SDeck.cards.Remove(TempCard);
        HandleTextFile.WriteLog((LogLine += 1) + " Action Log: Discard Story Card " + TempCard.name + "#BNF-1", SName);
        return(TempCard);
    }
コード例 #30
0
 public void AiTurn()
 {
     if (players[turn].GetComponent <AiPlayer>() != null)
     {
         HandleTextFile.WriteLog((LogLine += 1) + " AI Log: AI Player Draws Story Card", SName);
         EndTurn();
         ToggleBoard(turn, 0);
     }
 }