Exemplo n.º 1
0
    public virtual int GetBaseLevel()
    {
        var stairVec     = HushPuppy.GetVecAsTileVec(this.transform.position);
        var stairBaseVec = stairVec + Vector3Int.down;

        return(GetLevel(stairBaseVec));
    }
Exemplo n.º 2
0
    void Initialize_References()
    {
        rb = this.GetComponentInChildren <Rigidbody2D>();
        sr = this.GetComponentInChildren <SpriteRenderer>();

        player = HushPuppy.safeFindComponent("Player", "Player") as Player;
    }
Exemplo n.º 3
0
    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;
    }
Exemplo n.º 4
0
    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);
        }
    }
Exemplo n.º 5
0
    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;
    }
Exemplo n.º 6
0
    void Start()
    {
        player = HushPuppy.safeFindComponent("Player", "Player") as Player;

        sprite.enabled = false;
        Set_Rotation();
    }
Exemplo n.º 7
0
    public IEnumerator Start_Attack()
    {
        hurt_active = true;

        sprite.color = HushPuppy.getColorWithOpacity(sprite.color, 1f);
        yield return(new WaitForSeconds(attack_duration));
    }
Exemplo n.º 8
0
    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;
    }
Exemplo n.º 9
0
    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));
    }
Exemplo n.º 10
0
    public IEnumerator Die_Coroutine()
    {
        this.sr.color = HushPuppy.getColorWithOpacity(this.sr.color, 0.3f);

        yield return(new WaitForSeconds(timeBetweenRespawns));

        ResetState();
    }
Exemplo n.º 11
0
    void init()
    {
        rb        = this.GetComponentInChildren <Rigidbody2D>();
        sr        = this.GetComponentInChildren <SpriteRenderer>();
        particles = this.GetComponentInChildren <EnemyParticles>();

        player = (Player)HushPuppy.safeFindComponent("Player", "Player");
    }
Exemplo n.º 12
0
    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);
    }
Exemplo n.º 13
0
    void Generate()
    {
        Vector3 position = HushPuppy.GenerateValidPosition(
            () => this.transform.position + (Vector3)(this.spreadRadius * Random.insideUnitCircle),
            (vec) => mapManager.IsPositionValid(vec));

        Generate(position);
    }
Exemplo n.º 14
0
 void Start()
 {
     if (invert)
     {
         this.gameObject.SetActive(false);
         sr.color = HushPuppy.getColorWithOpacity(sr.color, 0f);
     }
 }
Exemplo n.º 15
0
 Vector3Int GetCurrentPosInt()
 {
     return(HushPuppy.GetVecAsTileVec(new Vector3(
                                          this.transform.position.x - 0.5f,
                                          this.transform.position.y - 0.5f,
                                          this.transform.position.z
                                          )));
 }
Exemplo n.º 16
0
    public bool IsPositionValid(Vector3 position)
    {
        Vector3Int vec = HushPuppy.GetVecAsTileVec(position);

        TileBase seaTile   = seaTilemap.GetTile(vec);
        bool     insideSea = seaTile != null;

        return(!insideSea);
    }
Exemplo n.º 17
0
    void Set_Alpha(float alpha)
    {
        if (alpha < 0f || alpha > 1f)
        {
            print("Alpha not received correctly.");
        }

        sr.color = HushPuppy.getColorWithOpacity(sr.color, alpha);
    }
Exemplo n.º 18
0
    IEnumerator RandomWalk()
    {
        Vector3 destination = HushPuppy.GenerateValidPosition(
            () => this.transform.position + 3f * ((Vector3)Random.insideUnitCircle),
            (vec) => mapManager.IsPositionValid(vec)
            );

        yield return(WalkTo(destination));
    }
Exemplo n.º 19
0
    public static ObjectPoolManager GetObjectPoolManager()
    {
        var o = (ObjectPoolManager)HushPuppy.safeFindComponent("GameController", "ObjectPoolManager");

        if (o == null)
        {
            print("Inactive"); Debug.Break();
        }
        return(o);
    }
Exemplo n.º 20
0
    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);
    }
Exemplo n.º 21
0
    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);
    }
Exemplo n.º 22
0
    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>();
    }
Exemplo n.º 23
0
    public void Select_Choice(int index)
    {
        if (inkStory.currentChoices.Count > 0)
        {
            inkStory.ChooseChoiceIndex(index);
            choice_selected = true;
        }

        HushPuppy.destroyChildren(choiceContainer);
    }
Exemplo n.º 24
0
    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;
    }
Exemplo n.º 25
0
    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);
        }
    }
Exemplo n.º 26
0
    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);
        }
    }
Exemplo n.º 27
0
    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);
            }
        }
    }
Exemplo n.º 28
0
    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);
    }
Exemplo n.º 29
0
    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"));
    }
Exemplo n.º 30
0
    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());
    }