private async void HandleImpactStars(ContactPoint2D contactPoint, GameEntity playerEntity) { float angle = Vector2.Angle(playerEntity.velocity.Value.normalized.Abs(), contactPoint.normal.normalized.Abs()); float angleThreshold = GameConfigurations.GameConstantsConfiguration.ImpatStarCollisionAngleThreshold; float velocityThreshold = GameConfigurations.GameConstantsConfiguration.ImpactStarEffectVelocityThreshold; if (playerEntity.velocity.Value.magnitude >= velocityThreshold && angle <= angleThreshold) { GameEntity impactStarEntity = Contexts.sharedInstance.game.CreateEntity(); GameEntity impactStarEntity2 = Contexts.sharedInstance.game.CreateEntity(); impactStarEntity2.isImpactStar = true; impactStarEntity.isImpactStar = true; Task <bool> impactStar1Task = AssetLoaderUtils.InstantiateAssetAsyncTask(GameConfigurations.AssetReferenceConfiguration.ImpactStarReference, impactStarEntity, contactPoint.point, Quaternion.identity); Task <bool> impactStar2Task = AssetLoaderUtils.InstantiateAssetAsyncTask(GameConfigurations.AssetReferenceConfiguration.ImpactStarReference, impactStarEntity2, contactPoint.point, Quaternion.identity); if (await impactStar1Task) { GameObject impactStarObject = impactStarEntity.view.Value; impactStarObject.transform.Rotate(0, 0, Vector2.SignedAngle(Vector2.up, contactPoint.normal)); Animation impactAnimation = impactStarObject.GetComponentInChildren <Animation>(); impactStarEntity.AddAnimation(impactAnimation); } if (await impactStar2Task) { GameObject impactStarObject2 = impactStarEntity2.view.Value; impactStarObject2.transform.Rotate(180 * contactPoint.normal.x, 180 * contactPoint.normal.y, Vector2.SignedAngle(Vector2.up, contactPoint.normal)); Animation impactAnimation2 = impactStarObject2.GetComponentInChildren <Animation>(); impactStarEntity2.AddAnimation(impactAnimation2); } } }
private void Start() { GameEntity flipperAnimationEntity = Contexts.sharedInstance.game.CreateEntity(); flipperAnimationEntity.AddView(gameObject); flipperAnimationEntity.isFlipperAnimation = true; flipperAnimationEntity.AddAnimation(GetComponent <Animation>()); gameObject.Link(flipperAnimationEntity); }