Пример #1
0
        /// <summary>
        /// Generates default setting files in directory.
        /// </summary>
        /// <param name="directory">Directory to use for creating new files.</param>
        public static void Create(string directory)
        {
            var altitudeMapRules = new AltitudeMapRules();

            altitudeMapRules.Default();
            RulesIO.Save(directory + "\\GenerateAltitudeRules", altitudeMapRules);

            var erosionMapRules = new ErosionMapRules();

            erosionMapRules.Default();
            RulesIO.Save(directory + "\\GenerateErosionRules", erosionMapRules);

            var generateRules = new GenerateRules();

            generateRules.Default();
            RulesIO.Save(directory + "\\GenerationRules", generateRules);

            var moveRules = new MoveRules();

            moveRules.Default();
            RulesIO.Save(directory + "\\MoveRules", moveRules);

            var rainfallMapRules = new RainfallMapRules();

            rainfallMapRules.Default();
            RulesIO.Save(directory + "\\RainfallMapRules", rainfallMapRules);

            var plateData = new PlateData();

            plateData.Default();
            PlateIO.Save(directory + "\\PlateData", plateData);
        }
Пример #2
0
    public void SetArithmeticLeftAndRight(PlateData data)
    {
        if (leftdata.Equals(0))
        {
            leftSprite.spriteName = "a" + data.answer.ToString();
            leftSprite.alpha      = 1;
            leftdata = data.answer;
        }
        else
        {
            if (rightdata.Equals(0))
            {
                rightSprite.spriteName = "a" + data.answer.ToString();
                rightSprite.alpha      = 1;
                rightdata = data.answer;
            }
        }

        if (leftSprite.alpha.Equals(1) && rightSprite.alpha.Equals(1))
        {
            if (UIPlateManager.instance != null)
            {
                UIPlateManager.instance.PlateColliderSwitch(false);
            }
            resultdata = leftdata + rightdata;
            Invoke("CheckResult", 1f);
        }
    }
	public void SetArithmeticLeftAndRight(PlateData data)
	{
		if (leftdata.Equals (0)) {
			leftSprite.spriteName = "a"+data.answer.ToString ();
			leftSprite.alpha = 1;
			leftdata = data.answer;
		} else {
			if(rightdata.Equals(0))
			{
				rightSprite.spriteName = "a"+data.answer.ToString();
				rightSprite.alpha = 1;
				rightdata = data.answer;
			}
		}

		if(leftSprite.alpha.Equals(1) && rightSprite.alpha.Equals(1))
		{
			if(UIPlateManager.instance != null)
				UIPlateManager.instance.PlateColliderSwitch(false);
			resultdata = leftdata+rightdata;
			Invoke("CheckResult",1f);
		}
	}
Пример #4
0
        public void createRoute(int length)
        {
            // New list of plates
            plates = new List <Plate>();
            EnvironmentData data = Data.Instance.getEnvByTheme(Theme.FOREST);

            PlateData[] options = data.plates;

            if (options.Length == 0)
            {
                Debug.Log("Plates data is empty");
                return;
            }

            // Assume, that first is always exist
            GameObject plateInstance = Instantiate(options[0].prefab) as GameObject;

            plateInstance.transform.SetParent(transform);
            plateInstance.transform.position = transform.position;
            Plate plate = plateInstance.GetComponent <Plate>();

            // Shift base plate to north
            plateInstance.transform.Translate(plate.north.transform.localPosition);
            plate.southConnector.isFree = false;
            // The first plate will be the first battlefield
            battleField     = plate;
            plate.plateData = options[0];
            plates.Add(plate);

            for (int index = 1; index < length; index++)
            {
                // Choosing free connector
                Plate            last      = plates[index - 1].GetComponent <Plate>();
                List <Connector> free      = last.getFreeConnectors();
                Connector        chosen    = Utils.getRandomElement(free);
                List <PlateData> solutions = getPlatesByType(options, chosen.compatibleType);

                if (solutions.Count > 0)
                {
                    PlateData plateData = Utils.getRandomElement(solutions);
                    plateInstance = Instantiate(plateData.prefab) as GameObject;
                    plateInstance.transform.SetParent(transform);
                    plate = plateInstance.GetComponent <Plate>();

                    plate.connectTo(chosen);
                    chosen.isFree = false;

                    // Place transfer at last
                    if (index == (length - 1))
                    {
                        GameObject transferInstance = Instantiate(transfer) as GameObject;
                        transferInstance.transform.SetParent(transform);
                        plateInstance.GetComponent <Plate>().placeTransfer(transferInstance);
                    }

                    // When hero steps on this plate, made it current battlefield
                    plate.OnHeroCome += delegate() {
                        battleField = plate;
                    };

                    plate.plateData = plateData;
                    plates.Add(plate);
                }
            }
        }