コード例 #1
0
ファイル: GameManager.cs プロジェクト: NestorSaga/Musica2
    void Start()
    {
        p1Life = Assignations.Instance.initialLife;
        p2Life = Assignations.Instance.initialLife;

        turnNumber = 1;
        InitTurn();
        currentNotes = startingNotes;

        listening = false;

        initialRowsNumber = Assignations.Instance.initialRowsNumber;
        grid = GameObject.FindGameObjectWithTag("Grid").GetComponent <PopulateGrid>();
        // El tempo tiene que depender de la dificultad:
        // EASY --> tempo = 4
        // MEDIUM --> tempo = 2
        // DIFFICULT --> tempo = 1
        if (DifficultyManager.Instance != null)
        {
            tempo = DifficultyManager.Instance.difficulty;
        }
        else
        {
            tempo = 2;
        }
    }
コード例 #2
0
ファイル: SceneOrganiser.cs プロジェクト: mahclark/GreenEyes
    private IEnumerator MakeDataPanel(ObjectData data, Vector3 position, Quaternion rotation)
    {
        yield return(new WaitForSeconds(0));

        Debug.Log("make a data panel");

        GameObject dataPanel = GameObject.Instantiate(dataPanelPrefab, position, rotation);

        dataPanel.transform.localPosition = position;

        Transform window = dataPanel.transform.Find("SF Window");

        Transform       titleLbl  = window.Find("Title");
        TextMeshProUGUI titleMesh = titleLbl.GetComponent <TextMeshProUGUI>();

        titleMesh.text = data.name;

        Transform icons = window.Find("Icons");

        PopulateGrid populateGrid = icons.GetComponent <PopulateGrid>();

        populateGrid.scores[0] = data.carbonScore;
        populateGrid.scores[1] = data.waterScore;
        populateGrid.scores[2] = data.landScore;
        populateGrid.Populate();
    }
コード例 #3
0
    void Awake()
    {
        btn = GetComponent <Button>();
        btn.onClick.AddListener(OnClickTask);

        grid = GameObject.FindGameObjectWithTag("InventoryView").GetComponent <PopulateGrid>();
    }
コード例 #4
0
    static void OpenWindow()
    {
        PopulateGrid window = (PopulateGrid)GetWindow(typeof(PopulateGrid));

        window.minSize = new Vector2(400, 200);
        window.Show();
    }
コード例 #5
0
ファイル: FluidSolver.cs プロジェクト: ania1234/fluidLearning
    private void Swap(ref float[] grid1, ref float[] grid2)
    {
        var temp = grid1;

        grid1 = grid2;
        grid2 = temp;
    }
コード例 #6
0
ファイル: Movement.cs プロジェクト: GrantS92/Sokoban-Game
        //checks if the player has successfully moved the box to the win location.
        private void winCheck(Coordinate win)
        {
            if (Window.winLocation.Equals(win) == true)
            {
                PopulateGrid.drawContents("images\\bin2.bmp", Window.winLocation);
                MoveCount   = 0;
                levelCount += 1;

                //sets the message box title, body and creates yes/no button

                if (MessageBox.Show("WINNER! play Again?", "Congratulations", MessageBoxButton.YesNo) == MessageBoxResult.No)
                {
                    Window.MoveLabel.Text = "WINNER";
                    Window.MoveCount.Text = "Level Completed!";
                }
                else
                {
                    try
                    {
                        PopulateGrid.levels[levelCount]();
                        Window.MoveCount.Text = Convert.ToString(MoveCount);
                    }
                    catch (Exception e)
                    {
                        MainWindow main = new MainWindow();
                        MessageBox.Show("No more levels");
                        Window.Close();
                        main.Show();
                    }
                }
            }
        }
コード例 #7
0
 void Awake()
 {
     gameController = GameObject.FindGameObjectWithTag("GameController");
     eleDB          = gameController.GetComponent <ElementDatabase>();
     parent         = GameObject.FindGameObjectWithTag("CombinationView").transform;
     activeElements = gameController.GetComponent <ActiveElements>();
     comboDB        = gameController.GetComponent <CombinationDatabase>();
     inventory      = gameController.GetComponent <Inventory>();
     grid           = GameObject.FindGameObjectWithTag("InventoryView").GetComponent <PopulateGrid>();
 }
コード例 #8
0
        public FormServerSettings(ConnectionInfo connectionInfo)
        {
            InitializeComponent();

            _populateGrid        = OnPopulateGrid;
            this._connectionInfo = connectionInfo;

            _packeteer = LoginPacketeerFactory.GetNewPacketeer(connectionInfo);
            _packeteer.OnMessageReceived += Packeteer_OnMessageReceived;
        }
コード例 #9
0
 private void Start()
 {
     attemptsText   = GameObject.FindGameObjectWithTag("AttemptsText").GetComponent <TextMeshProUGUI>();
     scoreText      = GameObject.FindGameObjectWithTag("ScoreText").GetComponent <TextMeshProUGUI>();
     containerPanel = GameObject.FindGameObjectWithTag("PanelContainer");
     if (populateScript == null)
     {
         populateScript = GetComponentInParent <PopulateGrid>();
     }
     audio = GetComponent <AudioSource>();
 }
コード例 #10
0
 private void Awake()
 {
     if (instance == null)
     {
         //DontDestroyOnLoad (gameObject);
         instance = this;
     }
     else if (instance != this)
     {
         Destroy(gameObject);
     }
 }
コード例 #11
0
    void Awake()
    {
        if (GM != null)
        {
            GameObject.Destroy(GM);
        }
        else
        {
            GM = this;
        }

        //DontDestroyOnLoad(this);
    }
コード例 #12
0
    public void OnclickButton()
    {
        if (firstTime)
        {
            Obj = GameObject.Find("Content").GetComponent <PopulateGrid>();

            if (Obj != null)
            {
                // Debug.Log(Obj.name);
            }
            NoOfTurbines = Obj.numberToCreate;
            //Debug.Log(NoOfTurbines);
            Turbines = new GameObject[NoOfTurbines];

            for (int i = 0; i < NoOfTurbines; i++)
            {
                Turbines[i] = Obj.Turbines[i];
                Turbines[i].SetActive(false);
            }
            firstTime = false;
        }
        int.TryParse(EventSystem.current.currentSelectedGameObject.name, out name);

        if (EventSystem.current.currentSelectedGameObject.GetComponent <Image>().color != Color.green)
        {
            EventSystem.current.currentSelectedGameObject.GetComponent <Image>().color = Color.green;
        }
        else
        {
            EventSystem.current.currentSelectedGameObject.GetComponent <Image>().color = new Color(194f, 194f, 194f);
        }
        //Debug.Log(name.ToString());
        // Debug.Log("No of turbines " + Turbines.Length);
        //for (int i=0;i<Turbines.Length;i++)
        //{
        //    Debug.Log(Turbines[i].gameObject.name);
        //}
        if (Turbines[name].activeInHierarchy == true)
        {
            Turbines[name].SetActive(false);
        }
        else
        {
            Turbines[name].SetActive(true);
        }
    }
コード例 #13
0
    void Start()
    {
        Content      = GameObject.Find("Content");
        BarChatSetts = GameObject.Find("BarChatSetts(Clone)");
        GraphClose   = GameObject.Find("GraphClose");
        barChart     = barChartObj.GetComponent <BarChart>();
        PopulateGrid   populate       = Content.GetComponent <PopulateGrid>();
        CanvasBarChart canvasBarChart = barChart.GetComponent <CanvasBarChart>();

        canvasBarChart.DataSource.ClearCategories();

        GraphClose.GetComponent <Button>().onClick.AddListener(() => CloseGraph());

        string TurbineHeight = "";

        barChart.DataSource.StartBatch();
        if (barChart != null)
        {
            List <string> list = new List <string>();
            for (int i = 0; i < populate.GeneratedPowerSet.Length / 5; i++)
            {
                if (populate.GeneratedPowerSet[i, 1] != 0)
                {
                    list.Add("Power of Turbine Height " + TurbineHeight + "- Row " + populate.GeneratedPowerSet[i, 0] + " : " + populate.GeneratedPowerSet[i, 1] + " | WindInput of " + "Turbine Height " + TurbineHeight + "- Row " + populate.GeneratedPowerSet[i, 0] + " : " + populate.GeneratedPowerSet[i, 2]);
                    TurbineHeight = populate.getTrubineHeight(Convert.ToInt32(populate.GeneratedPowerSet[i, 0])).ToString();
                    canvasBarChart.DataSource.AddCategory("T" + TurbineHeight + "-" + populate.GeneratedPowerSet[i, 0], MaterialList[UnityEngine.Random.Range(0, MaterialList.Length)]);

                    barChart.DataSource.SetValue("T" + TurbineHeight + "-" + populate.GeneratedPowerSet[i, 0], "Power", populate.GeneratedPowerSet[i, 1]);
                    barChart.DataSource.SetValue("T" + TurbineHeight + "-" + populate.GeneratedPowerSet[i, 0], "WInput", populate.GeneratedPowerSet[i, 2]);
                }
            }
            using (System.IO.StreamWriter file =
                       new System.IO.StreamWriter(@"D:\\PowerOutPutAndWindInput.txt"))
            {
                foreach (string line in list)
                {
                    // If the line doesn't contain the word 'Second', write the line to the file.
                    file.WriteLine(line);
                }
            }
        }
        barChart.DataSource.EndBatch();
    }
コード例 #14
0
    private void Start()
    {
        turnState = TTurnState.COMPOSING;

        rows = GameManager.Instance.ReturnRows();

        //cells = new GameObject[rows];

        grid = GameObject.FindGameObjectWithTag("Grid").GetComponent <PopulateGrid>();

        grid.Populate(rows);

        if (GameManager.Instance.getPlayerinTurn() == 1)
        {
            GameManager.Instance.UpdateText("p1");
        }
        else
        {
            GameManager.Instance.UpdateText("p2");
        }
    }
コード例 #15
0
    void Start()
    {
        GameObject go = GameObject.FindWithTag("Content");

        other = (PopulateGrid)go.GetComponent(typeof(PopulateGrid));
    }
コード例 #16
0
    /// <summary>
    /// Sent each frame where another object is within a trigger collider
    /// attached to this object (2D physics only).
    /// </summary>
    /// <param name="other">The other Collider2D involved in this collision.</param>
    void OnTriggerStay2D(Collider2D other)
    {
        if (other.gameObject.tag == "DraggableElement" && canCollide == true && gameObject.GetComponent <ElementDragHandler>().dragging == false)
        {
            //Destroy(other.gameObject);
            Image image    = other.gameObject.GetComponent <Image>();
            Color newColor = new Color(image.color.r, image.color.g, image.color.b, 1);
            image.color = newColor;


            //RecipeDictionary d = new RecipeDictionary();

            // finds the index of the element created. Returns -99 if no recipe found.
            int elementIndex = IsValidRecipe(this, other.gameObject.GetComponent <DraggableElement>());

            //when the a spell is casted destroy the ingredients
            if (elementIndex > 89 && ((elementIndex != 92) && (elementIndex != 109)))
            {
                Destroy(this.gameObject);
                Destroy(other.gameObject);
            }

            // unlock spell
            cSpell.ToggleCheckmark(elementIndex);


            //if wine recipe is completed return the wine sprite
            if (elementIndex == 92)
            {
                elementIndex = 9;
            }
            //shrinking spell is completed return a tiny tray
            else if (elementIndex == 109)
            {
                elementIndex = 24;
            }

            // make sure valid element can be added (out of bounds)
            if (elementIndex != -99 && elementIndex < 89)
            {
                other.gameObject.GetComponent <DraggableElement>().image.sprite  = elDic.allElements[elementIndex].icon;
                other.gameObject.GetComponent <DraggableElement>().elementID     = elDic.allElements[elementIndex].elementID;
                other.gameObject.GetComponent <DraggableElement>().nameText.text = elDic.allElements[elementIndex].elementName;
                other.gameObject.GetComponent <DraggableElement>().element       = elDic.allElements[elementIndex];

                //check if this element has not been discovered
                if (!elDic.allElements[elementIndex].active)
                {
                    // set created element to active
                    elDic.allElements[elementIndex].active = true;

                    // add element to UI inventory
                    PopulateGrid unlockedItems = FindObjectOfType <PopulateGrid>();
                    unlockedItems.AddItem(elementIndex);

                    // check if beast pelt
                    if (elementIndex == 62)
                    {
                        // set beast blood and hair to active
                        elDic.allElements[63].active = true;
                        unlockedItems.AddItem(63);
                        elDic.allElements[64].active = true;
                        unlockedItems.AddItem(64);
                    }
                    // check if blood
                    else if (elementIndex == 17)
                    {
                        // set beast blood and hair to active
                        elDic.allElements[20].active = true;
                        unlockedItems.AddItem(20);
                    }

                    // Play New discovery sound effect
                    audio.PlayNewCombo();
                }
                else
                {
                    // play regular Combination sound effect
                    audio.PlayCombo();
                }
                // check if beast pelt
                if (elementIndex == 62)
                {
                    // spawn beast blood and hair
                    myItem.SpawnBeastItem();
                }
                // check if blood
                else if (elementIndex == 17)
                {
                    // spawn human eye
                    myItem.SpawnHumanItem();
                }
                Destroy(this.gameObject);
            }
            else
            {
                // play no combo sound ONCE!!!
                if (!soundPlayed)
                {
                    audio.PlayNoCombo();
                    soundPlayed = true;
                }
            }
        }
    }
コード例 #17
0
 void Awake()
 {
     dropdown = GetComponent <TMP_Dropdown>();
     grid     = GameObject.FindGameObjectWithTag("InventoryView").GetComponent <PopulateGrid>();
 }
コード例 #18
0
 void Start()
 {
     gridComp       = GetComponent <PopulateGrid>();
     scoreBehaviour = GameObject.Find("Score").GetComponent <ScoreBehaviour>();
 }
コード例 #19
0
    public void Update()
    {
        FromPreviousScene = GameObject.Find("ButtonScript").GetComponent <InputsAndButtons>();
        Slider            = GameObject.Find("Slider") as GameObject;
        Obj = GameObject.Find("Content").GetComponent <PopulateGrid>();
        WindSpeedInputFromCanvas = GameObject.Find("InputFieldWindSpeed");
        if (FromPreviousScene == null || Slider == null || WindSpeedInputFromCanvas == null || Obj == null)
        {
        }
        else
        {
            if (isfirst == false)
            {
                isfirst = true;
                Slider.GetComponent <Slider>().value = 90;
                Obj.GeneratedPowerSet[TurbineRow, 3]++;
                for (int i = 0; i < NoOfTurbines; i++)
                {
                    Turbines[i] = Obj.Turbines[i];
                }
                WingSize  = FromPreviousScene.Radius;
                WindSpeed = FromPreviousScene.WindSpeed;

                int n = TurbineNo;
                while ((n / 10) >= 1)
                {
                    TurbineColoumn++;
                    n = n / 10;
                }



                NoOfTurbines = Obj.numberToCreate;
                //Debug.Log(NoOfTurbines);
                Turbines = new GameObject[NoOfTurbines];


                XPosition.text = "XPosition:" + this.transform.position.x;
                YPosition.text = "YPosition:" + this.transform.position.z;
                Height.text    = "Height:" + Obj.getTrubineHeight(TurbineRow);
                ValueOfK       = FromPreviousScene.ValuefK;
            }



            //if (this.gameObject.activeSelf)
            Ray myray = new Ray(this.transform.position, -Vector3.forward);
            // Ray myray  = Physics.Raycast(this.transform.position, -Vector3.forward, 500f);
            Debug.DrawRay(this.transform.position, -this.transform.right, Color.blue);
            //   if (Physics.Raycast(new Vector3(this.transform.position.x,this.transform.position.y+5,this.transform.position.z), this.transform.right, out TurbineHit, 5000f))
            {
                // Debug.Log("reached");
                // Debug.Log(TurbineHit.collider.gameObject.name);
                //    WindSpeedInput = TurbineHit.collider.gameObject.GetComponentInParent<canvasLook>().WindSpeedOutput;
            }
            //else
            {
                WindSpeedInput = WindSpeed;
                //  Debug.Log("not reached");
            }
            if (WindSpeedInputFromCanvas.GetComponent <InputField>().text != null)
            {
                float.TryParse(WindSpeedInputFromCanvas.GetComponent <InputField>().text, out WindSpeed);
            }
            {
                newRotation             = Quaternion.Euler(0f, Slider.GetComponent <Slider>().value, 0f);
                this.transform.rotation = newRotation;
                Neww = WindSpeed;
                thiscanvas.transform.LookAt(Camera.main.transform);
                thiscanvas.transform.Rotate(0, 180, 0);
                ThrustCoefficient = PopulateGrid.ThrustCoefficient;
                //  ThrustCoefficient = WindSpeed / (0.5f * 1.23f * (3.14f * (WingSize*this.transform.localScale.x) * (WingSize*this.transform.localScale.x)) * (WindSpeed * WindSpeed));

                /*
                 * if (TurbineRow == 1)
                 * {
                 *  WindSpeedInput = WindSpeed;
                 * }
                 * //Debug.Log("running");
                 * //Debug.Log("Turbine Row No" + TurbineRow);
                 * //Debug.Log(Turbines.Length);
                 *
                 * for (int i = TurbineRow - 1; i > 0; i--)
                 * {
                 *  //Debug.Log("inn tht");
                 *  //Debug.Log("Turbine no " + (TurbineNo -(i * (FromPreviousScene.Width / FromPreviousScene.TurbineSize))));
                 *
                 *  if (Turbines[TurbineNo - (i * (FromPreviousScene.Width / FromPreviousScene.TurbineSize))].gameObject.activeSelf == true)
                 *  {
                 *      //Debug.Log(TurbineNo - (i * (FromPreviousScene.Width / FromPreviousScene.TurbineSize)));
                 *
                 *      Neww = Turbines[TurbineNo - (i * (FromPreviousScene.Width / FromPreviousScene.TurbineSize))].GetComponent<canvasLook>().WindSpeedOutput;
                 *    //  Debug.Log("Wind speed input" + WindSpeedInput);
                 *     // firstTurbine =  false;
                 *  }
                 *  else
                 *  {
                 *      WindSpeedInput = Neww;
                 *  }
                 *
                 *  //Debug.Log("Wind speed input" + WindSpeedInput);
                 * }
                 * WindSpeedInput = Neww;
                 *
                 *
                 */
                float turbineHeight = Obj.getTrubineHeight(TurbineRow);
                if (FromPreviousScene.IsSameHeight == false)
                {
                    WindSpeedInput = WindSpeedCalculator.CalculateWindSpeed(turbineHeight, WindSpeedInput);
                }
                Obj.GeneratedPowerSet[TurbineRow, 4] = WindSpeedInput;
                float radius   = Obj.GetTurbineRadius(TurbineRow);
                float Diameter = 2 * (radius);
                float alpha    = 0.5f / (Mathf.Log(turbineHeight / 0.0024f));
                float dx       = Diameter + (2 * ValueOfK * Mathf.Sin(alpha));
                //    balance[(int)(this.transform.localScale.x)] = dx;
                if ((int)(TurbineRow) == 1)
                {
                    // WindSpeedOutput = (1 - Mathf.Sqrt(1 - ThrustCoefficient)) / (1);
                    WindSpeedOutput      = balance[0] = 0;
                    Obj.TurbineOutput[1] = WindSpeedInput;
                }
                else
                {
                    // WindSpeedInput = balance[(int)(this.transform.localScale.x)];
                    if (FromPreviousScene.IsGrid)
                    {
                        WindSpeedOutput = balance[(int)(TurbineRow - 1)] = (1 - Mathf.Sqrt(1 - ThrustCoefficient)) / (Mathf.Pow(1 + (ValueOfK * (((Obj.getTrubineHeight((int)(TurbineRow - 1)) / 1.5f) * 2) * PopulateGrid.XDiaValue)) / (GetPreviousTurbineRadius(TurbineRow - 1)), 2f));
                    }
                    else
                    {
                        if (TurbineRow % 2 == 0)
                        {
                            WindSpeedOutput = (1 - Mathf.Sqrt(1 - ThrustCoefficient)) / (Mathf.Pow(1 + (ValueOfK * (((Obj.getTrubineHeight((int)(TurbineRow - 1)) / 1.5f) * 2) * (PopulateGrid.YDiaValue))) / (GetPreviousTurbineRadius(TurbineRow - 1)), 2f));
                        }
                        else
                        {
                            WindSpeedOutput = (1 - Mathf.Sqrt(1 - ThrustCoefficient)) / (Mathf.Pow(1 + (ValueOfK * ((Obj.getTrubineHeight((int)(TurbineRow - 1)) / 1.5f) * 2) * (PopulateGrid.YDiaValue)) / (GetPreviousTurbineRadius(TurbineRow - 1)), 2f));
                        }
                    }

                    if (FromPreviousScene.IsSameHeight)
                    {
                        //   if (Obj.TurbineOutput[TurbineRow] == 0.0f)
                        {
                            Obj.TurbineOutput[TurbineRow] = Obj.TurbineOutput[TurbineRow - 1] - WindSpeedOutput;
                        }
                        WindSpeedInput = Obj.TurbineOutput[TurbineRow];
                    }
                    else
                    {
                        WindSpeedInput = WindSpeedInput - WindSpeedOutput;
                    }
                }


                //if (this.transform.localScale.x == 8)
                //{
                //    WindSpeedOutput = WindSpeedInput * ((1 - (1 - Mathf.Sqrt(1 - ThrustCoefficient))) * (((WingSize * this.transform.localScale.x) * (WingSize * this.transform.localScale.x)) / ( ( ( (WingSize * this.transform.localScale.x) * (WingSize * this.transform.localScale.x)) + 2f * 0.05f * TurbineRow))) );
                //}
                //else
                //{e
                //    WindSpeedOutput = WindSpeed;
                //}

                ThrustCoefficientText.text = ("ThrustCoefficient " + ThrustCoefficient);
                //  WindSpeedOutputText.text = ( "Wind Speed Output "+ (WindSpeedInput * ((1 - (1 - Mathf.Sqrt(1 - ThrustCoefficient))) * ((WingSize * WingSize) / ((WingSize * WingSize) + 2f * 0.05f * TurbineRow)))).ToString());
                WindSpeedOutputText.text = ("velocity Deficit " + WindSpeedOutput);
                float GeneratedPower = (0.5f * 1.23f * (3.14f * (radius) * (radius)) * (WindSpeedInput * WindSpeedInput * WindSpeedInput) * PopulateGrid.PowerCoefficient) / 1000000;
                PowerGeneratedText.text = ("Power Generated " + GeneratedPower.ToString());
                WindInput.text          = ("WI:" + WindSpeedInput.ToString());

                Obj.GeneratedPower[this.GetComponent <canvasLook>().TurbineNo] = GeneratedPower;
                Obj.GeneratedPowerSet[TurbineRow, 0] = TurbineRow;
                Obj.GeneratedPowerSet[TurbineRow, 1] = GeneratedPower;
                Obj.GeneratedPowerSet[TurbineRow, 2] = WindSpeedInput;
            }
        }
    }