コード例 #1
0
ファイル: Card.cs プロジェクト: flexo735/LD_41_Phoenix
    public void defend_against_attack(Card enemy_card)
    {
        Debug.Assert(enemy_card.current_state == card_states.Attacking);
        Debug.Assert(current_state == card_states.Waiting);
        enemy_card.health -= this.defence_power;
        this.health       -= enemy_card.attack_power;

        enemy_card.health_text.text = "" + enemy_card.health;
        this.health_text.text       = "" + this.health;

        if (enemy_card.health <= 0)
        {
            enemy_card.card_destroyed();
        }
        else
        {
            enemy_card.current_state = card_states.Cooldown;             //If they aren't killed the attack is aborted and they are put into cooldown for the remaining attack time.
        }

        if (this.health <= 0)
        {
            this.card_destroyed();
        }
        else
        {
            time_left     = defence_time;
            max_time_left = defence_time;
            current_state = card_states.Cooldown;

            timer_bar.enabled = true;

            set_movement_target(enemy_card.gameObject, 0.2f);
        }
    }
コード例 #2
0
ファイル: Card.cs プロジェクト: flexo735/LD_41_Phoenix
    // Update is called once per frame
    void Update()
    {
        if (current_state == card_states.Cooldown)
        {
            time_left -= Time.deltaTime;
            if (time_left <= 0)
            {
                current_state     = card_states.Waiting;
                timer_bar.enabled = false;
            }
        }

        else if (current_state == card_states.Attacking)
        {
            time_left -= Time.deltaTime;
            if (time_left <= 0)
            {
                current_state     = card_states.Waiting;
                timer_bar.enabled = false;
                finish_attack(attack_target);
            }
        }

        // Keep the Cards on the screen
        else if (current_state == card_states.Hand)
        {
            if (transform.position.y > gameCamera.orthographicSize - 1.0f * transform.localScale.y)
            {
                transform.position = new Vector3(transform.position.x, gameCamera.orthographicSize - 1.0f * transform.localScale.y, transform.position.z);
            }
            else if (transform.position.y < 1.0f * transform.localScale.y - gameCamera.orthographicSize)
            {
                transform.position = new Vector3(transform.position.x, 1.0f * transform.localScale.y - gameCamera.orthographicSize, transform.position.z);
            }
            if (transform.position.x > gameCamera.orthographicSize * gameCamera.aspect - 0.75f * transform.localScale.x)
            {
                transform.position = new Vector3(gameCamera.orthographicSize * gameCamera.aspect - 0.75f * transform.localScale.x, transform.position.y, transform.position.z);
            }
            else if (transform.position.x < 0.75f * transform.localScale.x - gameCamera.orthographicSize * gameCamera.aspect)
            {
                transform.position = new Vector3(0.75f * transform.localScale.x - gameCamera.orthographicSize * gameCamera.aspect, transform.position.y, transform.position.z);
            }
        }

        if (current_state == card_states.Attacking || current_state == card_states.Cooldown)
        {
            //We want to update the thing.
            timer_bar.fillAmount   = time_left / max_time_left;
            start_timer_bar_colour = (current_state == card_states.Attacking)? Color.red : Color.blue;
            Color lerped_colour = Color.Lerp(end_timer_bar_colour, start_timer_bar_colour, time_left / max_time_left);
            timer_bar.color = lerped_colour;
        }
    }
コード例 #3
0
ファイル: Card.cs プロジェクト: flexo735/LD_41_Phoenix
    public void start_attack(Player_Hand the_target)
    {
        if (!controlling_player.locked_out)
        {
            current_state = card_states.Attacking;
            time_left     = attack_time;
            max_time_left = attack_time;
            attack_target = the_target;

            timer_bar.enabled = true;
        }
    }
コード例 #4
0
ファイル: Card.cs プロジェクト: flexo735/LD_41_Phoenix
    public void play_card_to_combat_spot(combat_spot the_spot)
    {
        if (held_in.play_card(this.gameObject))
        {
            held_in = the_spot;
            the_spot.currently_holding = this.gameObject;
            current_state = card_states.Cooldown;
            time_left     = casting_time;
            max_time_left = casting_time;
            held_in.arrange_cards();

            timer_bar.enabled = true;
        }
    }