public virtual int GetBaseLevel() { var stairVec = HushPuppy.GetVecAsTileVec(this.transform.position); var stairBaseVec = stairVec + Vector3Int.down; return(GetLevel(stairBaseVec)); }
void Initialize_References() { rb = this.GetComponentInChildren <Rigidbody2D>(); sr = this.GetComponentInChildren <SpriteRenderer>(); player = HushPuppy.safeFindComponent("Player", "Player") as Player; }
public IEnumerator Attack() { //telegraph sprite.enabled = true; sprite.color = HushPuppy.getColorWithOpacity(sprite.color, 0f); sprite.DOFade(0.5f, 0.1f); yield return(new WaitForSeconds(telegraph_time)); //capable of doing damage hurt_box_active = true; flames.Play(); sprite.color = HushPuppy.getColorWithOpacity(sprite.color, 1f); yield return(new WaitForSeconds(attack_duration)); //end flames.Stop(); sprite.color = HushPuppy.getColorWithOpacity(sprite.color, 0.5f); yield return(new WaitForSeconds(flames.main.startLifetime.constant)); hurt_box_active = false; sprite.DOFade(0f, 0.1f); yield return(new WaitForSeconds(0.1f)); sprite.enabled = false; }
IEnumerator Destroy_Capture() { float wait_time = 0.2f; spearCapture.transform.DOScale( spearCapture.transform.localScale * 1.2f, wait_time ); spearCapture.DOColor( HushPuppy.getColorWithOpacity(spearCapture.color, 0f), wait_time ); yield return(new WaitForSeconds(wait_time)); Destroy(spearCapture.gameObject); player.is_capturing_spear = false; if (spear != null) { Destroy(spear.gameObject); } else { //is fixed in dragon var dragon = GameObject.FindGameObjectWithTag("Dragon"); Vector3 blood_pos = (this.transform.position + dragon.transform.position) / 2; var blood = Instantiate(blood_prefab, blood_pos, Quaternion.identity); blood.GetComponentInChildren <Blood>().Initialize(3f); Destroy(this.transform.parent.gameObject); } }
IEnumerator UpdateStance() { switch (player.current_weapon) { case Weapon.BOW: currentStance = bowStance; break; case Weapon.KNIFE: currentStance = knifeStance; break; case Weapon.SPEAR: currentStance = spearStance; break; default: break; } while (player.charge > 0.0f) { sr.sprite = currentStance.armed; yield return(null); } sr.sprite = currentStance.afterThrow; yield return(HushPuppy.WaitForEndOfFrames(recoveryFrames)); sr.sprite = defaultSprite; }
void Start() { player = HushPuppy.safeFindComponent("Player", "Player") as Player; sprite.enabled = false; Set_Rotation(); }
public IEnumerator Start_Attack() { hurt_active = true; sprite.color = HushPuppy.getColorWithOpacity(sprite.color, 1f); yield return(new WaitForSeconds(attack_duration)); }
IEnumerator Idle() { var duration = Random.Range(0.5f, 0.7f); yield return(new WaitForSeconds(duration)); var dir = HushPuppy.GenerateValidPosition( () => new Vector3( Random.Range(-distance, distance), Random.Range(-distance, distance)), (vec) => { var hit = Physics2D.BoxCast( this.transform.position, Vector2.one, 0f, vec.normalized, vec.magnitude, 1 << LayerMask.NameToLayer("Walls") | (1 << LayerMask.NameToLayer("Stairs")) | TilemapHelper.GetLayerMaskCreatureCollision(this.currFloorLevel) ); var outOfBounds = !TilemapHelper.InsideSameRoom( this.transform.position, this.transform.position + vec, RoomManager.Get().dimensions ); return(!hit && !outOfBounds); }); this.target = this.transform.position + dir; }
public IEnumerator Telegraph() { sprite.enabled = true; sprite.color = HushPuppy.getColorWithOpacity(sprite.color, 0f); sprite.DOFade(0.3f, 0.1f); yield return(new WaitForSeconds(telegraph_duration)); }
public IEnumerator Die_Coroutine() { this.sr.color = HushPuppy.getColorWithOpacity(this.sr.color, 0.3f); yield return(new WaitForSeconds(timeBetweenRespawns)); ResetState(); }
void init() { rb = this.GetComponentInChildren <Rigidbody2D>(); sr = this.GetComponentInChildren <SpriteRenderer>(); particles = this.GetComponentInChildren <EnemyParticles>(); player = (Player)HushPuppy.safeFindComponent("Player", "Player"); }
public static Vector3 TilePosInFrontOfObj(GameObject obj, Vector3 direction, bool local = true) { Vector3 target = local ? obj.transform.localPosition : obj.transform.position; target = target + direction * 0.5f; target = HushPuppy.GetVecAsTileVec(target, false, true); return(target); }
void Generate() { Vector3 position = HushPuppy.GenerateValidPosition( () => this.transform.position + (Vector3)(this.spreadRadius * Random.insideUnitCircle), (vec) => mapManager.IsPositionValid(vec)); Generate(position); }
void Start() { if (invert) { this.gameObject.SetActive(false); sr.color = HushPuppy.getColorWithOpacity(sr.color, 0f); } }
Vector3Int GetCurrentPosInt() { return(HushPuppy.GetVecAsTileVec(new Vector3( this.transform.position.x - 0.5f, this.transform.position.y - 0.5f, this.transform.position.z ))); }
public bool IsPositionValid(Vector3 position) { Vector3Int vec = HushPuppy.GetVecAsTileVec(position); TileBase seaTile = seaTilemap.GetTile(vec); bool insideSea = seaTile != null; return(!insideSea); }
void Set_Alpha(float alpha) { if (alpha < 0f || alpha > 1f) { print("Alpha not received correctly."); } sr.color = HushPuppy.getColorWithOpacity(sr.color, alpha); }
IEnumerator RandomWalk() { Vector3 destination = HushPuppy.GenerateValidPosition( () => this.transform.position + 3f * ((Vector3)Random.insideUnitCircle), (vec) => mapManager.IsPositionValid(vec) ); yield return(WalkTo(destination)); }
public static ObjectPoolManager GetObjectPoolManager() { var o = (ObjectPoolManager)HushPuppy.safeFindComponent("GameController", "ObjectPoolManager"); if (o == null) { print("Inactive"); Debug.Break(); } return(o); }
void Start() { // foreach (KnifeIron iron in GameObject.FindObjectsOfType<KnifeIron>()) { // iron.Set_Magnet(this); // } UI_text = Instantiate(UI_prefab, HushPuppy.safeFind("Canvas").transform, false). GetComponentInChildren <TextMeshProUGUI>(); UI_text.transform.position = Camera.main.WorldToScreenPoint(this.transform.position); }
IEnumerator moveCooldown(int frames) { this.GetComponent <SpriteRenderer>().flipX = !this.GetComponent <SpriteRenderer>().flipX; canMove = false; yield return(HushPuppy.WaitUntilNFrames(frames)); canMove = true; this.GetComponent <SpriteRenderer>().flipX = !this.GetComponent <SpriteRenderer>().flipX; rb.velocity = new Vector2(0f, rb.velocity.y); }
public void Initialize() { worldCanvas = HushPuppy.safeFind("WorldCanvas"); player = HushPuppy.safeFindComponent("Player", "Player") as Player; GameObject aux = Instantiate(spearCapture_prefab, worldCanvas.transform, false); aux.transform.position = this.transform.position; spearCapture = aux.GetComponentInChildren <Image>(); }
public void Select_Choice(int index) { if (inkStory.currentChoices.Count > 0) { inkStory.ChooseChoiceIndex(index); choice_selected = true; } HushPuppy.destroyChildren(choiceContainer); }
public IEnumerator End_Attack() { hurt_active = false; sprite.color = HushPuppy.getColorWithOpacity(sprite.color, 0.5f); sprite.DOFade(0f, 0.1f); yield return(new WaitForSeconds(0.1f)); sprite.enabled = false; }
void FixedUpdate() { if (sineMovement || cosineMovement) { framecount++; sinusoidalAmplitude += data.amplitudeAcceleration * Time.deltaTime; sinusoidalPeriod += data.periodAcceleration * Time.deltaTime; acceleration_senoid_y = new Vector2(0, sinusoidalAmplitude * Mathf.Cos(framecount / (sinusoidalPeriod * 2))); acceleration_senoid_y = HushPuppy.rotateVector(acceleration_senoid_y, angle_grad + 90); if (sineMovement) { acceleration_senoid_y *= -1; } } if (player_direction) { acceleration_player_direction = (player.position - this.transform.position).normalized * player_direction_magnitude; } if (emitter_direction) { acceleration_emitter_direction = (start_position - this.transform.position).normalized * emitter_direction_magnitude; } rb.velocity += (acceleration + acceleration_senoid_y + acceleration_player_direction + acceleration_emitter_direction) * Time.deltaTime * timeSlowModifier; if (rb.velocity.sqrMagnitude > data.maxVelocity) { rb.velocity = rb.velocity.normalized * data.maxVelocity; } if (rb.velocity.magnitude < 0.5 && shouldStopWhenVelocityZero) { rb.velocity = acceleration = Vector2.zero; } if (data.faceVelocity) { float angle = Mathf.Atan2(rb.velocity.y, rb.velocity.x) * Mathf.Rad2Deg; this.transform.rotation = Quaternion.AngleAxis(angle + 90, Vector3.forward); } }
void ClearPath() { var walls = TilemapHelper.GetWallsTilemap(); var posInt = HushPuppy.GetVecAsTileVec(this.transform.position); var tile = walls.GetTile(posInt); if (tile != null) { var sprite = ((Tile)tile).sprite; fakeWall.sprite = sprite; walls.SetTile(posInt, null); } }
void Set_Alpha(float alpha) { if (alpha < 0f || alpha > 1f) { print("Alpha not received correctly."); } foreach (SpriteRenderer s in GetComponentsInChildren <SpriteRenderer>()) { if (s.gameObject.tag != "SpearCapture") { s.color = HushPuppy.getColorWithOpacity(s.color, alpha); } } }
public static int GetFloor(Vector3 position) { var posInt = HushPuppy.GetVecAsTileVec(position); int maxLevel = -1; foreach (var tilemap in GetAllFloors()) { var targetTile = tilemap.map.GetTile(posInt); if (targetTile != null) { maxLevel = tilemap.level > maxLevel ? tilemap.level : maxLevel; } } return(maxLevel); }
public static DialogManager Get() { var gc = GameObject.FindGameObjectWithTag("GameController"); if (gc == null) { Debug.LogError("GameController not found."); return(null); } var o = gc.GetComponent <DialogManager>(); if (o == null) { Debug.LogError("DialogManager not found in GameController."); return(null); } return((DialogManager)HushPuppy.safeFindComponent("GameController", "DialogManager")); }
public void Take_Damage(int amount) { if (took_hit_invincible) { return; } health -= (float)amount / 100f; if (health < 0) { ((SceneLoader)HushPuppy.safeFindComponent("GameController", "SceneLoader")).Game_Over(); Destroy(this.gameObject); } StartCoroutine(Take_Damage_Cooldown()); }