public void StartInteraction(IDynamic otherDynamic) { Interacting = true; _tempDynamic = otherDynamic; _hero.SetWalkingActivation(false, true); _hero.SetStickinessActivation(false); var otherCollider = ((MonoBehaviour)otherDynamic).GetComponent <Collider2D>(); _cloneOtherDynamic = _poolManager.GetPoolable <DynamicCollider>(otherCollider.transform.position, otherCollider.transform.rotation, 1, otherDynamic.PoolableType, defaultParent: false); _cloneOtherDynamic.transform.localScale = otherCollider.transform.localScale; _cloneHeroCollider = _poolManager.GetPoolable <DynamicNinjaCollider>(transform.position, transform.rotation, defaultParent: false); CloneHeroStickiness = _cloneHeroCollider.GetComponent <Stickiness>(); _cloneHero = _cloneHeroCollider.GetComponent <DynamicNinja>(); _cloneHero.SetNinja(_hero); CloneHeroStickiness.Awake(); CloneHeroStickiness.Start(); CloneHeroStickiness.ContactPoint.SetParent(_cloneOtherDynamic.Transform, true); _cloneHeroCollider.Transform.SetParent(_cloneOtherDynamic.Transform, true); _previousPosition = _cloneHeroCollider.Transform.localPosition; _hero.Transform.SetParent(otherCollider.transform, true); _hero.Stickiness.Collider.isTrigger = true; _hero.Stickiness.Rigidbody.angularVelocity = 0; _hero.Stickiness.Rigidbody.velocity = Vector2.zero; CloneHeroStickiness.ReactToObstacle(_cloneOtherDynamic, _hero.Stickiness.GetContactPosition()); }
private void Update() { if (_hero == null) { _hero = Hero.Instance; _heroTransform = _hero?.Transform; _heroStickiness = _hero?.Stickiness; ParentTransform.position = _heroTransform.position; var background = FindObjectOfType <Background>(); if (background != null) { background.CenterBackground(); } } switch (CameraMode) { case CameraMode.Follow: Follow(_heroTransform); break; case CameraMode.Center: Center(_centerPos); break; } }
public override void Die(Transform killer = null, Audio sound = null, float volume = 1f) { if (Dead) { return; } Dead = true; Stickiness.Detach(); Jumper?.CancelJump(); if (killer != null) { Stickiness.Rigidbody.AddForce((Transform.position - killer.position).normalized * 10000); } if (sound != null) { _audioManager.PlaySound(_audioSource, sound, volume); } SetAllBehavioursActivation(false, false); StopDisplayGhosts(); Renderer.color = ColorUtils.Red; _timeManager.StartSlowDownProgressive(.3f); if (DynamicInteraction.Interacting) { DynamicInteraction.StopInteraction(false); } StartCoroutine(Dying()); }
private void Start() { _canvasTransform = UICamera.Instance.Canvas.transform; _uiCamera = UICamera.Instance.Camera; _hero = Hero.Instance; _stickiness = _hero?.Stickiness; _jumper = _hero?.Jumper; _dynamicInteraction = _hero?.DynamicInteraction; }
protected virtual void Awake() { _dynamicEntity = GetComponent <IDynamic>(); _dynamicInteraction = GetComponent <DynamicInteraction>(); _cameraBehaviour = CameraBehaviour.Instance; _timeManager = TimeManager.Instance; _stickiness = GetComponent <Stickiness>(); _poolManager = PoolManager.Instance; _audioSource = GetComponent <AudioSource>(); _audioManager = AudioManager.Instance; _initGravity = _dynamicEntity.Rigidbody.gravityScale; }
public void SetWalkingActivation(bool active, bool grounded) { if (Utils.IsNull(Stickiness)) { return; } if (!active) { Stickiness.StopWalking(grounded); } Stickiness.CanWalk = active; }
private void Update() { if (!HeroSpawned()) { return; } _stickiness = (_dynamicInteraction != null && _dynamicInteraction.Interacting) ? _dynamicInteraction.CloneHeroStickiness : Hero.Instance.Stickiness; HandleWalkTouchInitEvent(); HandleJumpTouchInitEvent(); if (!HandleJumpTouchEvent()) { HandleWalkTouchEvent(); } HandleWalkTouchEndEvent(); HandleJumpTouchEndEvent(); }
private bool HeroSpawned() { //Waiting for hero to spawn if (_hero == null) { _hero = Hero.Instance; if (_hero == null) { return(false); } _stickiness = _hero.Stickiness; _jumper = _hero.Jumper; _dynamicInteraction = _hero.DynamicInteraction; } return(true); }
public void StopInteraction(bool reinit) { _hero.Transform.SetParent(null); if (reinit) { _hero.SetAllBehavioursActivation(true, false); } _tempDynamic.LaunchQuickDeactivate(); _hero.Stickiness.Collider.isTrigger = false; _hero.Stickiness.Rigidbody.isKinematic = false; Interacting = false; if (_cloneOtherDynamic != null && _cloneOtherDynamic.Active) { CloneHeroStickiness = null; _cloneHeroCollider.Transform.SetParent(null); _cloneHeroCollider.Sleep(); _cloneOtherDynamic.Sleep(); } _tempDynamic = null; }
public Location(int line, int ch, Stickiness sticky = Stickiness.After) { this.line = line; this.ch = ch; this.sticky = sticky; }