//-Implementation private void Awake() { _sprite = XUtils.getComponent <SpriteRenderer>( gameObject, XUtils.AccessPolicy.ShouldExist ); _collider = XUtils.getComponent <BoxCollider2D>( gameObject, XUtils.AccessPolicy.ShouldExist ); XUtils.getComponent <MouseAttachComponent>( gameObject, XUtils.AccessPolicy.ShouldBeCreated ).onMouseMove += (Vector2 inMousePosition) => { updateColor(); }; XUtils.getComponent <MouseClickTrackingComponent>( gameObject, XUtils.AccessPolicy.ShouldBeCreated ).onClick += () => { if (!isPossibleToBuild()) { return; } ConstructionSiteObject theConstructionSite = createConstructionSite(); getUIInterface().processConstructionStart(theConstructionSite); Destroy(gameObject); }; }
internal void removeWayElementsUpToEnd(int inBeginIndex) { _wayElements.removeElementsUpToEnd(inBeginIndex, (HierarchicalGridWayUIElement inWayElement) => { XUtils.getComponent <RectTransform>( inWayElement.gameObject, XUtils.AccessPolicy.ShouldExist ).SetParent(null); }); }
void Awake() { _carRigidBody = XUtils.getComponent <Rigidbody2D>( _car, XUtils.AccessPolicy.ShouldExist ); _camera = XUtils.getComponent <Camera>( gameObject, XUtils.AccessPolicy.ShouldExist ); }
//-Internal API internal void addWayElement(HierarchicalGridWayUIElement inWayElement) { XUtils.getComponent <LayoutElement>( inWayElement, XUtils.AccessPolicy.ShouldBeCreated ).flexibleHeight = 1; XUtils.getComponent <RectTransform>( inWayElement, XUtils.AccessPolicy.ShouldExist ).SetParent(_rectTransformForPlacingWayElements, false); _wayElements.add(inWayElement); }
//Methods //-API public void attach( GameObject inUI, WorldObjectAttachPoint inAttachPoint, bool inDestroyUIWithObject = true) { XUtils.getComponent <RectTransform>( inUI, XUtils.AccessPolicy.ShouldExist ).SetParent(_worldAttachTransform, false); var theNewAttach = new UIAttach_ToWorldObjectAttachPoint( inUI.GetComponent <RectTransform>(), inAttachPoint, inDestroyUIWithObject ); _uiAttaches_toWorldObjectAttachPoint.add(theNewAttach); }
private void refreshShowingElement() { XUtils.check(_elementShownInGrid); _gridRectTransform.DetachChildren(); foreach (HierarchicalUIElementObject theChildElement in _elementShownInGrid._elements) { XUtils.getComponent <RectTransform>( theChildElement, XUtils.AccessPolicy.ShouldExist ).SetParent(_gridRectTransform, false); } }
private void Awake() { _selectButton.onClick.AddListener(() => { select(); }); var theTransform = XUtils.getComponent <RectTransform>( this, XUtils.AccessPolicy.ShouldExist ); Vector2 theSize = theTransform.sizeDelta; theSize.x = 100; theTransform.sizeDelta = theSize; }
//-Car control private void Update_CarControl() { //Car movement update if (_isGasIsPressed) { _carPhysics.applyGas(); } if (_isReversIsPressed) { _carPhysics.applyRevers(); } if (_isClockwiseRotatePressed) { _carPhysics.rotateSteeringWheelClockwise(); } if (_isCounterClockwiseRotatePressed) { _carPhysics.rotateSteeringWheelCounterClockwise(); } //Car shooting update if (_isMouseButtonPressed) { foreach (WeaponLogic theGunLogic in _weaponsLogic) { theGunLogic.doShoot(); } } foreach (WeaponLogic theGunLogic in _weaponsLogic) { var theTargetComponent = XUtils.getComponent <RotateToTargetAngleLogic>(theGunLogic); if (!theTargetComponent) { continue; } Vector2 theTurretPosition = theGunLogic.transform.position; Vector2 theDelta = XUtils.getMouseWorldPosition() - theTurretPosition; theTargetComponent.setTargetAngle( Mathf.Atan2(theDelta.y, theDelta.x) * Mathf.Rad2Deg ); } }
//TODO: Find how to organize Damage API Classes better public static void applyDamage(GameObject inGameObject, Damage inDamage) { XUtils.check(inGameObject); var theDamageProxy = XUtils.getComponent <DamageProxy>( inGameObject, XUtils.AccessPolicy.JustFind ); if (theDamageProxy) { theDamageProxy.applyDamage(inDamage); return; } var theDurability = XUtils.getComponent <DurabilityComponent>( inGameObject, XUtils.AccessPolicy.JustFind ); if (theDurability) { theDurability.changeHitPoints(-inDamage.damageAmount); } }
BuildingSelectionUIElementObject createBuildingSelectionUI( BuildingScheme inBuildingSceme) { GameObject theBuildingSelectionUIGameObject = Instantiate(_buildingSelectionUIElementPrefab); var theBuildingSelectionUI = XUtils.getComponent <BuildingSelectionUIElementObject>( theBuildingSelectionUIGameObject, XUtils.AccessPolicy.ShouldExist ); theBuildingSelectionUI.init(inBuildingSceme, (BuildingScheme inBuildingScheme) => { BuildingPlanObject theBuildingPlan = XUtils.createObject( inBuildingScheme.buildingPlan ); theBuildingPlan.init(_carCity); theBuildingPlan.getUIInterface().init( _carCity, _constructionSiteUIPrefab ); }); return(theBuildingSelectionUI); }
//-Implementation private void Awake() { _camera = XUtils.getComponent <Camera>( this, XUtils.AccessPolicy.ShouldExist ); }
private void Awake() { _lineRender = XUtils.getComponent <LineRenderer>( this, XUtils.AccessPolicy.ShouldExist ); }
public BuildingPlanUIInterface getUIInterface() { return(XUtils.getComponent <BuildingPlanUIInterface>( this, XUtils.AccessPolicy.CreateIfNo )); }
//-Implementation private void Awake() { _durabilityComponent = XUtils.getComponent <DurabilityComponent>( this, XUtils.AccessPolicy.ShouldExist ); }