// Use this for initialization void Start() { _moveScript = gameObject.GetComponent <SpriteMovement>(); if (_moveScript == null) { Debug.Log("<color=red> Error: Move script not attached to Player</color>"); } _rotationAngles = new Vector3(); _animator = gameObject.GetComponent <Animator>(); if (FlashLight != null) { _rotationAngles = FlashLight.transform.eulerAngles; } if (FlashLight == null) { Debug.Log("Flashlight not found :("); } if (TutorialTrigger) { StartCoroutine(TutorialScript()); } }
void Start() { sprite = FindObjectOfType <SpriteMovement>(); healthBar = FindObjectOfType <HealthBar>(); animation.SetBool("Portal_null", false); animation.SetBool("Portal_start", true); }
protected void AniCtlPauseTime(float pauseTime) { SpriteMovement mov = this.Movement; if (mov != null) { mov.AniCtlPause(pauseTime); } }
// Use this for initialization void Start() { _animator = gameObject.GetComponent <Animator>(); _moveScript = gameObject.GetComponent <SpriteMovement>(); if (_moveScript == null) { Debug.Log("<color=red> Error: Move script not attached to NPC</color>"); } StartCoroutine(tutScript()); }
private void AttachAttribeToSpriteMovement() { PlayerAttribe attribe = this.Attribe; if (attribe == null) { return; } SpriteMovement movement = this.Movement; if (movement == null) { return; } movement.StartVec = attribe.StateStartVec; }
public void FiniteAnimate(SpriteMovement movement, byte spriteChange) { if (movement != CurrentDirection) { CurrentDirection = movement; CurrentSprite = 0; currentSpriteChange = 0; } else { if (currentSpriteChange < spriteChange) { currentSpriteChange++; CurrentSprite = (byte)((CurrentSprite + 1) % SpriteXCoordinates[(int)CurrentDirection].Length); } } UpdateSpriteCoordinates(); }
public void Animate(SpriteMovement movement) { if (movement != CurrentDirection) { CurrentDirection = movement; CurrentSprite = 0; currentSpriteChange = 0; } else { currentSpriteChange++; if (currentSpriteChange >= SPRITE_CHANGE) { currentSpriteChange = 0; CurrentSprite = (byte)((CurrentSprite + 1) % SpriteXCoordinates[(int)CurrentDirection].Length); } } UpdateSpriteCoordinates(); }
// Use this for initialization void Start () { instance = this; myTransform = transform; anim = GetComponent<Animator> (); }
void Start() { sprite = FindObjectOfType <SpriteMovement>(); }
// Start is called before the first frame update void Start() { character = this.GetComponent <Character>(); spriteMovement = this.GetComponent <SpriteMovement>(); }
protected virtual void Init() { tilemapInfo = TilemapInfo.Instance; spriteMovement = this.GetComponent <SpriteMovement>(); }
private Vector3 getEvasiveForces(Vector3 currForce) { Collider[] closeCollisions = Physics.OverlapSphere(transform.position, vision); SortedDictionary <float, SpriteMovement> confirmedCollisions = new SortedDictionary <float, SpriteMovement>(); foreach (var closeCollision in closeCollisions) { if (closeCollision.transform.position == transform.position) //thats me { continue; } else { SpriteMovement scriptInfo = closeCollision.GetComponent <SpriteMovement>(); Vector3 futurePos = closeCollision.transform.position; float safeCombined = safeDistance; safeCombined = Mathf.Pow(safeCombined, 2); Vector3 velDiff = currVelocity - scriptInfo.currVelocity; Vector3 xjMinxi = futurePos - transform.position; float a = (Mathf.Pow(velDiff[0], 2) + Mathf.Pow(velDiff[1], 2)); float b = (0 - 2) * (velDiff[0] + velDiff[1]); float c = (safeCombined) - (Mathf.Pow(xjMinxi[0], 2)) - (Mathf.Pow(xjMinxi[1], 2)); float bSqr = Mathf.Pow(b, 2); float time1 = -1; float time2 = -1; if (bSqr - 4 * a * c < 0) { // do nothing } else { time1 = b + Mathf.Sqrt(bSqr - 4 * a * c); time1 = time1 / (2 * a); time2 = b - Mathf.Sqrt(bSqr - 4 * a * c); time2 = time2 / (2 * a); } if (time1 > 0 && time2 > 0) { confirmedCollisions.Add(Mathf.Min(time1, time2), scriptInfo); } else if (time1 > 0) { confirmedCollisions.Add(time1, scriptInfo); } else if (time2 > 0) { confirmedCollisions.Add(time2, scriptInfo); } } } Vector3 returnVec = new Vector3(0, 0, 0); int i = 0; if (confirmedCollisions.Count > 0) { foreach (KeyValuePair <float, SpriteMovement> entry in confirmedCollisions) { if (i == N) { break; } Vector3 avoidance = new Vector3(0, 0, 0); Vector3 ci = transform.position + entry.Key * currForce; Vector3 cj = entry.Value.transform.position + entry.Key * entry.Value.currVelocity; avoidance = ci - cj; avoidance = avoidance / (avoidance.magnitude); returnVec += avoidance; bool stillCollides = checkIfStillCollides(returnVec + currForce, confirmedCollisions); if (!stillCollides) { break; } i++; } } if (i != 0) { return(returnVec / i); } else { return(returnVec); }; }
// Start is called before the first frame update void Start() { SpriteFreeMove = GetComponent <SpriteFacement>(); SpriteJumpMove = GetComponent <SpriteMovement>(); }