Ejemplo n.º 1
0
    public int EatHuman(GameActor actor, int row, int column)
    {
        if (!IsPosValid(row, column))
        {
            Debug.LogError("<NavigationMap::EatHuman>, invalid index, row : " + row + ", column: " + column);
        }

        int kill_counter = 0;
        // just eat the first human
        GameActor target_actor  = null;
        bool      is_dino_died  = false;
        bool      is_human_died = false;

        for (int i = 0; i < actor_map_[row, column].Count; ++i)
        {
            target_actor = actor_map_[row, column][i];

            if (!target_actor.isAlive())
            {
                continue;
            }

            if (target_actor.Type() == ActorType.human)
            {
                if (actor.isAlive() && target_actor.isAlive())
                {
                    actor.Combat(target_actor);
                    if (!target_actor.isAlive())
                    {
                        ++kill_counter;
                        is_human_died = true;
                        ++GameStatics.human_died;
                    }

                    if (!actor.isAlive())
                    {
                        is_dino_died = true;
                        ++GameStatics.monster_died;
                    }
                }
            }
        }

        if (is_dino_died)
        {
            scene_game_.PlayAudioDinoDie();
        }
        else if (is_human_died)
        {
            scene_game_.PlayAudioHumanDie();
        }
        return(kill_counter);
    }
Ejemplo n.º 2
0
    public int EatHuman( GameActor actor, int row, int column )
    {
        if ( !IsPosValid ( row, column ) ) {
            Debug.LogError ( "<NavigationMap::EatHuman>, invalid index, row : " + row + ", column: " + column );
        }

        int kill_counter = 0;
        // just eat the first human
        GameActor target_actor = null;
        bool is_dino_died = false;
        bool is_human_died = false;
        for ( int i = 0; i < actor_map_[row,column].Count; ++i ) {
            target_actor = actor_map_[row,column][i];

            if ( !target_actor.isAlive() )
                continue;

            if ( target_actor.Type() == ActorType.human ) {
                if ( actor.isAlive() && target_actor.isAlive() ) {
                    actor.Combat ( target_actor );
                    if ( !target_actor.isAlive() ) {
                        ++kill_counter;
                        is_human_died = true;
                        ++GameStatics.human_died;
                    }

                    if ( !actor.isAlive() ) {
                        is_dino_died = true;
                        ++GameStatics.monster_died;
                    }
                }
            }
        }

        if ( is_dino_died ) {
            scene_game_.PlayAudioDinoDie ();
        } else if ( is_human_died ) {
            scene_game_.PlayAudioHumanDie ();
        }
        return kill_counter;
    }