private MapUtil() { mapConfig = MapConfig.getInstance(); ballConfig = BallConfig.getInstance(); row = Convert.ToInt32(mapConfig.MapWidth() / mapConfig.TileWidth()); col = Convert.ToInt32(mapConfig.MapHeight() / mapConfig.TileHeight()); }
// +++ life cycle +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public StateOutOfBounds(GameObject go) { // collect references and store them localy // for ease of use ballScript = go.GetComponent <nvp_Ball_scr>(); ballConfig = ballScript.ballConfig; transform = ballScript.transform; }
public void Convert(Entity entity, EntityManager dstManager, GameObjectConversionSystem conversionSystem) { var ballConfig = new BallConfig { Prefab = conversionSystem.GetPrimaryEntity(config.BallPrefab) }; dstManager.AddComponentData(entity, ballConfig); }
// +++ life cycle +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ public StateMoving(GameObject go) { // get observed component ballScript = go.GetComponent <nvp_Ball_scr>(); ballConfig = ballScript.ballConfig; // collect references from the ballscript // that are needed to access within this behavior currentSpeed = ballConfig.startSpeed; ballTransform = ballScript.transform; }
private void Awake() { config = new BallConfig(ConfigResourceLoader.inst.loadConfig("Config/ball.xml").ToXml()); //rotator = ball.addComponent<BallRotator>(); //rotator.parabolaK = config.parabolaK; //rotator.arclineK = config.arclineK; #if UNITY_EDITOR instance = this; logicPosition = new System.Collections.Generic.LinkedList <Vector3?>(); #endif }
public void Init(BallConfig ballConfig, ResourceConfig resourceConfig = null) { this.ballConfig = ballConfig; this.resourceConfig = resourceConfig; ballImage.sprite = Resources.Load <Sprite>(ballConfig.icon); if (resourceConfig != null) { resourceIcon.sprite = Resources.Load <Sprite>(resourceConfig.icon); } }
protected override JobHandle OnUpdate(JobHandle inputDeps) { NativeArray <BallConfig> ballConfigs = ballConfigQuery.ToComponentDataArray <BallConfig>(Allocator.TempJob); Random random = new Random((uint)(Time.DeltaTime * 1000)); Entities .WithStoreEntityQueryInField(ref spawnQuery) .WithStructuralChanges() .ForEach((in BallSpawnCommand command) => { BallConfig cfg = ballConfigs.GetRandom(random); LocalToWorld xform = EntityManager.GetComponentData <LocalToWorld>(cfg.Prefab); Entity newBall = EntityManager.Instantiate(cfg.Prefab); LimitDOFJoint.Create2D(EntityManager, newBall, new RigidTransform(xform.Value)); }).Run();
public void Init(VertexPath path, BallConfig config, Action <GameObject> onBallCollision, Action <GameObject> onBallOvercome, Action onEndPortalReached) { _path = path; _config = config; _onBallCollision = onBallCollision; _onBallOvercome = onBallOvercome; _onEndPortalReached = onEndPortalReached; _onRoadPos = 0; DistanceTraveled = 0; CurrentType = config.InitialType.Value; UpdateBallPosition(DistanceTraveled); UpdateCameraPosition(DistanceTraveled); _touched = !waitForTouch; _canMove = true; }
private void SpawnBall(BallConfig ballConfig) { var prefab = Resources.Load <GameObject>(ballConfig.prefab); if (prefab != null) { var ball = GameObject.Instantiate(prefab, transform); ball.transform.position = ballsSpawnPoint.position; var ballView = ball.GetComponent <BallView>(); if (ballView != null) { var resource = CalculateNextResource(); ballView.Init(ballConfig, resource); ballViews.Add(ballView); ballView.rigidbody.AddRelativeForce(ballsSpawnPoint.transform.up * 20.0f, ForceMode2D.Impulse); ballView.onMouseDown += OnBallClicked; } } }
private void Awake() { if (Instance == null) { Instance = this; } else { Destroy(gameObject); return; } transform = GetComponent <Transform>(); rigidbody = GetComponent <Rigidbody>(); if (config == null) { Debug.LogWarning("Config was not assigned for ball. Assigning default config."); config = ScriptableObject.CreateInstance <BallConfig>(); } }
// Start is called before the first frame update void Start() { child = transform.GetChild(0); rotation = transform.parent.GetChild(1); rb = GetComponent <Rigidbody>(); ballDur = GetComponent <BallDurability>(); cfg = GetComponent <BallCollision>().ballConfig; childPosition = child.localPosition; rb.centerOfMass = Vector3.zero; layer = LayerMask.NameToLayer("Map"); circleSpeed = Random.Range(cfg.minCircleSpeed, cfg.maxCircleSpeed); dir = Random.Range(0f, 360f); if (Random.value < 0.5f) { circleSpeed *= -1; } NewCircular(); }
public void Add(BallConfig ball) { balls.Add(ball); }
// Use this for initialization void Start() { ballConfig = BallConfig.getInstance(); }